babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The dirty prepass flag value
  862. */
  863. static readonly MATERIAL_PrePassDirtyFlag: number;
  864. /**
  865. * The all dirty flag value
  866. */
  867. static readonly MATERIAL_AllDirtyFlag: number;
  868. /**
  869. * Returns the triangle fill mode
  870. */
  871. static readonly MATERIAL_TriangleFillMode: number;
  872. /**
  873. * Returns the wireframe mode
  874. */
  875. static readonly MATERIAL_WireFrameFillMode: number;
  876. /**
  877. * Returns the point fill mode
  878. */
  879. static readonly MATERIAL_PointFillMode: number;
  880. /**
  881. * Returns the point list draw mode
  882. */
  883. static readonly MATERIAL_PointListDrawMode: number;
  884. /**
  885. * Returns the line list draw mode
  886. */
  887. static readonly MATERIAL_LineListDrawMode: number;
  888. /**
  889. * Returns the line loop draw mode
  890. */
  891. static readonly MATERIAL_LineLoopDrawMode: number;
  892. /**
  893. * Returns the line strip draw mode
  894. */
  895. static readonly MATERIAL_LineStripDrawMode: number;
  896. /**
  897. * Returns the triangle strip draw mode
  898. */
  899. static readonly MATERIAL_TriangleStripDrawMode: number;
  900. /**
  901. * Returns the triangle fan draw mode
  902. */
  903. static readonly MATERIAL_TriangleFanDrawMode: number;
  904. /**
  905. * Stores the clock-wise side orientation
  906. */
  907. static readonly MATERIAL_ClockWiseSideOrientation: number;
  908. /**
  909. * Stores the counter clock-wise side orientation
  910. */
  911. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  912. /**
  913. * Nothing
  914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  915. */
  916. static readonly ACTION_NothingTrigger: number;
  917. /**
  918. * On pick
  919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  920. */
  921. static readonly ACTION_OnPickTrigger: number;
  922. /**
  923. * On left pick
  924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  925. */
  926. static readonly ACTION_OnLeftPickTrigger: number;
  927. /**
  928. * On right pick
  929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  930. */
  931. static readonly ACTION_OnRightPickTrigger: number;
  932. /**
  933. * On center pick
  934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnCenterPickTrigger: number;
  937. /**
  938. * On pick down
  939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickDownTrigger: number;
  942. /**
  943. * On double pick
  944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnDoublePickTrigger: number;
  947. /**
  948. * On pick up
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPickUpTrigger: number;
  952. /**
  953. * On pick out.
  954. * This trigger will only be raised if you also declared a OnPickDown
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickOutTrigger: number;
  958. /**
  959. * On long press
  960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  961. */
  962. static readonly ACTION_OnLongPressTrigger: number;
  963. /**
  964. * On pointer over
  965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  966. */
  967. static readonly ACTION_OnPointerOverTrigger: number;
  968. /**
  969. * On pointer out
  970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  971. */
  972. static readonly ACTION_OnPointerOutTrigger: number;
  973. /**
  974. * On every frame
  975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  976. */
  977. static readonly ACTION_OnEveryFrameTrigger: number;
  978. /**
  979. * On intersection enter
  980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  981. */
  982. static readonly ACTION_OnIntersectionEnterTrigger: number;
  983. /**
  984. * On intersection exit
  985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  986. */
  987. static readonly ACTION_OnIntersectionExitTrigger: number;
  988. /**
  989. * On key down
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnKeyDownTrigger: number;
  993. /**
  994. * On key up
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnKeyUpTrigger: number;
  998. /**
  999. * Billboard mode will only apply to Y axis
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1002. /**
  1003. * Billboard mode will apply to all axes
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1006. /**
  1007. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1008. */
  1009. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1010. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1011. * Test order :
  1012. * Is the bounding sphere outside the frustum ?
  1013. * If not, are the bounding box vertices outside the frustum ?
  1014. * It not, then the cullable object is in the frustum.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1017. /** Culling strategy : Bounding Sphere Only.
  1018. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1019. * It's also less accurate than the standard because some not visible objects can still be selected.
  1020. * Test : is the bounding sphere outside the frustum ?
  1021. * If not, then the cullable object is in the frustum.
  1022. */
  1023. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1024. /** Culling strategy : Optimistic Inclusion.
  1025. * This in an inclusion test first, then the standard exclusion test.
  1026. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1027. * 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.
  1028. * Anyway, it's as accurate as the standard strategy.
  1029. * Test :
  1030. * Is the cullable object bounding sphere center in the frustum ?
  1031. * If not, apply the default culling strategy.
  1032. */
  1033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1034. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1035. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1036. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1037. * 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.
  1038. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1039. * Test :
  1040. * Is the cullable object bounding sphere center in the frustum ?
  1041. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1042. */
  1043. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1044. /**
  1045. * No logging while loading
  1046. */
  1047. static readonly SCENELOADER_NO_LOGGING: number;
  1048. /**
  1049. * Minimal logging while loading
  1050. */
  1051. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1052. /**
  1053. * Summary logging while loading
  1054. */
  1055. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1056. /**
  1057. * Detailled logging while loading
  1058. */
  1059. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1060. /**
  1061. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1062. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1063. */
  1064. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1065. /**
  1066. * Constant used to retrieve the position texture index in the textures array in the prepass
  1067. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1068. */
  1069. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1070. /**
  1071. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1072. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1073. */
  1074. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1075. /**
  1076. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1077. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1078. */
  1079. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1080. /**
  1081. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1082. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1083. */
  1084. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1085. /**
  1086. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1087. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1088. */
  1089. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1090. /**
  1091. * Constant used to retrieve albedo index in the textures array in the prepass
  1092. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1093. */
  1094. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1095. }
  1096. }
  1097. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1098. import { Nullable } from "babylonjs/types";
  1099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module "babylonjs/Engines/IPipelineContext" {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module "babylonjs/Meshes/dataBuffer" {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1189. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1190. /** @hidden */
  1191. export interface ProcessingOptions {
  1192. defines: string[];
  1193. indexParameters: any;
  1194. isFragment: boolean;
  1195. shouldUseHighPrecisionShader: boolean;
  1196. supportsUniformBuffers: boolean;
  1197. shadersRepository: string;
  1198. includesShadersStore: {
  1199. [key: string]: string;
  1200. };
  1201. processor?: IShaderProcessor;
  1202. version: string;
  1203. platformName: string;
  1204. lookForClosingBracketForUniformBuffer?: boolean;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1208. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1234. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1235. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1236. /** @hidden */
  1237. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1238. process(preprocessors: {
  1239. [key: string]: string;
  1240. }, options: ProcessingOptions): string;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1244. /** @hidden */
  1245. export class ShaderDefineExpression {
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. private static _OperatorPriority;
  1250. private static _Stack;
  1251. static postfixToInfix(postfix: string[]): string;
  1252. static infixToPostfix(infix: string): string[];
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1256. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1257. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1258. /** @hidden */
  1259. export class ShaderCodeTestNode extends ShaderCodeNode {
  1260. testExpression: ShaderDefineExpression;
  1261. isValid(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1270. define: string;
  1271. not: boolean;
  1272. constructor(define: string, not?: boolean);
  1273. isTrue(preprocessors: {
  1274. [key: string]: string;
  1275. }): boolean;
  1276. }
  1277. }
  1278. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1279. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1280. /** @hidden */
  1281. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1282. leftOperand: ShaderDefineExpression;
  1283. rightOperand: ShaderDefineExpression;
  1284. isTrue(preprocessors: {
  1285. [key: string]: string;
  1286. }): boolean;
  1287. }
  1288. }
  1289. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1290. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1291. /** @hidden */
  1292. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1293. leftOperand: ShaderDefineExpression;
  1294. rightOperand: ShaderDefineExpression;
  1295. isTrue(preprocessors: {
  1296. [key: string]: string;
  1297. }): boolean;
  1298. }
  1299. }
  1300. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1301. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1302. /** @hidden */
  1303. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1304. define: string;
  1305. operand: string;
  1306. testValue: string;
  1307. constructor(define: string, operand: string, testValue: string);
  1308. isTrue(preprocessors: {
  1309. [key: string]: string;
  1310. }): boolean;
  1311. }
  1312. }
  1313. declare module "babylonjs/Offline/IOfflineProvider" {
  1314. /**
  1315. * Class used to enable access to offline support
  1316. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1317. */
  1318. export interface IOfflineProvider {
  1319. /**
  1320. * Gets a boolean indicating if scene must be saved in the database
  1321. */
  1322. enableSceneOffline: boolean;
  1323. /**
  1324. * Gets a boolean indicating if textures must be saved in the database
  1325. */
  1326. enableTexturesOffline: boolean;
  1327. /**
  1328. * Open the offline support and make it available
  1329. * @param successCallback defines the callback to call on success
  1330. * @param errorCallback defines the callback to call on error
  1331. */
  1332. open(successCallback: () => void, errorCallback: () => void): void;
  1333. /**
  1334. * Loads an image from the offline support
  1335. * @param url defines the url to load from
  1336. * @param image defines the target DOM image
  1337. */
  1338. loadImage(url: string, image: HTMLImageElement): void;
  1339. /**
  1340. * Loads a file from offline support
  1341. * @param url defines the URL to load from
  1342. * @param sceneLoaded defines a callback to call on success
  1343. * @param progressCallBack defines a callback to call when progress changed
  1344. * @param errorCallback defines a callback to call on error
  1345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1346. */
  1347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/filesInputStore" {
  1351. /**
  1352. * Class used to help managing file picking and drag'n'drop
  1353. * File Storage
  1354. */
  1355. export class FilesInputStore {
  1356. /**
  1357. * List of files ready to be loaded
  1358. */
  1359. static FilesToLoad: {
  1360. [key: string]: File;
  1361. };
  1362. }
  1363. }
  1364. declare module "babylonjs/Misc/retryStrategy" {
  1365. import { WebRequest } from "babylonjs/Misc/webRequest";
  1366. /**
  1367. * Class used to define a retry strategy when error happens while loading assets
  1368. */
  1369. export class RetryStrategy {
  1370. /**
  1371. * Function used to defines an exponential back off strategy
  1372. * @param maxRetries defines the maximum number of retries (3 by default)
  1373. * @param baseInterval defines the interval between retries
  1374. * @returns the strategy function to use
  1375. */
  1376. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1377. }
  1378. }
  1379. declare module "babylonjs/Misc/baseError" {
  1380. /**
  1381. * @ignore
  1382. * Application error to support additional information when loading a file
  1383. */
  1384. export abstract class BaseError extends Error {
  1385. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/fileTools" {
  1389. import { WebRequest } from "babylonjs/Misc/webRequest";
  1390. import { Nullable } from "babylonjs/types";
  1391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1392. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1393. import { BaseError } from "babylonjs/Misc/baseError";
  1394. /** @ignore */
  1395. export class LoadFileError extends BaseError {
  1396. request?: WebRequest;
  1397. file?: File;
  1398. /**
  1399. * Creates a new LoadFileError
  1400. * @param message defines the message of the error
  1401. * @param request defines the optional web request
  1402. * @param file defines the optional file
  1403. */
  1404. constructor(message: string, object?: WebRequest | File);
  1405. }
  1406. /** @ignore */
  1407. export class RequestFileError extends BaseError {
  1408. request: WebRequest;
  1409. /**
  1410. * Creates a new LoadFileError
  1411. * @param message defines the message of the error
  1412. * @param request defines the optional web request
  1413. */
  1414. constructor(message: string, request: WebRequest);
  1415. }
  1416. /** @ignore */
  1417. export class ReadFileError extends BaseError {
  1418. file: File;
  1419. /**
  1420. * Creates a new ReadFileError
  1421. * @param message defines the message of the error
  1422. * @param file defines the optional file
  1423. */
  1424. constructor(message: string, file: File);
  1425. }
  1426. /**
  1427. * @hidden
  1428. */
  1429. export class FileTools {
  1430. /**
  1431. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1432. */
  1433. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1434. /**
  1435. * Gets or sets the base URL to use to load assets
  1436. */
  1437. static BaseUrl: string;
  1438. /**
  1439. * Default behaviour for cors in the application.
  1440. * It can be a string if the expected behavior is identical in the entire app.
  1441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1442. */
  1443. static CorsBehavior: string | ((url: string | string[]) => string);
  1444. /**
  1445. * Gets or sets a function used to pre-process url before using them to load assets
  1446. */
  1447. static PreprocessUrl: (url: string) => string;
  1448. /**
  1449. * Removes unwanted characters from an url
  1450. * @param url defines the url to clean
  1451. * @returns the cleaned url
  1452. */
  1453. private static _CleanUrl;
  1454. /**
  1455. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1456. * @param url define the url we are trying
  1457. * @param element define the dom element where to configure the cors policy
  1458. */
  1459. static SetCorsBehavior(url: string | string[], element: {
  1460. crossOrigin: string | null;
  1461. }): void;
  1462. /**
  1463. * Loads an image as an HTMLImageElement.
  1464. * @param input url string, ArrayBuffer, or Blob to load
  1465. * @param onLoad callback called when the image successfully loads
  1466. * @param onError callback called when the image fails to load
  1467. * @param offlineProvider offline provider for caching
  1468. * @param mimeType optional mime type
  1469. * @returns the HTMLImageElement of the loaded image
  1470. */
  1471. 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>;
  1472. /**
  1473. * Reads a file from a File object
  1474. * @param file defines the file to load
  1475. * @param onSuccess defines the callback to call when data is loaded
  1476. * @param onProgress defines the callback to call during loading process
  1477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1478. * @param onError defines the callback to call when an error occurs
  1479. * @returns a file request object
  1480. */
  1481. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. */
  1492. 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;
  1493. /**
  1494. * Loads a file
  1495. * @param url url to load
  1496. * @param onSuccess callback called when the file successfully loads
  1497. * @param onProgress callback called while file is loading (if the server supports this mode)
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @param onOpened callback called when the web request is opened
  1501. * @returns a file request object
  1502. */
  1503. 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;
  1504. /**
  1505. * Checks if the loaded document was accessed via `file:`-Protocol.
  1506. * @returns boolean
  1507. */
  1508. static IsFileURL(): boolean;
  1509. }
  1510. }
  1511. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1512. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1513. import { WebRequest } from "babylonjs/Misc/webRequest";
  1514. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1515. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1517. /** @hidden */
  1518. export class ShaderProcessor {
  1519. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1520. private static _ProcessPrecision;
  1521. private static _ExtractOperation;
  1522. private static _BuildSubExpression;
  1523. private static _BuildExpression;
  1524. private static _MoveCursorWithinIf;
  1525. private static _MoveCursor;
  1526. private static _EvaluatePreProcessors;
  1527. private static _PreparePreProcessors;
  1528. private static _ProcessShaderConversion;
  1529. private static _ProcessIncludes;
  1530. /**
  1531. * Loads a file from a url
  1532. * @param url url to load
  1533. * @param onSuccess callback called when the file successfully loads
  1534. * @param onProgress callback called while file is loading (if the server supports this mode)
  1535. * @param offlineProvider defines the offline provider for caching
  1536. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1537. * @param onError callback called when the file fails to load
  1538. * @returns a file request object
  1539. * @hidden
  1540. */
  1541. 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;
  1542. }
  1543. }
  1544. declare module "babylonjs/Maths/math.like" {
  1545. import { float, int, DeepImmutable } from "babylonjs/types";
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IColor4Like {
  1550. r: float;
  1551. g: float;
  1552. b: float;
  1553. a: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IColor3Like {
  1559. r: float;
  1560. g: float;
  1561. b: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IVector4Like {
  1567. x: float;
  1568. y: float;
  1569. z: float;
  1570. w: float;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IVector3Like {
  1576. x: float;
  1577. y: float;
  1578. z: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector2Like {
  1584. x: float;
  1585. y: float;
  1586. }
  1587. /**
  1588. * @hidden
  1589. */
  1590. export interface IMatrixLike {
  1591. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1592. updateFlag: int;
  1593. }
  1594. /**
  1595. * @hidden
  1596. */
  1597. export interface IViewportLike {
  1598. x: float;
  1599. y: float;
  1600. width: float;
  1601. height: float;
  1602. }
  1603. /**
  1604. * @hidden
  1605. */
  1606. export interface IPlaneLike {
  1607. normal: IVector3Like;
  1608. d: float;
  1609. normalize(): void;
  1610. }
  1611. }
  1612. declare module "babylonjs/Materials/iEffectFallbacks" {
  1613. import { Effect } from "babylonjs/Materials/effect";
  1614. /**
  1615. * Interface used to define common properties for effect fallbacks
  1616. */
  1617. export interface IEffectFallbacks {
  1618. /**
  1619. * Removes the defines that should be removed when falling back.
  1620. * @param currentDefines defines the current define statements for the shader.
  1621. * @param effect defines the current effect we try to compile
  1622. * @returns The resulting defines with defines of the current rank removed.
  1623. */
  1624. reduce(currentDefines: string, effect: Effect): string;
  1625. /**
  1626. * Removes the fallback from the bound mesh.
  1627. */
  1628. unBindMesh(): void;
  1629. /**
  1630. * Checks to see if more fallbacks are still availible.
  1631. */
  1632. hasMoreFallbacks: boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1636. /**
  1637. * Class used to evalaute queries containing `and` and `or` operators
  1638. */
  1639. export class AndOrNotEvaluator {
  1640. /**
  1641. * Evaluate a query
  1642. * @param query defines the query to evaluate
  1643. * @param evaluateCallback defines the callback used to filter result
  1644. * @returns true if the query matches
  1645. */
  1646. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1647. private static _HandleParenthesisContent;
  1648. private static _SimplifyNegation;
  1649. }
  1650. }
  1651. declare module "babylonjs/Misc/tags" {
  1652. /**
  1653. * Class used to store custom tags
  1654. */
  1655. export class Tags {
  1656. /**
  1657. * Adds support for tags on the given object
  1658. * @param obj defines the object to use
  1659. */
  1660. static EnableFor(obj: any): void;
  1661. /**
  1662. * Removes tags support
  1663. * @param obj defines the object to use
  1664. */
  1665. static DisableFor(obj: any): void;
  1666. /**
  1667. * Gets a boolean indicating if the given object has tags
  1668. * @param obj defines the object to use
  1669. * @returns a boolean
  1670. */
  1671. static HasTags(obj: any): boolean;
  1672. /**
  1673. * Gets the tags available on a given object
  1674. * @param obj defines the object to use
  1675. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1676. * @returns the tags
  1677. */
  1678. static GetTags(obj: any, asString?: boolean): any;
  1679. /**
  1680. * Adds tags to an object
  1681. * @param obj defines the object to use
  1682. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1683. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1684. */
  1685. static AddTagsTo(obj: any, tagsString: string): void;
  1686. /**
  1687. * @hidden
  1688. */
  1689. static _AddTagTo(obj: any, tag: string): void;
  1690. /**
  1691. * Removes specific tags from a specific object
  1692. * @param obj defines the object to use
  1693. * @param tagsString defines the tags to remove
  1694. */
  1695. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _RemoveTagFrom(obj: any, tag: string): void;
  1700. /**
  1701. * Defines if tags hosted on an object match a given query
  1702. * @param obj defines the object to use
  1703. * @param tagsQuery defines the tag query
  1704. * @returns a boolean
  1705. */
  1706. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1707. }
  1708. }
  1709. declare module "babylonjs/Maths/math.scalar" {
  1710. /**
  1711. * Scalar computation library
  1712. */
  1713. export class Scalar {
  1714. /**
  1715. * Two pi constants convenient for computation.
  1716. */
  1717. static TwoPi: number;
  1718. /**
  1719. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. * @param a number
  1721. * @param b number
  1722. * @param epsilon (default = 1.401298E-45)
  1723. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1724. */
  1725. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1726. /**
  1727. * Returns a string : the upper case translation of the number i to hexadecimal.
  1728. * @param i number
  1729. * @returns the upper case translation of the number i to hexadecimal.
  1730. */
  1731. static ToHex(i: number): string;
  1732. /**
  1733. * Returns -1 if value is negative and +1 is value is positive.
  1734. * @param value the value
  1735. * @returns the value itself if it's equal to zero.
  1736. */
  1737. static Sign(value: number): number;
  1738. /**
  1739. * Returns the value itself if it's between min and max.
  1740. * Returns min if the value is lower than min.
  1741. * Returns max if the value is greater than max.
  1742. * @param value the value to clmap
  1743. * @param min the min value to clamp to (default: 0)
  1744. * @param max the max value to clamp to (default: 1)
  1745. * @returns the clamped value
  1746. */
  1747. static Clamp(value: number, min?: number, max?: number): number;
  1748. /**
  1749. * the log2 of value.
  1750. * @param value the value to compute log2 of
  1751. * @returns the log2 of value.
  1752. */
  1753. static Log2(value: number): number;
  1754. /**
  1755. * Loops the value, so that it is never larger than length and never smaller than 0.
  1756. *
  1757. * This is similar to the modulo operator but it works with floating point numbers.
  1758. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1759. * With t = 5 and length = 2.5, the result would be 0.0.
  1760. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1761. * @param value the value
  1762. * @param length the length
  1763. * @returns the looped value
  1764. */
  1765. static Repeat(value: number, length: number): number;
  1766. /**
  1767. * Normalize the value between 0.0 and 1.0 using min and max values
  1768. * @param value value to normalize
  1769. * @param min max to normalize between
  1770. * @param max min to normalize between
  1771. * @returns the normalized value
  1772. */
  1773. static Normalize(value: number, min: number, max: number): number;
  1774. /**
  1775. * Denormalize the value from 0.0 and 1.0 using min and max values
  1776. * @param normalized value to denormalize
  1777. * @param min max to denormalize between
  1778. * @param max min to denormalize between
  1779. * @returns the denormalized value
  1780. */
  1781. static Denormalize(normalized: number, min: number, max: number): number;
  1782. /**
  1783. * Calculates the shortest difference between two given angles given in degrees.
  1784. * @param current current angle in degrees
  1785. * @param target target angle in degrees
  1786. * @returns the delta
  1787. */
  1788. static DeltaAngle(current: number, target: number): number;
  1789. /**
  1790. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1791. * @param tx value
  1792. * @param length length
  1793. * @returns The returned value will move back and forth between 0 and length
  1794. */
  1795. static PingPong(tx: number, length: number): number;
  1796. /**
  1797. * Interpolates between min and max with smoothing at the limits.
  1798. *
  1799. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1800. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1801. * @param from from
  1802. * @param to to
  1803. * @param tx value
  1804. * @returns the smooth stepped value
  1805. */
  1806. static SmoothStep(from: number, to: number, tx: number): number;
  1807. /**
  1808. * Moves a value current towards target.
  1809. *
  1810. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1811. * Negative values of maxDelta pushes the value away from target.
  1812. * @param current current value
  1813. * @param target target value
  1814. * @param maxDelta max distance to move
  1815. * @returns resulting value
  1816. */
  1817. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1818. /**
  1819. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1820. *
  1821. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1822. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1823. * @param current current value
  1824. * @param target target value
  1825. * @param maxDelta max distance to move
  1826. * @returns resulting angle
  1827. */
  1828. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1829. /**
  1830. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1831. * @param start start value
  1832. * @param end target value
  1833. * @param amount amount to lerp between
  1834. * @returns the lerped value
  1835. */
  1836. static Lerp(start: number, end: number, amount: number): number;
  1837. /**
  1838. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1839. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1840. * @param start start value
  1841. * @param end target value
  1842. * @param amount amount to lerp between
  1843. * @returns the lerped value
  1844. */
  1845. static LerpAngle(start: number, end: number, amount: number): number;
  1846. /**
  1847. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1848. * @param a start value
  1849. * @param b target value
  1850. * @param value value between a and b
  1851. * @returns the inverseLerp value
  1852. */
  1853. static InverseLerp(a: number, b: number, value: number): number;
  1854. /**
  1855. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1856. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1857. * @param value1 spline value
  1858. * @param tangent1 spline value
  1859. * @param value2 spline value
  1860. * @param tangent2 spline value
  1861. * @param amount input value
  1862. * @returns hermite result
  1863. */
  1864. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1865. /**
  1866. * Returns a random float number between and min and max values
  1867. * @param min min value of random
  1868. * @param max max value of random
  1869. * @returns random value
  1870. */
  1871. static RandomRange(min: number, max: number): number;
  1872. /**
  1873. * This function returns percentage of a number in a given range.
  1874. *
  1875. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1876. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1877. * @param number to convert to percentage
  1878. * @param min min range
  1879. * @param max max range
  1880. * @returns the percentage
  1881. */
  1882. static RangeToPercent(number: number, min: number, max: number): number;
  1883. /**
  1884. * This function returns number that corresponds to the percentage in a given range.
  1885. *
  1886. * PercentToRange(0.34,0,100) will return 34.
  1887. * @param percent to convert to number
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the number
  1891. */
  1892. static PercentToRange(percent: number, min: number, max: number): number;
  1893. /**
  1894. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1895. * @param angle The angle to normalize in radian.
  1896. * @return The converted angle.
  1897. */
  1898. static NormalizeRadians(angle: number): number;
  1899. }
  1900. }
  1901. declare module "babylonjs/Maths/math.constants" {
  1902. /**
  1903. * Constant used to convert a value to gamma space
  1904. * @ignorenaming
  1905. */
  1906. export const ToGammaSpace: number;
  1907. /**
  1908. * Constant used to convert a value to linear space
  1909. * @ignorenaming
  1910. */
  1911. export const ToLinearSpace = 2.2;
  1912. /**
  1913. * Constant used to define the minimal number value in Babylon.js
  1914. * @ignorenaming
  1915. */
  1916. let Epsilon: number;
  1917. export { Epsilon };
  1918. }
  1919. declare module "babylonjs/Maths/math.viewport" {
  1920. /**
  1921. * Class used to represent a viewport on screen
  1922. */
  1923. export class Viewport {
  1924. /** viewport left coordinate */
  1925. x: number;
  1926. /** viewport top coordinate */
  1927. y: number;
  1928. /**viewport width */
  1929. width: number;
  1930. /** viewport height */
  1931. height: number;
  1932. /**
  1933. * Creates a Viewport object located at (x, y) and sized (width, height)
  1934. * @param x defines viewport left coordinate
  1935. * @param y defines viewport top coordinate
  1936. * @param width defines the viewport width
  1937. * @param height defines the viewport height
  1938. */
  1939. constructor(
  1940. /** viewport left coordinate */
  1941. x: number,
  1942. /** viewport top coordinate */
  1943. y: number,
  1944. /**viewport width */
  1945. width: number,
  1946. /** viewport height */
  1947. height: number);
  1948. /**
  1949. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1950. * @param renderWidth defines the rendering width
  1951. * @param renderHeight defines the rendering height
  1952. * @returns a new Viewport
  1953. */
  1954. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1955. /**
  1956. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1957. * @param renderWidth defines the rendering width
  1958. * @param renderHeight defines the rendering height
  1959. * @param ref defines the target viewport
  1960. * @returns the current viewport
  1961. */
  1962. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1963. /**
  1964. * Returns a new Viewport copied from the current one
  1965. * @returns a new Viewport
  1966. */
  1967. clone(): Viewport;
  1968. }
  1969. }
  1970. declare module "babylonjs/Misc/arrayTools" {
  1971. /**
  1972. * Class containing a set of static utilities functions for arrays.
  1973. */
  1974. export class ArrayTools {
  1975. /**
  1976. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1977. * @param size the number of element to construct and put in the array
  1978. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1979. * @returns a new array filled with new objects
  1980. */
  1981. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1982. }
  1983. }
  1984. declare module "babylonjs/Maths/math.plane" {
  1985. import { DeepImmutable } from "babylonjs/types";
  1986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1987. /**
  1988. * Represents a plane by the equation ax + by + cz + d = 0
  1989. */
  1990. export class Plane {
  1991. private static _TmpMatrix;
  1992. /**
  1993. * Normal of the plane (a,b,c)
  1994. */
  1995. normal: Vector3;
  1996. /**
  1997. * d component of the plane
  1998. */
  1999. d: number;
  2000. /**
  2001. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2002. * @param a a component of the plane
  2003. * @param b b component of the plane
  2004. * @param c c component of the plane
  2005. * @param d d component of the plane
  2006. */
  2007. constructor(a: number, b: number, c: number, d: number);
  2008. /**
  2009. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2010. */
  2011. asArray(): number[];
  2012. /**
  2013. * @returns a new plane copied from the current Plane.
  2014. */
  2015. clone(): Plane;
  2016. /**
  2017. * @returns the string "Plane".
  2018. */
  2019. getClassName(): string;
  2020. /**
  2021. * @returns the Plane hash code.
  2022. */
  2023. getHashCode(): number;
  2024. /**
  2025. * Normalize the current Plane in place.
  2026. * @returns the updated Plane.
  2027. */
  2028. normalize(): Plane;
  2029. /**
  2030. * Applies a transformation the plane and returns the result
  2031. * @param transformation the transformation matrix to be applied to the plane
  2032. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2033. */
  2034. transform(transformation: DeepImmutable<Matrix>): Plane;
  2035. /**
  2036. * Compute the dot product between the point and the plane normal
  2037. * @param point point to calculate the dot product with
  2038. * @returns the dot product (float) of the point coordinates and the plane normal.
  2039. */
  2040. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2041. /**
  2042. * Updates the current Plane from the plane defined by the three given points.
  2043. * @param point1 one of the points used to contruct the plane
  2044. * @param point2 one of the points used to contruct the plane
  2045. * @param point3 one of the points used to contruct the plane
  2046. * @returns the updated Plane.
  2047. */
  2048. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2049. /**
  2050. * Checks if the plane is facing a given direction
  2051. * @param direction the direction to check if the plane is facing
  2052. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2053. * @returns True is the vector "direction" is the same side than the plane normal.
  2054. */
  2055. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2056. /**
  2057. * Calculates the distance to a point
  2058. * @param point point to calculate distance to
  2059. * @returns the signed distance (float) from the given point to the Plane.
  2060. */
  2061. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2062. /**
  2063. * Creates a plane from an array
  2064. * @param array the array to create a plane from
  2065. * @returns a new Plane from the given array.
  2066. */
  2067. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2068. /**
  2069. * Creates a plane from three points
  2070. * @param point1 point used to create the plane
  2071. * @param point2 point used to create the plane
  2072. * @param point3 point used to create the plane
  2073. * @returns a new Plane defined by the three given points.
  2074. */
  2075. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2076. /**
  2077. * Creates a plane from an origin point and a normal
  2078. * @param origin origin of the plane to be constructed
  2079. * @param normal normal of the plane to be constructed
  2080. * @returns a new Plane the normal vector to this plane at the given origin point.
  2081. * Note : the vector "normal" is updated because normalized.
  2082. */
  2083. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2084. /**
  2085. * Calculates the distance from a plane and a point
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @param point point to calculate distance to
  2089. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2090. */
  2091. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2092. }
  2093. }
  2094. declare module "babylonjs/Engines/performanceConfigurator" {
  2095. /** @hidden */
  2096. export class PerformanceConfigurator {
  2097. /** @hidden */
  2098. static MatrixUse64Bits: boolean;
  2099. /** @hidden */
  2100. static MatrixTrackPrecisionChange: boolean;
  2101. /** @hidden */
  2102. static MatrixCurrentType: any;
  2103. /** @hidden */
  2104. static MatrixTrackedMatrices: Array<any> | null;
  2105. /** @hidden */
  2106. static SetMatrixPrecision(use64bits: boolean): void;
  2107. }
  2108. }
  2109. declare module "babylonjs/Maths/math.vector" {
  2110. import { Viewport } from "babylonjs/Maths/math.viewport";
  2111. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2112. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2113. import { Plane } from "babylonjs/Maths/math.plane";
  2114. /**
  2115. * Class representing a vector containing 2 coordinates
  2116. */
  2117. export class Vector2 {
  2118. /** defines the first coordinate */
  2119. x: number;
  2120. /** defines the second coordinate */
  2121. y: number;
  2122. /**
  2123. * Creates a new Vector2 from the given x and y coordinates
  2124. * @param x defines the first coordinate
  2125. * @param y defines the second coordinate
  2126. */
  2127. constructor(
  2128. /** defines the first coordinate */
  2129. x?: number,
  2130. /** defines the second coordinate */
  2131. y?: number);
  2132. /**
  2133. * Gets a string with the Vector2 coordinates
  2134. * @returns a string with the Vector2 coordinates
  2135. */
  2136. toString(): string;
  2137. /**
  2138. * Gets class name
  2139. * @returns the string "Vector2"
  2140. */
  2141. getClassName(): string;
  2142. /**
  2143. * Gets current vector hash code
  2144. * @returns the Vector2 hash code as a number
  2145. */
  2146. getHashCode(): number;
  2147. /**
  2148. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2149. * @param array defines the source array
  2150. * @param index defines the offset in source array
  2151. * @returns the current Vector2
  2152. */
  2153. toArray(array: FloatArray, index?: number): Vector2;
  2154. /**
  2155. * Update the current vector from an array
  2156. * @param array defines the destination array
  2157. * @param index defines the offset in the destination array
  2158. * @returns the current Vector3
  2159. */
  2160. fromArray(array: FloatArray, index?: number): Vector2;
  2161. /**
  2162. * Copy the current vector to an array
  2163. * @returns a new array with 2 elements: the Vector2 coordinates.
  2164. */
  2165. asArray(): number[];
  2166. /**
  2167. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2168. * @param source defines the source Vector2
  2169. * @returns the current updated Vector2
  2170. */
  2171. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets the Vector2 coordinates with the given floats
  2174. * @param x defines the first coordinate
  2175. * @param y defines the second coordinate
  2176. * @returns the current updated Vector2
  2177. */
  2178. copyFromFloats(x: number, y: number): Vector2;
  2179. /**
  2180. * Sets the Vector2 coordinates with the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns the current updated Vector2
  2184. */
  2185. set(x: number, y: number): Vector2;
  2186. /**
  2187. * Add another vector with the current one
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2190. */
  2191. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns a new Vector2
  2209. */
  2210. addVector3(otherVector: Vector3): Vector2;
  2211. /**
  2212. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. subtract(otherVector: Vector2): Vector2;
  2217. /**
  2218. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2219. * @param otherVector defines the other vector
  2220. * @param result defines the target vector
  2221. * @returns the unmodified current Vector2
  2222. */
  2223. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2224. /**
  2225. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2226. * @param otherVector defines the other vector
  2227. * @returns the current updated Vector2
  2228. */
  2229. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Multiplies in place the current Vector2 coordinates by the given ones
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2238. * @param otherVector defines the other vector
  2239. * @returns a new Vector2
  2240. */
  2241. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @param result defines the target vector
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2251. * @param x defines the first coordinate
  2252. * @param y defines the second coordinate
  2253. * @returns a new Vector2
  2254. */
  2255. multiplyByFloats(x: number, y: number): Vector2;
  2256. /**
  2257. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2258. * @param otherVector defines the other vector
  2259. * @returns a new Vector2
  2260. */
  2261. divide(otherVector: Vector2): Vector2;
  2262. /**
  2263. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @param result defines the target vector
  2266. * @returns the unmodified current Vector2
  2267. */
  2268. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2269. /**
  2270. * Divides the current Vector2 coordinates by the given ones
  2271. * @param otherVector defines the other vector
  2272. * @returns the current updated Vector2
  2273. */
  2274. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2275. /**
  2276. * Gets a new Vector2 with current Vector2 negated coordinates
  2277. * @returns a new Vector2
  2278. */
  2279. negate(): Vector2;
  2280. /**
  2281. * Negate this vector in place
  2282. * @returns this
  2283. */
  2284. negateInPlace(): Vector2;
  2285. /**
  2286. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2287. * @param result defines the Vector3 object where to store the result
  2288. * @returns the current Vector2
  2289. */
  2290. negateToRef(result: Vector2): Vector2;
  2291. /**
  2292. * Multiply the Vector2 coordinates by scale
  2293. * @param scale defines the scaling factor
  2294. * @returns the current updated Vector2
  2295. */
  2296. scaleInPlace(scale: number): Vector2;
  2297. /**
  2298. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2299. * @param scale defines the scaling factor
  2300. * @returns a new Vector2
  2301. */
  2302. scale(scale: number): Vector2;
  2303. /**
  2304. * Scale the current Vector2 values by a factor to a given Vector2
  2305. * @param scale defines the scale factor
  2306. * @param result defines the Vector2 object where to store the result
  2307. * @returns the unmodified current Vector2
  2308. */
  2309. scaleToRef(scale: number, result: Vector2): Vector2;
  2310. /**
  2311. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2312. * @param scale defines the scale factor
  2313. * @param result defines the Vector2 object where to store the result
  2314. * @returns the unmodified current Vector2
  2315. */
  2316. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2317. /**
  2318. * Gets a boolean if two vectors are equals
  2319. * @param otherVector defines the other vector
  2320. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2321. */
  2322. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2323. /**
  2324. * Gets a boolean if two vectors are equals (using an epsilon value)
  2325. * @param otherVector defines the other vector
  2326. * @param epsilon defines the minimal distance to consider equality
  2327. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2328. */
  2329. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2330. /**
  2331. * Gets a new Vector2 from current Vector2 floored values
  2332. * @returns a new Vector2
  2333. */
  2334. floor(): Vector2;
  2335. /**
  2336. * Gets a new Vector2 from current Vector2 floored values
  2337. * @returns a new Vector2
  2338. */
  2339. fract(): Vector2;
  2340. /**
  2341. * Gets the length of the vector
  2342. * @returns the vector length (float)
  2343. */
  2344. length(): number;
  2345. /**
  2346. * Gets the vector squared length
  2347. * @returns the vector squared length (float)
  2348. */
  2349. lengthSquared(): number;
  2350. /**
  2351. * Normalize the vector
  2352. * @returns the current updated Vector2
  2353. */
  2354. normalize(): Vector2;
  2355. /**
  2356. * Gets a new Vector2 copied from the Vector2
  2357. * @returns a new Vector2
  2358. */
  2359. clone(): Vector2;
  2360. /**
  2361. * Gets a new Vector2(0, 0)
  2362. * @returns a new Vector2
  2363. */
  2364. static Zero(): Vector2;
  2365. /**
  2366. * Gets a new Vector2(1, 1)
  2367. * @returns a new Vector2
  2368. */
  2369. static One(): Vector2;
  2370. /**
  2371. * Gets a new Vector2 set from the given index element of the given array
  2372. * @param array defines the data source
  2373. * @param offset defines the offset in the data source
  2374. * @returns a new Vector2
  2375. */
  2376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2377. /**
  2378. * Sets "result" from the given index element of the given array
  2379. * @param array defines the data source
  2380. * @param offset defines the offset in the data source
  2381. * @param result defines the target vector
  2382. */
  2383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2384. /**
  2385. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2386. * @param value1 defines 1st point of control
  2387. * @param value2 defines 2nd point of control
  2388. * @param value3 defines 3rd point of control
  2389. * @param value4 defines 4th point of control
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * 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".
  2396. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2397. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2398. * @param value defines the value to clamp
  2399. * @param min defines the lower limit
  2400. * @param max defines the upper limit
  2401. * @returns a new Vector2
  2402. */
  2403. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2404. /**
  2405. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2406. * @param value1 defines the 1st control point
  2407. * @param tangent1 defines the outgoing tangent
  2408. * @param value2 defines the 2nd control point
  2409. * @param tangent2 defines the incoming tangent
  2410. * @param amount defines the interpolation factor
  2411. * @returns a new Vector2
  2412. */
  2413. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2416. * @param start defines the start vector
  2417. * @param end defines the end vector
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Gets the dot product of the vector "left" and the vector "right"
  2424. * @param left defines first vector
  2425. * @param right defines second vector
  2426. * @returns the dot product (float)
  2427. */
  2428. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2429. /**
  2430. * Returns a new Vector2 equal to the normalized given vector
  2431. * @param vector defines the vector to normalize
  2432. * @returns a new Vector2
  2433. */
  2434. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2435. /**
  2436. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2437. * @param left defines 1st vector
  2438. * @param right defines 2nd vector
  2439. * @returns a new Vector2
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2442. /**
  2443. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2444. * @param left defines 1st vector
  2445. * @param right defines 2nd vector
  2446. * @returns a new Vector2
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2449. /**
  2450. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2451. * @param vector defines the vector to transform
  2452. * @param transformation defines the matrix to apply
  2453. * @returns a new Vector2
  2454. */
  2455. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2456. /**
  2457. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2458. * @param vector defines the vector to transform
  2459. * @param transformation defines the matrix to apply
  2460. * @param result defines the target vector
  2461. */
  2462. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2463. /**
  2464. * Determines if a given vector is included in a triangle
  2465. * @param p defines the vector to test
  2466. * @param p0 defines 1st triangle point
  2467. * @param p1 defines 2nd triangle point
  2468. * @param p2 defines 3rd triangle point
  2469. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2470. */
  2471. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2472. /**
  2473. * Gets the distance between the vectors "value1" and "value2"
  2474. * @param value1 defines first vector
  2475. * @param value2 defines second vector
  2476. * @returns the distance between vectors
  2477. */
  2478. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2479. /**
  2480. * Returns the squared distance between the vectors "value1" and "value2"
  2481. * @param value1 defines first vector
  2482. * @param value2 defines second vector
  2483. * @returns the squared distance between vectors
  2484. */
  2485. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2486. /**
  2487. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2488. * @param value1 defines first vector
  2489. * @param value2 defines second vector
  2490. * @returns a new Vector2
  2491. */
  2492. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2493. /**
  2494. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2495. * @param p defines the middle point
  2496. * @param segA defines one point of the segment
  2497. * @param segB defines the other point of the segment
  2498. * @returns the shortest distance
  2499. */
  2500. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2501. }
  2502. /**
  2503. * Class used to store (x,y,z) vector representation
  2504. * A Vector3 is the main object used in 3D geometry
  2505. * It can represent etiher the coordinates of a point the space, either a direction
  2506. * Reminder: js uses a left handed forward facing system
  2507. */
  2508. export class Vector3 {
  2509. private static _UpReadOnly;
  2510. private static _ZeroReadOnly;
  2511. /** @hidden */
  2512. _x: number;
  2513. /** @hidden */
  2514. _y: number;
  2515. /** @hidden */
  2516. _z: number;
  2517. /** @hidden */
  2518. _isDirty: boolean;
  2519. /** Gets or sets the x coordinate */
  2520. get x(): number;
  2521. set x(value: number);
  2522. /** Gets or sets the y coordinate */
  2523. get y(): number;
  2524. set y(value: number);
  2525. /** Gets or sets the z coordinate */
  2526. get z(): number;
  2527. set z(value: number);
  2528. /**
  2529. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2530. * @param x defines the first coordinates (on X axis)
  2531. * @param y defines the second coordinates (on Y axis)
  2532. * @param z defines the third coordinates (on Z axis)
  2533. */
  2534. constructor(x?: number, y?: number, z?: number);
  2535. /**
  2536. * Creates a string representation of the Vector3
  2537. * @returns a string with the Vector3 coordinates.
  2538. */
  2539. toString(): string;
  2540. /**
  2541. * Gets the class name
  2542. * @returns the string "Vector3"
  2543. */
  2544. getClassName(): string;
  2545. /**
  2546. * Creates the Vector3 hash code
  2547. * @returns a number which tends to be unique between Vector3 instances
  2548. */
  2549. getHashCode(): number;
  2550. /**
  2551. * Creates an array containing three elements : the coordinates of the Vector3
  2552. * @returns a new array of numbers
  2553. */
  2554. asArray(): number[];
  2555. /**
  2556. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2557. * @param array defines the destination array
  2558. * @param index defines the offset in the destination array
  2559. * @returns the current Vector3
  2560. */
  2561. toArray(array: FloatArray, index?: number): Vector3;
  2562. /**
  2563. * Update the current vector from an array
  2564. * @param array defines the destination array
  2565. * @param index defines the offset in the destination array
  2566. * @returns the current Vector3
  2567. */
  2568. fromArray(array: FloatArray, index?: number): Vector3;
  2569. /**
  2570. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2571. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2572. */
  2573. toQuaternion(): Quaternion;
  2574. /**
  2575. * Adds the given vector to the current Vector3
  2576. * @param otherVector defines the second operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2580. /**
  2581. * Adds the given coordinates to the current Vector3
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2590. * @param otherVector defines the second operand
  2591. * @returns the resulting Vector3
  2592. */
  2593. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2594. /**
  2595. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2596. * @param otherVector defines the second operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2601. /**
  2602. * Subtract the given vector from the current Vector3
  2603. * @param otherVector defines the second operand
  2604. * @returns the current updated Vector3
  2605. */
  2606. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2607. /**
  2608. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the resulting Vector3
  2611. */
  2612. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2615. * @param otherVector defines the second operand
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the current Vector3
  2618. */
  2619. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2620. /**
  2621. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2622. * @param x defines the x coordinate of the operand
  2623. * @param y defines the y coordinate of the operand
  2624. * @param z defines the z coordinate of the operand
  2625. * @returns the resulting Vector3
  2626. */
  2627. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2628. /**
  2629. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @param result defines the Vector3 object where to store the result
  2634. * @returns the current Vector3
  2635. */
  2636. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2637. /**
  2638. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2639. * @returns a new Vector3
  2640. */
  2641. negate(): Vector3;
  2642. /**
  2643. * Negate this vector in place
  2644. * @returns this
  2645. */
  2646. negateInPlace(): Vector3;
  2647. /**
  2648. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2649. * @param result defines the Vector3 object where to store the result
  2650. * @returns the current Vector3
  2651. */
  2652. negateToRef(result: Vector3): Vector3;
  2653. /**
  2654. * Multiplies the Vector3 coordinates by the float "scale"
  2655. * @param scale defines the multiplier factor
  2656. * @returns the current updated Vector3
  2657. */
  2658. scaleInPlace(scale: number): Vector3;
  2659. /**
  2660. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns a new Vector3
  2663. */
  2664. scale(scale: number): Vector3;
  2665. /**
  2666. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2667. * @param scale defines the multiplier factor
  2668. * @param result defines the Vector3 object where to store the result
  2669. * @returns the current Vector3
  2670. */
  2671. scaleToRef(scale: number, result: Vector3): Vector3;
  2672. /**
  2673. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2674. * @param scale defines the scale factor
  2675. * @param result defines the Vector3 object where to store the result
  2676. * @returns the unmodified current Vector3
  2677. */
  2678. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2679. /**
  2680. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2681. * @param origin defines the origin of the projection ray
  2682. * @param plane defines the plane to project to
  2683. * @returns the projected vector3
  2684. */
  2685. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2686. /**
  2687. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2688. * @param origin defines the origin of the projection ray
  2689. * @param plane defines the plane to project to
  2690. * @param result defines the Vector3 where to store the result
  2691. */
  2692. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2693. /**
  2694. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2695. * @param otherVector defines the second operand
  2696. * @returns true if both vectors are equals
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2701. * @param otherVector defines the second operand
  2702. * @param epsilon defines the minimal distance to define values as equals
  2703. * @returns true if both vectors are distant less than epsilon
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2706. /**
  2707. * Returns true if the current Vector3 coordinates equals the given floats
  2708. * @param x defines the x coordinate of the operand
  2709. * @param y defines the y coordinate of the operand
  2710. * @param z defines the z coordinate of the operand
  2711. * @returns true if both vectors are equals
  2712. */
  2713. equalsToFloats(x: number, y: number, z: number): boolean;
  2714. /**
  2715. * Multiplies the current Vector3 coordinates by the given ones
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2720. /**
  2721. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2722. * @param otherVector defines the second operand
  2723. * @returns the new Vector3
  2724. */
  2725. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2728. * @param otherVector defines the second operand
  2729. * @param result defines the Vector3 object where to store the result
  2730. * @returns the current Vector3
  2731. */
  2732. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2735. * @param x defines the x coordinate of the operand
  2736. * @param y defines the y coordinate of the operand
  2737. * @param z defines the z coordinate of the operand
  2738. * @returns the new Vector3
  2739. */
  2740. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2743. * @param otherVector defines the second operand
  2744. * @returns the new Vector3
  2745. */
  2746. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2747. /**
  2748. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2749. * @param otherVector defines the second operand
  2750. * @param result defines the Vector3 object where to store the result
  2751. * @returns the current Vector3
  2752. */
  2753. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2754. /**
  2755. * Divides the current Vector3 coordinates by the given ones.
  2756. * @param otherVector defines the second operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. divideInPlace(otherVector: Vector3): Vector3;
  2760. /**
  2761. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2762. * @param other defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2774. * @param x defines the x coordinate of the operand
  2775. * @param y defines the y coordinate of the operand
  2776. * @param z defines the z coordinate of the operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2782. * @param x defines the x coordinate of the operand
  2783. * @param y defines the y coordinate of the operand
  2784. * @param z defines the z coordinate of the operand
  2785. * @returns the current updated Vector3
  2786. */
  2787. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2790. * Check if is non uniform within a certain amount of decimal places to account for this
  2791. * @param epsilon the amount the values can differ
  2792. * @returns if the the vector is non uniform to a certain number of decimal places
  2793. */
  2794. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2795. /**
  2796. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2797. */
  2798. get isNonUniform(): boolean;
  2799. /**
  2800. * Gets a new Vector3 from current Vector3 floored values
  2801. * @returns a new Vector3
  2802. */
  2803. floor(): Vector3;
  2804. /**
  2805. * Gets a new Vector3 from current Vector3 floored values
  2806. * @returns a new Vector3
  2807. */
  2808. fract(): Vector3;
  2809. /**
  2810. * Gets the length of the Vector3
  2811. * @returns the length of the Vector3
  2812. */
  2813. length(): number;
  2814. /**
  2815. * Gets the squared length of the Vector3
  2816. * @returns squared length of the Vector3
  2817. */
  2818. lengthSquared(): number;
  2819. /**
  2820. * Normalize the current Vector3.
  2821. * Please note that this is an in place operation.
  2822. * @returns the current updated Vector3
  2823. */
  2824. normalize(): Vector3;
  2825. /**
  2826. * Reorders the x y z properties of the vector in place
  2827. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2828. * @returns the current updated vector
  2829. */
  2830. reorderInPlace(order: string): this;
  2831. /**
  2832. * Rotates the vector around 0,0,0 by a quaternion
  2833. * @param quaternion the rotation quaternion
  2834. * @param result vector to store the result
  2835. * @returns the resulting vector
  2836. */
  2837. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2838. /**
  2839. * Rotates a vector around a given point
  2840. * @param quaternion the rotation quaternion
  2841. * @param point the point to rotate around
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2846. /**
  2847. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2848. * The cross product is then orthogonal to both current and "other"
  2849. * @param other defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. cross(other: Vector3): Vector3;
  2853. /**
  2854. * Normalize the current Vector3 with the given input length.
  2855. * Please note that this is an in place operation.
  2856. * @param len the length of the vector
  2857. * @returns the current updated Vector3
  2858. */
  2859. normalizeFromLength(len: number): Vector3;
  2860. /**
  2861. * Normalize the current Vector3 to a new vector
  2862. * @returns the new Vector3
  2863. */
  2864. normalizeToNew(): Vector3;
  2865. /**
  2866. * Normalize the current Vector3 to the reference
  2867. * @param reference define the Vector3 to update
  2868. * @returns the updated Vector3
  2869. */
  2870. normalizeToRef(reference: Vector3): Vector3;
  2871. /**
  2872. * Creates a new Vector3 copied from the current Vector3
  2873. * @returns the new Vector3
  2874. */
  2875. clone(): Vector3;
  2876. /**
  2877. * Copies the given vector coordinates to the current Vector3 ones
  2878. * @param source defines the source Vector3
  2879. * @returns the current updated Vector3
  2880. */
  2881. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Copies the given floats to the current Vector3 coordinates
  2884. * @param x defines the x coordinate of the operand
  2885. * @param y defines the y coordinate of the operand
  2886. * @param z defines the z coordinate of the operand
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFromFloats(x: number, y: number, z: number): Vector3;
  2890. /**
  2891. * Copies the given floats to the current Vector3 coordinates
  2892. * @param x defines the x coordinate of the operand
  2893. * @param y defines the y coordinate of the operand
  2894. * @param z defines the z coordinate of the operand
  2895. * @returns the current updated Vector3
  2896. */
  2897. set(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given float to the current Vector3 coordinates
  2900. * @param v defines the x, y and z coordinates of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. setAll(v: number): Vector3;
  2904. /**
  2905. * Get the clip factor between two vectors
  2906. * @param vector0 defines the first operand
  2907. * @param vector1 defines the second operand
  2908. * @param axis defines the axis to use
  2909. * @param size defines the size along the axis
  2910. * @returns the clip factor
  2911. */
  2912. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2913. /**
  2914. * Get angle between two vectors
  2915. * @param vector0 angle between vector0 and vector1
  2916. * @param vector1 angle between vector0 and vector1
  2917. * @param normal direction of the normal
  2918. * @return the angle between vector0 and vector1
  2919. */
  2920. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2921. /**
  2922. * Returns a new Vector3 set from the index "offset" of the given array
  2923. * @param array defines the source array
  2924. * @param offset defines the offset in the source array
  2925. * @returns the new Vector3
  2926. */
  2927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2930. * @param array defines the source array
  2931. * @param offset defines the offset in the source array
  2932. * @returns the new Vector3
  2933. * @deprecated Please use FromArray instead.
  2934. */
  2935. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2943. /**
  2944. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2945. * @param array defines the source array
  2946. * @param offset defines the offset in the source array
  2947. * @param result defines the Vector3 where to store the result
  2948. * @deprecated Please use FromArrayToRef instead.
  2949. */
  2950. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the given floats.
  2953. * @param x defines the x coordinate of the source
  2954. * @param y defines the y coordinate of the source
  2955. * @param z defines the z coordinate of the source
  2956. * @param result defines the Vector3 where to store the result
  2957. */
  2958. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2961. * @returns a new empty Vector3
  2962. */
  2963. static Zero(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2966. * @returns a new unit Vector3
  2967. */
  2968. static One(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2971. * @returns a new up Vector3
  2972. */
  2973. static Up(): Vector3;
  2974. /**
  2975. * Gets a up Vector3 that must not be updated
  2976. */
  2977. static get UpReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Gets a zero Vector3 that must not be updated
  2980. */
  2981. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2982. /**
  2983. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2984. * @returns a new down Vector3
  2985. */
  2986. static Down(): Vector3;
  2987. /**
  2988. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2989. * @param rightHandedSystem is the scene right-handed (negative z)
  2990. * @returns a new forward Vector3
  2991. */
  2992. static Forward(rightHandedSystem?: boolean): 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 Backward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3001. * @returns a new right Vector3
  3002. */
  3003. static Right(): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3006. * @returns a new left Vector3
  3007. */
  3008. static Left(): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3011. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3012. * @param vector defines the Vector3 to transform
  3013. * @param transformation defines the transformation matrix
  3014. * @returns the transformed Vector3
  3015. */
  3016. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3017. /**
  3018. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3019. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3020. * @param vector defines the Vector3 to transform
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3027. * This method computes tranformed coordinates only, not transformed direction vectors
  3028. * @param x define the x coordinate of the source vector
  3029. * @param y define the y coordinate of the source vector
  3030. * @param z define the z coordinate of the source vector
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3038. * @param vector defines the Vector3 to transform
  3039. * @param transformation defines the transformation matrix
  3040. * @returns the new Vector3
  3041. */
  3042. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3046. * @param vector defines the Vector3 to transform
  3047. * @param transformation defines the transformation matrix
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param x define the x coordinate of the source vector
  3055. * @param y define the y coordinate of the source vector
  3056. * @param z define the z coordinate of the source vector
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3063. * @param value1 defines the first control point
  3064. * @param value2 defines the second control point
  3065. * @param value3 defines the third control point
  3066. * @param value4 defines the fourth control point
  3067. * @param amount defines the amount on the spline to use
  3068. * @returns the new Vector3
  3069. */
  3070. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * 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"
  3073. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3074. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3075. * @param value defines the current value
  3076. * @param min defines the lower range value
  3077. * @param max defines the upper range value
  3078. * @returns the new Vector3
  3079. */
  3080. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Checks if a given vector is inside a specific range
  3093. * @param v defines the vector to test
  3094. * @param min defines the minimum range
  3095. * @param max defines the maximum range
  3096. */
  3097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3098. /**
  3099. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3100. * @param value1 defines the first control point
  3101. * @param tangent1 defines the first tangent vector
  3102. * @param value2 defines the second control point
  3103. * @param tangent2 defines the second tangent vector
  3104. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3105. * @returns the new Vector3
  3106. */
  3107. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3110. * @param start defines the start value
  3111. * @param end defines the end value
  3112. * @param amount max defines amount between both (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3118. * @param start defines the start value
  3119. * @param end defines the end value
  3120. * @param amount max defines amount between both (between 0 and 1)
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3124. /**
  3125. * Returns the dot product (float) between the vectors "left" and "right"
  3126. * @param left defines the left operand
  3127. * @param right defines the right operand
  3128. * @returns the dot product
  3129. */
  3130. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3133. * The cross product is then orthogonal to both "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the cross product
  3137. */
  3138. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3139. /**
  3140. * Sets the given vector "result" with the cross product of "left" and "right"
  3141. * The cross product is then orthogonal to both "left" and "right"
  3142. * @param left defines the left operand
  3143. * @param right defines the right operand
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3147. /**
  3148. * Returns a new Vector3 as the normalization of the given vector
  3149. * @param vector defines the Vector3 to normalize
  3150. * @returns the new Vector3
  3151. */
  3152. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Sets the given vector "result" with the normalization of the given first vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @param result defines the Vector3 where to store the result
  3157. */
  3158. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3159. /**
  3160. * Project a Vector3 onto screen space
  3161. * @param vector defines the Vector3 to project
  3162. * @param world defines the world matrix to use
  3163. * @param transform defines the transform (view x projection) matrix to use
  3164. * @param viewport defines the screen viewport to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3168. /** @hidden */
  3169. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3170. /**
  3171. * Unproject from screen space to object space
  3172. * @param source defines the screen space Vector3 to use
  3173. * @param viewportWidth defines the current width of the viewport
  3174. * @param viewportHeight defines the current height of the viewport
  3175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3176. * @param transform defines the transform (view x projection) matrix to use
  3177. * @returns the new Vector3
  3178. */
  3179. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3180. /**
  3181. * Unproject from screen space to object space
  3182. * @param source defines the screen space Vector3 to use
  3183. * @param viewportWidth defines the current width of the viewport
  3184. * @param viewportHeight defines the current height of the viewport
  3185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3186. * @param view defines the view matrix to use
  3187. * @param projection defines the projection matrix to use
  3188. * @returns the new Vector3
  3189. */
  3190. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3191. /**
  3192. * Unproject from screen space to object space
  3193. * @param source defines the screen space Vector3 to use
  3194. * @param viewportWidth defines the current width of the viewport
  3195. * @param viewportHeight defines the current height of the viewport
  3196. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3197. * @param view defines the view matrix to use
  3198. * @param projection defines the projection matrix to use
  3199. * @param result defines the Vector3 where to store the result
  3200. */
  3201. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3202. /**
  3203. * Unproject from screen space to object space
  3204. * @param sourceX defines the screen space x coordinate to use
  3205. * @param sourceY defines the screen space y coordinate to use
  3206. * @param sourceZ defines the screen space z coordinate to use
  3207. * @param viewportWidth defines the current width of the viewport
  3208. * @param viewportHeight defines the current height of the viewport
  3209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3210. * @param view defines the view matrix to use
  3211. * @param projection defines the projection matrix to use
  3212. * @param result defines the Vector3 where to store the result
  3213. */
  3214. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3215. /**
  3216. * Gets the minimal coordinate values between two Vector3
  3217. * @param left defines the first operand
  3218. * @param right defines the second operand
  3219. * @returns the new Vector3
  3220. */
  3221. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3222. /**
  3223. * Gets the maximal coordinate values between two Vector3
  3224. * @param left defines the first operand
  3225. * @param right defines the second operand
  3226. * @returns the new Vector3
  3227. */
  3228. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3229. /**
  3230. * Returns the distance between the vectors "value1" and "value2"
  3231. * @param value1 defines the first operand
  3232. * @param value2 defines the second operand
  3233. * @returns the distance
  3234. */
  3235. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3236. /**
  3237. * Returns the squared distance between the vectors "value1" and "value2"
  3238. * @param value1 defines the first operand
  3239. * @param value2 defines the second operand
  3240. * @returns the squared distance
  3241. */
  3242. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3243. /**
  3244. * Returns a new Vector3 located at the center between "value1" and "value2"
  3245. * @param value1 defines the first operand
  3246. * @param value2 defines the second operand
  3247. * @returns the new Vector3
  3248. */
  3249. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3252. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3253. * to something in order to rotate it from its local system to the given target system
  3254. * Note: axis1, axis2 and axis3 are normalized during this operation
  3255. * @param axis1 defines the first axis
  3256. * @param axis2 defines the second axis
  3257. * @param axis3 defines the third axis
  3258. * @returns a new Vector3
  3259. */
  3260. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3263. * @param axis1 defines the first axis
  3264. * @param axis2 defines the second axis
  3265. * @param axis3 defines the third axis
  3266. * @param ref defines the Vector3 where to store the result
  3267. */
  3268. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3269. }
  3270. /**
  3271. * Vector4 class created for EulerAngle class conversion to Quaternion
  3272. */
  3273. export class Vector4 {
  3274. /** x value of the vector */
  3275. x: number;
  3276. /** y value of the vector */
  3277. y: number;
  3278. /** z value of the vector */
  3279. z: number;
  3280. /** w value of the vector */
  3281. w: number;
  3282. /**
  3283. * Creates a Vector4 object from the given floats.
  3284. * @param x x value of the vector
  3285. * @param y y value of the vector
  3286. * @param z z value of the vector
  3287. * @param w w value of the vector
  3288. */
  3289. constructor(
  3290. /** x value of the vector */
  3291. x: number,
  3292. /** y value of the vector */
  3293. y: number,
  3294. /** z value of the vector */
  3295. z: number,
  3296. /** w value of the vector */
  3297. w: number);
  3298. /**
  3299. * Returns the string with the Vector4 coordinates.
  3300. * @returns a string containing all the vector values
  3301. */
  3302. toString(): string;
  3303. /**
  3304. * Returns the string "Vector4".
  3305. * @returns "Vector4"
  3306. */
  3307. getClassName(): string;
  3308. /**
  3309. * Returns the Vector4 hash code.
  3310. * @returns a unique hash code
  3311. */
  3312. getHashCode(): number;
  3313. /**
  3314. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3315. * @returns the resulting array
  3316. */
  3317. asArray(): number[];
  3318. /**
  3319. * Populates the given array from the given index with the Vector4 coordinates.
  3320. * @param array array to populate
  3321. * @param index index of the array to start at (default: 0)
  3322. * @returns the Vector4.
  3323. */
  3324. toArray(array: FloatArray, index?: number): Vector4;
  3325. /**
  3326. * Update the current vector from an array
  3327. * @param array defines the destination array
  3328. * @param index defines the offset in the destination array
  3329. * @returns the current Vector3
  3330. */
  3331. fromArray(array: FloatArray, index?: number): Vector4;
  3332. /**
  3333. * Adds the given vector to the current Vector4.
  3334. * @param otherVector the vector to add
  3335. * @returns the updated Vector4.
  3336. */
  3337. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3338. /**
  3339. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3340. * @param otherVector the vector to add
  3341. * @returns the resulting vector
  3342. */
  3343. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @param result the vector to store the result
  3348. * @returns the current Vector4.
  3349. */
  3350. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3351. /**
  3352. * Subtract in place the given vector from the current Vector4.
  3353. * @param otherVector the vector to subtract
  3354. * @returns the updated Vector4.
  3355. */
  3356. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3359. * @param otherVector the vector to add
  3360. * @returns the new vector with the result
  3361. */
  3362. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to subtract
  3366. * @param result the vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3372. */
  3373. /**
  3374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3375. * @param x value to subtract
  3376. * @param y value to subtract
  3377. * @param z value to subtract
  3378. * @param w value to subtract
  3379. * @returns new vector containing the result
  3380. */
  3381. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3382. /**
  3383. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3384. * @param x value to subtract
  3385. * @param y value to subtract
  3386. * @param z value to subtract
  3387. * @param w value to subtract
  3388. * @param result the vector to store the result in
  3389. * @returns the current Vector4.
  3390. */
  3391. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3394. * @returns a new vector with the negated values
  3395. */
  3396. negate(): Vector4;
  3397. /**
  3398. * Negate this vector in place
  3399. * @returns this
  3400. */
  3401. negateInPlace(): Vector4;
  3402. /**
  3403. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3404. * @param result defines the Vector3 object where to store the result
  3405. * @returns the current Vector4
  3406. */
  3407. negateToRef(result: Vector4): Vector4;
  3408. /**
  3409. * Multiplies the current Vector4 coordinates by scale (float).
  3410. * @param scale the number to scale with
  3411. * @returns the updated Vector4.
  3412. */
  3413. scaleInPlace(scale: number): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns a new vector with the result
  3418. */
  3419. scale(scale: number): Vector4;
  3420. /**
  3421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @param result a vector to store the result in
  3424. * @returns the current Vector4.
  3425. */
  3426. scaleToRef(scale: number, result: Vector4): Vector4;
  3427. /**
  3428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3429. * @param scale defines the scale factor
  3430. * @param result defines the Vector4 object where to store the result
  3431. * @returns the unmodified current Vector4
  3432. */
  3433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3434. /**
  3435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3436. * @param otherVector the vector to compare against
  3437. * @returns true if they are equal
  3438. */
  3439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3442. * @param otherVector vector to compare against
  3443. * @param epsilon (Default: very small number)
  3444. * @returns true if they are equal
  3445. */
  3446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3447. /**
  3448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3449. * @param x x value to compare against
  3450. * @param y y value to compare against
  3451. * @param z z value to compare against
  3452. * @param w w value to compare against
  3453. * @returns true if equal
  3454. */
  3455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3456. /**
  3457. * Multiplies in place the current Vector4 by the given one.
  3458. * @param otherVector vector to multiple with
  3459. * @returns the updated Vector4.
  3460. */
  3461. multiplyInPlace(otherVector: Vector4): Vector4;
  3462. /**
  3463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns resulting new vector
  3466. */
  3467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3468. /**
  3469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @param result vector to store the result
  3472. * @returns the current Vector4.
  3473. */
  3474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3477. * @param x x value multiply with
  3478. * @param y y value multiply with
  3479. * @param z z value multiply with
  3480. * @param w w value multiply with
  3481. * @returns resulting new vector
  3482. */
  3483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3484. /**
  3485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3486. * @param otherVector vector to devide with
  3487. * @returns resulting new vector
  3488. */
  3489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3490. /**
  3491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @param result vector to store the result
  3494. * @returns the current Vector4.
  3495. */
  3496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3497. /**
  3498. * Divides the current Vector3 coordinates by the given ones.
  3499. * @param otherVector vector to devide with
  3500. * @returns the updated Vector3.
  3501. */
  3502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3503. /**
  3504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3505. * @param other defines the second operand
  3506. * @returns the current updated Vector4
  3507. */
  3508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Gets a new Vector4 from current Vector4 floored values
  3517. * @returns a new Vector4
  3518. */
  3519. floor(): Vector4;
  3520. /**
  3521. * Gets a new Vector4 from current Vector3 floored values
  3522. * @returns a new Vector4
  3523. */
  3524. fract(): Vector4;
  3525. /**
  3526. * Returns the Vector4 length (float).
  3527. * @returns the length
  3528. */
  3529. length(): number;
  3530. /**
  3531. * Returns the Vector4 squared length (float).
  3532. * @returns the length squared
  3533. */
  3534. lengthSquared(): number;
  3535. /**
  3536. * Normalizes in place the Vector4.
  3537. * @returns the updated Vector4.
  3538. */
  3539. normalize(): Vector4;
  3540. /**
  3541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3542. * @returns this converted to a new vector3
  3543. */
  3544. toVector3(): Vector3;
  3545. /**
  3546. * Returns a new Vector4 copied from the current one.
  3547. * @returns the new cloned vector
  3548. */
  3549. clone(): Vector4;
  3550. /**
  3551. * Updates the current Vector4 with the given one coordinates.
  3552. * @param source the source vector to copy from
  3553. * @returns the updated Vector4.
  3554. */
  3555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3556. /**
  3557. * Updates the current Vector4 coordinates with the given floats.
  3558. * @param x float to copy from
  3559. * @param y float to copy from
  3560. * @param z float to copy from
  3561. * @param w float to copy from
  3562. * @returns the updated Vector4.
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3565. /**
  3566. * Updates the current Vector4 coordinates with the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @returns the updated Vector4.
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Vector4;
  3574. /**
  3575. * Copies the given float to the current Vector3 coordinates
  3576. * @param v defines the x, y, z and w coordinates of the operand
  3577. * @returns the current updated Vector3
  3578. */
  3579. setAll(v: number): Vector4;
  3580. /**
  3581. * Returns a new Vector4 set from the starting index of the given array.
  3582. * @param array the array to pull values from
  3583. * @param offset the offset into the array to start at
  3584. * @returns the new vector
  3585. */
  3586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3587. /**
  3588. * Updates the given vector "result" from the starting index of the given array.
  3589. * @param array the array to pull values from
  3590. * @param offset the offset into the array to start at
  3591. * @param result the vector to store the result in
  3592. */
  3593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3594. /**
  3595. * Updates the given vector "result" from the starting index of the given Float32Array.
  3596. * @param array the array to pull values from
  3597. * @param offset the offset into the array to start at
  3598. * @param result the vector to store the result in
  3599. */
  3600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3601. /**
  3602. * Updates the given vector "result" coordinates from the given floats.
  3603. * @param x float to set from
  3604. * @param y float to set from
  3605. * @param z float to set from
  3606. * @param w float to set from
  3607. * @param result the vector to the floats in
  3608. */
  3609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3610. /**
  3611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3612. * @returns the new vector
  3613. */
  3614. static Zero(): Vector4;
  3615. /**
  3616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3617. * @returns the new vector
  3618. */
  3619. static One(): Vector4;
  3620. /**
  3621. * Returns a new normalized Vector4 from the given one.
  3622. * @param vector the vector to normalize
  3623. * @returns the vector
  3624. */
  3625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Updates the given vector "result" from the normalization of the given one.
  3628. * @param vector the vector to normalize
  3629. * @param result the vector to store the result in
  3630. */
  3631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3632. /**
  3633. * Returns a vector with the minimum values from the left and right vectors
  3634. * @param left left vector to minimize
  3635. * @param right right vector to minimize
  3636. * @returns a new vector with the minimum of the left and right vector values
  3637. */
  3638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3639. /**
  3640. * Returns a vector with the maximum values from the left and right vectors
  3641. * @param left left vector to maximize
  3642. * @param right right vector to maximize
  3643. * @returns a new vector with the maximum of the left and right vector values
  3644. */
  3645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Returns the distance (float) between the vectors "value1" and "value2".
  3648. * @param value1 value to calulate the distance between
  3649. * @param value2 value to calulate the distance between
  3650. * @return the distance between the two vectors
  3651. */
  3652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3653. /**
  3654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3655. * @param value1 value to calulate the distance between
  3656. * @param value2 value to calulate the distance between
  3657. * @return the distance between the two vectors squared
  3658. */
  3659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3660. /**
  3661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3662. * @param value1 value to calulate the center between
  3663. * @param value2 value to calulate the center between
  3664. * @return the center between the two vectors
  3665. */
  3666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3667. /**
  3668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3669. * This methods computes transformed normalized direction vectors only.
  3670. * @param vector the vector to transform
  3671. * @param transformation the transformation matrix to apply
  3672. * @returns the new vector
  3673. */
  3674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3675. /**
  3676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3677. * This methods computes transformed normalized direction vectors only.
  3678. * @param vector the vector to transform
  3679. * @param transformation the transformation matrix to apply
  3680. * @param result the vector to store the result in
  3681. */
  3682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3683. /**
  3684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3685. * This methods computes transformed normalized direction vectors only.
  3686. * @param x value to transform
  3687. * @param y value to transform
  3688. * @param z value to transform
  3689. * @param w value to transform
  3690. * @param transformation the transformation matrix to apply
  3691. * @param result the vector to store the results in
  3692. */
  3693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3694. /**
  3695. * Creates a new Vector4 from a Vector3
  3696. * @param source defines the source data
  3697. * @param w defines the 4th component (default is 0)
  3698. * @returns a new Vector4
  3699. */
  3700. static FromVector3(source: Vector3, w?: number): Vector4;
  3701. }
  3702. /**
  3703. * Class used to store quaternion data
  3704. * @see https://en.wikipedia.org/wiki/Quaternion
  3705. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3706. */
  3707. export class Quaternion {
  3708. /** @hidden */
  3709. _x: number;
  3710. /** @hidden */
  3711. _y: number;
  3712. /** @hidden */
  3713. _z: number;
  3714. /** @hidden */
  3715. _w: number;
  3716. /** @hidden */
  3717. _isDirty: boolean;
  3718. /** Gets or sets the x coordinate */
  3719. get x(): number;
  3720. set x(value: number);
  3721. /** Gets or sets the y coordinate */
  3722. get y(): number;
  3723. set y(value: number);
  3724. /** Gets or sets the z coordinate */
  3725. get z(): number;
  3726. set z(value: number);
  3727. /** Gets or sets the w coordinate */
  3728. get w(): number;
  3729. set w(value: number);
  3730. /**
  3731. * Creates a new Quaternion from the given floats
  3732. * @param x defines the first component (0 by default)
  3733. * @param y defines the second component (0 by default)
  3734. * @param z defines the third component (0 by default)
  3735. * @param w defines the fourth component (1.0 by default)
  3736. */
  3737. constructor(x?: number, y?: number, z?: number, w?: number);
  3738. /**
  3739. * Gets a string representation for the current quaternion
  3740. * @returns a string with the Quaternion coordinates
  3741. */
  3742. toString(): string;
  3743. /**
  3744. * Gets the class name of the quaternion
  3745. * @returns the string "Quaternion"
  3746. */
  3747. getClassName(): string;
  3748. /**
  3749. * Gets a hash code for this quaternion
  3750. * @returns the quaternion hash code
  3751. */
  3752. getHashCode(): number;
  3753. /**
  3754. * Copy the quaternion to an array
  3755. * @returns a new array populated with 4 elements from the quaternion coordinates
  3756. */
  3757. asArray(): number[];
  3758. /**
  3759. * Check if two quaternions are equals
  3760. * @param otherQuaternion defines the second operand
  3761. * @return true if the current quaternion and the given one coordinates are strictly equals
  3762. */
  3763. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3764. /**
  3765. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3766. * @param otherQuaternion defines the other quaternion
  3767. * @param epsilon defines the minimal distance to consider equality
  3768. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3769. */
  3770. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3771. /**
  3772. * Clone the current quaternion
  3773. * @returns a new quaternion copied from the current one
  3774. */
  3775. clone(): Quaternion;
  3776. /**
  3777. * Copy a quaternion to the current one
  3778. * @param other defines the other quaternion
  3779. * @returns the updated current quaternion
  3780. */
  3781. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the given float coordinates
  3784. * @param x defines the x coordinate
  3785. * @param y defines the y coordinate
  3786. * @param z defines the z coordinate
  3787. * @param w defines the w coordinate
  3788. * @returns the updated current quaternion
  3789. */
  3790. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3791. /**
  3792. * Updates the current quaternion from the given float coordinates
  3793. * @param x defines the x coordinate
  3794. * @param y defines the y coordinate
  3795. * @param z defines the z coordinate
  3796. * @param w defines the w coordinate
  3797. * @returns the updated current quaternion
  3798. */
  3799. set(x: number, y: number, z: number, w: number): Quaternion;
  3800. /**
  3801. * Adds two quaternions
  3802. * @param other defines the second operand
  3803. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3804. */
  3805. add(other: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Add a quaternion to the current one
  3808. * @param other defines the quaternion to add
  3809. * @returns the current quaternion
  3810. */
  3811. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Subtract two quaternions
  3814. * @param other defines the second operand
  3815. * @returns a new quaternion as the subtraction result of the given one from the current one
  3816. */
  3817. subtract(other: Quaternion): Quaternion;
  3818. /**
  3819. * Multiplies the current quaternion by a scale factor
  3820. * @param value defines the scale factor
  3821. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3822. */
  3823. scale(value: number): Quaternion;
  3824. /**
  3825. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3826. * @param scale defines the scale factor
  3827. * @param result defines the Quaternion object where to store the result
  3828. * @returns the unmodified current quaternion
  3829. */
  3830. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3831. /**
  3832. * Multiplies in place the current quaternion by a scale factor
  3833. * @param value defines the scale factor
  3834. * @returns the current modified quaternion
  3835. */
  3836. scaleInPlace(value: number): Quaternion;
  3837. /**
  3838. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3839. * @param scale defines the scale factor
  3840. * @param result defines the Quaternion object where to store the result
  3841. * @returns the unmodified current quaternion
  3842. */
  3843. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3844. /**
  3845. * Multiplies two quaternions
  3846. * @param q1 defines the second operand
  3847. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3848. */
  3849. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3850. /**
  3851. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3852. * @param q1 defines the second operand
  3853. * @param result defines the target quaternion
  3854. * @returns the current quaternion
  3855. */
  3856. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3857. /**
  3858. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3859. * @param q1 defines the second operand
  3860. * @returns the currentupdated quaternion
  3861. */
  3862. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3863. /**
  3864. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3865. * @param ref defines the target quaternion
  3866. * @returns the current quaternion
  3867. */
  3868. conjugateToRef(ref: Quaternion): Quaternion;
  3869. /**
  3870. * Conjugates in place (1-q) the current quaternion
  3871. * @returns the current updated quaternion
  3872. */
  3873. conjugateInPlace(): Quaternion;
  3874. /**
  3875. * Conjugates in place (1-q) the current quaternion
  3876. * @returns a new quaternion
  3877. */
  3878. conjugate(): Quaternion;
  3879. /**
  3880. * Gets length of current quaternion
  3881. * @returns the quaternion length (float)
  3882. */
  3883. length(): number;
  3884. /**
  3885. * Normalize in place the current quaternion
  3886. * @returns the current updated quaternion
  3887. */
  3888. normalize(): Quaternion;
  3889. /**
  3890. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3891. * @param order is a reserved parameter and is ignored for now
  3892. * @returns a new Vector3 containing the Euler angles
  3893. */
  3894. toEulerAngles(order?: string): Vector3;
  3895. /**
  3896. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3897. * @param result defines the vector which will be filled with the Euler angles
  3898. * @returns the current unchanged quaternion
  3899. */
  3900. toEulerAnglesToRef(result: Vector3): Quaternion;
  3901. /**
  3902. * Updates the given rotation matrix with the current quaternion values
  3903. * @param result defines the target matrix
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toRotationMatrix(result: Matrix): Quaternion;
  3907. /**
  3908. * Updates the current quaternion from the given rotation matrix values
  3909. * @param matrix defines the source matrix
  3910. * @returns the current updated quaternion
  3911. */
  3912. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3913. /**
  3914. * Creates a new quaternion from a rotation matrix
  3915. * @param matrix defines the source matrix
  3916. * @returns a new quaternion created from the given rotation matrix values
  3917. */
  3918. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Updates the given quaternion with the given rotation matrix values
  3921. * @param matrix defines the source matrix
  3922. * @param result defines the target quaternion
  3923. */
  3924. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3925. /**
  3926. * Returns the dot product (float) between the quaternions "left" and "right"
  3927. * @param left defines the left operand
  3928. * @param right defines the right operand
  3929. * @returns the dot product
  3930. */
  3931. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3932. /**
  3933. * Checks if the two quaternions are close to each other
  3934. * @param quat0 defines the first quaternion to check
  3935. * @param quat1 defines the second quaternion to check
  3936. * @returns true if the two quaternions are close to each other
  3937. */
  3938. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3939. /**
  3940. * Creates an empty quaternion
  3941. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3942. */
  3943. static Zero(): Quaternion;
  3944. /**
  3945. * Inverse a given quaternion
  3946. * @param q defines the source quaternion
  3947. * @returns a new quaternion as the inverted current quaternion
  3948. */
  3949. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @param result the quaternion the result will be stored in
  3954. * @returns the result quaternion
  3955. */
  3956. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3957. /**
  3958. * Creates an identity quaternion
  3959. * @returns the identity quaternion
  3960. */
  3961. static Identity(): Quaternion;
  3962. /**
  3963. * Gets a boolean indicating if the given quaternion is identity
  3964. * @param quaternion defines the quaternion to check
  3965. * @returns true if the quaternion is identity
  3966. */
  3967. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3968. /**
  3969. * Creates a quaternion from a rotation around an axis
  3970. * @param axis defines the axis to use
  3971. * @param angle defines the angle to use
  3972. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3973. */
  3974. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3975. /**
  3976. * Creates a rotation around an axis and stores it into the given quaternion
  3977. * @param axis defines the axis to use
  3978. * @param angle defines the angle to use
  3979. * @param result defines the target quaternion
  3980. * @returns the target quaternion
  3981. */
  3982. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3983. /**
  3984. * Creates a new quaternion from data stored into an array
  3985. * @param array defines the data source
  3986. * @param offset defines the offset in the source array where the data starts
  3987. * @returns a new quaternion
  3988. */
  3989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3990. /**
  3991. * Updates the given quaternion "result" from the starting index of the given array.
  3992. * @param array the array to pull values from
  3993. * @param offset the offset into the array to start at
  3994. * @param result the quaternion to store the result in
  3995. */
  3996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3997. /**
  3998. * Create a quaternion from Euler rotation angles
  3999. * @param x Pitch
  4000. * @param y Yaw
  4001. * @param z Roll
  4002. * @returns the new Quaternion
  4003. */
  4004. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4005. /**
  4006. * Updates a quaternion from Euler rotation angles
  4007. * @param x Pitch
  4008. * @param y Yaw
  4009. * @param z Roll
  4010. * @param result the quaternion to store the result
  4011. * @returns the updated quaternion
  4012. */
  4013. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4014. /**
  4015. * Create a quaternion from Euler rotation vector
  4016. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4017. * @returns the new Quaternion
  4018. */
  4019. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4020. /**
  4021. * Updates a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @param result the quaternion to store the result
  4024. * @returns the updated quaternion
  4025. */
  4026. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4027. /**
  4028. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4029. * @param yaw defines the rotation around Y axis
  4030. * @param pitch defines the rotation around X axis
  4031. * @param roll defines the rotation around Z axis
  4032. * @returns the new quaternion
  4033. */
  4034. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4035. /**
  4036. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4037. * @param yaw defines the rotation around Y axis
  4038. * @param pitch defines the rotation around X axis
  4039. * @param roll defines the rotation around Z axis
  4040. * @param result defines the target quaternion
  4041. */
  4042. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4043. /**
  4044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4045. * @param alpha defines the rotation around first axis
  4046. * @param beta defines the rotation around second axis
  4047. * @param gamma defines the rotation around third axis
  4048. * @returns the new quaternion
  4049. */
  4050. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4051. /**
  4052. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4053. * @param alpha defines the rotation around first axis
  4054. * @param beta defines the rotation around second axis
  4055. * @param gamma defines the rotation around third axis
  4056. * @param result defines the target quaternion
  4057. */
  4058. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4059. /**
  4060. * 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)
  4061. * @param axis1 defines the first axis
  4062. * @param axis2 defines the second axis
  4063. * @param axis3 defines the third axis
  4064. * @returns the new quaternion
  4065. */
  4066. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4067. /**
  4068. * 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
  4069. * @param axis1 defines the first axis
  4070. * @param axis2 defines the second axis
  4071. * @param axis3 defines the third axis
  4072. * @param ref defines the target quaternion
  4073. */
  4074. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4075. /**
  4076. * Interpolates between two quaternions
  4077. * @param left defines first quaternion
  4078. * @param right defines second quaternion
  4079. * @param amount defines the gradient to use
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. /**
  4084. * Interpolates between two quaternions and stores it into a target quaternion
  4085. * @param left defines first quaternion
  4086. * @param right defines second quaternion
  4087. * @param amount defines the gradient to use
  4088. * @param result defines the target quaternion
  4089. */
  4090. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4091. /**
  4092. * Interpolate between two quaternions using Hermite interpolation
  4093. * @param value1 defines first quaternion
  4094. * @param tangent1 defines the incoming tangent
  4095. * @param value2 defines second quaternion
  4096. * @param tangent2 defines the outgoing tangent
  4097. * @param amount defines the target quaternion
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. }
  4102. /**
  4103. * Class used to store matrix data (4x4)
  4104. */
  4105. export class Matrix {
  4106. /**
  4107. * Gets the precision of matrix computations
  4108. */
  4109. static get Use64Bits(): boolean;
  4110. private static _updateFlagSeed;
  4111. private static _identityReadOnly;
  4112. private _isIdentity;
  4113. private _isIdentityDirty;
  4114. private _isIdentity3x2;
  4115. private _isIdentity3x2Dirty;
  4116. /**
  4117. * Gets the update flag of the matrix which is an unique number for the matrix.
  4118. * It will be incremented every time the matrix data change.
  4119. * You can use it to speed the comparison between two versions of the same matrix.
  4120. */
  4121. updateFlag: number;
  4122. private readonly _m;
  4123. /**
  4124. * Gets the internal data of the matrix
  4125. */
  4126. get m(): DeepImmutable<Float32Array | Array<number>>;
  4127. /** @hidden */
  4128. _markAsUpdated(): void;
  4129. /** @hidden */
  4130. private _updateIdentityStatus;
  4131. /**
  4132. * Creates an empty matrix (filled with zeros)
  4133. */
  4134. constructor();
  4135. /**
  4136. * Check if the current matrix is identity
  4137. * @returns true is the matrix is the identity matrix
  4138. */
  4139. isIdentity(): boolean;
  4140. /**
  4141. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4142. * @returns true is the matrix is the identity matrix
  4143. */
  4144. isIdentityAs3x2(): boolean;
  4145. /**
  4146. * Gets the determinant of the matrix
  4147. * @returns the matrix determinant
  4148. */
  4149. determinant(): number;
  4150. /**
  4151. * Returns the matrix as a Float32Array or Array<number>
  4152. * @returns the matrix underlying array
  4153. */
  4154. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4155. /**
  4156. * Returns the matrix as a Float32Array or Array<number>
  4157. * @returns the matrix underlying array.
  4158. */
  4159. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4160. /**
  4161. * Inverts the current matrix in place
  4162. * @returns the current inverted matrix
  4163. */
  4164. invert(): Matrix;
  4165. /**
  4166. * Sets all the matrix elements to zero
  4167. * @returns the current matrix
  4168. */
  4169. reset(): Matrix;
  4170. /**
  4171. * Adds the current matrix with a second one
  4172. * @param other defines the matrix to add
  4173. * @returns a new matrix as the addition of the current matrix and the given one
  4174. */
  4175. add(other: DeepImmutable<Matrix>): Matrix;
  4176. /**
  4177. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4178. * @param other defines the matrix to add
  4179. * @param result defines the target matrix
  4180. * @returns the current matrix
  4181. */
  4182. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4183. /**
  4184. * Adds in place the given matrix to the current matrix
  4185. * @param other defines the second operand
  4186. * @returns the current updated matrix
  4187. */
  4188. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4189. /**
  4190. * Sets the given matrix to the current inverted Matrix
  4191. * @param other defines the target matrix
  4192. * @returns the unmodified current matrix
  4193. */
  4194. invertToRef(other: Matrix): Matrix;
  4195. /**
  4196. * add a value at the specified position in the current Matrix
  4197. * @param index the index of the value within the matrix. between 0 and 15.
  4198. * @param value the value to be added
  4199. * @returns the current updated matrix
  4200. */
  4201. addAtIndex(index: number, value: number): Matrix;
  4202. /**
  4203. * mutiply the specified position in the current Matrix by a value
  4204. * @param index the index of the value within the matrix. between 0 and 15.
  4205. * @param value the value to be added
  4206. * @returns the current updated matrix
  4207. */
  4208. multiplyAtIndex(index: number, value: number): Matrix;
  4209. /**
  4210. * Inserts the translation vector (using 3 floats) in the current matrix
  4211. * @param x defines the 1st component of the translation
  4212. * @param y defines the 2nd component of the translation
  4213. * @param z defines the 3rd component of the translation
  4214. * @returns the current updated matrix
  4215. */
  4216. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4217. /**
  4218. * Adds the translation vector (using 3 floats) in the current matrix
  4219. * @param x defines the 1st component of the translation
  4220. * @param y defines the 2nd component of the translation
  4221. * @param z defines the 3rd component of the translation
  4222. * @returns the current updated matrix
  4223. */
  4224. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4225. /**
  4226. * Inserts the translation vector in the current matrix
  4227. * @param vector3 defines the translation to insert
  4228. * @returns the current updated matrix
  4229. */
  4230. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4231. /**
  4232. * Gets the translation value of the current matrix
  4233. * @returns a new Vector3 as the extracted translation from the matrix
  4234. */
  4235. getTranslation(): Vector3;
  4236. /**
  4237. * Fill a Vector3 with the extracted translation from the matrix
  4238. * @param result defines the Vector3 where to store the translation
  4239. * @returns the current matrix
  4240. */
  4241. getTranslationToRef(result: Vector3): Matrix;
  4242. /**
  4243. * Remove rotation and scaling part from the matrix
  4244. * @returns the updated matrix
  4245. */
  4246. removeRotationAndScaling(): Matrix;
  4247. /**
  4248. * Multiply two matrices
  4249. * @param other defines the second operand
  4250. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4251. */
  4252. multiply(other: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Copy the current matrix from the given one
  4255. * @param other defines the source matrix
  4256. * @returns the current updated matrix
  4257. */
  4258. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Populates the given array from the starting index with the current matrix values
  4261. * @param array defines the target array
  4262. * @param offset defines the offset in the target array where to start storing values
  4263. * @returns the current matrix
  4264. */
  4265. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4266. /**
  4267. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4268. * @param other defines the second operand
  4269. * @param result defines the matrix where to store the multiplication
  4270. * @returns the current matrix
  4271. */
  4272. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4273. /**
  4274. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4275. * @param other defines the second operand
  4276. * @param result defines the array where to store the multiplication
  4277. * @param offset defines the offset in the target array where to start storing values
  4278. * @returns the current matrix
  4279. */
  4280. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4281. /**
  4282. * Check equality between this matrix and a second one
  4283. * @param value defines the second matrix to compare
  4284. * @returns true is the current matrix and the given one values are strictly equal
  4285. */
  4286. equals(value: DeepImmutable<Matrix>): boolean;
  4287. /**
  4288. * Clone the current matrix
  4289. * @returns a new matrix from the current matrix
  4290. */
  4291. clone(): Matrix;
  4292. /**
  4293. * Returns the name of the current matrix class
  4294. * @returns the string "Matrix"
  4295. */
  4296. getClassName(): string;
  4297. /**
  4298. * Gets the hash code of the current matrix
  4299. * @returns the hash code
  4300. */
  4301. getHashCode(): number;
  4302. /**
  4303. * Decomposes the current Matrix into a translation, rotation and scaling components
  4304. * @param scale defines the scale vector3 given as a reference to update
  4305. * @param rotation defines the rotation quaternion given as a reference to update
  4306. * @param translation defines the translation vector3 given as a reference to update
  4307. * @returns true if operation was successful
  4308. */
  4309. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4310. /**
  4311. * Gets specific row of the matrix
  4312. * @param index defines the number of the row to get
  4313. * @returns the index-th row of the current matrix as a new Vector4
  4314. */
  4315. getRow(index: number): Nullable<Vector4>;
  4316. /**
  4317. * Sets the index-th row of the current matrix to the vector4 values
  4318. * @param index defines the number of the row to set
  4319. * @param row defines the target vector4
  4320. * @returns the updated current matrix
  4321. */
  4322. setRow(index: number, row: Vector4): Matrix;
  4323. /**
  4324. * Compute the transpose of the matrix
  4325. * @returns the new transposed matrix
  4326. */
  4327. transpose(): Matrix;
  4328. /**
  4329. * Compute the transpose of the matrix and store it in a given matrix
  4330. * @param result defines the target matrix
  4331. * @returns the current matrix
  4332. */
  4333. transposeToRef(result: Matrix): Matrix;
  4334. /**
  4335. * Sets the index-th row of the current matrix with the given 4 x float values
  4336. * @param index defines the row index
  4337. * @param x defines the x component to set
  4338. * @param y defines the y component to set
  4339. * @param z defines the z component to set
  4340. * @param w defines the w component to set
  4341. * @returns the updated current matrix
  4342. */
  4343. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4344. /**
  4345. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4346. * @param scale defines the scale factor
  4347. * @returns a new matrix
  4348. */
  4349. scale(scale: number): Matrix;
  4350. /**
  4351. * Scale the current matrix values by a factor to a given result matrix
  4352. * @param scale defines the scale factor
  4353. * @param result defines the matrix to store the result
  4354. * @returns the current matrix
  4355. */
  4356. scaleToRef(scale: number, result: Matrix): Matrix;
  4357. /**
  4358. * Scale the current matrix values by a factor and add the result to a given matrix
  4359. * @param scale defines the scale factor
  4360. * @param result defines the Matrix to store the result
  4361. * @returns the current matrix
  4362. */
  4363. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4364. /**
  4365. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4366. * @param ref matrix to store the result
  4367. */
  4368. toNormalMatrix(ref: Matrix): void;
  4369. /**
  4370. * Gets only rotation part of the current matrix
  4371. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4372. */
  4373. getRotationMatrix(): Matrix;
  4374. /**
  4375. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4376. * @param result defines the target matrix to store data to
  4377. * @returns the current matrix
  4378. */
  4379. getRotationMatrixToRef(result: Matrix): Matrix;
  4380. /**
  4381. * Toggles model matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleModelMatrixHandInPlace(): void;
  4384. /**
  4385. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4386. */
  4387. toggleProjectionMatrixHandInPlace(): void;
  4388. /**
  4389. * Creates a matrix from an array
  4390. * @param array defines the source array
  4391. * @param offset defines an offset in the source array
  4392. * @returns a new Matrix set from the starting index of the given array
  4393. */
  4394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4395. /**
  4396. * Copy the content of an array into a given matrix
  4397. * @param array defines the source array
  4398. * @param offset defines an offset in the source array
  4399. * @param result defines the target matrix
  4400. */
  4401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4402. /**
  4403. * Stores an array into a matrix after having multiplied each component by a given factor
  4404. * @param array defines the source array
  4405. * @param offset defines the offset in the source array
  4406. * @param scale defines the scaling factor
  4407. * @param result defines the target matrix
  4408. */
  4409. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4410. /**
  4411. * Gets an identity matrix that must not be updated
  4412. */
  4413. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4414. /**
  4415. * Stores a list of values (16) inside a given matrix
  4416. * @param initialM11 defines 1st value of 1st row
  4417. * @param initialM12 defines 2nd value of 1st row
  4418. * @param initialM13 defines 3rd value of 1st row
  4419. * @param initialM14 defines 4th value of 1st row
  4420. * @param initialM21 defines 1st value of 2nd row
  4421. * @param initialM22 defines 2nd value of 2nd row
  4422. * @param initialM23 defines 3rd value of 2nd row
  4423. * @param initialM24 defines 4th value of 2nd row
  4424. * @param initialM31 defines 1st value of 3rd row
  4425. * @param initialM32 defines 2nd value of 3rd row
  4426. * @param initialM33 defines 3rd value of 3rd row
  4427. * @param initialM34 defines 4th value of 3rd row
  4428. * @param initialM41 defines 1st value of 4th row
  4429. * @param initialM42 defines 2nd value of 4th row
  4430. * @param initialM43 defines 3rd value of 4th row
  4431. * @param initialM44 defines 4th value of 4th row
  4432. * @param result defines the target matrix
  4433. */
  4434. 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;
  4435. /**
  4436. * Creates new matrix from a list of values (16)
  4437. * @param initialM11 defines 1st value of 1st row
  4438. * @param initialM12 defines 2nd value of 1st row
  4439. * @param initialM13 defines 3rd value of 1st row
  4440. * @param initialM14 defines 4th value of 1st row
  4441. * @param initialM21 defines 1st value of 2nd row
  4442. * @param initialM22 defines 2nd value of 2nd row
  4443. * @param initialM23 defines 3rd value of 2nd row
  4444. * @param initialM24 defines 4th value of 2nd row
  4445. * @param initialM31 defines 1st value of 3rd row
  4446. * @param initialM32 defines 2nd value of 3rd row
  4447. * @param initialM33 defines 3rd value of 3rd row
  4448. * @param initialM34 defines 4th value of 3rd row
  4449. * @param initialM41 defines 1st value of 4th row
  4450. * @param initialM42 defines 2nd value of 4th row
  4451. * @param initialM43 defines 3rd value of 4th row
  4452. * @param initialM44 defines 4th value of 4th row
  4453. * @returns the new matrix
  4454. */
  4455. 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;
  4456. /**
  4457. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4458. * @param scale defines the scale vector3
  4459. * @param rotation defines the rotation quaternion
  4460. * @param translation defines the translation vector3
  4461. * @returns a new matrix
  4462. */
  4463. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4464. /**
  4465. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4466. * @param scale defines the scale vector3
  4467. * @param rotation defines the rotation quaternion
  4468. * @param translation defines the translation vector3
  4469. * @param result defines the target matrix
  4470. */
  4471. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a new identity matrix
  4474. * @returns a new identity matrix
  4475. */
  4476. static Identity(): Matrix;
  4477. /**
  4478. * Creates a new identity matrix and stores the result in a given matrix
  4479. * @param result defines the target matrix
  4480. */
  4481. static IdentityToRef(result: Matrix): void;
  4482. /**
  4483. * Creates a new zero matrix
  4484. * @returns a new zero matrix
  4485. */
  4486. static Zero(): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the X axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationX(angle: number): Matrix;
  4493. /**
  4494. * Creates a new matrix as the invert of a given matrix
  4495. * @param source defines the source matrix
  4496. * @returns the new matrix
  4497. */
  4498. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4501. * @param angle defines the angle (in radians) to use
  4502. * @param result defines the target matrix
  4503. */
  4504. static RotationXToRef(angle: number, result: Matrix): void;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Y axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationY(angle: number): Matrix;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4513. * @param angle defines the angle (in radians) to use
  4514. * @param result defines the target matrix
  4515. */
  4516. static RotationYToRef(angle: number, result: Matrix): void;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Z axis
  4519. * @param angle defines the angle (in radians) to use
  4520. * @return the new matrix
  4521. */
  4522. static RotationZ(angle: number): Matrix;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4525. * @param angle defines the angle (in radians) to use
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationZToRef(angle: number, result: Matrix): void;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the given axis
  4531. * @param axis defines the axis to use
  4532. * @param angle defines the angle (in radians) to use
  4533. * @return the new matrix
  4534. */
  4535. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4536. /**
  4537. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4538. * @param axis defines the axis to use
  4539. * @param angle defines the angle (in radians) to use
  4540. * @param result defines the target matrix
  4541. */
  4542. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4543. /**
  4544. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4545. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4546. * @param from defines the vector to align
  4547. * @param to defines the vector to align to
  4548. * @param result defines the target matrix
  4549. */
  4550. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Creates a rotation matrix
  4553. * @param yaw defines the yaw angle in radians (Y axis)
  4554. * @param pitch defines the pitch angle in radians (X axis)
  4555. * @param roll defines the roll angle in radians (Z axis)
  4556. * @returns the new rotation matrix
  4557. */
  4558. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4559. /**
  4560. * Creates a rotation matrix and stores it in a given matrix
  4561. * @param yaw defines the yaw angle in radians (Y axis)
  4562. * @param pitch defines the pitch angle in radians (X axis)
  4563. * @param roll defines the roll angle in radians (Z axis)
  4564. * @param result defines the target matrix
  4565. */
  4566. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4567. /**
  4568. * Creates a scaling matrix
  4569. * @param x defines the scale factor on X axis
  4570. * @param y defines the scale factor on Y axis
  4571. * @param z defines the scale factor on Z axis
  4572. * @returns the new matrix
  4573. */
  4574. static Scaling(x: number, y: number, z: number): Matrix;
  4575. /**
  4576. * Creates a scaling matrix and stores it in a given matrix
  4577. * @param x defines the scale factor on X axis
  4578. * @param y defines the scale factor on Y axis
  4579. * @param z defines the scale factor on Z axis
  4580. * @param result defines the target matrix
  4581. */
  4582. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4583. /**
  4584. * Creates a translation matrix
  4585. * @param x defines the translation on X axis
  4586. * @param y defines the translation on Y axis
  4587. * @param z defines the translationon Z axis
  4588. * @returns the new matrix
  4589. */
  4590. static Translation(x: number, y: number, z: number): Matrix;
  4591. /**
  4592. * Creates a translation matrix and stores it in a given matrix
  4593. * @param x defines the translation on X axis
  4594. * @param y defines the translation on Y axis
  4595. * @param z defines the translationon Z axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4599. /**
  4600. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4601. * @param startValue defines the start value
  4602. * @param endValue defines the end value
  4603. * @param gradient defines the gradient factor
  4604. * @returns the new matrix
  4605. */
  4606. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4607. /**
  4608. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4609. * @param startValue defines the start value
  4610. * @param endValue defines the end value
  4611. * @param gradient defines the gradient factor
  4612. * @param result defines the Matrix object where to store data
  4613. */
  4614. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Builds a new matrix whose values are computed by:
  4617. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4618. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4619. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4620. * @param startValue defines the first matrix
  4621. * @param endValue defines the second matrix
  4622. * @param gradient defines the gradient between the two matrices
  4623. * @returns the new matrix
  4624. */
  4625. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4626. /**
  4627. * Update a matrix to values which are computed by:
  4628. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4629. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4630. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4631. * @param startValue defines the first matrix
  4632. * @param endValue defines the second matrix
  4633. * @param gradient defines the gradient between the two matrices
  4634. * @param result defines the target matrix
  4635. */
  4636. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in left handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in left handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * 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"
  4657. * This function works in right handed mode
  4658. * @param eye defines the final position of the entity
  4659. * @param target defines where the entity should look at
  4660. * @param up defines the up vector for the entity
  4661. * @returns the new matrix
  4662. */
  4663. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4664. /**
  4665. * 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".
  4666. * This function works in right handed mode
  4667. * @param eye defines the final position of the entity
  4668. * @param target defines where the entity should look at
  4669. * @param up defines the up vector for the entity
  4670. * @param result defines the target matrix
  4671. */
  4672. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param width defines the viewport width
  4676. * @param height defines the viewport height
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Store a left-handed orthographic projection to a given matrix
  4684. * @param width defines the viewport width
  4685. * @param height defines the viewport height
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a left-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a right-handed orthographic projection matrix
  4715. * @param left defines the viewport left coordinate
  4716. * @param right defines the viewport right coordinate
  4717. * @param bottom defines the viewport bottom coordinate
  4718. * @param top defines the viewport top coordinate
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed orthographic projection matrix
  4722. */
  4723. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed orthographic projection into a given matrix
  4726. * @param left defines the viewport left coordinate
  4727. * @param right defines the viewport right coordinate
  4728. * @param bottom defines the viewport bottom coordinate
  4729. * @param top defines the viewport top coordinate
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @param result defines the target matrix
  4733. */
  4734. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4735. /**
  4736. * Creates a left-handed perspective projection matrix
  4737. * @param width defines the viewport width
  4738. * @param height defines the viewport height
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a left-handed perspective projection matrix
  4742. */
  4743. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Creates a left-handed perspective projection matrix
  4746. * @param fov defines the horizontal field of view
  4747. * @param aspect defines the aspect ratio
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @returns a new matrix as a left-handed perspective projection matrix
  4751. */
  4752. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4753. /**
  4754. * Stores a left-handed perspective projection into a given matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @param result defines the target matrix
  4760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4761. */
  4762. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4763. /**
  4764. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4765. * @param fov defines the horizontal field of view
  4766. * @param aspect defines the aspect ratio
  4767. * @param znear defines the near clip plane
  4768. * @param zfar not used as infinity is used as far clip
  4769. * @param result defines the target matrix
  4770. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4771. */
  4772. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4773. /**
  4774. * Creates a right-handed perspective projection matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @returns a new matrix as a right-handed perspective projection matrix
  4780. */
  4781. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4782. /**
  4783. * Stores a right-handed perspective projection into a given matrix
  4784. * @param fov defines the horizontal field of view
  4785. * @param aspect defines the aspect ratio
  4786. * @param znear defines the near clip plane
  4787. * @param zfar defines the far clip plane
  4788. * @param result defines the target matrix
  4789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4790. */
  4791. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4792. /**
  4793. * Stores a right-handed perspective projection into a given matrix
  4794. * @param fov defines the horizontal field of view
  4795. * @param aspect defines the aspect ratio
  4796. * @param znear defines the near clip plane
  4797. * @param zfar not used as infinity is used as far clip
  4798. * @param result defines the target matrix
  4799. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4800. */
  4801. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4802. /**
  4803. * Stores a perspective projection for WebVR info a given matrix
  4804. * @param fov defines the field of view
  4805. * @param znear defines the near clip plane
  4806. * @param zfar defines the far clip plane
  4807. * @param result defines the target matrix
  4808. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4809. */
  4810. static PerspectiveFovWebVRToRef(fov: {
  4811. upDegrees: number;
  4812. downDegrees: number;
  4813. leftDegrees: number;
  4814. rightDegrees: number;
  4815. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4816. /**
  4817. * Computes a complete transformation matrix
  4818. * @param viewport defines the viewport to use
  4819. * @param world defines the world matrix
  4820. * @param view defines the view matrix
  4821. * @param projection defines the projection matrix
  4822. * @param zmin defines the near clip plane
  4823. * @param zmax defines the far clip plane
  4824. * @returns the transformation matrix
  4825. */
  4826. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4827. /**
  4828. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4829. * @param matrix defines the matrix to use
  4830. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4831. */
  4832. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4833. /**
  4834. * Extracts a 3x3 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 9 elements : the 3x3 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Compute the transpose of a given matrix
  4841. * @param matrix defines the matrix to transpose
  4842. * @returns the new matrix
  4843. */
  4844. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4845. /**
  4846. * Compute the transpose of a matrix and store it in a target matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @param result defines the target matrix
  4849. */
  4850. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4851. /**
  4852. * Computes a reflection matrix from a plane
  4853. * @param plane defines the reflection plane
  4854. * @returns a new matrix
  4855. */
  4856. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @param result defines the target matrix
  4861. */
  4862. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4863. /**
  4864. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4865. * @param xaxis defines the value of the 1st axis
  4866. * @param yaxis defines the value of the 2nd axis
  4867. * @param zaxis defines the value of the 3rd axis
  4868. * @param result defines the target matrix
  4869. */
  4870. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4871. /**
  4872. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4873. * @param quat defines the quaternion to use
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4877. }
  4878. /**
  4879. * @hidden
  4880. */
  4881. export class TmpVectors {
  4882. static Vector2: Vector2[];
  4883. static Vector3: Vector3[];
  4884. static Vector4: Vector4[];
  4885. static Quaternion: Quaternion[];
  4886. static Matrix: Matrix[];
  4887. }
  4888. }
  4889. declare module "babylonjs/Maths/math.path" {
  4890. import { DeepImmutable, Nullable } from "babylonjs/types";
  4891. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4892. /**
  4893. * Defines potential orientation for back face culling
  4894. */
  4895. export enum Orientation {
  4896. /**
  4897. * Clockwise
  4898. */
  4899. CW = 0,
  4900. /** Counter clockwise */
  4901. CCW = 1
  4902. }
  4903. /** Class used to represent a Bezier curve */
  4904. export class BezierCurve {
  4905. /**
  4906. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4907. * @param t defines the time
  4908. * @param x1 defines the left coordinate on X axis
  4909. * @param y1 defines the left coordinate on Y axis
  4910. * @param x2 defines the right coordinate on X axis
  4911. * @param y2 defines the right coordinate on Y axis
  4912. * @returns the interpolated value
  4913. */
  4914. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4915. }
  4916. /**
  4917. * Defines angle representation
  4918. */
  4919. export class Angle {
  4920. private _radians;
  4921. /**
  4922. * Creates an Angle object of "radians" radians (float).
  4923. * @param radians the angle in radians
  4924. */
  4925. constructor(radians: number);
  4926. /**
  4927. * Get value in degrees
  4928. * @returns the Angle value in degrees (float)
  4929. */
  4930. degrees(): number;
  4931. /**
  4932. * Get value in radians
  4933. * @returns the Angle value in radians (float)
  4934. */
  4935. radians(): number;
  4936. /**
  4937. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4938. * @param a defines first point as the origin
  4939. * @param b defines point
  4940. * @returns a new Angle
  4941. */
  4942. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4943. /**
  4944. * Gets a new Angle object from the given float in radians
  4945. * @param radians defines the angle value in radians
  4946. * @returns a new Angle
  4947. */
  4948. static FromRadians(radians: number): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in degrees
  4951. * @param degrees defines the angle value in degrees
  4952. * @returns a new Angle
  4953. */
  4954. static FromDegrees(degrees: number): Angle;
  4955. }
  4956. /**
  4957. * This represents an arc in a 2d space.
  4958. */
  4959. export class Arc2 {
  4960. /** Defines the start point of the arc */
  4961. startPoint: Vector2;
  4962. /** Defines the mid point of the arc */
  4963. midPoint: Vector2;
  4964. /** Defines the end point of the arc */
  4965. endPoint: Vector2;
  4966. /**
  4967. * Defines the center point of the arc.
  4968. */
  4969. centerPoint: Vector2;
  4970. /**
  4971. * Defines the radius of the arc.
  4972. */
  4973. radius: number;
  4974. /**
  4975. * Defines the angle of the arc (from mid point to end point).
  4976. */
  4977. angle: Angle;
  4978. /**
  4979. * Defines the start angle of the arc (from start point to middle point).
  4980. */
  4981. startAngle: Angle;
  4982. /**
  4983. * Defines the orientation of the arc (clock wise/counter clock wise).
  4984. */
  4985. orientation: Orientation;
  4986. /**
  4987. * Creates an Arc object from the three given points : start, middle and end.
  4988. * @param startPoint Defines the start point of the arc
  4989. * @param midPoint Defines the midlle point of the arc
  4990. * @param endPoint Defines the end point of the arc
  4991. */
  4992. constructor(
  4993. /** Defines the start point of the arc */
  4994. startPoint: Vector2,
  4995. /** Defines the mid point of the arc */
  4996. midPoint: Vector2,
  4997. /** Defines the end point of the arc */
  4998. endPoint: Vector2);
  4999. }
  5000. /**
  5001. * Represents a 2D path made up of multiple 2D points
  5002. */
  5003. export class Path2 {
  5004. private _points;
  5005. private _length;
  5006. /**
  5007. * If the path start and end point are the same
  5008. */
  5009. closed: boolean;
  5010. /**
  5011. * Creates a Path2 object from the starting 2D coordinates x and y.
  5012. * @param x the starting points x value
  5013. * @param y the starting points y value
  5014. */
  5015. constructor(x: number, y: number);
  5016. /**
  5017. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5018. * @param x the added points x value
  5019. * @param y the added points y value
  5020. * @returns the updated Path2.
  5021. */
  5022. addLineTo(x: number, y: number): Path2;
  5023. /**
  5024. * 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.
  5025. * @param midX middle point x value
  5026. * @param midY middle point y value
  5027. * @param endX end point x value
  5028. * @param endY end point y value
  5029. * @param numberOfSegments (default: 36)
  5030. * @returns the updated Path2.
  5031. */
  5032. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5033. /**
  5034. * Closes the Path2.
  5035. * @returns the Path2.
  5036. */
  5037. close(): Path2;
  5038. /**
  5039. * Gets the sum of the distance between each sequential point in the path
  5040. * @returns the Path2 total length (float).
  5041. */
  5042. length(): number;
  5043. /**
  5044. * Gets the points which construct the path
  5045. * @returns the Path2 internal array of points.
  5046. */
  5047. getPoints(): Vector2[];
  5048. /**
  5049. * Retreives the point at the distance aways from the starting point
  5050. * @param normalizedLengthPosition the length along the path to retreive the point from
  5051. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5052. */
  5053. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5054. /**
  5055. * Creates a new path starting from an x and y position
  5056. * @param x starting x value
  5057. * @param y starting y value
  5058. * @returns a new Path2 starting at the coordinates (x, y).
  5059. */
  5060. static StartingAt(x: number, y: number): Path2;
  5061. }
  5062. /**
  5063. * Represents a 3D path made up of multiple 3D points
  5064. */
  5065. export class Path3D {
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[];
  5070. private _curve;
  5071. private _distances;
  5072. private _tangents;
  5073. private _normals;
  5074. private _binormals;
  5075. private _raw;
  5076. private _alignTangentsWithPath;
  5077. private readonly _pointAtData;
  5078. /**
  5079. * new Path3D(path, normal, raw)
  5080. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5081. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5082. * @param path an array of Vector3, the curve axis of the Path3D
  5083. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5084. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5085. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5086. */
  5087. constructor(
  5088. /**
  5089. * an array of Vector3, the curve axis of the Path3D
  5090. */
  5091. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5092. /**
  5093. * Returns the Path3D array of successive Vector3 designing its curve.
  5094. * @returns the Path3D array of successive Vector3 designing its curve.
  5095. */
  5096. getCurve(): Vector3[];
  5097. /**
  5098. * Returns the Path3D array of successive Vector3 designing its curve.
  5099. * @returns the Path3D array of successive Vector3 designing its curve.
  5100. */
  5101. getPoints(): Vector3[];
  5102. /**
  5103. * @returns the computed length (float) of the path.
  5104. */
  5105. length(): number;
  5106. /**
  5107. * Returns an array populated with tangent vectors on each Path3D curve point.
  5108. * @returns an array populated with tangent vectors on each Path3D curve point.
  5109. */
  5110. getTangents(): Vector3[];
  5111. /**
  5112. * Returns an array populated with normal vectors on each Path3D curve point.
  5113. * @returns an array populated with normal vectors on each Path3D curve point.
  5114. */
  5115. getNormals(): Vector3[];
  5116. /**
  5117. * Returns an array populated with binormal vectors on each Path3D curve point.
  5118. * @returns an array populated with binormal vectors on each Path3D curve point.
  5119. */
  5120. getBinormals(): Vector3[];
  5121. /**
  5122. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5123. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5124. */
  5125. getDistances(): number[];
  5126. /**
  5127. * Returns an interpolated point along this path
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @returns a new Vector3 as the point
  5130. */
  5131. getPointAt(position: number): Vector3;
  5132. /**
  5133. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5136. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5137. */
  5138. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5139. /**
  5140. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5141. * @param position the position of the point along this path, from 0.0 to 1.0
  5142. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5143. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5144. */
  5145. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5146. /**
  5147. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5150. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5151. */
  5152. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5153. /**
  5154. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5155. * @param position the position of the point along this path, from 0.0 to 1.0
  5156. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5157. */
  5158. getDistanceAt(position: number): number;
  5159. /**
  5160. * Returns the array index of the previous point of an interpolated point along this path
  5161. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5162. * @returns the array index
  5163. */
  5164. getPreviousPointIndexAt(position: number): number;
  5165. /**
  5166. * 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)
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the sub position
  5169. */
  5170. getSubPositionAt(position: number): number;
  5171. /**
  5172. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5173. * @param target the vector of which to get the closest position to
  5174. * @returns the position of the closest virtual point on this path to the target vector
  5175. */
  5176. getClosestPositionTo(target: Vector3): number;
  5177. /**
  5178. * Returns a sub path (slice) of this path
  5179. * @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
  5180. * @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
  5181. * @returns a sub path (slice) of this path
  5182. */
  5183. slice(start?: number, end?: number): Path3D;
  5184. /**
  5185. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5186. * @param path path which all values are copied into the curves points
  5187. * @param firstNormal which should be projected onto the curve
  5188. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5189. * @returns the same object updated.
  5190. */
  5191. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5192. private _compute;
  5193. private _getFirstNonNullVector;
  5194. private _getLastNonNullVector;
  5195. private _normalVector;
  5196. /**
  5197. * Updates the point at data for an interpolated point along this curve
  5198. * @param position the position of the point along this curve, from 0.0 to 1.0
  5199. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5200. * @returns the (updated) point at data
  5201. */
  5202. private _updatePointAtData;
  5203. /**
  5204. * Updates the point at data from the specified parameters
  5205. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5206. * @param point the interpolated point
  5207. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5208. */
  5209. private _setPointAtData;
  5210. /**
  5211. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5212. */
  5213. private _updateInterpolationMatrix;
  5214. }
  5215. /**
  5216. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5217. * A Curve3 is designed from a series of successive Vector3.
  5218. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5219. */
  5220. export class Curve3 {
  5221. private _points;
  5222. private _length;
  5223. /**
  5224. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5225. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5226. * @param v1 (Vector3) the control point
  5227. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5234. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5235. * @param v1 (Vector3) the first control point
  5236. * @param v2 (Vector3) the second control point
  5237. * @param v3 (Vector3) the end point of the Cubic Bezier
  5238. * @param nbPoints (integer) the wanted number of points in the curve
  5239. * @returns the created Curve3
  5240. */
  5241. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5242. /**
  5243. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5244. * @param p1 (Vector3) the origin point of the Hermite Spline
  5245. * @param t1 (Vector3) the tangent vector at the origin point
  5246. * @param p2 (Vector3) the end point of the Hermite Spline
  5247. * @param t2 (Vector3) the tangent vector at the end point
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a CatmullRom Spline curve :
  5254. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5255. * @param nbPoints (integer) the wanted number of points between each curve control points
  5256. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5260. /**
  5261. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5262. * A Curve3 is designed from a series of successive Vector3.
  5263. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5264. * @param points points which make up the curve
  5265. */
  5266. constructor(points: Vector3[]);
  5267. /**
  5268. * @returns the Curve3 stored array of successive Vector3
  5269. */
  5270. getPoints(): Vector3[];
  5271. /**
  5272. * @returns the computed length (float) of the curve.
  5273. */
  5274. length(): number;
  5275. /**
  5276. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5277. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5278. * curveA and curveB keep unchanged.
  5279. * @param curve the curve to continue from this curve
  5280. * @returns the newly constructed curve
  5281. */
  5282. continue(curve: DeepImmutable<Curve3>): Curve3;
  5283. private _computeLength;
  5284. }
  5285. }
  5286. declare module "babylonjs/Animations/easing" {
  5287. /**
  5288. * This represents the main contract an easing function should follow.
  5289. * Easing functions are used throughout the animation system.
  5290. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export interface IEasingFunction {
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5295. * of the easing function.
  5296. * The link below provides some of the most common examples of easing functions.
  5297. * @see https://easings.net/
  5298. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5299. * @returns the corresponding value on the curve defined by the easing function
  5300. */
  5301. ease(gradient: number): number;
  5302. }
  5303. /**
  5304. * Base class used for every default easing function.
  5305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5306. */
  5307. export class EasingFunction implements IEasingFunction {
  5308. /**
  5309. * Interpolation follows the mathematical formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEIN: number;
  5312. /**
  5313. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5314. */
  5315. static readonly EASINGMODE_EASEOUT: number;
  5316. /**
  5317. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5318. */
  5319. static readonly EASINGMODE_EASEINOUT: number;
  5320. private _easingMode;
  5321. /**
  5322. * Sets the easing mode of the current function.
  5323. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5324. */
  5325. setEasingMode(easingMode: number): void;
  5326. /**
  5327. * Gets the current easing mode.
  5328. * @returns the easing mode
  5329. */
  5330. getEasingMode(): number;
  5331. /**
  5332. * @hidden
  5333. */
  5334. easeInCore(gradient: number): number;
  5335. /**
  5336. * Given an input gradient between 0 and 1, this returns the corresponding value
  5337. * of the easing function.
  5338. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5339. * @returns the corresponding value on the curve defined by the easing function
  5340. */
  5341. ease(gradient: number): number;
  5342. }
  5343. /**
  5344. * Easing function with a circle shape (see link below).
  5345. * @see https://easings.net/#easeInCirc
  5346. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5347. */
  5348. export class CircleEase extends EasingFunction implements IEasingFunction {
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a ease back shape (see link below).
  5354. * @see https://easings.net/#easeInBack
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class BackEase extends EasingFunction implements IEasingFunction {
  5358. /** Defines the amplitude of the function */
  5359. amplitude: number;
  5360. /**
  5361. * Instantiates a back ease easing
  5362. * @see https://easings.net/#easeInBack
  5363. * @param amplitude Defines the amplitude of the function
  5364. */
  5365. constructor(
  5366. /** Defines the amplitude of the function */
  5367. amplitude?: number);
  5368. /** @hidden */
  5369. easeInCore(gradient: number): number;
  5370. }
  5371. /**
  5372. * Easing function with a bouncing shape (see link below).
  5373. * @see https://easings.net/#easeInBounce
  5374. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5375. */
  5376. export class BounceEase extends EasingFunction implements IEasingFunction {
  5377. /** Defines the number of bounces */
  5378. bounces: number;
  5379. /** Defines the amplitude of the bounce */
  5380. bounciness: number;
  5381. /**
  5382. * Instantiates a bounce easing
  5383. * @see https://easings.net/#easeInBounce
  5384. * @param bounces Defines the number of bounces
  5385. * @param bounciness Defines the amplitude of the bounce
  5386. */
  5387. constructor(
  5388. /** Defines the number of bounces */
  5389. bounces?: number,
  5390. /** Defines the amplitude of the bounce */
  5391. bounciness?: number);
  5392. /** @hidden */
  5393. easeInCore(gradient: number): number;
  5394. }
  5395. /**
  5396. * Easing function with a power of 3 shape (see link below).
  5397. * @see https://easings.net/#easeInCubic
  5398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5399. */
  5400. export class CubicEase extends EasingFunction implements IEasingFunction {
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with an elastic shape (see link below).
  5406. * @see https://easings.net/#easeInElastic
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the number of oscillations*/
  5411. oscillations: number;
  5412. /** Defines the amplitude of the oscillations*/
  5413. springiness: number;
  5414. /**
  5415. * Instantiates an elastic easing function
  5416. * @see https://easings.net/#easeInElastic
  5417. * @param oscillations Defines the number of oscillations
  5418. * @param springiness Defines the amplitude of the oscillations
  5419. */
  5420. constructor(
  5421. /** Defines the number of oscillations*/
  5422. oscillations?: number,
  5423. /** Defines the amplitude of the oscillations*/
  5424. springiness?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with an exponential shape (see link below).
  5430. * @see https://easings.net/#easeInExpo
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5434. /** Defines the exponent of the function */
  5435. exponent: number;
  5436. /**
  5437. * Instantiates an exponential easing function
  5438. * @see https://easings.net/#easeInExpo
  5439. * @param exponent Defines the exponent of the function
  5440. */
  5441. constructor(
  5442. /** Defines the exponent of the function */
  5443. exponent?: number);
  5444. /** @hidden */
  5445. easeInCore(gradient: number): number;
  5446. }
  5447. /**
  5448. * Easing function with a power shape (see link below).
  5449. * @see https://easings.net/#easeInQuad
  5450. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5451. */
  5452. export class PowerEase extends EasingFunction implements IEasingFunction {
  5453. /** Defines the power of the function */
  5454. power: number;
  5455. /**
  5456. * Instantiates an power base easing function
  5457. * @see https://easings.net/#easeInQuad
  5458. * @param power Defines the power of the function
  5459. */
  5460. constructor(
  5461. /** Defines the power of the function */
  5462. power?: number);
  5463. /** @hidden */
  5464. easeInCore(gradient: number): number;
  5465. }
  5466. /**
  5467. * Easing function with a power of 2 shape (see link below).
  5468. * @see https://easings.net/#easeInQuad
  5469. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5470. */
  5471. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5472. /** @hidden */
  5473. easeInCore(gradient: number): number;
  5474. }
  5475. /**
  5476. * Easing function with a power of 4 shape (see link below).
  5477. * @see https://easings.net/#easeInQuart
  5478. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5479. */
  5480. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 5 shape (see link below).
  5486. * @see https://easings.net/#easeInQuint
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a sin shape (see link below).
  5495. * @see https://easings.net/#easeInSine
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class SineEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a bezier shape (see link below).
  5504. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5508. /** Defines the x component of the start tangent in the bezier curve */
  5509. x1: number;
  5510. /** Defines the y component of the start tangent in the bezier curve */
  5511. y1: number;
  5512. /** Defines the x component of the end tangent in the bezier curve */
  5513. x2: number;
  5514. /** Defines the y component of the end tangent in the bezier curve */
  5515. y2: number;
  5516. /**
  5517. * Instantiates a bezier function
  5518. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5519. * @param x1 Defines the x component of the start tangent in the bezier curve
  5520. * @param y1 Defines the y component of the start tangent in the bezier curve
  5521. * @param x2 Defines the x component of the end tangent in the bezier curve
  5522. * @param y2 Defines the y component of the end tangent in the bezier curve
  5523. */
  5524. constructor(
  5525. /** Defines the x component of the start tangent in the bezier curve */
  5526. x1?: number,
  5527. /** Defines the y component of the start tangent in the bezier curve */
  5528. y1?: number,
  5529. /** Defines the x component of the end tangent in the bezier curve */
  5530. x2?: number,
  5531. /** Defines the y component of the end tangent in the bezier curve */
  5532. y2?: number);
  5533. /** @hidden */
  5534. easeInCore(gradient: number): number;
  5535. }
  5536. }
  5537. declare module "babylonjs/Maths/math.color" {
  5538. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5539. /**
  5540. * Class used to hold a RBG color
  5541. */
  5542. export class Color3 {
  5543. /**
  5544. * Defines the red component (between 0 and 1, default is 0)
  5545. */
  5546. r: number;
  5547. /**
  5548. * Defines the green component (between 0 and 1, default is 0)
  5549. */
  5550. g: number;
  5551. /**
  5552. * Defines the blue component (between 0 and 1, default is 0)
  5553. */
  5554. b: number;
  5555. /**
  5556. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5557. * @param r defines the red component (between 0 and 1, default is 0)
  5558. * @param g defines the green component (between 0 and 1, default is 0)
  5559. * @param b defines the blue component (between 0 and 1, default is 0)
  5560. */
  5561. constructor(
  5562. /**
  5563. * Defines the red component (between 0 and 1, default is 0)
  5564. */
  5565. r?: number,
  5566. /**
  5567. * Defines the green component (between 0 and 1, default is 0)
  5568. */
  5569. g?: number,
  5570. /**
  5571. * Defines the blue component (between 0 and 1, default is 0)
  5572. */
  5573. b?: number);
  5574. /**
  5575. * Creates a string with the Color3 current values
  5576. * @returns the string representation of the Color3 object
  5577. */
  5578. toString(): string;
  5579. /**
  5580. * Returns the string "Color3"
  5581. * @returns "Color3"
  5582. */
  5583. getClassName(): string;
  5584. /**
  5585. * Compute the Color3 hash code
  5586. * @returns an unique number that can be used to hash Color3 objects
  5587. */
  5588. getHashCode(): number;
  5589. /**
  5590. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5591. * @param array defines the array where to store the r,g,b components
  5592. * @param index defines an optional index in the target array to define where to start storing values
  5593. * @returns the current Color3 object
  5594. */
  5595. toArray(array: FloatArray, index?: number): Color3;
  5596. /**
  5597. * Update the current color with values stored in an array from the starting index of the given array
  5598. * @param array defines the source array
  5599. * @param offset defines an offset in the source array
  5600. * @returns the current Color3 object
  5601. */
  5602. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5603. /**
  5604. * Returns a new Color4 object from the current Color3 and the given alpha
  5605. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5606. * @returns a new Color4 object
  5607. */
  5608. toColor4(alpha?: number): Color4;
  5609. /**
  5610. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5611. * @returns the new array
  5612. */
  5613. asArray(): number[];
  5614. /**
  5615. * Returns the luminance value
  5616. * @returns a float value
  5617. */
  5618. toLuminance(): number;
  5619. /**
  5620. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5621. * @param otherColor defines the second operand
  5622. * @returns the new Color3 object
  5623. */
  5624. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5627. * @param otherColor defines the second operand
  5628. * @param result defines the Color3 object where to store the result
  5629. * @returns the current Color3
  5630. */
  5631. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5632. /**
  5633. * Determines equality between Color3 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgb values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color3>): boolean;
  5638. /**
  5639. * Determines equality between the current Color3 object and a set of r,b,g values
  5640. * @param r defines the red component to check
  5641. * @param g defines the green component to check
  5642. * @param b defines the blue component to check
  5643. * @returns true if the rgb values are equal to the given ones
  5644. */
  5645. equalsFloats(r: number, g: number, b: number): boolean;
  5646. /**
  5647. * Multiplies in place each rgb value by scale
  5648. * @param scale defines the scaling factor
  5649. * @returns the updated Color3
  5650. */
  5651. scale(scale: number): Color3;
  5652. /**
  5653. * Multiplies the rgb values by scale and stores the result into "result"
  5654. * @param scale defines the scaling factor
  5655. * @param result defines the Color3 object where to store the result
  5656. * @returns the unmodified current Color3
  5657. */
  5658. scaleToRef(scale: number, result: Color3): Color3;
  5659. /**
  5660. * Scale the current Color3 values by a factor and add the result to a given Color3
  5661. * @param scale defines the scale factor
  5662. * @param result defines color to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5666. /**
  5667. * Clamps the rgb values by the min and max values and stores the result into "result"
  5668. * @param min defines minimum clamping value (default is 0)
  5669. * @param max defines maximum clamping value (default is 1)
  5670. * @param result defines color to store the result into
  5671. * @returns the original Color3
  5672. */
  5673. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5674. /**
  5675. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5676. * @param otherColor defines the second operand
  5677. * @returns the new Color3
  5678. */
  5679. add(otherColor: DeepImmutable<Color3>): Color3;
  5680. /**
  5681. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5682. * @param otherColor defines the second operand
  5683. * @param result defines Color3 object to store the result into
  5684. * @returns the unmodified current Color3
  5685. */
  5686. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5687. /**
  5688. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5689. * @param otherColor defines the second operand
  5690. * @returns the new Color3
  5691. */
  5692. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5693. /**
  5694. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5695. * @param otherColor defines the second operand
  5696. * @param result defines Color3 object to store the result into
  5697. * @returns the unmodified current Color3
  5698. */
  5699. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5700. /**
  5701. * Copy the current object
  5702. * @returns a new Color3 copied the current one
  5703. */
  5704. clone(): Color3;
  5705. /**
  5706. * Copies the rgb values from the source in the current Color3
  5707. * @param source defines the source Color3 object
  5708. * @returns the updated Color3 object
  5709. */
  5710. copyFrom(source: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Updates the Color3 rgb values from the given floats
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @returns the current Color3 object
  5717. */
  5718. copyFromFloats(r: number, g: number, b: number): Color3;
  5719. /**
  5720. * Updates the Color3 rgb values from the given floats
  5721. * @param r defines the red component to read from
  5722. * @param g defines the green component to read from
  5723. * @param b defines the blue component to read from
  5724. * @returns the current Color3 object
  5725. */
  5726. set(r: number, g: number, b: number): Color3;
  5727. /**
  5728. * Compute the Color3 hexadecimal code as a string
  5729. * @returns a string containing the hexadecimal representation of the Color3 object
  5730. */
  5731. toHexString(): string;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to linear space
  5734. * @returns a new Color3 object
  5735. */
  5736. toLinearSpace(): Color3;
  5737. /**
  5738. * Converts current color in rgb space to HSV values
  5739. * @returns a new color3 representing the HSV values
  5740. */
  5741. toHSV(): Color3;
  5742. /**
  5743. * Converts current color in rgb space to HSV values
  5744. * @param result defines the Color3 where to store the HSV values
  5745. */
  5746. toHSVToRef(result: Color3): void;
  5747. /**
  5748. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5749. * @param convertedColor defines the Color3 object where to store the linear space version
  5750. * @returns the unmodified Color3
  5751. */
  5752. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5753. /**
  5754. * Computes a new Color3 converted from the current one to gamma space
  5755. * @returns a new Color3 object
  5756. */
  5757. toGammaSpace(): Color3;
  5758. /**
  5759. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5760. * @param convertedColor defines the Color3 object where to store the gamma space version
  5761. * @returns the unmodified Color3
  5762. */
  5763. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5764. private static _BlackReadOnly;
  5765. /**
  5766. * Convert Hue, saturation and value to a Color3 (RGB)
  5767. * @param hue defines the hue
  5768. * @param saturation defines the saturation
  5769. * @param value defines the value
  5770. * @param result defines the Color3 where to store the RGB values
  5771. */
  5772. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5773. /**
  5774. * Creates a new Color3 from the string containing valid hexadecimal values
  5775. * @param hex defines a string containing valid hexadecimal values
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromHexString(hex: string): Color3;
  5779. /**
  5780. * Creates a new Color3 from the starting index of the given array
  5781. * @param array defines the source array
  5782. * @param offset defines an offset in the source array
  5783. * @returns a new Color3 object
  5784. */
  5785. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5786. /**
  5787. * Creates a new Color3 from the starting index element of the given array
  5788. * @param array defines the source array to read from
  5789. * @param offset defines the offset in the source array
  5790. * @param result defines the target Color3 object
  5791. */
  5792. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from integer values (< 256)
  5795. * @param r defines the red component to read from (value between 0 and 255)
  5796. * @param g defines the green component to read from (value between 0 and 255)
  5797. * @param b defines the blue component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number): Color3;
  5801. /**
  5802. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5803. * @param start defines the start Color3 value
  5804. * @param end defines the end Color3 value
  5805. * @param amount defines the gradient value between start and end
  5806. * @returns a new Color3 object
  5807. */
  5808. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5809. /**
  5810. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5811. * @param left defines the start value
  5812. * @param right defines the end value
  5813. * @param amount defines the gradient factor
  5814. * @param result defines the Color3 object where to store the result
  5815. */
  5816. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5817. /**
  5818. * Returns a Color3 value containing a red color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Red(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a green color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Green(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a blue color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Blue(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a black color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Black(): Color3;
  5837. /**
  5838. * Gets a Color3 value containing a black color that must not be updated
  5839. */
  5840. static get BlackReadOnly(): DeepImmutable<Color3>;
  5841. /**
  5842. * Returns a Color3 value containing a white color
  5843. * @returns a new Color3 object
  5844. */
  5845. static White(): Color3;
  5846. /**
  5847. * Returns a Color3 value containing a purple color
  5848. * @returns a new Color3 object
  5849. */
  5850. static Purple(): Color3;
  5851. /**
  5852. * Returns a Color3 value containing a magenta color
  5853. * @returns a new Color3 object
  5854. */
  5855. static Magenta(): Color3;
  5856. /**
  5857. * Returns a Color3 value containing a yellow color
  5858. * @returns a new Color3 object
  5859. */
  5860. static Yellow(): Color3;
  5861. /**
  5862. * Returns a Color3 value containing a gray color
  5863. * @returns a new Color3 object
  5864. */
  5865. static Gray(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a teal color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Teal(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a random color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Random(): Color3;
  5876. }
  5877. /**
  5878. * Class used to hold a RBGA color
  5879. */
  5880. export class Color4 {
  5881. /**
  5882. * Defines the red component (between 0 and 1, default is 0)
  5883. */
  5884. r: number;
  5885. /**
  5886. * Defines the green component (between 0 and 1, default is 0)
  5887. */
  5888. g: number;
  5889. /**
  5890. * Defines the blue component (between 0 and 1, default is 0)
  5891. */
  5892. b: number;
  5893. /**
  5894. * Defines the alpha component (between 0 and 1, default is 1)
  5895. */
  5896. a: number;
  5897. /**
  5898. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5899. * @param r defines the red component (between 0 and 1, default is 0)
  5900. * @param g defines the green component (between 0 and 1, default is 0)
  5901. * @param b defines the blue component (between 0 and 1, default is 0)
  5902. * @param a defines the alpha component (between 0 and 1, default is 1)
  5903. */
  5904. constructor(
  5905. /**
  5906. * Defines the red component (between 0 and 1, default is 0)
  5907. */
  5908. r?: number,
  5909. /**
  5910. * Defines the green component (between 0 and 1, default is 0)
  5911. */
  5912. g?: number,
  5913. /**
  5914. * Defines the blue component (between 0 and 1, default is 0)
  5915. */
  5916. b?: number,
  5917. /**
  5918. * Defines the alpha component (between 0 and 1, default is 1)
  5919. */
  5920. a?: number);
  5921. /**
  5922. * Adds in place the given Color4 values to the current Color4 object
  5923. * @param right defines the second operand
  5924. * @returns the current updated Color4 object
  5925. */
  5926. addInPlace(right: DeepImmutable<Color4>): Color4;
  5927. /**
  5928. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5929. * @returns the new array
  5930. */
  5931. asArray(): number[];
  5932. /**
  5933. * Stores from the starting index in the given array the Color4 successive values
  5934. * @param array defines the array where to store the r,g,b components
  5935. * @param index defines an optional index in the target array to define where to start storing values
  5936. * @returns the current Color4 object
  5937. */
  5938. toArray(array: number[], index?: number): Color4;
  5939. /**
  5940. * Update the current color with values stored in an array from the starting index of the given array
  5941. * @param array defines the source array
  5942. * @param offset defines an offset in the source array
  5943. * @returns the current Color4 object
  5944. */
  5945. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5946. /**
  5947. * Determines equality between Color4 objects
  5948. * @param otherColor defines the second operand
  5949. * @returns true if the rgba values are equal to the given ones
  5950. */
  5951. equals(otherColor: DeepImmutable<Color4>): boolean;
  5952. /**
  5953. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5954. * @param right defines the second operand
  5955. * @returns a new Color4 object
  5956. */
  5957. add(right: DeepImmutable<Color4>): Color4;
  5958. /**
  5959. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. subtract(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5966. * @param right defines the second operand
  5967. * @param result defines the Color4 object where to store the result
  5968. * @returns the current Color4 object
  5969. */
  5970. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5971. /**
  5972. * Creates a new Color4 with the current Color4 values multiplied by scale
  5973. * @param scale defines the scaling factor to apply
  5974. * @returns a new Color4 object
  5975. */
  5976. scale(scale: number): Color4;
  5977. /**
  5978. * Multiplies the current Color4 values by scale and stores the result in "result"
  5979. * @param scale defines the scaling factor to apply
  5980. * @param result defines the Color4 object where to store the result
  5981. * @returns the current unmodified Color4
  5982. */
  5983. scaleToRef(scale: number, result: Color4): Color4;
  5984. /**
  5985. * Scale the current Color4 values by a factor and add the result to a given Color4
  5986. * @param scale defines the scale factor
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the unmodified current Color4
  5989. */
  5990. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5991. /**
  5992. * Clamps the rgb values by the min and max values and stores the result into "result"
  5993. * @param min defines minimum clamping value (default is 0)
  5994. * @param max defines maximum clamping value (default is 1)
  5995. * @param result defines color to store the result into.
  5996. * @returns the cuurent Color4
  5997. */
  5998. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5999. /**
  6000. * Multipy an Color4 value by another and return a new Color4 object
  6001. * @param color defines the Color4 value to multiply by
  6002. * @returns a new Color4 object
  6003. */
  6004. multiply(color: Color4): Color4;
  6005. /**
  6006. * Multipy a Color4 value by another and push the result in a reference value
  6007. * @param color defines the Color4 value to multiply by
  6008. * @param result defines the Color4 to fill the result in
  6009. * @returns the result Color4
  6010. */
  6011. multiplyToRef(color: Color4, result: Color4): Color4;
  6012. /**
  6013. * Creates a string with the Color4 current values
  6014. * @returns the string representation of the Color4 object
  6015. */
  6016. toString(): string;
  6017. /**
  6018. * Returns the string "Color4"
  6019. * @returns "Color4"
  6020. */
  6021. getClassName(): string;
  6022. /**
  6023. * Compute the Color4 hash code
  6024. * @returns an unique number that can be used to hash Color4 objects
  6025. */
  6026. getHashCode(): number;
  6027. /**
  6028. * Creates a new Color4 copied from the current one
  6029. * @returns a new Color4 object
  6030. */
  6031. clone(): Color4;
  6032. /**
  6033. * Copies the given Color4 values into the current one
  6034. * @param source defines the source Color4 object
  6035. * @returns the current updated Color4 object
  6036. */
  6037. copyFrom(source: Color4): Color4;
  6038. /**
  6039. * Copies the given float values into the current one
  6040. * @param r defines the red component to read from
  6041. * @param g defines the green component to read from
  6042. * @param b defines the blue component to read from
  6043. * @param a defines the alpha component to read from
  6044. * @returns the current updated Color4 object
  6045. */
  6046. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6047. /**
  6048. * Copies the given float values into the current one
  6049. * @param r defines the red component to read from
  6050. * @param g defines the green component to read from
  6051. * @param b defines the blue component to read from
  6052. * @param a defines the alpha component to read from
  6053. * @returns the current updated Color4 object
  6054. */
  6055. set(r: number, g: number, b: number, a: number): Color4;
  6056. /**
  6057. * Compute the Color4 hexadecimal code as a string
  6058. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6059. * @returns a string containing the hexadecimal representation of the Color4 object
  6060. */
  6061. toHexString(returnAsColor3?: boolean): string;
  6062. /**
  6063. * Computes a new Color4 converted from the current one to linear space
  6064. * @returns a new Color4 object
  6065. */
  6066. toLinearSpace(): Color4;
  6067. /**
  6068. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6069. * @param convertedColor defines the Color4 object where to store the linear space version
  6070. * @returns the unmodified Color4
  6071. */
  6072. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6073. /**
  6074. * Computes a new Color4 converted from the current one to gamma space
  6075. * @returns a new Color4 object
  6076. */
  6077. toGammaSpace(): Color4;
  6078. /**
  6079. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6080. * @param convertedColor defines the Color4 object where to store the gamma space version
  6081. * @returns the unmodified Color4
  6082. */
  6083. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6084. /**
  6085. * Creates a new Color4 from the string containing valid hexadecimal values
  6086. * @param hex defines a string containing valid hexadecimal values
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromHexString(hex: string): Color4;
  6090. /**
  6091. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6092. * @param left defines the start value
  6093. * @param right defines the end value
  6094. * @param amount defines the gradient factor
  6095. * @returns a new Color4 object
  6096. */
  6097. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6098. /**
  6099. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6100. * @param left defines the start value
  6101. * @param right defines the end value
  6102. * @param amount defines the gradient factor
  6103. * @param result defines the Color4 object where to store data
  6104. */
  6105. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6106. /**
  6107. * Creates a new Color4 from a Color3 and an alpha value
  6108. * @param color3 defines the source Color3 to read from
  6109. * @param alpha defines the alpha component (1.0 by default)
  6110. * @returns a new Color4 object
  6111. */
  6112. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6113. /**
  6114. * Creates a new Color4 from the starting index element of the given array
  6115. * @param array defines the source array to read from
  6116. * @param offset defines the offset in the source array
  6117. * @returns a new Color4 object
  6118. */
  6119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6120. /**
  6121. * Creates a new Color4 from the starting index element of the given array
  6122. * @param array defines the source array to read from
  6123. * @param offset defines the offset in the source array
  6124. * @param result defines the target Color4 object
  6125. */
  6126. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6127. /**
  6128. * Creates a new Color3 from integer values (< 256)
  6129. * @param r defines the red component to read from (value between 0 and 255)
  6130. * @param g defines the green component to read from (value between 0 and 255)
  6131. * @param b defines the blue component to read from (value between 0 and 255)
  6132. * @param a defines the alpha component to read from (value between 0 and 255)
  6133. * @returns a new Color3 object
  6134. */
  6135. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6136. /**
  6137. * Check the content of a given array and convert it to an array containing RGBA data
  6138. * If the original array was already containing count * 4 values then it is returned directly
  6139. * @param colors defines the array to check
  6140. * @param count defines the number of RGBA data to expect
  6141. * @returns an array containing count * 4 values (RGBA)
  6142. */
  6143. static CheckColors4(colors: number[], count: number): number[];
  6144. }
  6145. /**
  6146. * @hidden
  6147. */
  6148. export class TmpColors {
  6149. static Color3: Color3[];
  6150. static Color4: Color4[];
  6151. }
  6152. }
  6153. declare module "babylonjs/Animations/animationKey" {
  6154. /**
  6155. * Defines an interface which represents an animation key frame
  6156. */
  6157. export interface IAnimationKey {
  6158. /**
  6159. * Frame of the key frame
  6160. */
  6161. frame: number;
  6162. /**
  6163. * Value at the specifies key frame
  6164. */
  6165. value: any;
  6166. /**
  6167. * The input tangent for the cubic hermite spline
  6168. */
  6169. inTangent?: any;
  6170. /**
  6171. * The output tangent for the cubic hermite spline
  6172. */
  6173. outTangent?: any;
  6174. /**
  6175. * The animation interpolation type
  6176. */
  6177. interpolation?: AnimationKeyInterpolation;
  6178. }
  6179. /**
  6180. * Enum for the animation key frame interpolation type
  6181. */
  6182. export enum AnimationKeyInterpolation {
  6183. /**
  6184. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6185. */
  6186. STEP = 1
  6187. }
  6188. }
  6189. declare module "babylonjs/Animations/animationRange" {
  6190. /**
  6191. * Represents the range of an animation
  6192. */
  6193. export class AnimationRange {
  6194. /**The name of the animation range**/
  6195. name: string;
  6196. /**The starting frame of the animation */
  6197. from: number;
  6198. /**The ending frame of the animation*/
  6199. to: number;
  6200. /**
  6201. * Initializes the range of an animation
  6202. * @param name The name of the animation range
  6203. * @param from The starting frame of the animation
  6204. * @param to The ending frame of the animation
  6205. */
  6206. constructor(
  6207. /**The name of the animation range**/
  6208. name: string,
  6209. /**The starting frame of the animation */
  6210. from: number,
  6211. /**The ending frame of the animation*/
  6212. to: number);
  6213. /**
  6214. * Makes a copy of the animation range
  6215. * @returns A copy of the animation range
  6216. */
  6217. clone(): AnimationRange;
  6218. }
  6219. }
  6220. declare module "babylonjs/Animations/animationEvent" {
  6221. /**
  6222. * Composed of a frame, and an action function
  6223. */
  6224. export class AnimationEvent {
  6225. /** The frame for which the event is triggered **/
  6226. frame: number;
  6227. /** The event to perform when triggered **/
  6228. action: (currentFrame: number) => void;
  6229. /** Specifies if the event should be triggered only once**/
  6230. onlyOnce?: boolean | undefined;
  6231. /**
  6232. * Specifies if the animation event is done
  6233. */
  6234. isDone: boolean;
  6235. /**
  6236. * Initializes the animation event
  6237. * @param frame The frame for which the event is triggered
  6238. * @param action The event to perform when triggered
  6239. * @param onlyOnce Specifies if the event should be triggered only once
  6240. */
  6241. constructor(
  6242. /** The frame for which the event is triggered **/
  6243. frame: number,
  6244. /** The event to perform when triggered **/
  6245. action: (currentFrame: number) => void,
  6246. /** Specifies if the event should be triggered only once**/
  6247. onlyOnce?: boolean | undefined);
  6248. /** @hidden */
  6249. _clone(): AnimationEvent;
  6250. }
  6251. }
  6252. declare module "babylonjs/Behaviors/behavior" {
  6253. import { Nullable } from "babylonjs/types";
  6254. /**
  6255. * Interface used to define a behavior
  6256. */
  6257. export interface Behavior<T> {
  6258. /** gets or sets behavior's name */
  6259. name: string;
  6260. /**
  6261. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6262. */
  6263. init(): void;
  6264. /**
  6265. * Called when the behavior is attached to a target
  6266. * @param target defines the target where the behavior is attached to
  6267. */
  6268. attach(target: T): void;
  6269. /**
  6270. * Called when the behavior is detached from its target
  6271. */
  6272. detach(): void;
  6273. }
  6274. /**
  6275. * Interface implemented by classes supporting behaviors
  6276. */
  6277. export interface IBehaviorAware<T> {
  6278. /**
  6279. * Attach a behavior
  6280. * @param behavior defines the behavior to attach
  6281. * @returns the current host
  6282. */
  6283. addBehavior(behavior: Behavior<T>): T;
  6284. /**
  6285. * Remove a behavior from the current object
  6286. * @param behavior defines the behavior to detach
  6287. * @returns the current host
  6288. */
  6289. removeBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Gets a behavior using its name to search
  6292. * @param name defines the name to search
  6293. * @returns the behavior or null if not found
  6294. */
  6295. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6296. }
  6297. }
  6298. declare module "babylonjs/Misc/smartArray" {
  6299. /**
  6300. * Defines an array and its length.
  6301. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6302. */
  6303. export interface ISmartArrayLike<T> {
  6304. /**
  6305. * The data of the array.
  6306. */
  6307. data: Array<T>;
  6308. /**
  6309. * The active length of the array.
  6310. */
  6311. length: number;
  6312. }
  6313. /**
  6314. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6315. */
  6316. export class SmartArray<T> implements ISmartArrayLike<T> {
  6317. /**
  6318. * The full set of data from the array.
  6319. */
  6320. data: Array<T>;
  6321. /**
  6322. * The active length of the array.
  6323. */
  6324. length: number;
  6325. protected _id: number;
  6326. /**
  6327. * Instantiates a Smart Array.
  6328. * @param capacity defines the default capacity of the array.
  6329. */
  6330. constructor(capacity: number);
  6331. /**
  6332. * Pushes a value at the end of the active data.
  6333. * @param value defines the object to push in the array.
  6334. */
  6335. push(value: T): void;
  6336. /**
  6337. * Iterates over the active data and apply the lambda to them.
  6338. * @param func defines the action to apply on each value.
  6339. */
  6340. forEach(func: (content: T) => void): void;
  6341. /**
  6342. * Sorts the full sets of data.
  6343. * @param compareFn defines the comparison function to apply.
  6344. */
  6345. sort(compareFn: (a: T, b: T) => number): void;
  6346. /**
  6347. * Resets the active data to an empty array.
  6348. */
  6349. reset(): void;
  6350. /**
  6351. * Releases all the data from the array as well as the array.
  6352. */
  6353. dispose(): void;
  6354. /**
  6355. * Concats the active data with a given array.
  6356. * @param array defines the data to concatenate with.
  6357. */
  6358. concat(array: any): void;
  6359. /**
  6360. * Returns the position of a value in the active data.
  6361. * @param value defines the value to find the index for
  6362. * @returns the index if found in the active data otherwise -1
  6363. */
  6364. indexOf(value: T): number;
  6365. /**
  6366. * Returns whether an element is part of the active data.
  6367. * @param value defines the value to look for
  6368. * @returns true if found in the active data otherwise false
  6369. */
  6370. contains(value: T): boolean;
  6371. private static _GlobalId;
  6372. }
  6373. /**
  6374. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6375. * The data in this array can only be present once
  6376. */
  6377. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6378. private _duplicateId;
  6379. /**
  6380. * Pushes a value at the end of the active data.
  6381. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6382. * @param value defines the object to push in the array.
  6383. */
  6384. push(value: T): void;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * If the data is already present, it won t be added again
  6388. * @param value defines the object to push in the array.
  6389. * @returns true if added false if it was already present
  6390. */
  6391. pushNoDuplicate(value: T): boolean;
  6392. /**
  6393. * Resets the active data to an empty array.
  6394. */
  6395. reset(): void;
  6396. /**
  6397. * Concats the active data with a given array.
  6398. * This ensures no dupplicate will be present in the result.
  6399. * @param array defines the data to concatenate with.
  6400. */
  6401. concatWithNoDuplicate(array: any): void;
  6402. }
  6403. }
  6404. declare module "babylonjs/Cameras/cameraInputsManager" {
  6405. import { Nullable } from "babylonjs/types";
  6406. import { Camera } from "babylonjs/Cameras/camera";
  6407. /**
  6408. * @ignore
  6409. * This is a list of all the different input types that are available in the application.
  6410. * Fo instance: ArcRotateCameraGamepadInput...
  6411. */
  6412. export var CameraInputTypes: {};
  6413. /**
  6414. * This is the contract to implement in order to create a new input class.
  6415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6416. */
  6417. export interface ICameraInput<TCamera extends Camera> {
  6418. /**
  6419. * Defines the camera the input is attached to.
  6420. */
  6421. camera: Nullable<TCamera>;
  6422. /**
  6423. * Gets the class name of the current intput.
  6424. * @returns the class name
  6425. */
  6426. getClassName(): string;
  6427. /**
  6428. * Get the friendly name associated with the input class.
  6429. * @returns the input friendly name
  6430. */
  6431. getSimpleName(): string;
  6432. /**
  6433. * Attach the input controls to a specific dom element to get the input from.
  6434. * @param element Defines the element the controls should be listened from
  6435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6436. */
  6437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6438. /**
  6439. * Detach the current controls from the specified dom element.
  6440. * @param element Defines the element to stop listening the inputs from
  6441. */
  6442. detachControl(element: Nullable<HTMLElement>): void;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs?: () => void;
  6448. }
  6449. /**
  6450. * Represents a map of input types to input instance or input index to input instance.
  6451. */
  6452. export interface CameraInputsMap<TCamera extends Camera> {
  6453. /**
  6454. * Accessor to the input by input type.
  6455. */
  6456. [name: string]: ICameraInput<TCamera>;
  6457. /**
  6458. * Accessor to the input by input index.
  6459. */
  6460. [idx: number]: ICameraInput<TCamera>;
  6461. }
  6462. /**
  6463. * This represents the input manager used within a camera.
  6464. * It helps dealing with all the different kind of input attached to a camera.
  6465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6466. */
  6467. export class CameraInputsManager<TCamera extends Camera> {
  6468. /**
  6469. * Defines the list of inputs attahed to the camera.
  6470. */
  6471. attached: CameraInputsMap<TCamera>;
  6472. /**
  6473. * Defines the dom element the camera is collecting inputs from.
  6474. * This is null if the controls have not been attached.
  6475. */
  6476. attachedElement: Nullable<HTMLElement>;
  6477. /**
  6478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6479. */
  6480. noPreventDefault: boolean;
  6481. /**
  6482. * Defined the camera the input manager belongs to.
  6483. */
  6484. camera: TCamera;
  6485. /**
  6486. * Update the current camera state depending on the inputs that have been used this frame.
  6487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6488. */
  6489. checkInputs: () => void;
  6490. /**
  6491. * Instantiate a new Camera Input Manager.
  6492. * @param camera Defines the camera the input manager blongs to
  6493. */
  6494. constructor(camera: TCamera);
  6495. /**
  6496. * Add an input method to a camera
  6497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6498. * @param input camera input method
  6499. */
  6500. add(input: ICameraInput<TCamera>): void;
  6501. /**
  6502. * Remove a specific input method from a camera
  6503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6504. * @param inputToRemove camera input method
  6505. */
  6506. remove(inputToRemove: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input type from a camera
  6509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6510. * @param inputType the type of the input to remove
  6511. */
  6512. removeByType(inputType: string): void;
  6513. private _addCheckInputs;
  6514. /**
  6515. * Attach the input controls to the currently attached dom element to listen the events from.
  6516. * @param input Defines the input to attach
  6517. */
  6518. attachInput(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6521. * @param element Defines the dom element to collect the events from
  6522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6523. */
  6524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6525. /**
  6526. * Detach the current manager inputs controls from a specific dom element.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6529. */
  6530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6531. /**
  6532. * Rebuild the dynamic inputCheck function from the current list of
  6533. * defined inputs in the manager.
  6534. */
  6535. rebuildInputCheck(): void;
  6536. /**
  6537. * Remove all attached input methods from a camera
  6538. */
  6539. clear(): void;
  6540. /**
  6541. * Serialize the current input manager attached to a camera.
  6542. * This ensures than once parsed,
  6543. * the input associated to the camera will be identical to the current ones
  6544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6545. */
  6546. serialize(serializedCamera: any): void;
  6547. /**
  6548. * Parses an input manager serialized JSON to restore the previous list of inputs
  6549. * and states associated to a camera.
  6550. * @param parsedCamera Defines the JSON to parse
  6551. */
  6552. parse(parsedCamera: any): void;
  6553. }
  6554. }
  6555. declare module "babylonjs/Meshes/buffer" {
  6556. import { Nullable, DataArray } from "babylonjs/types";
  6557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6558. /**
  6559. * Class used to store data that will be store in GPU memory
  6560. */
  6561. export class Buffer {
  6562. private _engine;
  6563. private _buffer;
  6564. /** @hidden */
  6565. _data: Nullable<DataArray>;
  6566. private _updatable;
  6567. private _instanced;
  6568. private _divisor;
  6569. /**
  6570. * Gets the byte stride.
  6571. */
  6572. readonly byteStride: number;
  6573. /**
  6574. * Constructor
  6575. * @param engine the engine
  6576. * @param data the data to use for this buffer
  6577. * @param updatable whether the data is updatable
  6578. * @param stride the stride (optional)
  6579. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6580. * @param instanced whether the buffer is instanced (optional)
  6581. * @param useBytes set to true if the stride in in bytes (optional)
  6582. * @param divisor sets an optional divisor for instances (1 by default)
  6583. */
  6584. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6585. /**
  6586. * Create a new VertexBuffer based on the current buffer
  6587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6588. * @param offset defines offset in the buffer (0 by default)
  6589. * @param size defines the size in floats of attributes (position is 3 for instance)
  6590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6591. * @param instanced defines if the vertex buffer contains indexed data
  6592. * @param useBytes defines if the offset and stride are in bytes *
  6593. * @param divisor sets an optional divisor for instances (1 by default)
  6594. * @returns the new vertex buffer
  6595. */
  6596. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6597. /**
  6598. * Gets a boolean indicating if the Buffer is updatable?
  6599. * @returns true if the buffer is updatable
  6600. */
  6601. isUpdatable(): boolean;
  6602. /**
  6603. * Gets current buffer's data
  6604. * @returns a DataArray or null
  6605. */
  6606. getData(): Nullable<DataArray>;
  6607. /**
  6608. * Gets underlying native buffer
  6609. * @returns underlying native buffer
  6610. */
  6611. getBuffer(): Nullable<DataBuffer>;
  6612. /**
  6613. * Gets the stride in float32 units (i.e. byte stride / 4).
  6614. * May not be an integer if the byte stride is not divisible by 4.
  6615. * @returns the stride in float32 units
  6616. * @deprecated Please use byteStride instead.
  6617. */
  6618. getStrideSize(): number;
  6619. /**
  6620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6621. * @param data defines the data to store
  6622. */
  6623. create(data?: Nullable<DataArray>): void;
  6624. /** @hidden */
  6625. _rebuild(): void;
  6626. /**
  6627. * Update current buffer data
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates the data directly.
  6633. * @param data the new data
  6634. * @param offset the new offset
  6635. * @param vertexCount the vertex count (optional)
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6639. /**
  6640. * Release all resources
  6641. */
  6642. dispose(): void;
  6643. }
  6644. /**
  6645. * Specialized buffer used to store vertex data
  6646. */
  6647. export class VertexBuffer {
  6648. /** @hidden */
  6649. _buffer: Buffer;
  6650. private _kind;
  6651. private _size;
  6652. private _ownsBuffer;
  6653. private _instanced;
  6654. private _instanceDivisor;
  6655. /**
  6656. * The byte type.
  6657. */
  6658. static readonly BYTE: number;
  6659. /**
  6660. * The unsigned byte type.
  6661. */
  6662. static readonly UNSIGNED_BYTE: number;
  6663. /**
  6664. * The short type.
  6665. */
  6666. static readonly SHORT: number;
  6667. /**
  6668. * The unsigned short type.
  6669. */
  6670. static readonly UNSIGNED_SHORT: number;
  6671. /**
  6672. * The integer type.
  6673. */
  6674. static readonly INT: number;
  6675. /**
  6676. * The unsigned integer type.
  6677. */
  6678. static readonly UNSIGNED_INT: number;
  6679. /**
  6680. * The float type.
  6681. */
  6682. static readonly FLOAT: number;
  6683. /**
  6684. * Gets or sets the instance divisor when in instanced mode
  6685. */
  6686. get instanceDivisor(): number;
  6687. set instanceDivisor(value: number);
  6688. /**
  6689. * Gets the byte stride.
  6690. */
  6691. readonly byteStride: number;
  6692. /**
  6693. * Gets the byte offset.
  6694. */
  6695. readonly byteOffset: number;
  6696. /**
  6697. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6698. */
  6699. readonly normalized: boolean;
  6700. /**
  6701. * Gets the data type of each component in the array.
  6702. */
  6703. readonly type: number;
  6704. /**
  6705. * Constructor
  6706. * @param engine the engine
  6707. * @param data the data to use for this vertex buffer
  6708. * @param kind the vertex buffer kind
  6709. * @param updatable whether the data is updatable
  6710. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6711. * @param stride the stride (optional)
  6712. * @param instanced whether the buffer is instanced (optional)
  6713. * @param offset the offset of the data (optional)
  6714. * @param size the number of components (optional)
  6715. * @param type the type of the component (optional)
  6716. * @param normalized whether the data contains normalized data (optional)
  6717. * @param useBytes set to true if stride and offset are in bytes (optional)
  6718. * @param divisor defines the instance divisor to use (1 by default)
  6719. */
  6720. 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);
  6721. /** @hidden */
  6722. _rebuild(): void;
  6723. /**
  6724. * Returns the kind of the VertexBuffer (string)
  6725. * @returns a string
  6726. */
  6727. getKind(): string;
  6728. /**
  6729. * Gets a boolean indicating if the VertexBuffer is updatable?
  6730. * @returns true if the buffer is updatable
  6731. */
  6732. isUpdatable(): boolean;
  6733. /**
  6734. * Gets current buffer's data
  6735. * @returns a DataArray or null
  6736. */
  6737. getData(): Nullable<DataArray>;
  6738. /**
  6739. * Gets underlying native buffer
  6740. * @returns underlying native buffer
  6741. */
  6742. getBuffer(): Nullable<DataBuffer>;
  6743. /**
  6744. * Gets the stride in float32 units (i.e. byte stride / 4).
  6745. * May not be an integer if the byte stride is not divisible by 4.
  6746. * @returns the stride in float32 units
  6747. * @deprecated Please use byteStride instead.
  6748. */
  6749. getStrideSize(): number;
  6750. /**
  6751. * Returns the offset as a multiple of the type byte length.
  6752. * @returns the offset in bytes
  6753. * @deprecated Please use byteOffset instead.
  6754. */
  6755. getOffset(): number;
  6756. /**
  6757. * Returns the number of components per vertex attribute (integer)
  6758. * @returns the size in float
  6759. */
  6760. getSize(): number;
  6761. /**
  6762. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6763. * @returns true if this buffer is instanced
  6764. */
  6765. getIsInstanced(): boolean;
  6766. /**
  6767. * Returns the instancing divisor, zero for non-instanced (integer).
  6768. * @returns a number
  6769. */
  6770. getInstanceDivisor(): number;
  6771. /**
  6772. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6773. * @param data defines the data to store
  6774. */
  6775. create(data?: DataArray): void;
  6776. /**
  6777. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6778. * This function will create a new buffer if the current one is not updatable
  6779. * @param data defines the data to store
  6780. */
  6781. update(data: DataArray): void;
  6782. /**
  6783. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6784. * Returns the directly updated WebGLBuffer.
  6785. * @param data the new data
  6786. * @param offset the new offset
  6787. * @param useBytes set to true if the offset is in bytes
  6788. */
  6789. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6790. /**
  6791. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6792. */
  6793. dispose(): void;
  6794. /**
  6795. * Enumerates each value of this vertex buffer as numbers.
  6796. * @param count the number of values to enumerate
  6797. * @param callback the callback function called for each value
  6798. */
  6799. forEach(count: number, callback: (value: number, index: number) => void): void;
  6800. /**
  6801. * Positions
  6802. */
  6803. static readonly PositionKind: string;
  6804. /**
  6805. * Normals
  6806. */
  6807. static readonly NormalKind: string;
  6808. /**
  6809. * Tangents
  6810. */
  6811. static readonly TangentKind: string;
  6812. /**
  6813. * Texture coordinates
  6814. */
  6815. static readonly UVKind: string;
  6816. /**
  6817. * Texture coordinates 2
  6818. */
  6819. static readonly UV2Kind: string;
  6820. /**
  6821. * Texture coordinates 3
  6822. */
  6823. static readonly UV3Kind: string;
  6824. /**
  6825. * Texture coordinates 4
  6826. */
  6827. static readonly UV4Kind: string;
  6828. /**
  6829. * Texture coordinates 5
  6830. */
  6831. static readonly UV5Kind: string;
  6832. /**
  6833. * Texture coordinates 6
  6834. */
  6835. static readonly UV6Kind: string;
  6836. /**
  6837. * Colors
  6838. */
  6839. static readonly ColorKind: string;
  6840. /**
  6841. * Matrix indices (for bones)
  6842. */
  6843. static readonly MatricesIndicesKind: string;
  6844. /**
  6845. * Matrix weights (for bones)
  6846. */
  6847. static readonly MatricesWeightsKind: string;
  6848. /**
  6849. * Additional matrix indices (for bones)
  6850. */
  6851. static readonly MatricesIndicesExtraKind: string;
  6852. /**
  6853. * Additional matrix weights (for bones)
  6854. */
  6855. static readonly MatricesWeightsExtraKind: string;
  6856. /**
  6857. * Deduces the stride given a kind.
  6858. * @param kind The kind string to deduce
  6859. * @returns The deduced stride
  6860. */
  6861. static DeduceStride(kind: string): number;
  6862. /**
  6863. * Gets the byte length of the given type.
  6864. * @param type the type
  6865. * @returns the number of bytes
  6866. */
  6867. static GetTypeByteLength(type: number): number;
  6868. /**
  6869. * Enumerates each value of the given parameters as numbers.
  6870. * @param data the data to enumerate
  6871. * @param byteOffset the byte offset of the data
  6872. * @param byteStride the byte stride of the data
  6873. * @param componentCount the number of components per element
  6874. * @param componentType the type of the component
  6875. * @param count the number of values to enumerate
  6876. * @param normalized whether the data is normalized
  6877. * @param callback the callback function called for each value
  6878. */
  6879. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6880. private static _GetFloatValue;
  6881. }
  6882. }
  6883. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6884. import { Vector3 } from "babylonjs/Maths/math.vector";
  6885. import { Mesh } from "babylonjs/Meshes/mesh";
  6886. /**
  6887. * The options Interface for creating a Capsule Mesh
  6888. */
  6889. export interface ICreateCapsuleOptions {
  6890. /** The Orientation of the capsule. Default : Vector3.Up() */
  6891. orientation?: Vector3;
  6892. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6893. subdivisions: number;
  6894. /** Number of cylindrical segments on the capsule. */
  6895. tessellation: number;
  6896. /** Height or Length of the capsule. */
  6897. height: number;
  6898. /** Radius of the capsule. */
  6899. radius: number;
  6900. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6901. capSubdivisions: number;
  6902. /** Overwrite for the top radius. */
  6903. radiusTop?: number;
  6904. /** Overwrite for the bottom radius. */
  6905. radiusBottom?: number;
  6906. /** Overwrite for the top capSubdivisions. */
  6907. topCapSubdivisions?: number;
  6908. /** Overwrite for the bottom capSubdivisions. */
  6909. bottomCapSubdivisions?: number;
  6910. }
  6911. /**
  6912. * Class containing static functions to help procedurally build meshes
  6913. */
  6914. export class CapsuleBuilder {
  6915. /**
  6916. * Creates a capsule or a pill mesh
  6917. * @param name defines the name of the mesh
  6918. * @param options The constructors options.
  6919. * @param scene The scene the mesh is scoped to.
  6920. * @returns Capsule Mesh
  6921. */
  6922. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6942. import { Plane } from "babylonjs/Maths/math.plane";
  6943. /**
  6944. * Class used to store bounding sphere information
  6945. */
  6946. export class BoundingSphere {
  6947. /**
  6948. * Gets the center of the bounding sphere in local space
  6949. */
  6950. readonly center: Vector3;
  6951. /**
  6952. * Radius of the bounding sphere in local space
  6953. */
  6954. radius: number;
  6955. /**
  6956. * Gets the center of the bounding sphere in world space
  6957. */
  6958. readonly centerWorld: Vector3;
  6959. /**
  6960. * Radius of the bounding sphere in world space
  6961. */
  6962. radiusWorld: number;
  6963. /**
  6964. * Gets the minimum vector in local space
  6965. */
  6966. readonly minimum: Vector3;
  6967. /**
  6968. * Gets the maximum vector in local space
  6969. */
  6970. readonly maximum: Vector3;
  6971. private _worldMatrix;
  6972. private static readonly TmpVector3;
  6973. /**
  6974. * Creates a new bounding sphere
  6975. * @param min defines the minimum vector (in local space)
  6976. * @param max defines the maximum vector (in local space)
  6977. * @param worldMatrix defines the new world matrix
  6978. */
  6979. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6980. /**
  6981. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6982. * @param min defines the new minimum vector (in local space)
  6983. * @param max defines the new maximum vector (in local space)
  6984. * @param worldMatrix defines the new world matrix
  6985. */
  6986. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6987. /**
  6988. * Scale the current bounding sphere by applying a scale factor
  6989. * @param factor defines the scale factor to apply
  6990. * @returns the current bounding box
  6991. */
  6992. scale(factor: number): BoundingSphere;
  6993. /**
  6994. * Gets the world matrix of the bounding box
  6995. * @returns a matrix
  6996. */
  6997. getWorldMatrix(): DeepImmutable<Matrix>;
  6998. /** @hidden */
  6999. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7000. /**
  7001. * Tests if the bounding sphere is intersecting the frustum planes
  7002. * @param frustumPlanes defines the frustum planes to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7006. /**
  7007. * Tests if the bounding sphere center is in between the frustum planes.
  7008. * Used for optimistic fast inclusion.
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @returns true if the sphere center is in between the frustum planes
  7011. */
  7012. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a point is inside the bounding sphere
  7015. * @param point defines the point to test
  7016. * @returns true if the point is inside the bounding sphere
  7017. */
  7018. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7019. /**
  7020. * Checks if two sphere intersct
  7021. * @param sphere0 sphere 0
  7022. * @param sphere1 sphere 1
  7023. * @returns true if the speres intersect
  7024. */
  7025. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7026. }
  7027. }
  7028. declare module "babylonjs/Culling/boundingBox" {
  7029. import { DeepImmutable } from "babylonjs/types";
  7030. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7031. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7032. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /**
  7035. * Class used to store bounding box information
  7036. */
  7037. export class BoundingBox implements ICullable {
  7038. /**
  7039. * Gets the 8 vectors representing the bounding box in local space
  7040. */
  7041. readonly vectors: Vector3[];
  7042. /**
  7043. * Gets the center of the bounding box in local space
  7044. */
  7045. readonly center: Vector3;
  7046. /**
  7047. * Gets the center of the bounding box in world space
  7048. */
  7049. readonly centerWorld: Vector3;
  7050. /**
  7051. * Gets the extend size in local space
  7052. */
  7053. readonly extendSize: Vector3;
  7054. /**
  7055. * Gets the extend size in world space
  7056. */
  7057. readonly extendSizeWorld: Vector3;
  7058. /**
  7059. * Gets the OBB (object bounding box) directions
  7060. */
  7061. readonly directions: Vector3[];
  7062. /**
  7063. * Gets the 8 vectors representing the bounding box in world space
  7064. */
  7065. readonly vectorsWorld: Vector3[];
  7066. /**
  7067. * Gets the minimum vector in world space
  7068. */
  7069. readonly minimumWorld: Vector3;
  7070. /**
  7071. * Gets the maximum vector in world space
  7072. */
  7073. readonly maximumWorld: Vector3;
  7074. /**
  7075. * Gets the minimum vector in local space
  7076. */
  7077. readonly minimum: Vector3;
  7078. /**
  7079. * Gets the maximum vector in local space
  7080. */
  7081. readonly maximum: Vector3;
  7082. private _worldMatrix;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * @hidden
  7086. */
  7087. _tag: number;
  7088. /**
  7089. * Creates a new bounding box
  7090. * @param min defines the minimum vector (in local space)
  7091. * @param max defines the maximum vector (in local space)
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * Scale the current bounding box by applying a scale factor
  7104. * @param factor defines the scale factor to apply
  7105. * @returns the current bounding box
  7106. */
  7107. scale(factor: number): BoundingBox;
  7108. /**
  7109. * Gets the world matrix of the bounding box
  7110. * @returns a matrix
  7111. */
  7112. getWorldMatrix(): DeepImmutable<Matrix>;
  7113. /** @hidden */
  7114. _update(world: DeepImmutable<Matrix>): void;
  7115. /**
  7116. * Tests if the bounding box is intersecting the frustum planes
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @returns true if there is an intersection
  7119. */
  7120. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if the bounding box is entirely inside the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an inclusion
  7125. */
  7126. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if a point is inside the bounding box
  7129. * @param point defines the point to test
  7130. * @returns true if the point is inside the bounding box
  7131. */
  7132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7133. /**
  7134. * Tests if the bounding box intersects with a bounding sphere
  7135. * @param sphere defines the sphere to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7141. * @param min defines the min vector to use
  7142. * @param max defines the max vector to use
  7143. * @returns true if there is an intersection
  7144. */
  7145. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Tests if two bounding boxes are intersections
  7148. * @param box0 defines the first box to test
  7149. * @param box1 defines the second box to test
  7150. * @returns true if there is an intersection
  7151. */
  7152. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7153. /**
  7154. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7155. * @param minPoint defines the minimum vector of the bounding box
  7156. * @param maxPoint defines the maximum vector of the bounding box
  7157. * @param sphereCenter defines the sphere center
  7158. * @param sphereRadius defines the sphere radius
  7159. * @returns true if there is an intersection
  7160. */
  7161. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7162. /**
  7163. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7164. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7165. * @param frustumPlanes defines the frustum planes to test
  7166. * @return true if there is an inclusion
  7167. */
  7168. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7169. /**
  7170. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7171. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7172. * @param frustumPlanes defines the frustum planes to test
  7173. * @return true if there is an intersection
  7174. */
  7175. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7176. }
  7177. }
  7178. declare module "babylonjs/Collisions/collider" {
  7179. import { Nullable, IndicesArray } from "babylonjs/types";
  7180. import { Vector3 } from "babylonjs/Maths/math.vector";
  7181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. /** @hidden */
  7184. export class Collider {
  7185. /** Define if a collision was found */
  7186. collisionFound: boolean;
  7187. /**
  7188. * Define last intersection point in local space
  7189. */
  7190. intersectionPoint: Vector3;
  7191. /**
  7192. * Define last collided mesh
  7193. */
  7194. collidedMesh: Nullable<AbstractMesh>;
  7195. private _collisionPoint;
  7196. private _planeIntersectionPoint;
  7197. private _tempVector;
  7198. private _tempVector2;
  7199. private _tempVector3;
  7200. private _tempVector4;
  7201. private _edge;
  7202. private _baseToVertex;
  7203. private _destinationPoint;
  7204. private _slidePlaneNormal;
  7205. private _displacementVector;
  7206. /** @hidden */
  7207. _radius: Vector3;
  7208. /** @hidden */
  7209. _retry: number;
  7210. private _velocity;
  7211. private _basePoint;
  7212. private _epsilon;
  7213. /** @hidden */
  7214. _velocityWorldLength: number;
  7215. /** @hidden */
  7216. _basePointWorld: Vector3;
  7217. private _velocityWorld;
  7218. private _normalizedVelocity;
  7219. /** @hidden */
  7220. _initialVelocity: Vector3;
  7221. /** @hidden */
  7222. _initialPosition: Vector3;
  7223. private _nearestDistance;
  7224. private _collisionMask;
  7225. get collisionMask(): number;
  7226. set collisionMask(mask: number);
  7227. /**
  7228. * Gets the plane normal used to compute the sliding response (in local space)
  7229. */
  7230. get slidePlaneNormal(): Vector3;
  7231. /** @hidden */
  7232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7233. /** @hidden */
  7234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7235. /** @hidden */
  7236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7237. /** @hidden */
  7238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7239. /** @hidden */
  7240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7241. /** @hidden */
  7242. _getResponse(pos: Vector3, vel: Vector3): void;
  7243. }
  7244. }
  7245. declare module "babylonjs/Culling/boundingInfo" {
  7246. import { DeepImmutable } from "babylonjs/types";
  7247. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7248. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7249. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7250. import { Plane } from "babylonjs/Maths/math.plane";
  7251. import { Collider } from "babylonjs/Collisions/collider";
  7252. /**
  7253. * Interface for cullable objects
  7254. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7255. */
  7256. export interface ICullable {
  7257. /**
  7258. * Checks if the object or part of the object is in the frustum
  7259. * @param frustumPlanes Camera near/planes
  7260. * @returns true if the object is in frustum otherwise false
  7261. */
  7262. isInFrustum(frustumPlanes: Plane[]): boolean;
  7263. /**
  7264. * Checks if a cullable object (mesh...) is in the camera frustum
  7265. * Unlike isInFrustum this cheks the full bounding box
  7266. * @param frustumPlanes Camera near/planes
  7267. * @returns true if the object is in frustum otherwise false
  7268. */
  7269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7270. }
  7271. /**
  7272. * Info for a bounding data of a mesh
  7273. */
  7274. export class BoundingInfo implements ICullable {
  7275. /**
  7276. * Bounding box for the mesh
  7277. */
  7278. readonly boundingBox: BoundingBox;
  7279. /**
  7280. * Bounding sphere for the mesh
  7281. */
  7282. readonly boundingSphere: BoundingSphere;
  7283. private _isLocked;
  7284. private static readonly TmpVector3;
  7285. /**
  7286. * Constructs bounding info
  7287. * @param minimum min vector of the bounding box/sphere
  7288. * @param maximum max vector of the bounding box/sphere
  7289. * @param worldMatrix defines the new world matrix
  7290. */
  7291. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7292. /**
  7293. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7294. * @param min defines the new minimum vector (in local space)
  7295. * @param max defines the new maximum vector (in local space)
  7296. * @param worldMatrix defines the new world matrix
  7297. */
  7298. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7299. /**
  7300. * min vector of the bounding box/sphere
  7301. */
  7302. get minimum(): Vector3;
  7303. /**
  7304. * max vector of the bounding box/sphere
  7305. */
  7306. get maximum(): Vector3;
  7307. /**
  7308. * If the info is locked and won't be updated to avoid perf overhead
  7309. */
  7310. get isLocked(): boolean;
  7311. set isLocked(value: boolean);
  7312. /**
  7313. * Updates the bounding sphere and box
  7314. * @param world world matrix to be used to update
  7315. */
  7316. update(world: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7319. * @param center New center of the bounding info
  7320. * @param extend New extend of the bounding info
  7321. * @returns the current bounding info
  7322. */
  7323. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7324. /**
  7325. * Scale the current bounding info by applying a scale factor
  7326. * @param factor defines the scale factor to apply
  7327. * @returns the current bounding info
  7328. */
  7329. scale(factor: number): BoundingInfo;
  7330. /**
  7331. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7332. * @param frustumPlanes defines the frustum to test
  7333. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7334. * @returns true if the bounding info is in the frustum planes
  7335. */
  7336. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7337. /**
  7338. * Gets the world distance between the min and max points of the bounding box
  7339. */
  7340. get diagonalLength(): number;
  7341. /**
  7342. * Checks if a cullable object (mesh...) is in the camera frustum
  7343. * Unlike isInFrustum this cheks the full bounding box
  7344. * @param frustumPlanes Camera near/planes
  7345. * @returns true if the object is in frustum otherwise false
  7346. */
  7347. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /** @hidden */
  7349. _checkCollision(collider: Collider): boolean;
  7350. /**
  7351. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7353. * @param point the point to check intersection with
  7354. * @returns if the point intersects
  7355. */
  7356. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7357. /**
  7358. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7359. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7360. * @param boundingInfo the bounding info to check intersection with
  7361. * @param precise if the intersection should be done using OBB
  7362. * @returns if the bounding info intersects
  7363. */
  7364. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7365. }
  7366. }
  7367. declare module "babylonjs/Maths/math.functions" {
  7368. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7369. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7370. /**
  7371. * Extracts minimum and maximum values from a list of indexed positions
  7372. * @param positions defines the positions to use
  7373. * @param indices defines the indices to the positions
  7374. * @param indexStart defines the start index
  7375. * @param indexCount defines the end index
  7376. * @param bias defines bias value to add to the result
  7377. * @return minimum and maximum values
  7378. */
  7379. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7380. minimum: Vector3;
  7381. maximum: Vector3;
  7382. };
  7383. /**
  7384. * Extracts minimum and maximum values from a list of positions
  7385. * @param positions defines the positions to use
  7386. * @param start defines the start index in the positions array
  7387. * @param count defines the number of positions to handle
  7388. * @param bias defines bias value to add to the result
  7389. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7390. * @return minimum and maximum values
  7391. */
  7392. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7393. minimum: Vector3;
  7394. maximum: Vector3;
  7395. };
  7396. }
  7397. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7399. /** @hidden */
  7400. export class WebGLDataBuffer extends DataBuffer {
  7401. private _buffer;
  7402. constructor(resource: WebGLBuffer);
  7403. get underlyingResource(): any;
  7404. }
  7405. }
  7406. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7407. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7408. import { Nullable } from "babylonjs/types";
  7409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7410. /** @hidden */
  7411. export class WebGLPipelineContext implements IPipelineContext {
  7412. engine: ThinEngine;
  7413. program: Nullable<WebGLProgram>;
  7414. context?: WebGLRenderingContext;
  7415. vertexShader?: WebGLShader;
  7416. fragmentShader?: WebGLShader;
  7417. isParallelCompiled: boolean;
  7418. onCompiled?: () => void;
  7419. transformFeedback?: WebGLTransformFeedback | null;
  7420. vertexCompilationError: Nullable<string>;
  7421. fragmentCompilationError: Nullable<string>;
  7422. programLinkError: Nullable<string>;
  7423. programValidationError: Nullable<string>;
  7424. get isAsync(): boolean;
  7425. get isReady(): boolean;
  7426. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7427. _getVertexShaderCode(): string | null;
  7428. _getFragmentShaderCode(): string | null;
  7429. }
  7430. }
  7431. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7432. import { FloatArray, Nullable } from "babylonjs/types";
  7433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7435. module "babylonjs/Engines/thinEngine" {
  7436. interface ThinEngine {
  7437. /**
  7438. * Create an uniform buffer
  7439. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7440. * @param elements defines the content of the uniform buffer
  7441. * @returns the webGL uniform buffer
  7442. */
  7443. createUniformBuffer(elements: FloatArray): DataBuffer;
  7444. /**
  7445. * Create a dynamic uniform buffer
  7446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7447. * @param elements defines the content of the uniform buffer
  7448. * @returns the webGL uniform buffer
  7449. */
  7450. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7451. /**
  7452. * Update an existing uniform buffer
  7453. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7454. * @param uniformBuffer defines the target uniform buffer
  7455. * @param elements defines the content to update
  7456. * @param offset defines the offset in the uniform buffer where update should start
  7457. * @param count defines the size of the data to update
  7458. */
  7459. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7460. /**
  7461. * Bind an uniform buffer to the current webGL context
  7462. * @param buffer defines the buffer to bind
  7463. */
  7464. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7465. /**
  7466. * Bind a buffer to the current webGL context at a given location
  7467. * @param buffer defines the buffer to bind
  7468. * @param location defines the index where to bind the buffer
  7469. */
  7470. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7471. /**
  7472. * Bind a specific block at a given index in a specific shader program
  7473. * @param pipelineContext defines the pipeline context to use
  7474. * @param blockName defines the block name
  7475. * @param index defines the index where to bind the block
  7476. */
  7477. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7478. }
  7479. }
  7480. }
  7481. declare module "babylonjs/Materials/uniformBuffer" {
  7482. import { Nullable, FloatArray } from "babylonjs/types";
  7483. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7484. import { Engine } from "babylonjs/Engines/engine";
  7485. import { Effect } from "babylonjs/Materials/effect";
  7486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7487. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7488. import { Color3 } from "babylonjs/Maths/math.color";
  7489. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7490. /**
  7491. * Uniform buffer objects.
  7492. *
  7493. * Handles blocks of uniform on the GPU.
  7494. *
  7495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7496. *
  7497. * For more information, please refer to :
  7498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7499. */
  7500. export class UniformBuffer {
  7501. private _engine;
  7502. private _buffer;
  7503. private _data;
  7504. private _bufferData;
  7505. private _dynamic?;
  7506. private _uniformLocations;
  7507. private _uniformSizes;
  7508. private _uniformLocationPointer;
  7509. private _needSync;
  7510. private _noUBO;
  7511. private _currentEffect;
  7512. /** @hidden */
  7513. _alreadyBound: boolean;
  7514. private static _MAX_UNIFORM_SIZE;
  7515. private static _tempBuffer;
  7516. /**
  7517. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7518. * This is dynamic to allow compat with webgl 1 and 2.
  7519. * You will need to pass the name of the uniform as well as the value.
  7520. */
  7521. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7522. /**
  7523. * Lambda to Update a 2x2 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  7534. /**
  7535. * Lambda to Update a vec2 of 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7540. /**
  7541. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec4 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7558. /**
  7559. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7564. /**
  7565. * Lambda to Update vec4 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. updateVector4: (name: string, vector: Vector4) => void;
  7570. /**
  7571. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7576. /**
  7577. * Lambda to Update vec4 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7582. /**
  7583. * Instantiates a new Uniform buffer objects.
  7584. *
  7585. * Handles blocks of uniform on the GPU.
  7586. *
  7587. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7588. *
  7589. * For more information, please refer to :
  7590. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7591. * @param engine Define the engine the buffer is associated with
  7592. * @param data Define the data contained in the buffer
  7593. * @param dynamic Define if the buffer is updatable
  7594. */
  7595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7596. /**
  7597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7598. * or just falling back on setUniformXXX calls.
  7599. */
  7600. get useUbo(): boolean;
  7601. /**
  7602. * Indicates if the WebGL underlying uniform buffer is in sync
  7603. * with the javascript cache data.
  7604. */
  7605. get isSync(): boolean;
  7606. /**
  7607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7608. * Also, a dynamic UniformBuffer will disable cache verification and always
  7609. * update the underlying WebGL uniform buffer to the GPU.
  7610. * @returns if Dynamic, otherwise false
  7611. */
  7612. isDynamic(): boolean;
  7613. /**
  7614. * The data cache on JS side.
  7615. * @returns the underlying data as a float array
  7616. */
  7617. getData(): Float32Array;
  7618. /**
  7619. * The underlying WebGL Uniform buffer.
  7620. * @returns the webgl buffer
  7621. */
  7622. getBuffer(): Nullable<DataBuffer>;
  7623. /**
  7624. * std140 layout specifies how to align data within an UBO structure.
  7625. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7626. * for specs.
  7627. */
  7628. private _fillAlignment;
  7629. /**
  7630. * Adds an uniform in the buffer.
  7631. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7632. * for the layout to be correct !
  7633. * @param name Name of the uniform, as used in the uniform block in the shader.
  7634. * @param size Data size, or data directly.
  7635. */
  7636. addUniform(name: string, size: number | number[]): void;
  7637. /**
  7638. * Adds a Matrix 4x4 to the uniform buffer.
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param mat A 4x4 matrix.
  7641. */
  7642. addMatrix(name: string, mat: Matrix): void;
  7643. /**
  7644. * Adds a vec2 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param x Define the x component value of the vec2
  7647. * @param y Define the y component value of the vec2
  7648. */
  7649. addFloat2(name: string, x: number, y: number): void;
  7650. /**
  7651. * Adds a vec3 to the uniform buffer.
  7652. * @param name Name of the uniform, as used in the uniform block in the shader.
  7653. * @param x Define the x component value of the vec3
  7654. * @param y Define the y component value of the vec3
  7655. * @param z Define the z component value of the vec3
  7656. */
  7657. addFloat3(name: string, x: number, y: number, z: number): void;
  7658. /**
  7659. * Adds a vec3 to the uniform buffer.
  7660. * @param name Name of the uniform, as used in the uniform block in the shader.
  7661. * @param color Define the vec3 from a Color
  7662. */
  7663. addColor3(name: string, color: Color3): void;
  7664. /**
  7665. * Adds a vec4 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 rgb components from a Color
  7668. * @param alpha Define the a component of the vec4
  7669. */
  7670. addColor4(name: string, color: Color3, alpha: number): void;
  7671. /**
  7672. * Adds a vec3 to the uniform buffer.
  7673. * @param name Name of the uniform, as used in the uniform block in the shader.
  7674. * @param vector Define the vec3 components from a Vector
  7675. */
  7676. addVector3(name: string, vector: Vector3): void;
  7677. /**
  7678. * Adds a Matrix 3x3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. */
  7681. addMatrix3x3(name: string): void;
  7682. /**
  7683. * Adds a Matrix 2x2 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. */
  7686. addMatrix2x2(name: string): void;
  7687. /**
  7688. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7689. */
  7690. create(): void;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Updates the WebGL Uniform Buffer on the GPU.
  7695. * If the `dynamic` flag is set to true, no cache comparison is done.
  7696. * Otherwise, the buffer will be updated only if the cache differs.
  7697. */
  7698. update(): void;
  7699. /**
  7700. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7702. * @param data Define the flattened data
  7703. * @param size Define the size of the data.
  7704. */
  7705. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7706. private _valueCache;
  7707. private _cacheMatrix;
  7708. private _updateMatrix3x3ForUniform;
  7709. private _updateMatrix3x3ForEffect;
  7710. private _updateMatrix2x2ForEffect;
  7711. private _updateMatrix2x2ForUniform;
  7712. private _updateFloatForEffect;
  7713. private _updateFloatForUniform;
  7714. private _updateFloat2ForEffect;
  7715. private _updateFloat2ForUniform;
  7716. private _updateFloat3ForEffect;
  7717. private _updateFloat3ForUniform;
  7718. private _updateFloat4ForEffect;
  7719. private _updateFloat4ForUniform;
  7720. private _updateMatrixForEffect;
  7721. private _updateMatrixForUniform;
  7722. private _updateVector3ForEffect;
  7723. private _updateVector3ForUniform;
  7724. private _updateVector4ForEffect;
  7725. private _updateVector4ForUniform;
  7726. private _updateColor3ForEffect;
  7727. private _updateColor3ForUniform;
  7728. private _updateColor4ForEffect;
  7729. private _updateColor4ForUniform;
  7730. /**
  7731. * Sets a sampler uniform on the effect.
  7732. * @param name Define the name of the sampler.
  7733. * @param texture Define the texture to set in the sampler
  7734. */
  7735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7736. /**
  7737. * Directly updates the value of the uniform in the cache AND on the GPU.
  7738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7739. * @param data Define the flattened data
  7740. */
  7741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7742. /**
  7743. * Binds this uniform buffer to an effect.
  7744. * @param effect Define the effect to bind the buffer to
  7745. * @param name Name of the uniform block in the shader.
  7746. */
  7747. bindToEffect(effect: Effect, name: string): void;
  7748. /**
  7749. * Disposes the uniform buffer.
  7750. */
  7751. dispose(): void;
  7752. }
  7753. }
  7754. declare module "babylonjs/Misc/iInspectable" {
  7755. /**
  7756. * Enum that determines the text-wrapping mode to use.
  7757. */
  7758. export enum InspectableType {
  7759. /**
  7760. * Checkbox for booleans
  7761. */
  7762. Checkbox = 0,
  7763. /**
  7764. * Sliders for numbers
  7765. */
  7766. Slider = 1,
  7767. /**
  7768. * Vector3
  7769. */
  7770. Vector3 = 2,
  7771. /**
  7772. * Quaternions
  7773. */
  7774. Quaternion = 3,
  7775. /**
  7776. * Color3
  7777. */
  7778. Color3 = 4,
  7779. /**
  7780. * String
  7781. */
  7782. String = 5
  7783. }
  7784. /**
  7785. * Interface used to define custom inspectable properties.
  7786. * This interface is used by the inspector to display custom property grids
  7787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7788. */
  7789. export interface IInspectable {
  7790. /**
  7791. * Gets the label to display
  7792. */
  7793. label: string;
  7794. /**
  7795. * Gets the name of the property to edit
  7796. */
  7797. propertyName: string;
  7798. /**
  7799. * Gets the type of the editor to use
  7800. */
  7801. type: InspectableType;
  7802. /**
  7803. * Gets the minimum value of the property when using in "slider" mode
  7804. */
  7805. min?: number;
  7806. /**
  7807. * Gets the maximum value of the property when using in "slider" mode
  7808. */
  7809. max?: number;
  7810. /**
  7811. * Gets the setp to use when using in "slider" mode
  7812. */
  7813. step?: number;
  7814. }
  7815. }
  7816. declare module "babylonjs/Misc/timingTools" {
  7817. /**
  7818. * Class used to provide helper for timing
  7819. */
  7820. export class TimingTools {
  7821. /**
  7822. * Polyfill for setImmediate
  7823. * @param action defines the action to execute after the current execution block
  7824. */
  7825. static SetImmediate(action: () => void): void;
  7826. }
  7827. }
  7828. declare module "babylonjs/Misc/instantiationTools" {
  7829. /**
  7830. * Class used to enable instatition of objects by class name
  7831. */
  7832. export class InstantiationTools {
  7833. /**
  7834. * Use this object to register external classes like custom textures or material
  7835. * to allow the laoders to instantiate them
  7836. */
  7837. static RegisteredExternalClasses: {
  7838. [key: string]: Object;
  7839. };
  7840. /**
  7841. * Tries to instantiate a new object from a given class name
  7842. * @param className defines the class name to instantiate
  7843. * @returns the new object or null if the system was not able to do the instantiation
  7844. */
  7845. static Instantiate(className: string): any;
  7846. }
  7847. }
  7848. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7849. /**
  7850. * Define options used to create a depth texture
  7851. */
  7852. export class DepthTextureCreationOptions {
  7853. /** Specifies whether or not a stencil should be allocated in the texture */
  7854. generateStencil?: boolean;
  7855. /** Specifies whether or not bilinear filtering is enable on the texture */
  7856. bilinearFiltering?: boolean;
  7857. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7858. comparisonFunction?: number;
  7859. /** Specifies if the created texture is a cube texture */
  7860. isCube?: boolean;
  7861. }
  7862. }
  7863. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7865. import { Nullable } from "babylonjs/types";
  7866. import { Scene } from "babylonjs/scene";
  7867. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7868. module "babylonjs/Engines/thinEngine" {
  7869. interface ThinEngine {
  7870. /**
  7871. * Creates a depth stencil cube texture.
  7872. * This is only available in WebGL 2.
  7873. * @param size The size of face edge in the cube texture.
  7874. * @param options The options defining the cube texture.
  7875. * @returns The cube texture
  7876. */
  7877. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7878. /**
  7879. * Creates a cube texture
  7880. * @param rootUrl defines the url where the files to load is located
  7881. * @param scene defines the current scene
  7882. * @param files defines the list of files to load (1 per face)
  7883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7884. * @param onLoad defines an optional callback raised when the texture is loaded
  7885. * @param onError defines an optional callback raised if there is an issue to load the texture
  7886. * @param format defines the format of the data
  7887. * @param forcedExtension defines the extension to use to pick the right loader
  7888. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7889. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7890. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7891. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7892. * @returns the cube texture as an InternalTexture
  7893. */
  7894. 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;
  7895. /**
  7896. * Creates a cube texture
  7897. * @param rootUrl defines the url where the files to load is located
  7898. * @param scene defines the current scene
  7899. * @param files defines the list of files to load (1 per face)
  7900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7901. * @param onLoad defines an optional callback raised when the texture is loaded
  7902. * @param onError defines an optional callback raised if there is an issue to load the texture
  7903. * @param format defines the format of the data
  7904. * @param forcedExtension defines the extension to use to pick the right loader
  7905. * @returns the cube texture as an InternalTexture
  7906. */
  7907. 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;
  7908. /**
  7909. * Creates a cube texture
  7910. * @param rootUrl defines the url where the files to load is located
  7911. * @param scene defines the current scene
  7912. * @param files defines the list of files to load (1 per face)
  7913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7914. * @param onLoad defines an optional callback raised when the texture is loaded
  7915. * @param onError defines an optional callback raised if there is an issue to load the texture
  7916. * @param format defines the format of the data
  7917. * @param forcedExtension defines the extension to use to pick the right loader
  7918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7921. * @returns the cube texture as an InternalTexture
  7922. */
  7923. 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;
  7924. /** @hidden */
  7925. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7926. /** @hidden */
  7927. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7928. /** @hidden */
  7929. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7930. /** @hidden */
  7931. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7932. /**
  7933. * @hidden
  7934. */
  7935. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7936. }
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7940. import { Nullable } from "babylonjs/types";
  7941. import { Scene } from "babylonjs/scene";
  7942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7944. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7945. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7946. import { Observable } from "babylonjs/Misc/observable";
  7947. /**
  7948. * Class for creating a cube texture
  7949. */
  7950. export class CubeTexture extends BaseTexture {
  7951. private _delayedOnLoad;
  7952. /**
  7953. * Observable triggered once the texture has been loaded.
  7954. */
  7955. onLoadObservable: Observable<CubeTexture>;
  7956. /**
  7957. * The url of the texture
  7958. */
  7959. url: string;
  7960. /**
  7961. * Gets or sets the center of the bounding box associated with the cube texture.
  7962. * It must define where the camera used to render the texture was set
  7963. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7964. */
  7965. boundingBoxPosition: Vector3;
  7966. private _boundingBoxSize;
  7967. /**
  7968. * Gets or sets the size of the bounding box associated with the cube texture
  7969. * When defined, the cubemap will switch to local mode
  7970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7971. * @example https://www.babylonjs-playground.com/#RNASML
  7972. */
  7973. set boundingBoxSize(value: Vector3);
  7974. /**
  7975. * Returns the bounding box size
  7976. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7977. */
  7978. get boundingBoxSize(): Vector3;
  7979. protected _rotationY: number;
  7980. /**
  7981. * Sets texture matrix rotation angle around Y axis in radians.
  7982. */
  7983. set rotationY(value: number);
  7984. /**
  7985. * Gets texture matrix rotation angle around Y axis radians.
  7986. */
  7987. get rotationY(): number;
  7988. /**
  7989. * Are mip maps generated for this texture or not.
  7990. */
  7991. get noMipmap(): boolean;
  7992. private _noMipmap;
  7993. private _files;
  7994. protected _forcedExtension: Nullable<string>;
  7995. private _extensions;
  7996. private _textureMatrix;
  7997. private _format;
  7998. private _createPolynomials;
  7999. /**
  8000. * Creates a cube texture from an array of image urls
  8001. * @param files defines an array of image urls
  8002. * @param scene defines the hosting scene
  8003. * @param noMipmap specifies if mip maps are not used
  8004. * @returns a cube texture
  8005. */
  8006. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8007. /**
  8008. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8009. * @param url defines the url of the prefiltered texture
  8010. * @param scene defines the scene the texture is attached to
  8011. * @param forcedExtension defines the extension of the file if different from the url
  8012. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8013. * @return the prefiltered texture
  8014. */
  8015. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8016. /**
  8017. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8018. * as prefiltered data.
  8019. * @param rootUrl defines the url of the texture or the root name of the six images
  8020. * @param null defines the scene or engine the texture is attached to
  8021. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8022. * @param noMipmap defines if mipmaps should be created or not
  8023. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8024. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8025. * @param onError defines a callback triggered in case of error during load
  8026. * @param format defines the internal format to use for the texture once loaded
  8027. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8028. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8032. * @return the cube texture
  8033. */
  8034. 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);
  8035. /**
  8036. * Get the current class name of the texture useful for serialization or dynamic coding.
  8037. * @returns "CubeTexture"
  8038. */
  8039. getClassName(): string;
  8040. /**
  8041. * Update the url (and optional buffer) of this texture if url was null during construction.
  8042. * @param url the url of the texture
  8043. * @param forcedExtension defines the extension to use
  8044. * @param onLoad callback called when the texture is loaded (defaults to null)
  8045. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8046. */
  8047. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8048. /**
  8049. * Delays loading of the cube texture
  8050. * @param forcedExtension defines the extension to use
  8051. */
  8052. delayLoad(forcedExtension?: string): void;
  8053. /**
  8054. * Returns the reflection texture matrix
  8055. * @returns the reflection texture matrix
  8056. */
  8057. getReflectionTextureMatrix(): Matrix;
  8058. /**
  8059. * Sets the reflection texture matrix
  8060. * @param value Reflection texture matrix
  8061. */
  8062. setReflectionTextureMatrix(value: Matrix): void;
  8063. /**
  8064. * Parses text to create a cube texture
  8065. * @param parsedTexture define the serialized text to read from
  8066. * @param scene defines the hosting scene
  8067. * @param rootUrl defines the root url of the cube texture
  8068. * @returns a cube texture
  8069. */
  8070. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8071. /**
  8072. * Makes a clone, or deep copy, of the cube texture
  8073. * @returns a new cube texture
  8074. */
  8075. clone(): CubeTexture;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/materialDefines" {
  8079. /**
  8080. * Manages the defines for the Material
  8081. */
  8082. export class MaterialDefines {
  8083. /** @hidden */
  8084. protected _keys: string[];
  8085. private _isDirty;
  8086. /** @hidden */
  8087. _renderId: number;
  8088. /** @hidden */
  8089. _areLightsDirty: boolean;
  8090. /** @hidden */
  8091. _areLightsDisposed: boolean;
  8092. /** @hidden */
  8093. _areAttributesDirty: boolean;
  8094. /** @hidden */
  8095. _areTexturesDirty: boolean;
  8096. /** @hidden */
  8097. _areFresnelDirty: boolean;
  8098. /** @hidden */
  8099. _areMiscDirty: boolean;
  8100. /** @hidden */
  8101. _arePrePassDirty: boolean;
  8102. /** @hidden */
  8103. _areImageProcessingDirty: boolean;
  8104. /** @hidden */
  8105. _normals: boolean;
  8106. /** @hidden */
  8107. _uvs: boolean;
  8108. /** @hidden */
  8109. _needNormals: boolean;
  8110. /** @hidden */
  8111. _needUVs: boolean;
  8112. [id: string]: any;
  8113. /**
  8114. * Specifies if the material needs to be re-calculated
  8115. */
  8116. get isDirty(): boolean;
  8117. /**
  8118. * Marks the material to indicate that it has been re-calculated
  8119. */
  8120. markAsProcessed(): void;
  8121. /**
  8122. * Marks the material to indicate that it needs to be re-calculated
  8123. */
  8124. markAsUnprocessed(): void;
  8125. /**
  8126. * Marks the material to indicate all of its defines need to be re-calculated
  8127. */
  8128. markAllAsDirty(): void;
  8129. /**
  8130. * Marks the material to indicate that image processing needs to be re-calculated
  8131. */
  8132. markAsImageProcessingDirty(): void;
  8133. /**
  8134. * Marks the material to indicate the lights need to be re-calculated
  8135. * @param disposed Defines whether the light is dirty due to dispose or not
  8136. */
  8137. markAsLightDirty(disposed?: boolean): void;
  8138. /**
  8139. * Marks the attribute state as changed
  8140. */
  8141. markAsAttributesDirty(): void;
  8142. /**
  8143. * Marks the texture state as changed
  8144. */
  8145. markAsTexturesDirty(): void;
  8146. /**
  8147. * Marks the fresnel state as changed
  8148. */
  8149. markAsFresnelDirty(): void;
  8150. /**
  8151. * Marks the misc state as changed
  8152. */
  8153. markAsMiscDirty(): void;
  8154. /**
  8155. * Marks the prepass state as changed
  8156. */
  8157. markAsPrePassDirty(): void;
  8158. /**
  8159. * Rebuilds the material defines
  8160. */
  8161. rebuild(): void;
  8162. /**
  8163. * Specifies if two material defines are equal
  8164. * @param other - A material define instance to compare to
  8165. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8166. */
  8167. isEqual(other: MaterialDefines): boolean;
  8168. /**
  8169. * Clones this instance's defines to another instance
  8170. * @param other - material defines to clone values to
  8171. */
  8172. cloneTo(other: MaterialDefines): void;
  8173. /**
  8174. * Resets the material define values
  8175. */
  8176. reset(): void;
  8177. /**
  8178. * Converts the material define values to a string
  8179. * @returns - String of material define information
  8180. */
  8181. toString(): string;
  8182. }
  8183. }
  8184. declare module "babylonjs/Materials/colorCurves" {
  8185. import { Effect } from "babylonjs/Materials/effect";
  8186. /**
  8187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8189. * 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;
  8190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8191. */
  8192. export class ColorCurves {
  8193. private _dirty;
  8194. private _tempColor;
  8195. private _globalCurve;
  8196. private _highlightsCurve;
  8197. private _midtonesCurve;
  8198. private _shadowsCurve;
  8199. private _positiveCurve;
  8200. private _negativeCurve;
  8201. private _globalHue;
  8202. private _globalDensity;
  8203. private _globalSaturation;
  8204. private _globalExposure;
  8205. /**
  8206. * Gets the global Hue value.
  8207. * 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).
  8208. */
  8209. get globalHue(): number;
  8210. /**
  8211. * Sets the global Hue value.
  8212. * 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).
  8213. */
  8214. set globalHue(value: number);
  8215. /**
  8216. * Gets the global Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get globalDensity(): number;
  8221. /**
  8222. * Sets 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. set globalDensity(value: number);
  8227. /**
  8228. * Gets the global Saturation value.
  8229. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8230. */
  8231. get globalSaturation(): number;
  8232. /**
  8233. * Sets the global Saturation value.
  8234. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8235. */
  8236. set globalSaturation(value: number);
  8237. /**
  8238. * Gets the global Exposure value.
  8239. * 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.
  8240. */
  8241. get globalExposure(): number;
  8242. /**
  8243. * Sets the global Exposure value.
  8244. * 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.
  8245. */
  8246. set globalExposure(value: number);
  8247. private _highlightsHue;
  8248. private _highlightsDensity;
  8249. private _highlightsSaturation;
  8250. private _highlightsExposure;
  8251. /**
  8252. * Gets the highlights Hue value.
  8253. * 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).
  8254. */
  8255. get highlightsHue(): number;
  8256. /**
  8257. * Sets the highlights Hue value.
  8258. * 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).
  8259. */
  8260. set highlightsHue(value: number);
  8261. /**
  8262. * Gets the highlights Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get highlightsDensity(): number;
  8267. /**
  8268. * Sets 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. set highlightsDensity(value: number);
  8273. /**
  8274. * Gets the highlights Saturation value.
  8275. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8276. */
  8277. get highlightsSaturation(): number;
  8278. /**
  8279. * Sets the highlights Saturation value.
  8280. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8281. */
  8282. set highlightsSaturation(value: number);
  8283. /**
  8284. * Gets the highlights Exposure value.
  8285. * 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.
  8286. */
  8287. get highlightsExposure(): number;
  8288. /**
  8289. * Sets the highlights Exposure value.
  8290. * 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.
  8291. */
  8292. set highlightsExposure(value: number);
  8293. private _midtonesHue;
  8294. private _midtonesDensity;
  8295. private _midtonesSaturation;
  8296. private _midtonesExposure;
  8297. /**
  8298. * Gets the midtones Hue value.
  8299. * 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).
  8300. */
  8301. get midtonesHue(): number;
  8302. /**
  8303. * Sets the midtones Hue value.
  8304. * 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).
  8305. */
  8306. set midtonesHue(value: number);
  8307. /**
  8308. * Gets the midtones Density value.
  8309. * 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.
  8310. * Values less than zero provide a filter of opposite hue.
  8311. */
  8312. get midtonesDensity(): number;
  8313. /**
  8314. * Sets 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. set midtonesDensity(value: number);
  8319. /**
  8320. * Gets the midtones Saturation value.
  8321. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8322. */
  8323. get midtonesSaturation(): number;
  8324. /**
  8325. * Sets the midtones Saturation value.
  8326. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8327. */
  8328. set midtonesSaturation(value: number);
  8329. /**
  8330. * Gets the midtones Exposure value.
  8331. * 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.
  8332. */
  8333. get midtonesExposure(): number;
  8334. /**
  8335. * Sets the midtones Exposure value.
  8336. * 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.
  8337. */
  8338. set midtonesExposure(value: number);
  8339. private _shadowsHue;
  8340. private _shadowsDensity;
  8341. private _shadowsSaturation;
  8342. private _shadowsExposure;
  8343. /**
  8344. * Gets the shadows Hue value.
  8345. * 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).
  8346. */
  8347. get shadowsHue(): number;
  8348. /**
  8349. * Sets the shadows Hue value.
  8350. * 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).
  8351. */
  8352. set shadowsHue(value: number);
  8353. /**
  8354. * Gets the shadows Density value.
  8355. * 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.
  8356. * Values less than zero provide a filter of opposite hue.
  8357. */
  8358. get shadowsDensity(): number;
  8359. /**
  8360. * Sets 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. set shadowsDensity(value: number);
  8365. /**
  8366. * Gets the shadows Saturation value.
  8367. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8368. */
  8369. get shadowsSaturation(): number;
  8370. /**
  8371. * Sets the shadows Saturation value.
  8372. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8373. */
  8374. set shadowsSaturation(value: number);
  8375. /**
  8376. * Gets the shadows Exposure value.
  8377. * 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.
  8378. */
  8379. get shadowsExposure(): number;
  8380. /**
  8381. * Sets the shadows Exposure value.
  8382. * 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.
  8383. */
  8384. set shadowsExposure(value: number);
  8385. /**
  8386. * Returns the class name
  8387. * @returns The class name
  8388. */
  8389. getClassName(): string;
  8390. /**
  8391. * Binds the color curves to the shader.
  8392. * @param colorCurves The color curve to bind
  8393. * @param effect The effect to bind to
  8394. * @param positiveUniform The positive uniform shader parameter
  8395. * @param neutralUniform The neutral uniform shader parameter
  8396. * @param negativeUniform The negative uniform shader parameter
  8397. */
  8398. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8399. /**
  8400. * Prepare the list of uniforms associated with the ColorCurves effects.
  8401. * @param uniformsList The list of uniforms used in the effect
  8402. */
  8403. static PrepareUniforms(uniformsList: string[]): void;
  8404. /**
  8405. * Returns color grading data based on a hue, density, saturation and exposure value.
  8406. * @param filterHue The hue of the color filter.
  8407. * @param filterDensity The density of the color filter.
  8408. * @param saturation The saturation.
  8409. * @param exposure The exposure.
  8410. * @param result The result data container.
  8411. */
  8412. private getColorGradingDataToRef;
  8413. /**
  8414. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8415. * @param value The input slider value in range [-100,100].
  8416. * @returns Adjusted value.
  8417. */
  8418. private static applyColorGradingSliderNonlinear;
  8419. /**
  8420. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8421. * @param hue The hue (H) input.
  8422. * @param saturation The saturation (S) input.
  8423. * @param brightness The brightness (B) input.
  8424. * @result An RGBA color represented as Vector4.
  8425. */
  8426. private static fromHSBToRef;
  8427. /**
  8428. * Returns a value clamped between min and max
  8429. * @param value The value to clamp
  8430. * @param min The minimum of value
  8431. * @param max The maximum of value
  8432. * @returns The clamped value.
  8433. */
  8434. private static clamp;
  8435. /**
  8436. * Clones the current color curve instance.
  8437. * @return The cloned curves
  8438. */
  8439. clone(): ColorCurves;
  8440. /**
  8441. * Serializes the current color curve instance to a json representation.
  8442. * @return a JSON representation
  8443. */
  8444. serialize(): any;
  8445. /**
  8446. * Parses the color curve from a json representation.
  8447. * @param source the JSON source to parse
  8448. * @return The parsed curves
  8449. */
  8450. static Parse(source: any): ColorCurves;
  8451. }
  8452. }
  8453. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8454. import { Observable } from "babylonjs/Misc/observable";
  8455. import { Nullable } from "babylonjs/types";
  8456. import { Color4 } from "babylonjs/Maths/math.color";
  8457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8458. import { Effect } from "babylonjs/Materials/effect";
  8459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8460. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8461. /**
  8462. * Interface to follow in your material defines to integrate easily the
  8463. * Image proccessing functions.
  8464. * @hidden
  8465. */
  8466. export interface IImageProcessingConfigurationDefines {
  8467. IMAGEPROCESSING: boolean;
  8468. VIGNETTE: boolean;
  8469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8470. VIGNETTEBLENDMODEOPAQUE: boolean;
  8471. TONEMAPPING: boolean;
  8472. TONEMAPPING_ACES: boolean;
  8473. CONTRAST: boolean;
  8474. EXPOSURE: boolean;
  8475. COLORCURVES: boolean;
  8476. COLORGRADING: boolean;
  8477. COLORGRADING3D: boolean;
  8478. SAMPLER3DGREENDEPTH: boolean;
  8479. SAMPLER3DBGRMAP: boolean;
  8480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8481. }
  8482. /**
  8483. * @hidden
  8484. */
  8485. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8486. IMAGEPROCESSING: boolean;
  8487. VIGNETTE: boolean;
  8488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8489. VIGNETTEBLENDMODEOPAQUE: boolean;
  8490. TONEMAPPING: boolean;
  8491. TONEMAPPING_ACES: boolean;
  8492. CONTRAST: boolean;
  8493. COLORCURVES: boolean;
  8494. COLORGRADING: boolean;
  8495. COLORGRADING3D: boolean;
  8496. SAMPLER3DGREENDEPTH: boolean;
  8497. SAMPLER3DBGRMAP: boolean;
  8498. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8499. EXPOSURE: boolean;
  8500. constructor();
  8501. }
  8502. /**
  8503. * This groups together the common properties used for image processing either in direct forward pass
  8504. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8505. * or not.
  8506. */
  8507. export class ImageProcessingConfiguration {
  8508. /**
  8509. * Default tone mapping applied in BabylonJS.
  8510. */
  8511. static readonly TONEMAPPING_STANDARD: number;
  8512. /**
  8513. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8514. * to other engines rendering to increase portability.
  8515. */
  8516. static readonly TONEMAPPING_ACES: number;
  8517. /**
  8518. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8519. */
  8520. colorCurves: Nullable<ColorCurves>;
  8521. private _colorCurvesEnabled;
  8522. /**
  8523. * Gets wether the color curves effect is enabled.
  8524. */
  8525. get colorCurvesEnabled(): boolean;
  8526. /**
  8527. * Sets wether the color curves effect is enabled.
  8528. */
  8529. set colorCurvesEnabled(value: boolean);
  8530. private _colorGradingTexture;
  8531. /**
  8532. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8533. */
  8534. get colorGradingTexture(): Nullable<BaseTexture>;
  8535. /**
  8536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8537. */
  8538. set colorGradingTexture(value: Nullable<BaseTexture>);
  8539. private _colorGradingEnabled;
  8540. /**
  8541. * Gets wether the color grading effect is enabled.
  8542. */
  8543. get colorGradingEnabled(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is enabled.
  8546. */
  8547. set colorGradingEnabled(value: boolean);
  8548. private _colorGradingWithGreenDepth;
  8549. /**
  8550. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8551. */
  8552. get colorGradingWithGreenDepth(): boolean;
  8553. /**
  8554. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8555. */
  8556. set colorGradingWithGreenDepth(value: boolean);
  8557. private _colorGradingBGR;
  8558. /**
  8559. * Gets wether the color grading texture contains BGR values.
  8560. */
  8561. get colorGradingBGR(): boolean;
  8562. /**
  8563. * Sets wether the color grading texture contains BGR values.
  8564. */
  8565. set colorGradingBGR(value: boolean);
  8566. /** @hidden */
  8567. _exposure: number;
  8568. /**
  8569. * Gets the Exposure used in the effect.
  8570. */
  8571. get exposure(): number;
  8572. /**
  8573. * Sets the Exposure used in the effect.
  8574. */
  8575. set exposure(value: number);
  8576. private _toneMappingEnabled;
  8577. /**
  8578. * Gets wether the tone mapping effect is enabled.
  8579. */
  8580. get toneMappingEnabled(): boolean;
  8581. /**
  8582. * Sets wether the tone mapping effect is enabled.
  8583. */
  8584. set toneMappingEnabled(value: boolean);
  8585. private _toneMappingType;
  8586. /**
  8587. * Gets the type of tone mapping effect.
  8588. */
  8589. get toneMappingType(): number;
  8590. /**
  8591. * Sets the type of tone mapping effect used in BabylonJS.
  8592. */
  8593. set toneMappingType(value: number);
  8594. protected _contrast: number;
  8595. /**
  8596. * Gets the contrast used in the effect.
  8597. */
  8598. get contrast(): number;
  8599. /**
  8600. * Sets the contrast used in the effect.
  8601. */
  8602. set contrast(value: number);
  8603. /**
  8604. * Vignette stretch size.
  8605. */
  8606. vignetteStretch: number;
  8607. /**
  8608. * Vignette centre X Offset.
  8609. */
  8610. vignetteCentreX: number;
  8611. /**
  8612. * Vignette centre Y Offset.
  8613. */
  8614. vignetteCentreY: number;
  8615. /**
  8616. * Vignette weight or intensity of the vignette effect.
  8617. */
  8618. vignetteWeight: number;
  8619. /**
  8620. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8621. * if vignetteEnabled is set to true.
  8622. */
  8623. vignetteColor: Color4;
  8624. /**
  8625. * Camera field of view used by the Vignette effect.
  8626. */
  8627. vignetteCameraFov: number;
  8628. private _vignetteBlendMode;
  8629. /**
  8630. * Gets the vignette blend mode allowing different kind of effect.
  8631. */
  8632. get vignetteBlendMode(): number;
  8633. /**
  8634. * Sets the vignette blend mode allowing different kind of effect.
  8635. */
  8636. set vignetteBlendMode(value: number);
  8637. private _vignetteEnabled;
  8638. /**
  8639. * Gets wether the vignette effect is enabled.
  8640. */
  8641. get vignetteEnabled(): boolean;
  8642. /**
  8643. * Sets wether the vignette effect is enabled.
  8644. */
  8645. set vignetteEnabled(value: boolean);
  8646. private _applyByPostProcess;
  8647. /**
  8648. * Gets wether the image processing is applied through a post process or not.
  8649. */
  8650. get applyByPostProcess(): boolean;
  8651. /**
  8652. * Sets wether the image processing is applied through a post process or not.
  8653. */
  8654. set applyByPostProcess(value: boolean);
  8655. private _isEnabled;
  8656. /**
  8657. * Gets wether the image processing is enabled or not.
  8658. */
  8659. get isEnabled(): boolean;
  8660. /**
  8661. * Sets wether the image processing is enabled or not.
  8662. */
  8663. set isEnabled(value: boolean);
  8664. /**
  8665. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8666. */
  8667. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8668. /**
  8669. * Method called each time the image processing information changes requires to recompile the effect.
  8670. */
  8671. protected _updateParameters(): void;
  8672. /**
  8673. * Gets the current class name.
  8674. * @return "ImageProcessingConfiguration"
  8675. */
  8676. getClassName(): string;
  8677. /**
  8678. * Prepare the list of uniforms associated with the Image Processing effects.
  8679. * @param uniforms The list of uniforms used in the effect
  8680. * @param defines the list of defines currently in use
  8681. */
  8682. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8683. /**
  8684. * Prepare the list of samplers associated with the Image Processing effects.
  8685. * @param samplersList The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of defines associated to the shader.
  8691. * @param defines the list of defines to complete
  8692. * @param forPostProcess Define if we are currently in post process mode or not
  8693. */
  8694. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8695. /**
  8696. * Returns true if all the image processing information are ready.
  8697. * @returns True if ready, otherwise, false
  8698. */
  8699. isReady(): boolean;
  8700. /**
  8701. * Binds the image processing to the shader.
  8702. * @param effect The effect to bind to
  8703. * @param overrideAspectRatio Override the aspect ratio of the effect
  8704. */
  8705. bind(effect: Effect, overrideAspectRatio?: number): void;
  8706. /**
  8707. * Clones the current image processing instance.
  8708. * @return The cloned image processing
  8709. */
  8710. clone(): ImageProcessingConfiguration;
  8711. /**
  8712. * Serializes the current image processing instance to a json representation.
  8713. * @return a JSON representation
  8714. */
  8715. serialize(): any;
  8716. /**
  8717. * Parses the image processing from a json representation.
  8718. * @param source the JSON source to parse
  8719. * @return The parsed image processing
  8720. */
  8721. static Parse(source: any): ImageProcessingConfiguration;
  8722. private static _VIGNETTEMODE_MULTIPLY;
  8723. private static _VIGNETTEMODE_OPAQUE;
  8724. /**
  8725. * Used to apply the vignette as a mix with the pixel color.
  8726. */
  8727. static get VIGNETTEMODE_MULTIPLY(): number;
  8728. /**
  8729. * Used to apply the vignette as a replacement of the pixel color.
  8730. */
  8731. static get VIGNETTEMODE_OPAQUE(): number;
  8732. }
  8733. }
  8734. declare module "babylonjs/Shaders/postprocess.vertex" {
  8735. /** @hidden */
  8736. export var postprocessVertexShader: {
  8737. name: string;
  8738. shader: string;
  8739. };
  8740. }
  8741. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8743. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8744. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8745. /**
  8746. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8747. */
  8748. export type RenderTargetTextureSize = number | {
  8749. width: number;
  8750. height: number;
  8751. layers?: number;
  8752. };
  8753. module "babylonjs/Engines/thinEngine" {
  8754. interface ThinEngine {
  8755. /**
  8756. * Creates a new render target texture
  8757. * @param size defines the size of the texture
  8758. * @param options defines the options used to create the texture
  8759. * @returns a new render target texture stored in an InternalTexture
  8760. */
  8761. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8762. /**
  8763. * Creates a depth stencil texture.
  8764. * This is only available in WebGL 2 or with the depth texture extension available.
  8765. * @param size The size of face edge in the texture.
  8766. * @param options The options defining the texture.
  8767. * @returns The texture
  8768. */
  8769. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8770. /** @hidden */
  8771. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8772. }
  8773. }
  8774. }
  8775. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8776. /**
  8777. * Defines the kind of connection point for node based material
  8778. */
  8779. export enum NodeMaterialBlockConnectionPointTypes {
  8780. /** Float */
  8781. Float = 1,
  8782. /** Int */
  8783. Int = 2,
  8784. /** Vector2 */
  8785. Vector2 = 4,
  8786. /** Vector3 */
  8787. Vector3 = 8,
  8788. /** Vector4 */
  8789. Vector4 = 16,
  8790. /** Color3 */
  8791. Color3 = 32,
  8792. /** Color4 */
  8793. Color4 = 64,
  8794. /** Matrix */
  8795. Matrix = 128,
  8796. /** Custom object */
  8797. Object = 256,
  8798. /** Detect type based on connection */
  8799. AutoDetect = 1024,
  8800. /** Output type that will be defined by input type */
  8801. BasedOnInput = 2048
  8802. }
  8803. }
  8804. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8805. /**
  8806. * Enum used to define the target of a block
  8807. */
  8808. export enum NodeMaterialBlockTargets {
  8809. /** Vertex shader */
  8810. Vertex = 1,
  8811. /** Fragment shader */
  8812. Fragment = 2,
  8813. /** Neutral */
  8814. Neutral = 4,
  8815. /** Vertex and Fragment */
  8816. VertexAndFragment = 3
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8820. /**
  8821. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8822. */
  8823. export enum NodeMaterialBlockConnectionPointMode {
  8824. /** Value is an uniform */
  8825. Uniform = 0,
  8826. /** Value is a mesh attribute */
  8827. Attribute = 1,
  8828. /** Value is a varying between vertex and fragment shaders */
  8829. Varying = 2,
  8830. /** Mode is undefined */
  8831. Undefined = 3
  8832. }
  8833. }
  8834. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8835. /**
  8836. * Enum used to define system values e.g. values automatically provided by the system
  8837. */
  8838. export enum NodeMaterialSystemValues {
  8839. /** World */
  8840. World = 1,
  8841. /** View */
  8842. View = 2,
  8843. /** Projection */
  8844. Projection = 3,
  8845. /** ViewProjection */
  8846. ViewProjection = 4,
  8847. /** WorldView */
  8848. WorldView = 5,
  8849. /** WorldViewProjection */
  8850. WorldViewProjection = 6,
  8851. /** CameraPosition */
  8852. CameraPosition = 7,
  8853. /** Fog Color */
  8854. FogColor = 8,
  8855. /** Delta time */
  8856. DeltaTime = 9
  8857. }
  8858. }
  8859. declare module "babylonjs/Maths/math.axis" {
  8860. import { Vector3 } from "babylonjs/Maths/math.vector";
  8861. /** Defines supported spaces */
  8862. export enum Space {
  8863. /** Local (object) space */
  8864. LOCAL = 0,
  8865. /** World space */
  8866. WORLD = 1,
  8867. /** Bone space */
  8868. BONE = 2
  8869. }
  8870. /** Defines the 3 main axes */
  8871. export class Axis {
  8872. /** X axis */
  8873. static X: Vector3;
  8874. /** Y axis */
  8875. static Y: Vector3;
  8876. /** Z axis */
  8877. static Z: Vector3;
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.frustum" {
  8881. import { Matrix } from "babylonjs/Maths/math.vector";
  8882. import { DeepImmutable } from "babylonjs/types";
  8883. import { Plane } from "babylonjs/Maths/math.plane";
  8884. /**
  8885. * Represents a camera frustum
  8886. */
  8887. export class Frustum {
  8888. /**
  8889. * Gets the planes representing the frustum
  8890. * @param transform matrix to be applied to the returned planes
  8891. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8892. */
  8893. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8894. /**
  8895. * Gets the near frustum plane transformed by the transform matrix
  8896. * @param transform transformation matrix to be applied to the resulting frustum plane
  8897. * @param frustumPlane the resuling frustum plane
  8898. */
  8899. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8900. /**
  8901. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8932. * @param transform transformation matrix to be applied to the resulting frustum planes
  8933. * @param frustumPlanes the resuling frustum planes
  8934. */
  8935. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.size" {
  8939. /**
  8940. * Interface for the size containing width and height
  8941. */
  8942. export interface ISize {
  8943. /**
  8944. * Width
  8945. */
  8946. width: number;
  8947. /**
  8948. * Heighht
  8949. */
  8950. height: number;
  8951. }
  8952. /**
  8953. * Size containing widht and height
  8954. */
  8955. export class Size implements ISize {
  8956. /**
  8957. * Width
  8958. */
  8959. width: number;
  8960. /**
  8961. * Height
  8962. */
  8963. height: number;
  8964. /**
  8965. * Creates a Size object from the given width and height (floats).
  8966. * @param width width of the new size
  8967. * @param height height of the new size
  8968. */
  8969. constructor(width: number, height: number);
  8970. /**
  8971. * Returns a string with the Size width and height
  8972. * @returns a string with the Size width and height
  8973. */
  8974. toString(): string;
  8975. /**
  8976. * "Size"
  8977. * @returns the string "Size"
  8978. */
  8979. getClassName(): string;
  8980. /**
  8981. * Returns the Size hash code.
  8982. * @returns a hash code for a unique width and height
  8983. */
  8984. getHashCode(): number;
  8985. /**
  8986. * Updates the current size from the given one.
  8987. * @param src the given size
  8988. */
  8989. copyFrom(src: Size): void;
  8990. /**
  8991. * Updates in place the current Size from the given floats.
  8992. * @param width width of the new size
  8993. * @param height height of the new size
  8994. * @returns the updated Size.
  8995. */
  8996. copyFromFloats(width: number, height: number): Size;
  8997. /**
  8998. * Updates in place the current Size from the given floats.
  8999. * @param width width to set
  9000. * @param height height to set
  9001. * @returns the updated Size.
  9002. */
  9003. set(width: number, height: number): Size;
  9004. /**
  9005. * Multiplies the width and height by numbers
  9006. * @param w factor to multiple the width by
  9007. * @param h factor to multiple the height by
  9008. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9009. */
  9010. multiplyByFloats(w: number, h: number): Size;
  9011. /**
  9012. * Clones the size
  9013. * @returns a new Size copied from the given one.
  9014. */
  9015. clone(): Size;
  9016. /**
  9017. * True if the current Size and the given one width and height are strictly equal.
  9018. * @param other the other size to compare against
  9019. * @returns True if the current Size and the given one width and height are strictly equal.
  9020. */
  9021. equals(other: Size): boolean;
  9022. /**
  9023. * The surface of the Size : width * height (float).
  9024. */
  9025. get surface(): number;
  9026. /**
  9027. * Create a new size of zero
  9028. * @returns a new Size set to (0.0, 0.0)
  9029. */
  9030. static Zero(): Size;
  9031. /**
  9032. * Sums the width and height of two sizes
  9033. * @param otherSize size to add to this size
  9034. * @returns a new Size set as the addition result of the current Size and the given one.
  9035. */
  9036. add(otherSize: Size): Size;
  9037. /**
  9038. * Subtracts the width and height of two
  9039. * @param otherSize size to subtract to this size
  9040. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9041. */
  9042. subtract(otherSize: Size): Size;
  9043. /**
  9044. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9045. * @param start starting size to lerp between
  9046. * @param end end size to lerp between
  9047. * @param amount amount to lerp between the start and end values
  9048. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9049. */
  9050. static Lerp(start: Size, end: Size, amount: number): Size;
  9051. }
  9052. }
  9053. declare module "babylonjs/Maths/math.vertexFormat" {
  9054. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9055. /**
  9056. * Contains position and normal vectors for a vertex
  9057. */
  9058. export class PositionNormalVertex {
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position: Vector3;
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal: Vector3;
  9063. /**
  9064. * Creates a PositionNormalVertex
  9065. * @param position the position of the vertex (defaut: 0,0,0)
  9066. * @param normal the normal of the vertex (defaut: 0,1,0)
  9067. */
  9068. constructor(
  9069. /** the position of the vertex (defaut: 0,0,0) */
  9070. position?: Vector3,
  9071. /** the normal of the vertex (defaut: 0,1,0) */
  9072. normal?: Vector3);
  9073. /**
  9074. * Clones the PositionNormalVertex
  9075. * @returns the cloned PositionNormalVertex
  9076. */
  9077. clone(): PositionNormalVertex;
  9078. }
  9079. /**
  9080. * Contains position, normal and uv vectors for a vertex
  9081. */
  9082. export class PositionNormalTextureVertex {
  9083. /** the position of the vertex (defaut: 0,0,0) */
  9084. position: Vector3;
  9085. /** the normal of the vertex (defaut: 0,1,0) */
  9086. normal: Vector3;
  9087. /** the uv of the vertex (default: 0,0) */
  9088. uv: Vector2;
  9089. /**
  9090. * Creates a PositionNormalTextureVertex
  9091. * @param position the position of the vertex (defaut: 0,0,0)
  9092. * @param normal the normal of the vertex (defaut: 0,1,0)
  9093. * @param uv the uv of the vertex (default: 0,0)
  9094. */
  9095. constructor(
  9096. /** the position of the vertex (defaut: 0,0,0) */
  9097. position?: Vector3,
  9098. /** the normal of the vertex (defaut: 0,1,0) */
  9099. normal?: Vector3,
  9100. /** the uv of the vertex (default: 0,0) */
  9101. uv?: Vector2);
  9102. /**
  9103. * Clones the PositionNormalTextureVertex
  9104. * @returns the cloned PositionNormalTextureVertex
  9105. */
  9106. clone(): PositionNormalTextureVertex;
  9107. }
  9108. }
  9109. declare module "babylonjs/Maths/math" {
  9110. export * from "babylonjs/Maths/math.axis";
  9111. export * from "babylonjs/Maths/math.color";
  9112. export * from "babylonjs/Maths/math.constants";
  9113. export * from "babylonjs/Maths/math.frustum";
  9114. export * from "babylonjs/Maths/math.path";
  9115. export * from "babylonjs/Maths/math.plane";
  9116. export * from "babylonjs/Maths/math.size";
  9117. export * from "babylonjs/Maths/math.vector";
  9118. export * from "babylonjs/Maths/math.vertexFormat";
  9119. export * from "babylonjs/Maths/math.viewport";
  9120. }
  9121. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9122. /**
  9123. * Enum defining the type of animations supported by InputBlock
  9124. */
  9125. export enum AnimatedInputBlockTypes {
  9126. /** No animation */
  9127. None = 0,
  9128. /** Time based animation. Will only work for floats */
  9129. Time = 1
  9130. }
  9131. }
  9132. declare module "babylonjs/Lights/shadowLight" {
  9133. import { Camera } from "babylonjs/Cameras/camera";
  9134. import { Scene } from "babylonjs/scene";
  9135. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. import { Light } from "babylonjs/Lights/light";
  9138. /**
  9139. * Interface describing all the common properties and methods a shadow light needs to implement.
  9140. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9141. * as well as binding the different shadow properties to the effects.
  9142. */
  9143. export interface IShadowLight extends Light {
  9144. /**
  9145. * The light id in the scene (used in scene.findLighById for instance)
  9146. */
  9147. id: string;
  9148. /**
  9149. * The position the shdow will be casted from.
  9150. */
  9151. position: Vector3;
  9152. /**
  9153. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9154. */
  9155. direction: Vector3;
  9156. /**
  9157. * The transformed position. Position of the light in world space taking parenting in account.
  9158. */
  9159. transformedPosition: Vector3;
  9160. /**
  9161. * The transformed direction. Direction of the light in world space taking parenting in account.
  9162. */
  9163. transformedDirection: Vector3;
  9164. /**
  9165. * The friendly name of the light in the scene.
  9166. */
  9167. name: string;
  9168. /**
  9169. * Defines the shadow projection clipping minimum z value.
  9170. */
  9171. shadowMinZ: number;
  9172. /**
  9173. * Defines the shadow projection clipping maximum z value.
  9174. */
  9175. shadowMaxZ: number;
  9176. /**
  9177. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9178. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9179. */
  9180. computeTransformedInformation(): boolean;
  9181. /**
  9182. * Gets the scene the light belongs to.
  9183. * @returns The scene
  9184. */
  9185. getScene(): Scene;
  9186. /**
  9187. * Callback defining a custom Projection Matrix Builder.
  9188. * This can be used to override the default projection matrix computation.
  9189. */
  9190. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9191. /**
  9192. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9193. * @param matrix The materix to updated with the projection information
  9194. * @param viewMatrix The transform matrix of the light
  9195. * @param renderList The list of mesh to render in the map
  9196. * @returns The current light
  9197. */
  9198. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9199. /**
  9200. * Gets the current depth scale used in ESM.
  9201. * @returns The scale
  9202. */
  9203. getDepthScale(): number;
  9204. /**
  9205. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9206. * @returns true if a cube texture needs to be use
  9207. */
  9208. needCube(): boolean;
  9209. /**
  9210. * Detects if the projection matrix requires to be recomputed this frame.
  9211. * @returns true if it requires to be recomputed otherwise, false.
  9212. */
  9213. needProjectionMatrixCompute(): boolean;
  9214. /**
  9215. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9216. */
  9217. forceProjectionMatrixCompute(): void;
  9218. /**
  9219. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9220. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9221. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9222. */
  9223. getShadowDirection(faceIndex?: number): Vector3;
  9224. /**
  9225. * Gets the minZ used for shadow according to both the scene and the light.
  9226. * @param activeCamera The camera we are returning the min for
  9227. * @returns the depth min z
  9228. */
  9229. getDepthMinZ(activeCamera: Camera): number;
  9230. /**
  9231. * Gets the maxZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the max for
  9233. * @returns the depth max z
  9234. */
  9235. getDepthMaxZ(activeCamera: Camera): number;
  9236. }
  9237. /**
  9238. * Base implementation IShadowLight
  9239. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9240. */
  9241. export abstract class ShadowLight extends Light implements IShadowLight {
  9242. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9243. protected _position: Vector3;
  9244. protected _setPosition(value: Vector3): void;
  9245. /**
  9246. * Sets the position the shadow will be casted from. Also use as the light position for both
  9247. * point and spot lights.
  9248. */
  9249. get position(): Vector3;
  9250. /**
  9251. * Sets the position the shadow will be casted from. Also use as the light position for both
  9252. * point and spot lights.
  9253. */
  9254. set position(value: Vector3);
  9255. protected _direction: Vector3;
  9256. protected _setDirection(value: Vector3): void;
  9257. /**
  9258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9259. * Also use as the light direction on spot and directional lights.
  9260. */
  9261. get direction(): Vector3;
  9262. /**
  9263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9264. * Also use as the light direction on spot and directional lights.
  9265. */
  9266. set direction(value: Vector3);
  9267. protected _shadowMinZ: number;
  9268. /**
  9269. * Gets the shadow projection clipping minimum z value.
  9270. */
  9271. get shadowMinZ(): number;
  9272. /**
  9273. * Sets the shadow projection clipping minimum z value.
  9274. */
  9275. set shadowMinZ(value: number);
  9276. protected _shadowMaxZ: number;
  9277. /**
  9278. * Sets the shadow projection clipping maximum z value.
  9279. */
  9280. get shadowMaxZ(): number;
  9281. /**
  9282. * Gets the shadow projection clipping maximum z value.
  9283. */
  9284. set shadowMaxZ(value: number);
  9285. /**
  9286. * Callback defining a custom Projection Matrix Builder.
  9287. * This can be used to override the default projection matrix computation.
  9288. */
  9289. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9290. /**
  9291. * The transformed position. Position of the light in world space taking parenting in account.
  9292. */
  9293. transformedPosition: Vector3;
  9294. /**
  9295. * The transformed direction. Direction of the light in world space taking parenting in account.
  9296. */
  9297. transformedDirection: Vector3;
  9298. private _needProjectionMatrixCompute;
  9299. /**
  9300. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9301. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9302. */
  9303. computeTransformedInformation(): boolean;
  9304. /**
  9305. * Return the depth scale used for the shadow map.
  9306. * @returns the depth scale.
  9307. */
  9308. getDepthScale(): number;
  9309. /**
  9310. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9311. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9312. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9313. */
  9314. getShadowDirection(faceIndex?: number): Vector3;
  9315. /**
  9316. * Returns the ShadowLight absolute position in the World.
  9317. * @returns the position vector in world space
  9318. */
  9319. getAbsolutePosition(): Vector3;
  9320. /**
  9321. * Sets the ShadowLight direction toward the passed target.
  9322. * @param target The point to target in local space
  9323. * @returns the updated ShadowLight direction
  9324. */
  9325. setDirectionToTarget(target: Vector3): Vector3;
  9326. /**
  9327. * Returns the light rotation in euler definition.
  9328. * @returns the x y z rotation in local space.
  9329. */
  9330. getRotation(): Vector3;
  9331. /**
  9332. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9333. * @returns true if a cube texture needs to be use
  9334. */
  9335. needCube(): boolean;
  9336. /**
  9337. * Detects if the projection matrix requires to be recomputed this frame.
  9338. * @returns true if it requires to be recomputed otherwise, false.
  9339. */
  9340. needProjectionMatrixCompute(): boolean;
  9341. /**
  9342. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9343. */
  9344. forceProjectionMatrixCompute(): void;
  9345. /** @hidden */
  9346. _initCache(): void;
  9347. /** @hidden */
  9348. _isSynchronized(): boolean;
  9349. /**
  9350. * Computes the world matrix of the node
  9351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9352. * @returns the world matrix
  9353. */
  9354. computeWorldMatrix(force?: boolean): Matrix;
  9355. /**
  9356. * Gets the minZ used for shadow according to both the scene and the light.
  9357. * @param activeCamera The camera we are returning the min for
  9358. * @returns the depth min z
  9359. */
  9360. getDepthMinZ(activeCamera: Camera): number;
  9361. /**
  9362. * Gets the maxZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the max for
  9364. * @returns the depth max z
  9365. */
  9366. getDepthMaxZ(activeCamera: Camera): number;
  9367. /**
  9368. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9369. * @param matrix The materix to updated with the projection information
  9370. * @param viewMatrix The transform matrix of the light
  9371. * @param renderList The list of mesh to render in the map
  9372. * @returns The current light
  9373. */
  9374. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9378. /** @hidden */
  9379. export var packingFunctions: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9385. /** @hidden */
  9386. export var bayerDitherFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9392. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9393. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9394. /** @hidden */
  9395. export var shadowMapFragmentDeclaration: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9401. /** @hidden */
  9402. export var clipPlaneFragmentDeclaration: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9408. /** @hidden */
  9409. export var clipPlaneFragment: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9415. /** @hidden */
  9416. export var shadowMapFragment: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9422. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9425. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9426. /** @hidden */
  9427. export var shadowMapPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9433. /** @hidden */
  9434. export var bonesDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9440. /** @hidden */
  9441. export var morphTargetsVertexGlobalDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9447. /** @hidden */
  9448. export var morphTargetsVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9454. /** @hidden */
  9455. export var instancesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9461. /** @hidden */
  9462. export var helperFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9468. /** @hidden */
  9469. export var shadowMapVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9475. /** @hidden */
  9476. export var clipPlaneVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9482. /** @hidden */
  9483. export var morphTargetsVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9489. /** @hidden */
  9490. export var instancesVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9496. /** @hidden */
  9497. export var bonesVertex: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9503. /** @hidden */
  9504. export var shadowMapVertexNormalBias: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9510. /** @hidden */
  9511. export var shadowMapVertexMetric: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9517. /** @hidden */
  9518. export var clipPlaneVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9529. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9537. /** @hidden */
  9538. export var shadowMapVertexShader: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9544. /** @hidden */
  9545. export var depthBoxBlurPixelShader: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9551. /** @hidden */
  9552. export var shadowMapFragmentSoftTransparentShadow: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Materials/effectFallbacks" {
  9558. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9559. import { Effect } from "babylonjs/Materials/effect";
  9560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9561. /**
  9562. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9563. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9564. */
  9565. export class EffectFallbacks implements IEffectFallbacks {
  9566. private _defines;
  9567. private _currentRank;
  9568. private _maxRank;
  9569. private _mesh;
  9570. /**
  9571. * Removes the fallback from the bound mesh.
  9572. */
  9573. unBindMesh(): void;
  9574. /**
  9575. * Adds a fallback on the specified property.
  9576. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9577. * @param define The name of the define in the shader
  9578. */
  9579. addFallback(rank: number, define: string): void;
  9580. /**
  9581. * Sets the mesh to use CPU skinning when needing to fallback.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param mesh The mesh to use the fallbacks.
  9584. */
  9585. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9586. /**
  9587. * Checks to see if more fallbacks are still availible.
  9588. */
  9589. get hasMoreFallbacks(): boolean;
  9590. /**
  9591. * Removes the defines that should be removed when falling back.
  9592. * @param currentDefines defines the current define statements for the shader.
  9593. * @param effect defines the current effect we try to compile
  9594. * @returns The resulting defines with defines of the current rank removed.
  9595. */
  9596. reduce(currentDefines: string, effect: Effect): string;
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/action" {
  9600. import { Observable } from "babylonjs/Misc/observable";
  9601. import { Condition } from "babylonjs/Actions/condition";
  9602. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9603. import { Nullable } from "babylonjs/types";
  9604. import { Scene } from "babylonjs/scene";
  9605. import { ActionManager } from "babylonjs/Actions/actionManager";
  9606. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9607. import { Node } from "babylonjs/node";
  9608. /**
  9609. * Interface used to define Action
  9610. */
  9611. export interface IAction {
  9612. /**
  9613. * Trigger for the action
  9614. */
  9615. trigger: number;
  9616. /** Options of the trigger */
  9617. triggerOptions: any;
  9618. /**
  9619. * Gets the trigger parameters
  9620. * @returns the trigger parameters
  9621. */
  9622. getTriggerParameter(): any;
  9623. /**
  9624. * Internal only - executes current action event
  9625. * @hidden
  9626. */
  9627. _executeCurrent(evt?: ActionEvent): void;
  9628. /**
  9629. * Serialize placeholder for child classes
  9630. * @param parent of child
  9631. * @returns the serialized object
  9632. */
  9633. serialize(parent: any): any;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _prepare(): void;
  9639. /**
  9640. * Internal only - manager for action
  9641. * @hidden
  9642. */
  9643. _actionManager: Nullable<AbstractActionManager>;
  9644. /**
  9645. * Adds action to chain of actions, may be a DoNothingAction
  9646. * @param action defines the next action to execute
  9647. * @returns The action passed in
  9648. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9649. */
  9650. then(action: IAction): IAction;
  9651. }
  9652. /**
  9653. * The action to be carried out following a trigger
  9654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9655. */
  9656. export class Action implements IAction {
  9657. /** the trigger, with or without parameters, for the action */
  9658. triggerOptions: any;
  9659. /**
  9660. * Trigger for the action
  9661. */
  9662. trigger: number;
  9663. /**
  9664. * Internal only - manager for action
  9665. * @hidden
  9666. */
  9667. _actionManager: ActionManager;
  9668. private _nextActiveAction;
  9669. private _child;
  9670. private _condition?;
  9671. private _triggerParameter;
  9672. /**
  9673. * An event triggered prior to action being executed.
  9674. */
  9675. onBeforeExecuteObservable: Observable<Action>;
  9676. /**
  9677. * Creates a new Action
  9678. * @param triggerOptions the trigger, with or without parameters, for the action
  9679. * @param condition an optional determinant of action
  9680. */
  9681. constructor(
  9682. /** the trigger, with or without parameters, for the action */
  9683. triggerOptions: any, condition?: Condition);
  9684. /**
  9685. * Internal only
  9686. * @hidden
  9687. */
  9688. _prepare(): void;
  9689. /**
  9690. * Gets the trigger parameters
  9691. * @returns the trigger parameters
  9692. */
  9693. getTriggerParameter(): any;
  9694. /**
  9695. * Internal only - executes current action event
  9696. * @hidden
  9697. */
  9698. _executeCurrent(evt?: ActionEvent): void;
  9699. /**
  9700. * Execute placeholder for child classes
  9701. * @param evt optional action event
  9702. */
  9703. execute(evt?: ActionEvent): void;
  9704. /**
  9705. * Skips to next active action
  9706. */
  9707. skipToNextActiveAction(): void;
  9708. /**
  9709. * Adds action to chain of actions, may be a DoNothingAction
  9710. * @param action defines the next action to execute
  9711. * @returns The action passed in
  9712. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9713. */
  9714. then(action: Action): Action;
  9715. /**
  9716. * Internal only
  9717. * @hidden
  9718. */
  9719. _getProperty(propertyPath: string): string;
  9720. /**
  9721. * Internal only
  9722. * @hidden
  9723. */
  9724. _getEffectiveTarget(target: any, propertyPath: string): any;
  9725. /**
  9726. * Serialize placeholder for child classes
  9727. * @param parent of child
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. /**
  9732. * Internal only called by serialize
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedAction: any, parent?: any): any;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. static _SerializeValueAsString: (value: any) => string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. static _GetTargetProperty: (target: Scene | Node) => {
  9746. name: string;
  9747. targetType: string;
  9748. value: string;
  9749. };
  9750. }
  9751. }
  9752. declare module "babylonjs/Actions/condition" {
  9753. import { ActionManager } from "babylonjs/Actions/actionManager";
  9754. /**
  9755. * A Condition applied to an Action
  9756. */
  9757. export class Condition {
  9758. /**
  9759. * Internal only - manager for action
  9760. * @hidden
  9761. */
  9762. _actionManager: ActionManager;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. _evaluationId: number;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. _currentResult: boolean;
  9773. /**
  9774. * Creates a new Condition
  9775. * @param actionManager the manager of the action the condition is applied to
  9776. */
  9777. constructor(actionManager: ActionManager);
  9778. /**
  9779. * Check if the current condition is valid
  9780. * @returns a boolean
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. _getProperty(propertyPath: string): string;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. _getEffectiveTarget(target: any, propertyPath: string): any;
  9793. /**
  9794. * Serialize placeholder for child classes
  9795. * @returns the serialized object
  9796. */
  9797. serialize(): any;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. protected _serialize(serializedCondition: any): any;
  9803. }
  9804. /**
  9805. * Defines specific conditional operators as extensions of Condition
  9806. */
  9807. export class ValueCondition extends Condition {
  9808. /** path to specify the property of the target the conditional operator uses */
  9809. propertyPath: string;
  9810. /** the value compared by the conditional operator against the current value of the property */
  9811. value: any;
  9812. /** the conditional operator, default ValueCondition.IsEqual */
  9813. operator: number;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsEqual;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsDifferent;
  9824. /**
  9825. * Internal only
  9826. * @hidden
  9827. */
  9828. private static _IsGreater;
  9829. /**
  9830. * Internal only
  9831. * @hidden
  9832. */
  9833. private static _IsLesser;
  9834. /**
  9835. * returns the number for IsEqual
  9836. */
  9837. static get IsEqual(): number;
  9838. /**
  9839. * Returns the number for IsDifferent
  9840. */
  9841. static get IsDifferent(): number;
  9842. /**
  9843. * Returns the number for IsGreater
  9844. */
  9845. static get IsGreater(): number;
  9846. /**
  9847. * Returns the number for IsLesser
  9848. */
  9849. static get IsLesser(): number;
  9850. /**
  9851. * Internal only The action manager for the condition
  9852. * @hidden
  9853. */
  9854. _actionManager: ActionManager;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _target;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _effectiveTarget;
  9865. /**
  9866. * Internal only
  9867. * @hidden
  9868. */
  9869. private _property;
  9870. /**
  9871. * Creates a new ValueCondition
  9872. * @param actionManager manager for the action the condition applies to
  9873. * @param target for the action
  9874. * @param propertyPath path to specify the property of the target the conditional operator uses
  9875. * @param value the value compared by the conditional operator against the current value of the property
  9876. * @param operator the conditional operator, default ValueCondition.IsEqual
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** path to specify the property of the target the conditional operator uses */
  9880. propertyPath: string,
  9881. /** the value compared by the conditional operator against the current value of the property */
  9882. value: any,
  9883. /** the conditional operator, default ValueCondition.IsEqual */
  9884. operator?: number);
  9885. /**
  9886. * Compares the given value with the property value for the specified conditional operator
  9887. * @returns the result of the comparison
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the ValueCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Gets the name of the conditional operator for the ValueCondition
  9897. * @param operator the conditional operator
  9898. * @returns the name
  9899. */
  9900. static GetOperatorName(operator: number): string;
  9901. }
  9902. /**
  9903. * Defines a predicate condition as an extension of Condition
  9904. */
  9905. export class PredicateCondition extends Condition {
  9906. /** defines the predicate function used to validate the condition */
  9907. predicate: () => boolean;
  9908. /**
  9909. * Internal only - manager for action
  9910. * @hidden
  9911. */
  9912. _actionManager: ActionManager;
  9913. /**
  9914. * Creates a new PredicateCondition
  9915. * @param actionManager manager for the action the condition applies to
  9916. * @param predicate defines the predicate function used to validate the condition
  9917. */
  9918. constructor(actionManager: ActionManager,
  9919. /** defines the predicate function used to validate the condition */
  9920. predicate: () => boolean);
  9921. /**
  9922. * @returns the validity of the predicate condition
  9923. */
  9924. isValid(): boolean;
  9925. }
  9926. /**
  9927. * Defines a state condition as an extension of Condition
  9928. */
  9929. export class StateCondition extends Condition {
  9930. /** Value to compare with target state */
  9931. value: string;
  9932. /**
  9933. * Internal only - manager for action
  9934. * @hidden
  9935. */
  9936. _actionManager: ActionManager;
  9937. /**
  9938. * Internal only
  9939. * @hidden
  9940. */
  9941. private _target;
  9942. /**
  9943. * Creates a new StateCondition
  9944. * @param actionManager manager for the action the condition applies to
  9945. * @param target of the condition
  9946. * @param value to compare with target state
  9947. */
  9948. constructor(actionManager: ActionManager, target: any,
  9949. /** Value to compare with target state */
  9950. value: string);
  9951. /**
  9952. * Gets a boolean indicating if the current condition is met
  9953. * @returns the validity of the state
  9954. */
  9955. isValid(): boolean;
  9956. /**
  9957. * Serialize the StateCondition into a JSON compatible object
  9958. * @returns serialization object
  9959. */
  9960. serialize(): any;
  9961. }
  9962. }
  9963. declare module "babylonjs/Actions/directActions" {
  9964. import { Action } from "babylonjs/Actions/action";
  9965. import { Condition } from "babylonjs/Actions/condition";
  9966. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9967. /**
  9968. * This defines an action responsible to toggle a boolean once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class SwitchBooleanAction extends Action {
  9972. /**
  9973. * The path to the boolean property in the target object
  9974. */
  9975. propertyPath: string;
  9976. private _target;
  9977. private _effectiveTarget;
  9978. private _property;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the object containing the boolean
  9983. * @param propertyPath defines the path to the boolean property in the target object
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action toggle the boolean value.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible to set a the state field of the target
  10002. * to a desired value once triggered.
  10003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10004. */
  10005. export class SetStateAction extends Action {
  10006. /**
  10007. * The value to store in the state field.
  10008. */
  10009. value: string;
  10010. private _target;
  10011. /**
  10012. * Instantiate the action
  10013. * @param triggerOptions defines the trigger options
  10014. * @param target defines the object containing the state property
  10015. * @param value defines the value to store in the state field
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10019. /**
  10020. * Execute the action and store the value on the target state property.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible to set a property of the target
  10032. * to a desired value once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class SetValueAction extends Action {
  10036. /**
  10037. * The path of the property to set in the target.
  10038. */
  10039. propertyPath: string;
  10040. /**
  10041. * The value to set in the property
  10042. */
  10043. value: any;
  10044. private _target;
  10045. private _effectiveTarget;
  10046. private _property;
  10047. /**
  10048. * Instantiate the action
  10049. * @param triggerOptions defines the trigger options
  10050. * @param target defines the object containing the property
  10051. * @param propertyPath defines the path of the property to set in the target
  10052. * @param value defines the value to set in the property
  10053. * @param condition defines the trigger related conditions
  10054. */
  10055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10056. /** @hidden */
  10057. _prepare(): void;
  10058. /**
  10059. * Execute the action and set the targetted property to the desired value.
  10060. */
  10061. execute(): void;
  10062. /**
  10063. * Serializes the actions and its related information.
  10064. * @param parent defines the object to serialize in
  10065. * @returns the serialized object
  10066. */
  10067. serialize(parent: any): any;
  10068. }
  10069. /**
  10070. * This defines an action responsible to increment the target value
  10071. * to a desired value once triggered.
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10073. */
  10074. export class IncrementValueAction extends Action {
  10075. /**
  10076. * The path of the property to increment in the target.
  10077. */
  10078. propertyPath: string;
  10079. /**
  10080. * The value we should increment the property by.
  10081. */
  10082. value: any;
  10083. private _target;
  10084. private _effectiveTarget;
  10085. private _property;
  10086. /**
  10087. * Instantiate the action
  10088. * @param triggerOptions defines the trigger options
  10089. * @param target defines the object containing the property
  10090. * @param propertyPath defines the path of the property to increment in the target
  10091. * @param value defines the value value we should increment the property by
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and increment the target of the value amount.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible to start an animation once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class PlayAnimationAction extends Action {
  10113. /**
  10114. * Where the animation should start (animation frame)
  10115. */
  10116. from: number;
  10117. /**
  10118. * Where the animation should stop (animation frame)
  10119. */
  10120. to: number;
  10121. /**
  10122. * Define if the animation should loop or stop after the first play.
  10123. */
  10124. loop?: boolean;
  10125. private _target;
  10126. /**
  10127. * Instantiate the action
  10128. * @param triggerOptions defines the trigger options
  10129. * @param target defines the target animation or animation name
  10130. * @param from defines from where the animation should start (animation frame)
  10131. * @param end defines where the animation should stop (animation frame)
  10132. * @param loop defines if the animation should loop or stop after the first play
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and play the animation.
  10140. */
  10141. execute(): void;
  10142. /**
  10143. * Serializes the actions and its related information.
  10144. * @param parent defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(parent: any): any;
  10148. }
  10149. /**
  10150. * This defines an action responsible to stop an animation once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class StopAnimationAction extends Action {
  10154. private _target;
  10155. /**
  10156. * Instantiate the action
  10157. * @param triggerOptions defines the trigger options
  10158. * @param target defines the target animation or animation name
  10159. * @param condition defines the trigger related conditions
  10160. */
  10161. constructor(triggerOptions: any, target: any, condition?: Condition);
  10162. /** @hidden */
  10163. _prepare(): void;
  10164. /**
  10165. * Execute the action and stop the animation.
  10166. */
  10167. execute(): void;
  10168. /**
  10169. * Serializes the actions and its related information.
  10170. * @param parent defines the object to serialize in
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. }
  10175. /**
  10176. * This defines an action responsible that does nothing once triggered.
  10177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10178. */
  10179. export class DoNothingAction extends Action {
  10180. /**
  10181. * Instantiate the action
  10182. * @param triggerOptions defines the trigger options
  10183. * @param condition defines the trigger related conditions
  10184. */
  10185. constructor(triggerOptions?: any, condition?: Condition);
  10186. /**
  10187. * Execute the action and do nothing.
  10188. */
  10189. execute(): void;
  10190. /**
  10191. * Serializes the actions and its related information.
  10192. * @param parent defines the object to serialize in
  10193. * @returns the serialized object
  10194. */
  10195. serialize(parent: any): any;
  10196. }
  10197. /**
  10198. * This defines an action responsible to trigger several actions once triggered.
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10200. */
  10201. export class CombineAction extends Action {
  10202. /**
  10203. * The list of aggregated animations to run.
  10204. */
  10205. children: Action[];
  10206. /**
  10207. * Instantiate the action
  10208. * @param triggerOptions defines the trigger options
  10209. * @param children defines the list of aggregated animations to run
  10210. * @param condition defines the trigger related conditions
  10211. */
  10212. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10213. /** @hidden */
  10214. _prepare(): void;
  10215. /**
  10216. * Execute the action and executes all the aggregated actions.
  10217. */
  10218. execute(evt: ActionEvent): void;
  10219. /**
  10220. * Serializes the actions and its related information.
  10221. * @param parent defines the object to serialize in
  10222. * @returns the serialized object
  10223. */
  10224. serialize(parent: any): any;
  10225. }
  10226. /**
  10227. * This defines an action responsible to run code (external event) once triggered.
  10228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class ExecuteCodeAction extends Action {
  10231. /**
  10232. * The callback function to run.
  10233. */
  10234. func: (evt: ActionEvent) => void;
  10235. /**
  10236. * Instantiate the action
  10237. * @param triggerOptions defines the trigger options
  10238. * @param func defines the callback function to run
  10239. * @param condition defines the trigger related conditions
  10240. */
  10241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10242. /**
  10243. * Execute the action and run the attached code.
  10244. */
  10245. execute(evt: ActionEvent): void;
  10246. }
  10247. /**
  10248. * This defines an action responsible to set the parent property of the target once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class SetParentAction extends Action {
  10252. private _parent;
  10253. private _target;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the target containing the parent property
  10258. * @param parent defines from where the animation should start (animation frame)
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and set the parent property.
  10266. */
  10267. execute(): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. }
  10276. declare module "babylonjs/Actions/actionManager" {
  10277. import { Nullable } from "babylonjs/types";
  10278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10279. import { Scene } from "babylonjs/scene";
  10280. import { IAction } from "babylonjs/Actions/action";
  10281. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10282. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10283. /**
  10284. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10285. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10287. */
  10288. export class ActionManager extends AbstractActionManager {
  10289. /**
  10290. * Nothing
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly NothingTrigger: number;
  10294. /**
  10295. * On pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnPickTrigger: number;
  10299. /**
  10300. * On left pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnLeftPickTrigger: number;
  10304. /**
  10305. * On right pick
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnRightPickTrigger: number;
  10309. /**
  10310. * On center pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnCenterPickTrigger: number;
  10314. /**
  10315. * On pick down
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickDownTrigger: number;
  10319. /**
  10320. * On double pick
  10321. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10322. */
  10323. static readonly OnDoublePickTrigger: number;
  10324. /**
  10325. * On pick up
  10326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10327. */
  10328. static readonly OnPickUpTrigger: number;
  10329. /**
  10330. * On pick out.
  10331. * This trigger will only be raised if you also declared a OnPickDown
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickOutTrigger: number;
  10335. /**
  10336. * On long press
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnLongPressTrigger: number;
  10340. /**
  10341. * On pointer over
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnPointerOverTrigger: number;
  10345. /**
  10346. * On pointer out
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPointerOutTrigger: number;
  10350. /**
  10351. * On every frame
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnEveryFrameTrigger: number;
  10355. /**
  10356. * On intersection enter
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnIntersectionEnterTrigger: number;
  10360. /**
  10361. * On intersection exit
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnIntersectionExitTrigger: number;
  10365. /**
  10366. * On key down
  10367. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10368. */
  10369. static readonly OnKeyDownTrigger: number;
  10370. /**
  10371. * On key up
  10372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10373. */
  10374. static readonly OnKeyUpTrigger: number;
  10375. private _scene;
  10376. /**
  10377. * Creates a new action manager
  10378. * @param scene defines the hosting scene
  10379. */
  10380. constructor(scene: Scene);
  10381. /**
  10382. * Releases all associated resources
  10383. */
  10384. dispose(): void;
  10385. /**
  10386. * Gets hosting scene
  10387. * @returns the hosting scene
  10388. */
  10389. getScene(): Scene;
  10390. /**
  10391. * Does this action manager handles actions of any of the given triggers
  10392. * @param triggers defines the triggers to be tested
  10393. * @return a boolean indicating whether one (or more) of the triggers is handled
  10394. */
  10395. hasSpecificTriggers(triggers: number[]): boolean;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10398. * speed.
  10399. * @param triggerA defines the trigger to be tested
  10400. * @param triggerB defines the trigger to be tested
  10401. * @return a boolean indicating whether one (or more) of the triggers is handled
  10402. */
  10403. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10404. /**
  10405. * Does this action manager handles actions of a given trigger
  10406. * @param trigger defines the trigger to be tested
  10407. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10408. * @return whether the trigger is handled
  10409. */
  10410. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10411. /**
  10412. * Does this action manager has pointer triggers
  10413. */
  10414. get hasPointerTriggers(): boolean;
  10415. /**
  10416. * Does this action manager has pick triggers
  10417. */
  10418. get hasPickTriggers(): boolean;
  10419. /**
  10420. * Registers an action to this action manager
  10421. * @param action defines the action to be registered
  10422. * @return the action amended (prepared) after registration
  10423. */
  10424. registerAction(action: IAction): Nullable<IAction>;
  10425. /**
  10426. * Unregisters an action to this action manager
  10427. * @param action defines the action to be unregistered
  10428. * @return a boolean indicating whether the action has been unregistered
  10429. */
  10430. unregisterAction(action: IAction): Boolean;
  10431. /**
  10432. * Process a specific trigger
  10433. * @param trigger defines the trigger to process
  10434. * @param evt defines the event details to be processed
  10435. */
  10436. processTrigger(trigger: number, evt?: IActionEvent): void;
  10437. /** @hidden */
  10438. _getEffectiveTarget(target: any, propertyPath: string): any;
  10439. /** @hidden */
  10440. _getProperty(propertyPath: string): string;
  10441. /**
  10442. * Serialize this manager to a JSON object
  10443. * @param name defines the property name to store this manager
  10444. * @returns a JSON representation of this manager
  10445. */
  10446. serialize(name: string): any;
  10447. /**
  10448. * Creates a new ActionManager from a JSON data
  10449. * @param parsedActions defines the JSON data to read from
  10450. * @param object defines the hosting mesh
  10451. * @param scene defines the hosting scene
  10452. */
  10453. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10454. /**
  10455. * Get a trigger name by index
  10456. * @param trigger defines the trigger index
  10457. * @returns a trigger name
  10458. */
  10459. static GetTriggerName(trigger: number): string;
  10460. }
  10461. }
  10462. declare module "babylonjs/Sprites/sprite" {
  10463. import { Vector3 } from "babylonjs/Maths/math.vector";
  10464. import { Nullable } from "babylonjs/types";
  10465. import { ActionManager } from "babylonjs/Actions/actionManager";
  10466. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10467. import { Color4 } from "babylonjs/Maths/math.color";
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10470. import { Animation } from "babylonjs/Animations/animation";
  10471. /**
  10472. * Class used to represent a sprite
  10473. * @see https://doc.babylonjs.com/babylon101/sprites
  10474. */
  10475. export class Sprite implements IAnimatable {
  10476. /** defines the name */
  10477. name: string;
  10478. /** Gets or sets the current world position */
  10479. position: Vector3;
  10480. /** Gets or sets the main color */
  10481. color: Color4;
  10482. /** Gets or sets the width */
  10483. width: number;
  10484. /** Gets or sets the height */
  10485. height: number;
  10486. /** Gets or sets rotation angle */
  10487. angle: number;
  10488. /** Gets or sets the cell index in the sprite sheet */
  10489. cellIndex: number;
  10490. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10491. cellRef: string;
  10492. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10493. invertU: boolean;
  10494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10495. invertV: boolean;
  10496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10497. disposeWhenFinishedAnimating: boolean;
  10498. /** Gets the list of attached animations */
  10499. animations: Nullable<Array<Animation>>;
  10500. /** Gets or sets a boolean indicating if the sprite can be picked */
  10501. isPickable: boolean;
  10502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10503. useAlphaForPicking: boolean;
  10504. /** @hidden */
  10505. _xOffset: number;
  10506. /** @hidden */
  10507. _yOffset: number;
  10508. /** @hidden */
  10509. _xSize: number;
  10510. /** @hidden */
  10511. _ySize: number;
  10512. /**
  10513. * Gets or sets the associated action manager
  10514. */
  10515. actionManager: Nullable<ActionManager>;
  10516. /**
  10517. * An event triggered when the control has been disposed
  10518. */
  10519. onDisposeObservable: Observable<Sprite>;
  10520. private _animationStarted;
  10521. private _loopAnimation;
  10522. private _fromIndex;
  10523. private _toIndex;
  10524. private _delay;
  10525. private _direction;
  10526. private _manager;
  10527. private _time;
  10528. private _onAnimationEnd;
  10529. /**
  10530. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10531. */
  10532. isVisible: boolean;
  10533. /**
  10534. * Gets or sets the sprite size
  10535. */
  10536. get size(): number;
  10537. set size(value: number);
  10538. /**
  10539. * Returns a boolean indicating if the animation is started
  10540. */
  10541. get animationStarted(): boolean;
  10542. /**
  10543. * Gets or sets the unique id of the sprite
  10544. */
  10545. uniqueId: number;
  10546. /**
  10547. * Gets the manager of this sprite
  10548. */
  10549. get manager(): ISpriteManager;
  10550. /**
  10551. * Creates a new Sprite
  10552. * @param name defines the name
  10553. * @param manager defines the manager
  10554. */
  10555. constructor(
  10556. /** defines the name */
  10557. name: string, manager: ISpriteManager);
  10558. /**
  10559. * Returns the string "Sprite"
  10560. * @returns "Sprite"
  10561. */
  10562. getClassName(): string;
  10563. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10564. get fromIndex(): number;
  10565. set fromIndex(value: number);
  10566. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10567. get toIndex(): number;
  10568. set toIndex(value: number);
  10569. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10570. get loopAnimation(): boolean;
  10571. set loopAnimation(value: boolean);
  10572. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10573. get delay(): number;
  10574. set delay(value: number);
  10575. /**
  10576. * Starts an animation
  10577. * @param from defines the initial key
  10578. * @param to defines the end key
  10579. * @param loop defines if the animation must loop
  10580. * @param delay defines the start delay (in ms)
  10581. * @param onAnimationEnd defines a callback to call when animation ends
  10582. */
  10583. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10584. /** Stops current animation (if any) */
  10585. stopAnimation(): void;
  10586. /** @hidden */
  10587. _animate(deltaTime: number): void;
  10588. /** Release associated resources */
  10589. dispose(): void;
  10590. /**
  10591. * Serializes the sprite to a JSON object
  10592. * @returns the JSON object
  10593. */
  10594. serialize(): any;
  10595. /**
  10596. * Parses a JSON object to create a new sprite
  10597. * @param parsedSprite The JSON object to parse
  10598. * @param manager defines the hosting manager
  10599. * @returns the new sprite
  10600. */
  10601. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10602. }
  10603. }
  10604. declare module "babylonjs/Collisions/pickingInfo" {
  10605. import { Nullable } from "babylonjs/types";
  10606. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10608. import { Sprite } from "babylonjs/Sprites/sprite";
  10609. import { Ray } from "babylonjs/Culling/ray";
  10610. /**
  10611. * Information about the result of picking within a scene
  10612. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10613. */
  10614. export class PickingInfo {
  10615. /** @hidden */
  10616. _pickingUnavailable: boolean;
  10617. /**
  10618. * If the pick collided with an object
  10619. */
  10620. hit: boolean;
  10621. /**
  10622. * Distance away where the pick collided
  10623. */
  10624. distance: number;
  10625. /**
  10626. * The location of pick collision
  10627. */
  10628. pickedPoint: Nullable<Vector3>;
  10629. /**
  10630. * The mesh corresponding the the pick collision
  10631. */
  10632. pickedMesh: Nullable<AbstractMesh>;
  10633. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10634. bu: number;
  10635. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10636. bv: number;
  10637. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10638. faceId: number;
  10639. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10640. subMeshFaceId: number;
  10641. /** Id of the the submesh that was picked */
  10642. subMeshId: number;
  10643. /** If a sprite was picked, this will be the sprite the pick collided with */
  10644. pickedSprite: Nullable<Sprite>;
  10645. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10646. thinInstanceIndex: number;
  10647. /**
  10648. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10649. */
  10650. originMesh: Nullable<AbstractMesh>;
  10651. /**
  10652. * The ray that was used to perform the picking.
  10653. */
  10654. ray: Nullable<Ray>;
  10655. /**
  10656. * Gets the normal correspodning to the face the pick collided with
  10657. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10658. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10659. * @returns The normal correspodning to the face the pick collided with
  10660. */
  10661. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10662. /**
  10663. * Gets the texture coordinates of where the pick occured
  10664. * @returns the vector containing the coordnates of the texture
  10665. */
  10666. getTextureCoordinates(): Nullable<Vector2>;
  10667. }
  10668. }
  10669. declare module "babylonjs/Culling/ray" {
  10670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10677. import { Plane } from "babylonjs/Maths/math.plane";
  10678. /**
  10679. * Class representing a ray with position and direction
  10680. */
  10681. export class Ray {
  10682. /** origin point */
  10683. origin: Vector3;
  10684. /** direction */
  10685. direction: Vector3;
  10686. /** length of the ray */
  10687. length: number;
  10688. private static readonly _TmpVector3;
  10689. private _tmpRay;
  10690. /**
  10691. * Creates a new ray
  10692. * @param origin origin point
  10693. * @param direction direction
  10694. * @param length length of the ray
  10695. */
  10696. constructor(
  10697. /** origin point */
  10698. origin: Vector3,
  10699. /** direction */
  10700. direction: Vector3,
  10701. /** length of the ray */
  10702. length?: number);
  10703. /**
  10704. * Checks if the ray intersects a box
  10705. * This does not account for the ray lenght by design to improve perfs.
  10706. * @param minimum bound of the box
  10707. * @param maximum bound of the box
  10708. * @param intersectionTreshold extra extend to be added to the box in all direction
  10709. * @returns if the box was hit
  10710. */
  10711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10712. /**
  10713. * Checks if the ray intersects a box
  10714. * This does not account for the ray lenght by design to improve perfs.
  10715. * @param box the bounding box to check
  10716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10717. * @returns if the box was hit
  10718. */
  10719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10720. /**
  10721. * If the ray hits a sphere
  10722. * @param sphere the bounding sphere to check
  10723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10724. * @returns true if it hits the sphere
  10725. */
  10726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10727. /**
  10728. * If the ray hits a triange
  10729. * @param vertex0 triangle vertex
  10730. * @param vertex1 triangle vertex
  10731. * @param vertex2 triangle vertex
  10732. * @returns intersection information if hit
  10733. */
  10734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10735. /**
  10736. * Checks if ray intersects a plane
  10737. * @param plane the plane to check
  10738. * @returns the distance away it was hit
  10739. */
  10740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10741. /**
  10742. * Calculate the intercept of a ray on a given axis
  10743. * @param axis to check 'x' | 'y' | 'z'
  10744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10746. */
  10747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10748. /**
  10749. * Checks if ray intersects a mesh
  10750. * @param mesh the mesh to check
  10751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10752. * @returns picking info of the intersecton
  10753. */
  10754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10755. /**
  10756. * Checks if ray intersects a mesh
  10757. * @param meshes the meshes to check
  10758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10759. * @param results array to store result in
  10760. * @returns Array of picking infos
  10761. */
  10762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10763. private _comparePickingInfo;
  10764. private static smallnum;
  10765. private static rayl;
  10766. /**
  10767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10768. * @param sega the first point of the segment to test the intersection against
  10769. * @param segb the second point of the segment to test the intersection against
  10770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10772. */
  10773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10774. /**
  10775. * Update the ray from viewport position
  10776. * @param x position
  10777. * @param y y position
  10778. * @param viewportWidth viewport width
  10779. * @param viewportHeight viewport height
  10780. * @param world world matrix
  10781. * @param view view matrix
  10782. * @param projection projection matrix
  10783. * @returns this ray updated
  10784. */
  10785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10786. /**
  10787. * Creates a ray with origin and direction of 0,0,0
  10788. * @returns the new ray
  10789. */
  10790. static Zero(): Ray;
  10791. /**
  10792. * Creates a new ray from screen space and viewport
  10793. * @param x position
  10794. * @param y y position
  10795. * @param viewportWidth viewport width
  10796. * @param viewportHeight viewport height
  10797. * @param world world matrix
  10798. * @param view view matrix
  10799. * @param projection projection matrix
  10800. * @returns new ray
  10801. */
  10802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * 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
  10805. * transformed to the given world matrix.
  10806. * @param origin The origin point
  10807. * @param end The end point
  10808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10809. * @returns the new ray
  10810. */
  10811. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10812. /**
  10813. * Transforms a ray by a matrix
  10814. * @param ray ray to transform
  10815. * @param matrix matrix to apply
  10816. * @returns the resulting new ray
  10817. */
  10818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10819. /**
  10820. * Transforms a ray by a matrix
  10821. * @param ray ray to transform
  10822. * @param matrix matrix to apply
  10823. * @param result ray to store result in
  10824. */
  10825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10826. /**
  10827. * Unproject a ray from screen space to object space
  10828. * @param sourceX defines the screen space x coordinate to use
  10829. * @param sourceY defines the screen space y coordinate to use
  10830. * @param viewportWidth defines the current width of the viewport
  10831. * @param viewportHeight defines the current height of the viewport
  10832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10833. * @param view defines the view matrix to use
  10834. * @param projection defines the projection matrix to use
  10835. */
  10836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10837. }
  10838. /**
  10839. * Type used to define predicate used to select faces when a mesh intersection is detected
  10840. */
  10841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10842. module "babylonjs/scene" {
  10843. interface Scene {
  10844. /** @hidden */
  10845. _tempPickingRay: Nullable<Ray>;
  10846. /** @hidden */
  10847. _cachedRayForTransform: Ray;
  10848. /** @hidden */
  10849. _pickWithRayInverseMatrix: Matrix;
  10850. /** @hidden */
  10851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10852. /** @hidden */
  10853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10854. /** @hidden */
  10855. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10856. }
  10857. }
  10858. }
  10859. declare module "babylonjs/sceneComponent" {
  10860. import { Scene } from "babylonjs/scene";
  10861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10863. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10864. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10865. import { Nullable } from "babylonjs/types";
  10866. import { Camera } from "babylonjs/Cameras/camera";
  10867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10869. import { AbstractScene } from "babylonjs/abstractScene";
  10870. import { Mesh } from "babylonjs/Meshes/mesh";
  10871. /**
  10872. * Groups all the scene component constants in one place to ease maintenance.
  10873. * @hidden
  10874. */
  10875. export class SceneComponentConstants {
  10876. static readonly NAME_EFFECTLAYER: string;
  10877. static readonly NAME_LAYER: string;
  10878. static readonly NAME_LENSFLARESYSTEM: string;
  10879. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10880. static readonly NAME_PARTICLESYSTEM: string;
  10881. static readonly NAME_GAMEPAD: string;
  10882. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10883. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10884. static readonly NAME_PREPASSRENDERER: string;
  10885. static readonly NAME_DEPTHRENDERER: string;
  10886. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10887. static readonly NAME_SPRITE: string;
  10888. static readonly NAME_SUBSURFACE: string;
  10889. static readonly NAME_OUTLINERENDERER: string;
  10890. static readonly NAME_PROCEDURALTEXTURE: string;
  10891. static readonly NAME_SHADOWGENERATOR: string;
  10892. static readonly NAME_OCTREE: string;
  10893. static readonly NAME_PHYSICSENGINE: string;
  10894. static readonly NAME_AUDIO: string;
  10895. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10896. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10897. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10900. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10901. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10902. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10903. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10904. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10905. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10906. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10907. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10908. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10909. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10910. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10911. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10912. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10913. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10914. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10915. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10917. static readonly STEP_AFTERRENDER_AUDIO: number;
  10918. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10919. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10920. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10922. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10923. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10924. static readonly STEP_POINTERMOVE_SPRITE: number;
  10925. static readonly STEP_POINTERDOWN_SPRITE: number;
  10926. static readonly STEP_POINTERUP_SPRITE: number;
  10927. }
  10928. /**
  10929. * This represents a scene component.
  10930. *
  10931. * This is used to decouple the dependency the scene is having on the different workloads like
  10932. * layers, post processes...
  10933. */
  10934. export interface ISceneComponent {
  10935. /**
  10936. * The name of the component. Each component must have a unique name.
  10937. */
  10938. name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /**
  10944. * Register the component to one instance of a scene.
  10945. */
  10946. register(): void;
  10947. /**
  10948. * Rebuilds the elements related to this component in case of
  10949. * context lost for instance.
  10950. */
  10951. rebuild(): void;
  10952. /**
  10953. * Disposes the component and the associated ressources.
  10954. */
  10955. dispose(): void;
  10956. }
  10957. /**
  10958. * This represents a SERIALIZABLE scene component.
  10959. *
  10960. * This extends Scene Component to add Serialization methods on top.
  10961. */
  10962. export interface ISceneSerializableComponent extends ISceneComponent {
  10963. /**
  10964. * Adds all the elements from the container to the scene
  10965. * @param container the container holding the elements
  10966. */
  10967. addFromContainer(container: AbstractScene): void;
  10968. /**
  10969. * Removes all the elements in the container from the scene
  10970. * @param container contains the elements to remove
  10971. * @param dispose if the removed element should be disposed (default: false)
  10972. */
  10973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10974. /**
  10975. * Serializes the component data to the specified json object
  10976. * @param serializationObject The object to serialize to
  10977. */
  10978. serialize(serializationObject: any): void;
  10979. }
  10980. /**
  10981. * Strong typing of a Mesh related stage step action
  10982. */
  10983. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10984. /**
  10985. * Strong typing of a Evaluate Sub Mesh related stage step action
  10986. */
  10987. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10988. /**
  10989. * Strong typing of a Active Mesh related stage step action
  10990. */
  10991. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10992. /**
  10993. * Strong typing of a Camera related stage step action
  10994. */
  10995. export type CameraStageAction = (camera: Camera) => void;
  10996. /**
  10997. * Strong typing of a Camera Frame buffer related stage step action
  10998. */
  10999. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11000. /**
  11001. * Strong typing of a Render Target related stage step action
  11002. */
  11003. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11004. /**
  11005. * Strong typing of a RenderingGroup related stage step action
  11006. */
  11007. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11008. /**
  11009. * Strong typing of a Mesh Render related stage step action
  11010. */
  11011. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11012. /**
  11013. * Strong typing of a simple stage step action
  11014. */
  11015. export type SimpleStageAction = () => void;
  11016. /**
  11017. * Strong typing of a render target action.
  11018. */
  11019. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11020. /**
  11021. * Strong typing of a pointer move action.
  11022. */
  11023. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11024. /**
  11025. * Strong typing of a pointer up/down action.
  11026. */
  11027. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11028. /**
  11029. * Representation of a stage in the scene (Basically a list of ordered steps)
  11030. * @hidden
  11031. */
  11032. export class Stage<T extends Function> extends Array<{
  11033. index: number;
  11034. component: ISceneComponent;
  11035. action: T;
  11036. }> {
  11037. /**
  11038. * Hide ctor from the rest of the world.
  11039. * @param items The items to add.
  11040. */
  11041. private constructor();
  11042. /**
  11043. * Creates a new Stage.
  11044. * @returns A new instance of a Stage
  11045. */
  11046. static Create<T extends Function>(): Stage<T>;
  11047. /**
  11048. * Registers a step in an ordered way in the targeted stage.
  11049. * @param index Defines the position to register the step in
  11050. * @param component Defines the component attached to the step
  11051. * @param action Defines the action to launch during the step
  11052. */
  11053. registerStep(index: number, component: ISceneComponent, action: T): void;
  11054. /**
  11055. * Clears all the steps from the stage.
  11056. */
  11057. clear(): void;
  11058. }
  11059. }
  11060. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11061. import { Nullable } from "babylonjs/types";
  11062. import { Observable } from "babylonjs/Misc/observable";
  11063. import { Scene } from "babylonjs/scene";
  11064. import { Sprite } from "babylonjs/Sprites/sprite";
  11065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. import { Camera } from "babylonjs/Cameras/camera";
  11068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11069. import { ISceneComponent } from "babylonjs/sceneComponent";
  11070. module "babylonjs/scene" {
  11071. interface Scene {
  11072. /** @hidden */
  11073. _pointerOverSprite: Nullable<Sprite>;
  11074. /** @hidden */
  11075. _pickedDownSprite: Nullable<Sprite>;
  11076. /** @hidden */
  11077. _tempSpritePickingRay: Nullable<Ray>;
  11078. /**
  11079. * All of the sprite managers added to this scene
  11080. * @see https://doc.babylonjs.com/babylon101/sprites
  11081. */
  11082. spriteManagers: Array<ISpriteManager>;
  11083. /**
  11084. * An event triggered when sprites rendering is about to start
  11085. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11086. */
  11087. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11088. /**
  11089. * An event triggered when sprites rendering is done
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onAfterSpritesRenderingObservable: Observable<Scene>;
  11093. /** @hidden */
  11094. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Launch a ray to try to pick a sprite in the scene
  11096. * @param x position on screen
  11097. * @param y position on screen
  11098. * @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
  11099. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11100. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11101. * @returns a PickingInfo
  11102. */
  11103. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11104. /** Use the given ray to pick a sprite in the scene
  11105. * @param ray The ray (in world space) to use to pick meshes
  11106. * @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
  11107. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11108. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo
  11110. */
  11111. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11112. /** @hidden */
  11113. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11114. /** Launch a ray to try to pick sprites in the scene
  11115. * @param x position on screen
  11116. * @param y position on screen
  11117. * @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
  11118. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11119. * @returns a PickingInfo array
  11120. */
  11121. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11122. /** Use the given ray to pick sprites in the scene
  11123. * @param ray The ray (in world space) to use to pick meshes
  11124. * @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
  11125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11126. * @returns a PickingInfo array
  11127. */
  11128. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11129. /**
  11130. * Force the sprite under the pointer
  11131. * @param sprite defines the sprite to use
  11132. */
  11133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11134. /**
  11135. * Gets the sprite under the pointer
  11136. * @returns a Sprite or null if no sprite is under the pointer
  11137. */
  11138. getPointerOverSprite(): Nullable<Sprite>;
  11139. }
  11140. }
  11141. /**
  11142. * Defines the sprite scene component responsible to manage sprites
  11143. * in a given scene.
  11144. */
  11145. export class SpriteSceneComponent implements ISceneComponent {
  11146. /**
  11147. * The component name helpfull to identify the component in the list of scene components.
  11148. */
  11149. readonly name: string;
  11150. /**
  11151. * The scene the component belongs to.
  11152. */
  11153. scene: Scene;
  11154. /** @hidden */
  11155. private _spritePredicate;
  11156. /**
  11157. * Creates a new instance of the component for the given scene
  11158. * @param scene Defines the scene to register the component in
  11159. */
  11160. constructor(scene: Scene);
  11161. /**
  11162. * Registers the component in a given scene
  11163. */
  11164. register(): void;
  11165. /**
  11166. * Rebuilds the elements related to this component in case of
  11167. * context lost for instance.
  11168. */
  11169. rebuild(): void;
  11170. /**
  11171. * Disposes the component and the associated ressources.
  11172. */
  11173. dispose(): void;
  11174. private _pickSpriteButKeepRay;
  11175. private _pointerMove;
  11176. private _pointerDown;
  11177. private _pointerUp;
  11178. }
  11179. }
  11180. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11181. /** @hidden */
  11182. export var fogFragmentDeclaration: {
  11183. name: string;
  11184. shader: string;
  11185. };
  11186. }
  11187. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11188. /** @hidden */
  11189. export var fogFragment: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/sprites.fragment" {
  11195. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11196. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11197. /** @hidden */
  11198. export var spritesPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11204. /** @hidden */
  11205. export var fogVertexDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module "babylonjs/Shaders/sprites.vertex" {
  11211. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11212. /** @hidden */
  11213. export var spritesVertexShader: {
  11214. name: string;
  11215. shader: string;
  11216. };
  11217. }
  11218. declare module "babylonjs/Sprites/spriteManager" {
  11219. import { IDisposable, Scene } from "babylonjs/scene";
  11220. import { Nullable } from "babylonjs/types";
  11221. import { Observable } from "babylonjs/Misc/observable";
  11222. import { Sprite } from "babylonjs/Sprites/sprite";
  11223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { Texture } from "babylonjs/Materials/Textures/texture";
  11226. import "babylonjs/Shaders/sprites.fragment";
  11227. import "babylonjs/Shaders/sprites.vertex";
  11228. import { Ray } from "babylonjs/Culling/ray";
  11229. /**
  11230. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11231. */
  11232. export interface ISpriteManager extends IDisposable {
  11233. /**
  11234. * Gets manager's name
  11235. */
  11236. name: string;
  11237. /**
  11238. * Restricts the camera to viewing objects with the same layerMask.
  11239. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11240. */
  11241. layerMask: number;
  11242. /**
  11243. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11244. */
  11245. isPickable: boolean;
  11246. /**
  11247. * Gets the hosting scene
  11248. */
  11249. scene: Scene;
  11250. /**
  11251. * Specifies the rendering group id for this mesh (0 by default)
  11252. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11253. */
  11254. renderingGroupId: number;
  11255. /**
  11256. * Defines the list of sprites managed by the manager.
  11257. */
  11258. sprites: Array<Sprite>;
  11259. /**
  11260. * Gets or sets the spritesheet texture
  11261. */
  11262. texture: Texture;
  11263. /** Defines the default width of a cell in the spritesheet */
  11264. cellWidth: number;
  11265. /** Defines the default height of a cell in the spritesheet */
  11266. cellHeight: number;
  11267. /**
  11268. * Tests the intersection of a sprite with a specific ray.
  11269. * @param ray The ray we are sending to test the collision
  11270. * @param camera The camera space we are sending rays in
  11271. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11272. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11273. * @returns picking info or null.
  11274. */
  11275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11276. /**
  11277. * Intersects the sprites with a ray
  11278. * @param ray defines the ray to intersect with
  11279. * @param camera defines the current active camera
  11280. * @param predicate defines a predicate used to select candidate sprites
  11281. * @returns null if no hit or a PickingInfo array
  11282. */
  11283. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11284. /**
  11285. * Renders the list of sprites on screen.
  11286. */
  11287. render(): void;
  11288. }
  11289. /**
  11290. * Class used to manage multiple sprites on the same spritesheet
  11291. * @see https://doc.babylonjs.com/babylon101/sprites
  11292. */
  11293. export class SpriteManager implements ISpriteManager {
  11294. /** defines the manager's name */
  11295. name: string;
  11296. /** Define the Url to load snippets */
  11297. static SnippetUrl: string;
  11298. /** Snippet ID if the manager was created from the snippet server */
  11299. snippetId: string;
  11300. /** Gets the list of sprites */
  11301. sprites: Sprite[];
  11302. /** Gets or sets the rendering group id (0 by default) */
  11303. renderingGroupId: number;
  11304. /** Gets or sets camera layer mask */
  11305. layerMask: number;
  11306. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11307. fogEnabled: boolean;
  11308. /** Gets or sets a boolean indicating if the sprites are pickable */
  11309. isPickable: boolean;
  11310. /** Defines the default width of a cell in the spritesheet */
  11311. cellWidth: number;
  11312. /** Defines the default height of a cell in the spritesheet */
  11313. cellHeight: number;
  11314. /** Associative array from JSON sprite data file */
  11315. private _cellData;
  11316. /** Array of sprite names from JSON sprite data file */
  11317. private _spriteMap;
  11318. /** True when packed cell data from JSON file is ready*/
  11319. private _packedAndReady;
  11320. private _textureContent;
  11321. private _useInstancing;
  11322. /**
  11323. * An event triggered when the manager is disposed.
  11324. */
  11325. onDisposeObservable: Observable<SpriteManager>;
  11326. private _onDisposeObserver;
  11327. /**
  11328. * Callback called when the manager is disposed
  11329. */
  11330. set onDispose(callback: () => void);
  11331. private _capacity;
  11332. private _fromPacked;
  11333. private _spriteTexture;
  11334. private _epsilon;
  11335. private _scene;
  11336. private _vertexData;
  11337. private _buffer;
  11338. private _vertexBuffers;
  11339. private _spriteBuffer;
  11340. private _indexBuffer;
  11341. private _effectBase;
  11342. private _effectFog;
  11343. private _vertexBufferSize;
  11344. /**
  11345. * Gets or sets the unique id of the sprite
  11346. */
  11347. uniqueId: number;
  11348. /**
  11349. * Gets the array of sprites
  11350. */
  11351. get children(): Sprite[];
  11352. /**
  11353. * Gets the hosting scene
  11354. */
  11355. get scene(): Scene;
  11356. /**
  11357. * Gets the capacity of the manager
  11358. */
  11359. get capacity(): number;
  11360. /**
  11361. * Gets or sets the spritesheet texture
  11362. */
  11363. get texture(): Texture;
  11364. set texture(value: Texture);
  11365. private _blendMode;
  11366. /**
  11367. * Blend mode use to render the particle, it can be any of
  11368. * the static Constants.ALPHA_x properties provided in this class.
  11369. * Default value is Constants.ALPHA_COMBINE
  11370. */
  11371. get blendMode(): number;
  11372. set blendMode(blendMode: number);
  11373. /** Disables writing to the depth buffer when rendering the sprites.
  11374. * It can be handy to disable depth writing when using textures without alpha channel
  11375. * and setting some specific blend modes.
  11376. */
  11377. disableDepthWrite: boolean;
  11378. /**
  11379. * Creates a new sprite manager
  11380. * @param name defines the manager's name
  11381. * @param imgUrl defines the sprite sheet url
  11382. * @param capacity defines the maximum allowed number of sprites
  11383. * @param cellSize defines the size of a sprite cell
  11384. * @param scene defines the hosting scene
  11385. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11386. * @param samplingMode defines the smapling mode to use with spritesheet
  11387. * @param fromPacked set to false; do not alter
  11388. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11389. */
  11390. constructor(
  11391. /** defines the manager's name */
  11392. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11393. /**
  11394. * Returns the string "SpriteManager"
  11395. * @returns "SpriteManager"
  11396. */
  11397. getClassName(): string;
  11398. private _makePacked;
  11399. private _appendSpriteVertex;
  11400. private _checkTextureAlpha;
  11401. /**
  11402. * Intersects the sprites with a ray
  11403. * @param ray defines the ray to intersect with
  11404. * @param camera defines the current active camera
  11405. * @param predicate defines a predicate used to select candidate sprites
  11406. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11407. * @returns null if no hit or a PickingInfo
  11408. */
  11409. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11410. /**
  11411. * Intersects the sprites with a ray
  11412. * @param ray defines the ray to intersect with
  11413. * @param camera defines the current active camera
  11414. * @param predicate defines a predicate used to select candidate sprites
  11415. * @returns null if no hit or a PickingInfo array
  11416. */
  11417. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11418. /**
  11419. * Render all child sprites
  11420. */
  11421. render(): void;
  11422. /**
  11423. * Release associated resources
  11424. */
  11425. dispose(): void;
  11426. /**
  11427. * Serializes the sprite manager to a JSON object
  11428. * @param serializeTexture defines if the texture must be serialized as well
  11429. * @returns the JSON object
  11430. */
  11431. serialize(serializeTexture?: boolean): any;
  11432. /**
  11433. * Parses a JSON object to create a new sprite manager.
  11434. * @param parsedManager The JSON object to parse
  11435. * @param scene The scene to create the sprite managerin
  11436. * @param rootUrl The root url to use to load external dependencies like texture
  11437. * @returns the new sprite manager
  11438. */
  11439. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11440. /**
  11441. * Creates a sprite manager from a snippet saved in a remote file
  11442. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11443. * @param url defines the url to load from
  11444. * @param scene defines the hosting scene
  11445. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11446. * @returns a promise that will resolve to the new sprite manager
  11447. */
  11448. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11449. /**
  11450. * Creates a sprite manager from a snippet saved by the sprite editor
  11451. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11452. * @param scene defines the hosting scene
  11453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11454. * @returns a promise that will resolve to the new sprite manager
  11455. */
  11456. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11457. }
  11458. }
  11459. declare module "babylonjs/Misc/gradients" {
  11460. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11461. /** Interface used by value gradients (color, factor, ...) */
  11462. export interface IValueGradient {
  11463. /**
  11464. * Gets or sets the gradient value (between 0 and 1)
  11465. */
  11466. gradient: number;
  11467. }
  11468. /** Class used to store color4 gradient */
  11469. export class ColorGradient implements IValueGradient {
  11470. /**
  11471. * Gets or sets the gradient value (between 0 and 1)
  11472. */
  11473. gradient: number;
  11474. /**
  11475. * Gets or sets first associated color
  11476. */
  11477. color1: Color4;
  11478. /**
  11479. * Gets or sets second associated color
  11480. */
  11481. color2?: Color4 | undefined;
  11482. /**
  11483. * Creates a new color4 gradient
  11484. * @param gradient gets or sets the gradient value (between 0 and 1)
  11485. * @param color1 gets or sets first associated color
  11486. * @param color2 gets or sets first second color
  11487. */
  11488. constructor(
  11489. /**
  11490. * Gets or sets the gradient value (between 0 and 1)
  11491. */
  11492. gradient: number,
  11493. /**
  11494. * Gets or sets first associated color
  11495. */
  11496. color1: Color4,
  11497. /**
  11498. * Gets or sets second associated color
  11499. */
  11500. color2?: Color4 | undefined);
  11501. /**
  11502. * Will get a color picked randomly between color1 and color2.
  11503. * If color2 is undefined then color1 will be used
  11504. * @param result defines the target Color4 to store the result in
  11505. */
  11506. getColorToRef(result: Color4): void;
  11507. }
  11508. /** Class used to store color 3 gradient */
  11509. export class Color3Gradient implements IValueGradient {
  11510. /**
  11511. * Gets or sets the gradient value (between 0 and 1)
  11512. */
  11513. gradient: number;
  11514. /**
  11515. * Gets or sets the associated color
  11516. */
  11517. color: Color3;
  11518. /**
  11519. * Creates a new color3 gradient
  11520. * @param gradient gets or sets the gradient value (between 0 and 1)
  11521. * @param color gets or sets associated color
  11522. */
  11523. constructor(
  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. /** Class used to store factor gradient */
  11534. export class FactorGradient implements IValueGradient {
  11535. /**
  11536. * Gets or sets the gradient value (between 0 and 1)
  11537. */
  11538. gradient: number;
  11539. /**
  11540. * Gets or sets first associated factor
  11541. */
  11542. factor1: number;
  11543. /**
  11544. * Gets or sets second associated factor
  11545. */
  11546. factor2?: number | undefined;
  11547. /**
  11548. * Creates a new factor gradient
  11549. * @param gradient gets or sets the gradient value (between 0 and 1)
  11550. * @param factor1 gets or sets first associated factor
  11551. * @param factor2 gets or sets second associated factor
  11552. */
  11553. constructor(
  11554. /**
  11555. * Gets or sets the gradient value (between 0 and 1)
  11556. */
  11557. gradient: number,
  11558. /**
  11559. * Gets or sets first associated factor
  11560. */
  11561. factor1: number,
  11562. /**
  11563. * Gets or sets second associated factor
  11564. */
  11565. factor2?: number | undefined);
  11566. /**
  11567. * Will get a number picked randomly between factor1 and factor2.
  11568. * If factor2 is undefined then factor1 will be used
  11569. * @returns the picked number
  11570. */
  11571. getFactor(): number;
  11572. }
  11573. /**
  11574. * Helper used to simplify some generic gradient tasks
  11575. */
  11576. export class GradientHelper {
  11577. /**
  11578. * Gets the current gradient from an array of IValueGradient
  11579. * @param ratio defines the current ratio to get
  11580. * @param gradients defines the array of IValueGradient
  11581. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11582. */
  11583. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11584. }
  11585. }
  11586. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11587. import { Nullable } from "babylonjs/types";
  11588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11589. import { Scene } from "babylonjs/scene";
  11590. module "babylonjs/Engines/thinEngine" {
  11591. interface ThinEngine {
  11592. /**
  11593. * Creates a raw texture
  11594. * @param data defines the data to store in the texture
  11595. * @param width defines the width of the texture
  11596. * @param height defines the height of the texture
  11597. * @param format defines the format of the data
  11598. * @param generateMipMaps defines if the engine should generate the mip levels
  11599. * @param invertY defines if data must be stored with Y axis inverted
  11600. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11601. * @param compression defines the compression used (null by default)
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @returns the raw texture inside an InternalTexture
  11604. */
  11605. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11606. /**
  11607. * Update a raw texture
  11608. * @param texture defines the texture to update
  11609. * @param data defines the data to store in the texture
  11610. * @param format defines the format of the data
  11611. * @param invertY defines if data must be stored with Y axis inverted
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11614. /**
  11615. * Update a raw texture
  11616. * @param texture defines the texture to update
  11617. * @param data defines the data to store in the texture
  11618. * @param format defines the format of the data
  11619. * @param invertY defines if data must be stored with Y axis inverted
  11620. * @param compression defines the compression used (null by default)
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. */
  11623. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11624. /**
  11625. * Creates a new raw cube texture
  11626. * @param data defines the array of data to use to create each face
  11627. * @param size defines the size of the textures
  11628. * @param format defines the format of the data
  11629. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11630. * @param generateMipMaps defines if the engine should generate the mip levels
  11631. * @param invertY defines if data must be stored with Y axis inverted
  11632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11633. * @param compression defines the compression used (null by default)
  11634. * @returns the cube texture as an InternalTexture
  11635. */
  11636. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11637. /**
  11638. * Update a raw cube texture
  11639. * @param texture defines the texture to udpdate
  11640. * @param data defines the data to store
  11641. * @param format defines the data format
  11642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11643. * @param invertY defines if data must be stored with Y axis inverted
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. */
  11655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11656. /**
  11657. * Update a raw cube texture
  11658. * @param texture defines the texture to udpdate
  11659. * @param data defines the data to store
  11660. * @param format defines the data format
  11661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param compression defines the compression used (null by default)
  11664. * @param level defines which level of the texture to update
  11665. */
  11666. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11667. /**
  11668. * Creates a new raw cube texture from a specified url
  11669. * @param url defines the url where the data is located
  11670. * @param scene defines the current scene
  11671. * @param size defines the size of the textures
  11672. * @param format defines the format of the data
  11673. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11674. * @param noMipmap defines if the engine should avoid generating the mip levels
  11675. * @param callback defines a callback used to extract texture data from loaded data
  11676. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11677. * @param onLoad defines a callback called when texture is loaded
  11678. * @param onError defines a callback called if there is an error
  11679. * @returns the cube texture as an InternalTexture
  11680. */
  11681. 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;
  11682. /**
  11683. * Creates a new raw cube texture from a specified url
  11684. * @param url defines the url where the data is located
  11685. * @param scene defines the current scene
  11686. * @param size defines the size of the textures
  11687. * @param format defines the format of the data
  11688. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11689. * @param noMipmap defines if the engine should avoid generating the mip levels
  11690. * @param callback defines a callback used to extract texture data from loaded data
  11691. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11692. * @param onLoad defines a callback called when texture is loaded
  11693. * @param onError defines a callback called if there is an error
  11694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11695. * @param invertY defines if data must be stored with Y axis inverted
  11696. * @returns the cube texture as an InternalTexture
  11697. */
  11698. 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;
  11699. /**
  11700. * Creates a new raw 3D texture
  11701. * @param data defines the data used to create the texture
  11702. * @param width defines the width of the texture
  11703. * @param height defines the height of the texture
  11704. * @param depth defines the depth of the texture
  11705. * @param format defines the format of the texture
  11706. * @param generateMipMaps defines if the engine must generate mip levels
  11707. * @param invertY defines if data must be stored with Y axis inverted
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param compression defines the compressed used (can be null)
  11710. * @param textureType defines the compressed used (can be null)
  11711. * @returns a new raw 3D texture (stored in an InternalTexture)
  11712. */
  11713. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11714. /**
  11715. * Update a raw 3D texture
  11716. * @param texture defines the texture to update
  11717. * @param data defines the data to store
  11718. * @param format defines the data format
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11722. /**
  11723. * Update a raw 3D texture
  11724. * @param texture defines the texture to update
  11725. * @param data defines the data to store
  11726. * @param format defines the data format
  11727. * @param invertY defines if data must be stored with Y axis inverted
  11728. * @param compression defines the used compression (can be null)
  11729. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11730. */
  11731. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11732. /**
  11733. * Creates a new raw 2D array texture
  11734. * @param data defines the data used to create the texture
  11735. * @param width defines the width of the texture
  11736. * @param height defines the height of the texture
  11737. * @param depth defines the number of layers of the texture
  11738. * @param format defines the format of the texture
  11739. * @param generateMipMaps defines if the engine must generate mip levels
  11740. * @param invertY defines if data must be stored with Y axis inverted
  11741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11742. * @param compression defines the compressed used (can be null)
  11743. * @param textureType defines the compressed used (can be null)
  11744. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11745. */
  11746. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11747. /**
  11748. * Update a raw 2D array texture
  11749. * @param texture defines the texture to update
  11750. * @param data defines the data to store
  11751. * @param format defines the data format
  11752. * @param invertY defines if data must be stored with Y axis inverted
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11755. /**
  11756. * Update a raw 2D array texture
  11757. * @param texture defines the texture to update
  11758. * @param data defines the data to store
  11759. * @param format defines the data format
  11760. * @param invertY defines if data must be stored with Y axis inverted
  11761. * @param compression defines the used compression (can be null)
  11762. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11763. */
  11764. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11765. }
  11766. }
  11767. }
  11768. declare module "babylonjs/Materials/Textures/rawTexture" {
  11769. import { Texture } from "babylonjs/Materials/Textures/texture";
  11770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11771. import { Nullable } from "babylonjs/types";
  11772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11773. import { Scene } from "babylonjs/scene";
  11774. /**
  11775. * Raw texture can help creating a texture directly from an array of data.
  11776. * This can be super useful if you either get the data from an uncompressed source or
  11777. * if you wish to create your texture pixel by pixel.
  11778. */
  11779. export class RawTexture extends Texture {
  11780. /**
  11781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11782. */
  11783. format: number;
  11784. /**
  11785. * Instantiates a new RawTexture.
  11786. * Raw texture can help creating a texture directly from an array of data.
  11787. * This can be super useful if you either get the data from an uncompressed source or
  11788. * if you wish to create your texture pixel by pixel.
  11789. * @param data define the array of data to use to create the texture
  11790. * @param width define the width of the texture
  11791. * @param height define the height of the texture
  11792. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11793. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11794. * @param generateMipMaps define whether mip maps should be generated or not
  11795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11798. */
  11799. constructor(data: ArrayBufferView, width: number, height: number,
  11800. /**
  11801. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11802. */
  11803. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11804. /**
  11805. * Updates the texture underlying data.
  11806. * @param data Define the new data of the texture
  11807. */
  11808. update(data: ArrayBufferView): void;
  11809. /**
  11810. * Creates a luminance texture from some data.
  11811. * @param data Define the texture data
  11812. * @param width Define the width of the texture
  11813. * @param height Define the height of the texture
  11814. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11818. * @returns the luminance texture
  11819. */
  11820. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11821. /**
  11822. * Creates a luminance alpha texture from some data.
  11823. * @param data Define the texture data
  11824. * @param width Define the width of the texture
  11825. * @param height Define the height of the texture
  11826. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11830. * @returns the luminance alpha texture
  11831. */
  11832. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11833. /**
  11834. * Creates an alpha texture from some data.
  11835. * @param data Define the texture data
  11836. * @param width Define the width of the texture
  11837. * @param height Define the height of the texture
  11838. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11842. * @returns the alpha texture
  11843. */
  11844. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11845. /**
  11846. * Creates a RGB texture from some data.
  11847. * @param data Define the texture data
  11848. * @param width Define the width of the texture
  11849. * @param height Define the height of the texture
  11850. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11855. * @returns the RGB alpha texture
  11856. */
  11857. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11858. /**
  11859. * Creates a RGBA texture from some data.
  11860. * @param data Define the texture data
  11861. * @param width Define the width of the texture
  11862. * @param height Define the height of the texture
  11863. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11868. * @returns the RGBA texture
  11869. */
  11870. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11871. /**
  11872. * Creates a R texture from some data.
  11873. * @param data Define the texture data
  11874. * @param width Define the width of the texture
  11875. * @param height Define the height of the texture
  11876. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11880. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11881. * @returns the R texture
  11882. */
  11883. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11884. }
  11885. }
  11886. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11887. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11888. import { IndicesArray, DataArray } from "babylonjs/types";
  11889. module "babylonjs/Engines/thinEngine" {
  11890. interface ThinEngine {
  11891. /**
  11892. * Update a dynamic index buffer
  11893. * @param indexBuffer defines the target index buffer
  11894. * @param indices defines the data to update
  11895. * @param offset defines the offset in the target index buffer where update should start
  11896. */
  11897. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11898. /**
  11899. * Updates a dynamic vertex buffer.
  11900. * @param vertexBuffer the vertex buffer to update
  11901. * @param data the data used to update the vertex buffer
  11902. * @param byteOffset the byte offset of the data
  11903. * @param byteLength the byte length of the data
  11904. */
  11905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11906. }
  11907. }
  11908. }
  11909. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11910. import { Scene } from "babylonjs/scene";
  11911. import { ISceneComponent } from "babylonjs/sceneComponent";
  11912. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11913. module "babylonjs/abstractScene" {
  11914. interface AbstractScene {
  11915. /**
  11916. * The list of procedural textures added to the scene
  11917. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11918. */
  11919. proceduralTextures: Array<ProceduralTexture>;
  11920. }
  11921. }
  11922. /**
  11923. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11924. * in a given scene.
  11925. */
  11926. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11927. /**
  11928. * The component name helpfull to identify the component in the list of scene components.
  11929. */
  11930. readonly name: string;
  11931. /**
  11932. * The scene the component belongs to.
  11933. */
  11934. scene: Scene;
  11935. /**
  11936. * Creates a new instance of the component for the given scene
  11937. * @param scene Defines the scene to register the component in
  11938. */
  11939. constructor(scene: Scene);
  11940. /**
  11941. * Registers the component in a given scene
  11942. */
  11943. register(): void;
  11944. /**
  11945. * Rebuilds the elements related to this component in case of
  11946. * context lost for instance.
  11947. */
  11948. rebuild(): void;
  11949. /**
  11950. * Disposes the component and the associated ressources.
  11951. */
  11952. dispose(): void;
  11953. private _beforeClear;
  11954. }
  11955. }
  11956. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11958. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11959. module "babylonjs/Engines/thinEngine" {
  11960. interface ThinEngine {
  11961. /**
  11962. * Creates a new render target cube texture
  11963. * @param size defines the size of the texture
  11964. * @param options defines the options used to create the texture
  11965. * @returns a new render target cube texture stored in an InternalTexture
  11966. */
  11967. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11968. }
  11969. }
  11970. }
  11971. declare module "babylonjs/Shaders/procedural.vertex" {
  11972. /** @hidden */
  11973. export var proceduralVertexShader: {
  11974. name: string;
  11975. shader: string;
  11976. };
  11977. }
  11978. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11979. import { Observable } from "babylonjs/Misc/observable";
  11980. import { Nullable } from "babylonjs/types";
  11981. import { Scene } from "babylonjs/scene";
  11982. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11984. import { Effect } from "babylonjs/Materials/effect";
  11985. import { Texture } from "babylonjs/Materials/Textures/texture";
  11986. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11987. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11988. import "babylonjs/Shaders/procedural.vertex";
  11989. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11990. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11991. /**
  11992. * 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.
  11993. * This is the base class of any Procedural texture and contains most of the shareable code.
  11994. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11995. */
  11996. export class ProceduralTexture extends Texture {
  11997. /**
  11998. * Define if the texture is enabled or not (disabled texture will not render)
  11999. */
  12000. isEnabled: boolean;
  12001. /**
  12002. * Define if the texture must be cleared before rendering (default is true)
  12003. */
  12004. autoClear: boolean;
  12005. /**
  12006. * Callback called when the texture is generated
  12007. */
  12008. onGenerated: () => void;
  12009. /**
  12010. * Event raised when the texture is generated
  12011. */
  12012. onGeneratedObservable: Observable<ProceduralTexture>;
  12013. /**
  12014. * Event raised before the texture is generated
  12015. */
  12016. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12017. /**
  12018. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12019. */
  12020. nodeMaterialSource: Nullable<NodeMaterial>;
  12021. /** @hidden */
  12022. _generateMipMaps: boolean;
  12023. /** @hidden **/
  12024. _effect: Effect;
  12025. /** @hidden */
  12026. _textures: {
  12027. [key: string]: Texture;
  12028. };
  12029. /** @hidden */
  12030. protected _fallbackTexture: Nullable<Texture>;
  12031. private _size;
  12032. private _currentRefreshId;
  12033. private _frameId;
  12034. private _refreshRate;
  12035. private _vertexBuffers;
  12036. private _indexBuffer;
  12037. private _uniforms;
  12038. private _samplers;
  12039. private _fragment;
  12040. private _floats;
  12041. private _ints;
  12042. private _floatsArrays;
  12043. private _colors3;
  12044. private _colors4;
  12045. private _vectors2;
  12046. private _vectors3;
  12047. private _matrices;
  12048. private _fallbackTextureUsed;
  12049. private _fullEngine;
  12050. private _cachedDefines;
  12051. private _contentUpdateId;
  12052. private _contentData;
  12053. /**
  12054. * Instantiates a new procedural texture.
  12055. * 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.
  12056. * This is the base class of any Procedural texture and contains most of the shareable code.
  12057. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12058. * @param name Define the name of the texture
  12059. * @param size Define the size of the texture to create
  12060. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12061. * @param scene Define the scene the texture belongs to
  12062. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12063. * @param generateMipMaps Define if the texture should creates mip maps or not
  12064. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12065. */
  12066. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12067. /**
  12068. * The effect that is created when initializing the post process.
  12069. * @returns The created effect corresponding the the postprocess.
  12070. */
  12071. getEffect(): Effect;
  12072. /**
  12073. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12074. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12075. */
  12076. getContent(): Nullable<ArrayBufferView>;
  12077. private _createIndexBuffer;
  12078. /** @hidden */
  12079. _rebuild(): void;
  12080. /**
  12081. * Resets the texture in order to recreate its associated resources.
  12082. * This can be called in case of context loss
  12083. */
  12084. reset(): void;
  12085. protected _getDefines(): string;
  12086. /**
  12087. * Is the texture ready to be used ? (rendered at least once)
  12088. * @returns true if ready, otherwise, false.
  12089. */
  12090. isReady(): boolean;
  12091. /**
  12092. * Resets the refresh counter of the texture and start bak from scratch.
  12093. * Could be useful to regenerate the texture if it is setup to render only once.
  12094. */
  12095. resetRefreshCounter(): void;
  12096. /**
  12097. * Set the fragment shader to use in order to render the texture.
  12098. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12099. */
  12100. setFragment(fragment: any): void;
  12101. /**
  12102. * Define the refresh rate of the texture or the rendering frequency.
  12103. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12104. */
  12105. get refreshRate(): number;
  12106. set refreshRate(value: number);
  12107. /** @hidden */
  12108. _shouldRender(): boolean;
  12109. /**
  12110. * Get the size the texture is rendering at.
  12111. * @returns the size (on cube texture it is always squared)
  12112. */
  12113. getRenderSize(): RenderTargetTextureSize;
  12114. /**
  12115. * Resize the texture to new value.
  12116. * @param size Define the new size the texture should have
  12117. * @param generateMipMaps Define whether the new texture should create mip maps
  12118. */
  12119. resize(size: number, generateMipMaps: boolean): void;
  12120. private _checkUniform;
  12121. /**
  12122. * Set a texture in the shader program used to render.
  12123. * @param name Define the name of the uniform samplers as defined in the shader
  12124. * @param texture Define the texture to bind to this sampler
  12125. * @return the texture itself allowing "fluent" like uniform updates
  12126. */
  12127. setTexture(name: string, texture: Texture): ProceduralTexture;
  12128. /**
  12129. * Set a float in the shader.
  12130. * @param name Define the name of the uniform as defined in the shader
  12131. * @param value Define the value to give to the uniform
  12132. * @return the texture itself allowing "fluent" like uniform updates
  12133. */
  12134. setFloat(name: string, value: number): ProceduralTexture;
  12135. /**
  12136. * Set a int in the shader.
  12137. * @param name Define the name of the uniform as defined in the shader
  12138. * @param value Define the value to give to the uniform
  12139. * @return the texture itself allowing "fluent" like uniform updates
  12140. */
  12141. setInt(name: string, value: number): ProceduralTexture;
  12142. /**
  12143. * Set an array of floats in the shader.
  12144. * @param name Define the name of the uniform as defined in the shader
  12145. * @param value Define the value to give to the uniform
  12146. * @return the texture itself allowing "fluent" like uniform updates
  12147. */
  12148. setFloats(name: string, value: number[]): ProceduralTexture;
  12149. /**
  12150. * Set a vec3 in the shader from a Color3.
  12151. * @param name Define the name of the uniform as defined in the shader
  12152. * @param value Define the value to give to the uniform
  12153. * @return the texture itself allowing "fluent" like uniform updates
  12154. */
  12155. setColor3(name: string, value: Color3): ProceduralTexture;
  12156. /**
  12157. * Set a vec4 in the shader from a Color4.
  12158. * @param name Define the name of the uniform as defined in the shader
  12159. * @param value Define the value to give to the uniform
  12160. * @return the texture itself allowing "fluent" like uniform updates
  12161. */
  12162. setColor4(name: string, value: Color4): ProceduralTexture;
  12163. /**
  12164. * Set a vec2 in the shader from a Vector2.
  12165. * @param name Define the name of the uniform as defined in the shader
  12166. * @param value Define the value to give to the uniform
  12167. * @return the texture itself allowing "fluent" like uniform updates
  12168. */
  12169. setVector2(name: string, value: Vector2): ProceduralTexture;
  12170. /**
  12171. * Set a vec3 in the shader from a Vector3.
  12172. * @param name Define the name of the uniform as defined in the shader
  12173. * @param value Define the value to give to the uniform
  12174. * @return the texture itself allowing "fluent" like uniform updates
  12175. */
  12176. setVector3(name: string, value: Vector3): ProceduralTexture;
  12177. /**
  12178. * Set a mat4 in the shader from a MAtrix.
  12179. * @param name Define the name of the uniform as defined in the shader
  12180. * @param value Define the value to give to the uniform
  12181. * @return the texture itself allowing "fluent" like uniform updates
  12182. */
  12183. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12184. /**
  12185. * Render the texture to its associated render target.
  12186. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12187. */
  12188. render(useCameraPostProcess?: boolean): void;
  12189. /**
  12190. * Clone the texture.
  12191. * @returns the cloned texture
  12192. */
  12193. clone(): ProceduralTexture;
  12194. /**
  12195. * Dispose the texture and release its asoociated resources.
  12196. */
  12197. dispose(): void;
  12198. }
  12199. }
  12200. declare module "babylonjs/Particles/baseParticleSystem" {
  12201. import { Nullable } from "babylonjs/types";
  12202. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12204. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12205. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12206. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12207. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12208. import { Color4 } from "babylonjs/Maths/math.color";
  12209. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12210. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12211. import { Animation } from "babylonjs/Animations/animation";
  12212. import { Scene } from "babylonjs/scene";
  12213. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12214. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12215. /**
  12216. * This represents the base class for particle system in Babylon.
  12217. * 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.
  12218. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12219. * @example https://doc.babylonjs.com/babylon101/particles
  12220. */
  12221. export class BaseParticleSystem {
  12222. /**
  12223. * Source color is added to the destination color without alpha affecting the result
  12224. */
  12225. static BLENDMODE_ONEONE: number;
  12226. /**
  12227. * Blend current color and particle color using particle’s alpha
  12228. */
  12229. static BLENDMODE_STANDARD: number;
  12230. /**
  12231. * Add current color and particle color multiplied by particle’s alpha
  12232. */
  12233. static BLENDMODE_ADD: number;
  12234. /**
  12235. * Multiply current color with particle color
  12236. */
  12237. static BLENDMODE_MULTIPLY: number;
  12238. /**
  12239. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12240. */
  12241. static BLENDMODE_MULTIPLYADD: number;
  12242. /**
  12243. * List of animations used by the particle system.
  12244. */
  12245. animations: Animation[];
  12246. /**
  12247. * Gets or sets the unique id of the particle system
  12248. */
  12249. uniqueId: number;
  12250. /**
  12251. * The id of the Particle system.
  12252. */
  12253. id: string;
  12254. /**
  12255. * The friendly name of the Particle system.
  12256. */
  12257. name: string;
  12258. /**
  12259. * Snippet ID if the particle system was created from the snippet server
  12260. */
  12261. snippetId: string;
  12262. /**
  12263. * The rendering group used by the Particle system to chose when to render.
  12264. */
  12265. renderingGroupId: number;
  12266. /**
  12267. * The emitter represents the Mesh or position we are attaching the particle system to.
  12268. */
  12269. emitter: Nullable<AbstractMesh | Vector3>;
  12270. /**
  12271. * The maximum number of particles to emit per frame
  12272. */
  12273. emitRate: number;
  12274. /**
  12275. * If you want to launch only a few particles at once, that can be done, as well.
  12276. */
  12277. manualEmitCount: number;
  12278. /**
  12279. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12280. */
  12281. updateSpeed: number;
  12282. /**
  12283. * The amount of time the particle system is running (depends of the overall update speed).
  12284. */
  12285. targetStopDuration: number;
  12286. /**
  12287. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12288. */
  12289. disposeOnStop: boolean;
  12290. /**
  12291. * Minimum power of emitting particles.
  12292. */
  12293. minEmitPower: number;
  12294. /**
  12295. * Maximum power of emitting particles.
  12296. */
  12297. maxEmitPower: number;
  12298. /**
  12299. * Minimum life time of emitting particles.
  12300. */
  12301. minLifeTime: number;
  12302. /**
  12303. * Maximum life time of emitting particles.
  12304. */
  12305. maxLifeTime: number;
  12306. /**
  12307. * Minimum Size of emitting particles.
  12308. */
  12309. minSize: number;
  12310. /**
  12311. * Maximum Size of emitting particles.
  12312. */
  12313. maxSize: number;
  12314. /**
  12315. * Minimum scale of emitting particles on X axis.
  12316. */
  12317. minScaleX: number;
  12318. /**
  12319. * Maximum scale of emitting particles on X axis.
  12320. */
  12321. maxScaleX: number;
  12322. /**
  12323. * Minimum scale of emitting particles on Y axis.
  12324. */
  12325. minScaleY: number;
  12326. /**
  12327. * Maximum scale of emitting particles on Y axis.
  12328. */
  12329. maxScaleY: number;
  12330. /**
  12331. * Gets or sets the minimal initial rotation in radians.
  12332. */
  12333. minInitialRotation: number;
  12334. /**
  12335. * Gets or sets the maximal initial rotation in radians.
  12336. */
  12337. maxInitialRotation: number;
  12338. /**
  12339. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12340. */
  12341. minAngularSpeed: number;
  12342. /**
  12343. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12344. */
  12345. maxAngularSpeed: number;
  12346. /**
  12347. * The texture used to render each particle. (this can be a spritesheet)
  12348. */
  12349. particleTexture: Nullable<BaseTexture>;
  12350. /**
  12351. * The layer mask we are rendering the particles through.
  12352. */
  12353. layerMask: number;
  12354. /**
  12355. * This can help using your own shader to render the particle system.
  12356. * The according effect will be created
  12357. */
  12358. customShader: any;
  12359. /**
  12360. * By default particle system starts as soon as they are created. This prevents the
  12361. * automatic start to happen and let you decide when to start emitting particles.
  12362. */
  12363. preventAutoStart: boolean;
  12364. private _noiseTexture;
  12365. /**
  12366. * Gets or sets a texture used to add random noise to particle positions
  12367. */
  12368. get noiseTexture(): Nullable<ProceduralTexture>;
  12369. set noiseTexture(value: Nullable<ProceduralTexture>);
  12370. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12371. noiseStrength: Vector3;
  12372. /**
  12373. * Callback triggered when the particle animation is ending.
  12374. */
  12375. onAnimationEnd: Nullable<() => void>;
  12376. /**
  12377. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12378. */
  12379. blendMode: number;
  12380. /**
  12381. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12382. * to override the particles.
  12383. */
  12384. forceDepthWrite: boolean;
  12385. /** 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 */
  12386. preWarmCycles: number;
  12387. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12388. preWarmStepOffset: number;
  12389. /**
  12390. * 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)
  12391. */
  12392. spriteCellChangeSpeed: number;
  12393. /**
  12394. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12395. */
  12396. startSpriteCellID: number;
  12397. /**
  12398. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12399. */
  12400. endSpriteCellID: number;
  12401. /**
  12402. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12403. */
  12404. spriteCellWidth: number;
  12405. /**
  12406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12407. */
  12408. spriteCellHeight: number;
  12409. /**
  12410. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12411. */
  12412. spriteRandomStartCell: boolean;
  12413. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12414. translationPivot: Vector2;
  12415. /** @hidden */
  12416. protected _isAnimationSheetEnabled: boolean;
  12417. /**
  12418. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12419. */
  12420. beginAnimationOnStart: boolean;
  12421. /**
  12422. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12423. */
  12424. beginAnimationFrom: number;
  12425. /**
  12426. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12427. */
  12428. beginAnimationTo: number;
  12429. /**
  12430. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12431. */
  12432. beginAnimationLoop: boolean;
  12433. /**
  12434. * Gets or sets a world offset applied to all particles
  12435. */
  12436. worldOffset: Vector3;
  12437. /**
  12438. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12439. */
  12440. get isAnimationSheetEnabled(): boolean;
  12441. set isAnimationSheetEnabled(value: boolean);
  12442. /**
  12443. * Get hosting scene
  12444. * @returns the scene
  12445. */
  12446. getScene(): Nullable<Scene>;
  12447. /**
  12448. * You can use gravity if you want to give an orientation to your particles.
  12449. */
  12450. gravity: Vector3;
  12451. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12452. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12453. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12454. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12455. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12456. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12457. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12458. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12459. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12460. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12461. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12462. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12463. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12464. /**
  12465. * Defines the delay in milliseconds before starting the system (0 by default)
  12466. */
  12467. startDelay: number;
  12468. /**
  12469. * Gets the current list of drag gradients.
  12470. * You must use addDragGradient and removeDragGradient to udpate this list
  12471. * @returns the list of drag gradients
  12472. */
  12473. getDragGradients(): Nullable<Array<FactorGradient>>;
  12474. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12475. limitVelocityDamping: number;
  12476. /**
  12477. * Gets the current list of limit velocity gradients.
  12478. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12479. * @returns the list of limit velocity gradients
  12480. */
  12481. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12482. /**
  12483. * Gets the current list of color gradients.
  12484. * You must use addColorGradient and removeColorGradient to udpate this list
  12485. * @returns the list of color gradients
  12486. */
  12487. getColorGradients(): Nullable<Array<ColorGradient>>;
  12488. /**
  12489. * Gets the current list of size gradients.
  12490. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12491. * @returns the list of size gradients
  12492. */
  12493. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12494. /**
  12495. * Gets the current list of color remap gradients.
  12496. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12497. * @returns the list of color remap gradients
  12498. */
  12499. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12500. /**
  12501. * Gets the current list of alpha remap gradients.
  12502. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12503. * @returns the list of alpha remap gradients
  12504. */
  12505. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12506. /**
  12507. * Gets the current list of life time gradients.
  12508. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12509. * @returns the list of life time gradients
  12510. */
  12511. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12512. /**
  12513. * Gets the current list of angular speed gradients.
  12514. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12515. * @returns the list of angular speed gradients
  12516. */
  12517. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12518. /**
  12519. * Gets the current list of velocity gradients.
  12520. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12521. * @returns the list of velocity gradients
  12522. */
  12523. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12524. /**
  12525. * Gets the current list of start size gradients.
  12526. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12527. * @returns the list of start size gradients
  12528. */
  12529. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12530. /**
  12531. * Gets the current list of emit rate gradients.
  12532. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12533. * @returns the list of emit rate gradients
  12534. */
  12535. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12536. /**
  12537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12539. */
  12540. get direction1(): Vector3;
  12541. set direction1(value: Vector3);
  12542. /**
  12543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12545. */
  12546. get direction2(): Vector3;
  12547. set direction2(value: Vector3);
  12548. /**
  12549. * 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.
  12550. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12551. */
  12552. get minEmitBox(): Vector3;
  12553. set minEmitBox(value: Vector3);
  12554. /**
  12555. * 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.
  12556. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12557. */
  12558. get maxEmitBox(): Vector3;
  12559. set maxEmitBox(value: Vector3);
  12560. /**
  12561. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12562. */
  12563. color1: Color4;
  12564. /**
  12565. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12566. */
  12567. color2: Color4;
  12568. /**
  12569. * Color the particle will have at the end of its lifetime
  12570. */
  12571. colorDead: Color4;
  12572. /**
  12573. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12574. */
  12575. textureMask: Color4;
  12576. /**
  12577. * The particle emitter type defines the emitter used by the particle system.
  12578. * It can be for example box, sphere, or cone...
  12579. */
  12580. particleEmitterType: IParticleEmitterType;
  12581. /** @hidden */
  12582. _isSubEmitter: boolean;
  12583. /**
  12584. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12585. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12586. */
  12587. billboardMode: number;
  12588. protected _isBillboardBased: boolean;
  12589. /**
  12590. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12591. */
  12592. get isBillboardBased(): boolean;
  12593. set isBillboardBased(value: boolean);
  12594. /**
  12595. * The scene the particle system belongs to.
  12596. */
  12597. protected _scene: Nullable<Scene>;
  12598. /**
  12599. * The engine the particle system belongs to.
  12600. */
  12601. protected _engine: ThinEngine;
  12602. /**
  12603. * Local cache of defines for image processing.
  12604. */
  12605. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12606. /**
  12607. * Default configuration related to image processing available in the standard Material.
  12608. */
  12609. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12610. /**
  12611. * Gets the image processing configuration used either in this material.
  12612. */
  12613. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12614. /**
  12615. * Sets the Default image processing configuration used either in the this material.
  12616. *
  12617. * If sets to null, the scene one is in use.
  12618. */
  12619. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12620. /**
  12621. * Attaches a new image processing configuration to the Standard Material.
  12622. * @param configuration
  12623. */
  12624. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12625. /** @hidden */
  12626. protected _reset(): void;
  12627. /** @hidden */
  12628. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12629. /**
  12630. * Instantiates a particle system.
  12631. * 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.
  12632. * @param name The name of the particle system
  12633. */
  12634. constructor(name: string);
  12635. /**
  12636. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12639. * @returns the emitter
  12640. */
  12641. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12642. /**
  12643. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12644. * @param radius The radius of the hemisphere to emit from
  12645. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12646. * @returns the emitter
  12647. */
  12648. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12649. /**
  12650. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12651. * @param radius The radius of the sphere to emit from
  12652. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12653. * @returns the emitter
  12654. */
  12655. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12656. /**
  12657. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12658. * @param radius The radius of the sphere to emit from
  12659. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12660. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12661. * @returns the emitter
  12662. */
  12663. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12664. /**
  12665. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12666. * @param radius The radius of the emission cylinder
  12667. * @param height The height of the emission cylinder
  12668. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12669. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12670. * @returns the emitter
  12671. */
  12672. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12673. /**
  12674. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12675. * @param radius The radius of the cylinder to emit from
  12676. * @param height The height of the emission cylinder
  12677. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12680. * @returns the emitter
  12681. */
  12682. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12683. /**
  12684. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12685. * @param radius The radius of the cone to emit from
  12686. * @param angle The base angle of the cone
  12687. * @returns the emitter
  12688. */
  12689. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12690. /**
  12691. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12694. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12695. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12696. * @returns the emitter
  12697. */
  12698. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12699. }
  12700. }
  12701. declare module "babylonjs/Particles/subEmitter" {
  12702. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12703. import { Scene } from "babylonjs/scene";
  12704. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12705. /**
  12706. * Type of sub emitter
  12707. */
  12708. export enum SubEmitterType {
  12709. /**
  12710. * Attached to the particle over it's lifetime
  12711. */
  12712. ATTACHED = 0,
  12713. /**
  12714. * Created when the particle dies
  12715. */
  12716. END = 1
  12717. }
  12718. /**
  12719. * Sub emitter class used to emit particles from an existing particle
  12720. */
  12721. export class SubEmitter {
  12722. /**
  12723. * the particle system to be used by the sub emitter
  12724. */
  12725. particleSystem: ParticleSystem;
  12726. /**
  12727. * Type of the submitter (Default: END)
  12728. */
  12729. type: SubEmitterType;
  12730. /**
  12731. * 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)
  12732. * Note: This only is supported when using an emitter of type Mesh
  12733. */
  12734. inheritDirection: boolean;
  12735. /**
  12736. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12737. */
  12738. inheritedVelocityAmount: number;
  12739. /**
  12740. * Creates a sub emitter
  12741. * @param particleSystem the particle system to be used by the sub emitter
  12742. */
  12743. constructor(
  12744. /**
  12745. * the particle system to be used by the sub emitter
  12746. */
  12747. particleSystem: ParticleSystem);
  12748. /**
  12749. * Clones the sub emitter
  12750. * @returns the cloned sub emitter
  12751. */
  12752. clone(): SubEmitter;
  12753. /**
  12754. * Serialize current object to a JSON object
  12755. * @returns the serialized object
  12756. */
  12757. serialize(): any;
  12758. /** @hidden */
  12759. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12760. /**
  12761. * Creates a new SubEmitter from a serialized JSON version
  12762. * @param serializationObject defines the JSON object to read from
  12763. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12764. * @param rootUrl defines the rootUrl for data loading
  12765. * @returns a new SubEmitter
  12766. */
  12767. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12768. /** Release associated resources */
  12769. dispose(): void;
  12770. }
  12771. }
  12772. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12773. /** @hidden */
  12774. export var imageProcessingDeclaration: {
  12775. name: string;
  12776. shader: string;
  12777. };
  12778. }
  12779. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12780. /** @hidden */
  12781. export var imageProcessingFunctions: {
  12782. name: string;
  12783. shader: string;
  12784. };
  12785. }
  12786. declare module "babylonjs/Shaders/particles.fragment" {
  12787. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12788. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12789. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12790. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12791. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12792. /** @hidden */
  12793. export var particlesPixelShader: {
  12794. name: string;
  12795. shader: string;
  12796. };
  12797. }
  12798. declare module "babylonjs/Shaders/particles.vertex" {
  12799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12801. /** @hidden */
  12802. export var particlesVertexShader: {
  12803. name: string;
  12804. shader: string;
  12805. };
  12806. }
  12807. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12808. import { Nullable } from "babylonjs/types";
  12809. import { Plane } from "babylonjs/Maths/math";
  12810. /**
  12811. * Interface used to define entities containing multiple clip planes
  12812. */
  12813. export interface IClipPlanesHolder {
  12814. /**
  12815. * Gets or sets the active clipplane 1
  12816. */
  12817. clipPlane: Nullable<Plane>;
  12818. /**
  12819. * Gets or sets the active clipplane 2
  12820. */
  12821. clipPlane2: Nullable<Plane>;
  12822. /**
  12823. * Gets or sets the active clipplane 3
  12824. */
  12825. clipPlane3: Nullable<Plane>;
  12826. /**
  12827. * Gets or sets the active clipplane 4
  12828. */
  12829. clipPlane4: Nullable<Plane>;
  12830. /**
  12831. * Gets or sets the active clipplane 5
  12832. */
  12833. clipPlane5: Nullable<Plane>;
  12834. /**
  12835. * Gets or sets the active clipplane 6
  12836. */
  12837. clipPlane6: Nullable<Plane>;
  12838. }
  12839. }
  12840. declare module "babylonjs/Materials/thinMaterialHelper" {
  12841. import { Effect } from "babylonjs/Materials/effect";
  12842. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12843. /**
  12844. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12845. *
  12846. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12847. *
  12848. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12849. */
  12850. export class ThinMaterialHelper {
  12851. /**
  12852. * Binds the clip plane information from the holder to the effect.
  12853. * @param effect The effect we are binding the data to
  12854. * @param holder The entity containing the clip plane information
  12855. */
  12856. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12857. }
  12858. }
  12859. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12860. module "babylonjs/Engines/thinEngine" {
  12861. interface ThinEngine {
  12862. /**
  12863. * Sets alpha constants used by some alpha blending modes
  12864. * @param r defines the red component
  12865. * @param g defines the green component
  12866. * @param b defines the blue component
  12867. * @param a defines the alpha component
  12868. */
  12869. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12870. /**
  12871. * Sets the current alpha mode
  12872. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12873. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12874. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12875. */
  12876. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12877. /**
  12878. * Gets the current alpha mode
  12879. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12880. * @returns the current alpha mode
  12881. */
  12882. getAlphaMode(): number;
  12883. /**
  12884. * Sets the current alpha equation
  12885. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12886. */
  12887. setAlphaEquation(equation: number): void;
  12888. /**
  12889. * Gets the current alpha equation.
  12890. * @returns the current alpha equation
  12891. */
  12892. getAlphaEquation(): number;
  12893. }
  12894. }
  12895. }
  12896. declare module "babylonjs/Particles/particleSystem" {
  12897. import { Nullable } from "babylonjs/types";
  12898. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12899. import { Observable } from "babylonjs/Misc/observable";
  12900. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12901. import { Effect } from "babylonjs/Materials/effect";
  12902. import { IDisposable } from "babylonjs/scene";
  12903. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12904. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12905. import { Particle } from "babylonjs/Particles/particle";
  12906. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12907. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12908. import "babylonjs/Shaders/particles.fragment";
  12909. import "babylonjs/Shaders/particles.vertex";
  12910. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12911. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12912. import "babylonjs/Engines/Extensions/engine.alpha";
  12913. import { Scene } from "babylonjs/scene";
  12914. /**
  12915. * This represents a particle system in Babylon.
  12916. * 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.
  12917. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12918. * @example https://doc.babylonjs.com/babylon101/particles
  12919. */
  12920. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12921. /**
  12922. * Billboard mode will only apply to Y axis
  12923. */
  12924. static readonly BILLBOARDMODE_Y: number;
  12925. /**
  12926. * Billboard mode will apply to all axes
  12927. */
  12928. static readonly BILLBOARDMODE_ALL: number;
  12929. /**
  12930. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12931. */
  12932. static readonly BILLBOARDMODE_STRETCHED: number;
  12933. /**
  12934. * This function can be defined to provide custom update for active particles.
  12935. * This function will be called instead of regular update (age, position, color, etc.).
  12936. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12937. */
  12938. updateFunction: (particles: Particle[]) => void;
  12939. private _emitterWorldMatrix;
  12940. /**
  12941. * This function can be defined to specify initial direction for every new particle.
  12942. * It by default use the emitterType defined function
  12943. */
  12944. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12945. /**
  12946. * This function can be defined to specify initial position for every new particle.
  12947. * It by default use the emitterType defined function
  12948. */
  12949. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12950. /**
  12951. * @hidden
  12952. */
  12953. _inheritedVelocityOffset: Vector3;
  12954. /**
  12955. * An event triggered when the system is disposed
  12956. */
  12957. onDisposeObservable: Observable<IParticleSystem>;
  12958. private _onDisposeObserver;
  12959. /**
  12960. * Sets a callback that will be triggered when the system is disposed
  12961. */
  12962. set onDispose(callback: () => void);
  12963. private _particles;
  12964. private _epsilon;
  12965. private _capacity;
  12966. private _stockParticles;
  12967. private _newPartsExcess;
  12968. private _vertexData;
  12969. private _vertexBuffer;
  12970. private _vertexBuffers;
  12971. private _spriteBuffer;
  12972. private _indexBuffer;
  12973. private _effect;
  12974. private _customEffect;
  12975. private _cachedDefines;
  12976. private _scaledColorStep;
  12977. private _colorDiff;
  12978. private _scaledDirection;
  12979. private _scaledGravity;
  12980. private _currentRenderId;
  12981. private _alive;
  12982. private _useInstancing;
  12983. private _started;
  12984. private _stopped;
  12985. private _actualFrame;
  12986. private _scaledUpdateSpeed;
  12987. private _vertexBufferSize;
  12988. /** @hidden */
  12989. _currentEmitRateGradient: Nullable<FactorGradient>;
  12990. /** @hidden */
  12991. _currentEmitRate1: number;
  12992. /** @hidden */
  12993. _currentEmitRate2: number;
  12994. /** @hidden */
  12995. _currentStartSizeGradient: Nullable<FactorGradient>;
  12996. /** @hidden */
  12997. _currentStartSize1: number;
  12998. /** @hidden */
  12999. _currentStartSize2: number;
  13000. private readonly _rawTextureWidth;
  13001. private _rampGradientsTexture;
  13002. private _useRampGradients;
  13003. /** Gets or sets a matrix to use to compute projection */
  13004. defaultProjectionMatrix: Matrix;
  13005. /** Gets or sets a matrix to use to compute view */
  13006. defaultViewMatrix: Matrix;
  13007. /** Gets or sets a boolean indicating that ramp gradients must be used
  13008. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13009. */
  13010. get useRampGradients(): boolean;
  13011. set useRampGradients(value: boolean);
  13012. /**
  13013. * 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.
  13014. * 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: [])
  13015. */
  13016. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13017. private _subEmitters;
  13018. /**
  13019. * @hidden
  13020. * If the particle systems emitter should be disposed when the particle system is disposed
  13021. */
  13022. _disposeEmitterOnDispose: boolean;
  13023. /**
  13024. * The current active Sub-systems, this property is used by the root particle system only.
  13025. */
  13026. activeSubSystems: Array<ParticleSystem>;
  13027. /**
  13028. * Specifies if the particles are updated in emitter local space or world space
  13029. */
  13030. isLocal: boolean;
  13031. private _rootParticleSystem;
  13032. /**
  13033. * Gets the current list of active particles
  13034. */
  13035. get particles(): Particle[];
  13036. /**
  13037. * Gets the number of particles active at the same time.
  13038. * @returns The number of active particles.
  13039. */
  13040. getActiveCount(): number;
  13041. /**
  13042. * Returns the string "ParticleSystem"
  13043. * @returns a string containing the class name
  13044. */
  13045. getClassName(): string;
  13046. /**
  13047. * Gets a boolean indicating that the system is stopping
  13048. * @returns true if the system is currently stopping
  13049. */
  13050. isStopping(): boolean;
  13051. /**
  13052. * Gets the custom effect used to render the particles
  13053. * @param blendMode Blend mode for which the effect should be retrieved
  13054. * @returns The effect
  13055. */
  13056. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13057. /**
  13058. * Sets the custom effect used to render the particles
  13059. * @param effect The effect to set
  13060. * @param blendMode Blend mode for which the effect should be set
  13061. */
  13062. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13063. /** @hidden */
  13064. private _onBeforeDrawParticlesObservable;
  13065. /**
  13066. * Observable that will be called just before the particles are drawn
  13067. */
  13068. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13069. /**
  13070. * Gets the name of the particle vertex shader
  13071. */
  13072. get vertexShaderName(): string;
  13073. /**
  13074. * Instantiates a particle system.
  13075. * 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.
  13076. * @param name The name of the particle system
  13077. * @param capacity The max number of particles alive at the same time
  13078. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13079. * @param customEffect a custom effect used to change the way particles are rendered by default
  13080. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13081. * @param epsilon Offset used to render the particles
  13082. */
  13083. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13084. private _addFactorGradient;
  13085. private _removeFactorGradient;
  13086. /**
  13087. * Adds a new life time gradient
  13088. * @param gradient defines the gradient to use (between 0 and 1)
  13089. * @param factor defines the life time factor to affect to the specified gradient
  13090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13091. * @returns the current particle system
  13092. */
  13093. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13094. /**
  13095. * Remove a specific life time gradient
  13096. * @param gradient defines the gradient to remove
  13097. * @returns the current particle system
  13098. */
  13099. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13100. /**
  13101. * Adds a new size gradient
  13102. * @param gradient defines the gradient to use (between 0 and 1)
  13103. * @param factor defines the size factor to affect to the specified gradient
  13104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13105. * @returns the current particle system
  13106. */
  13107. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13108. /**
  13109. * Remove a specific size gradient
  13110. * @param gradient defines the gradient to remove
  13111. * @returns the current particle system
  13112. */
  13113. removeSizeGradient(gradient: number): IParticleSystem;
  13114. /**
  13115. * Adds a new color remap gradient
  13116. * @param gradient defines the gradient to use (between 0 and 1)
  13117. * @param min defines the color remap minimal range
  13118. * @param max defines the color remap maximal range
  13119. * @returns the current particle system
  13120. */
  13121. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13122. /**
  13123. * Remove a specific color remap gradient
  13124. * @param gradient defines the gradient to remove
  13125. * @returns the current particle system
  13126. */
  13127. removeColorRemapGradient(gradient: number): IParticleSystem;
  13128. /**
  13129. * Adds a new alpha remap gradient
  13130. * @param gradient defines the gradient to use (between 0 and 1)
  13131. * @param min defines the alpha remap minimal range
  13132. * @param max defines the alpha remap maximal range
  13133. * @returns the current particle system
  13134. */
  13135. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13136. /**
  13137. * Remove a specific alpha remap gradient
  13138. * @param gradient defines the gradient to remove
  13139. * @returns the current particle system
  13140. */
  13141. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13142. /**
  13143. * Adds a new angular speed gradient
  13144. * @param gradient defines the gradient to use (between 0 and 1)
  13145. * @param factor defines the angular speed to affect to the specified gradient
  13146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13147. * @returns the current particle system
  13148. */
  13149. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13150. /**
  13151. * Remove a specific angular speed gradient
  13152. * @param gradient defines the gradient to remove
  13153. * @returns the current particle system
  13154. */
  13155. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13156. /**
  13157. * Adds a new velocity gradient
  13158. * @param gradient defines the gradient to use (between 0 and 1)
  13159. * @param factor defines the velocity to affect to the specified gradient
  13160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13161. * @returns the current particle system
  13162. */
  13163. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13164. /**
  13165. * Remove a specific velocity gradient
  13166. * @param gradient defines the gradient to remove
  13167. * @returns the current particle system
  13168. */
  13169. removeVelocityGradient(gradient: number): IParticleSystem;
  13170. /**
  13171. * Adds a new limit velocity gradient
  13172. * @param gradient defines the gradient to use (between 0 and 1)
  13173. * @param factor defines the limit velocity value to affect to the specified gradient
  13174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13175. * @returns the current particle system
  13176. */
  13177. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13178. /**
  13179. * Remove a specific limit velocity gradient
  13180. * @param gradient defines the gradient to remove
  13181. * @returns the current particle system
  13182. */
  13183. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13184. /**
  13185. * Adds a new drag gradient
  13186. * @param gradient defines the gradient to use (between 0 and 1)
  13187. * @param factor defines the drag value to affect to the specified gradient
  13188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13189. * @returns the current particle system
  13190. */
  13191. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13192. /**
  13193. * Remove a specific drag gradient
  13194. * @param gradient defines the gradient to remove
  13195. * @returns the current particle system
  13196. */
  13197. removeDragGradient(gradient: number): IParticleSystem;
  13198. /**
  13199. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13200. * @param gradient defines the gradient to use (between 0 and 1)
  13201. * @param factor defines the emit rate value to affect to the specified gradient
  13202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13203. * @returns the current particle system
  13204. */
  13205. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13206. /**
  13207. * Remove a specific emit rate gradient
  13208. * @param gradient defines the gradient to remove
  13209. * @returns the current particle system
  13210. */
  13211. removeEmitRateGradient(gradient: number): IParticleSystem;
  13212. /**
  13213. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13214. * @param gradient defines the gradient to use (between 0 and 1)
  13215. * @param factor defines the start size value to affect to the specified gradient
  13216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13217. * @returns the current particle system
  13218. */
  13219. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13220. /**
  13221. * Remove a specific start size gradient
  13222. * @param gradient defines the gradient to remove
  13223. * @returns the current particle system
  13224. */
  13225. removeStartSizeGradient(gradient: number): IParticleSystem;
  13226. private _createRampGradientTexture;
  13227. /**
  13228. * Gets the current list of ramp gradients.
  13229. * You must use addRampGradient and removeRampGradient to udpate this list
  13230. * @returns the list of ramp gradients
  13231. */
  13232. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13233. /** Force the system to rebuild all gradients that need to be resync */
  13234. forceRefreshGradients(): void;
  13235. private _syncRampGradientTexture;
  13236. /**
  13237. * Adds a new ramp gradient used to remap particle colors
  13238. * @param gradient defines the gradient to use (between 0 and 1)
  13239. * @param color defines the color to affect to the specified gradient
  13240. * @returns the current particle system
  13241. */
  13242. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13243. /**
  13244. * Remove a specific ramp gradient
  13245. * @param gradient defines the gradient to remove
  13246. * @returns the current particle system
  13247. */
  13248. removeRampGradient(gradient: number): ParticleSystem;
  13249. /**
  13250. * Adds a new color gradient
  13251. * @param gradient defines the gradient to use (between 0 and 1)
  13252. * @param color1 defines the color to affect to the specified gradient
  13253. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13254. * @returns this particle system
  13255. */
  13256. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13257. /**
  13258. * Remove a specific color gradient
  13259. * @param gradient defines the gradient to remove
  13260. * @returns this particle system
  13261. */
  13262. removeColorGradient(gradient: number): IParticleSystem;
  13263. private _fetchR;
  13264. protected _reset(): void;
  13265. private _resetEffect;
  13266. private _createVertexBuffers;
  13267. private _createIndexBuffer;
  13268. /**
  13269. * Gets the maximum number of particles active at the same time.
  13270. * @returns The max number of active particles.
  13271. */
  13272. getCapacity(): number;
  13273. /**
  13274. * Gets whether there are still active particles in the system.
  13275. * @returns True if it is alive, otherwise false.
  13276. */
  13277. isAlive(): boolean;
  13278. /**
  13279. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13280. * @returns True if it has been started, otherwise false.
  13281. */
  13282. isStarted(): boolean;
  13283. private _prepareSubEmitterInternalArray;
  13284. /**
  13285. * Starts the particle system and begins to emit
  13286. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13287. */
  13288. start(delay?: number): void;
  13289. /**
  13290. * Stops the particle system.
  13291. * @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.
  13292. */
  13293. stop(stopSubEmitters?: boolean): void;
  13294. /**
  13295. * Remove all active particles
  13296. */
  13297. reset(): void;
  13298. /**
  13299. * @hidden (for internal use only)
  13300. */
  13301. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13302. /**
  13303. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13304. * Its lifetime will start back at 0.
  13305. */
  13306. recycleParticle: (particle: Particle) => void;
  13307. private _stopSubEmitters;
  13308. private _createParticle;
  13309. private _removeFromRoot;
  13310. private _emitFromParticle;
  13311. private _update;
  13312. /** @hidden */
  13313. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13314. /** @hidden */
  13315. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13316. /**
  13317. * Fill the defines array according to the current settings of the particle system
  13318. * @param defines Array to be updated
  13319. * @param blendMode blend mode to take into account when updating the array
  13320. */
  13321. fillDefines(defines: Array<string>, blendMode: number): void;
  13322. /**
  13323. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13324. * @param uniforms Uniforms array to fill
  13325. * @param attributes Attributes array to fill
  13326. * @param samplers Samplers array to fill
  13327. */
  13328. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13329. /** @hidden */
  13330. private _getEffect;
  13331. /**
  13332. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13333. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13334. */
  13335. animate(preWarmOnly?: boolean): void;
  13336. private _appendParticleVertices;
  13337. /**
  13338. * Rebuilds the particle system.
  13339. */
  13340. rebuild(): void;
  13341. /**
  13342. * Is this system ready to be used/rendered
  13343. * @return true if the system is ready
  13344. */
  13345. isReady(): boolean;
  13346. private _render;
  13347. /**
  13348. * Renders the particle system in its current state.
  13349. * @returns the current number of particles
  13350. */
  13351. render(): number;
  13352. /**
  13353. * Disposes the particle system and free the associated resources
  13354. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13355. */
  13356. dispose(disposeTexture?: boolean): void;
  13357. /**
  13358. * Clones the particle system.
  13359. * @param name The name of the cloned object
  13360. * @param newEmitter The new emitter to use
  13361. * @returns the cloned particle system
  13362. */
  13363. clone(name: string, newEmitter: any): ParticleSystem;
  13364. /**
  13365. * Serializes the particle system to a JSON object
  13366. * @param serializeTexture defines if the texture must be serialized as well
  13367. * @returns the JSON object
  13368. */
  13369. serialize(serializeTexture?: boolean): any;
  13370. /** @hidden */
  13371. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13372. /** @hidden */
  13373. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13374. /**
  13375. * Parses a JSON object to create a particle system.
  13376. * @param parsedParticleSystem The JSON object to parse
  13377. * @param sceneOrEngine The scene or the engine to create the particle system in
  13378. * @param rootUrl The root url to use to load external dependencies like texture
  13379. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13380. * @returns the Parsed particle system
  13381. */
  13382. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13383. }
  13384. }
  13385. declare module "babylonjs/Particles/particle" {
  13386. import { Nullable } from "babylonjs/types";
  13387. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13388. import { Color4 } from "babylonjs/Maths/math.color";
  13389. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13390. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13391. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13392. /**
  13393. * A particle represents one of the element emitted by a particle system.
  13394. * This is mainly define by its coordinates, direction, velocity and age.
  13395. */
  13396. export class Particle {
  13397. /**
  13398. * The particle system the particle belongs to.
  13399. */
  13400. particleSystem: ParticleSystem;
  13401. private static _Count;
  13402. /**
  13403. * Unique ID of the particle
  13404. */
  13405. id: number;
  13406. /**
  13407. * The world position of the particle in the scene.
  13408. */
  13409. position: Vector3;
  13410. /**
  13411. * The world direction of the particle in the scene.
  13412. */
  13413. direction: Vector3;
  13414. /**
  13415. * The color of the particle.
  13416. */
  13417. color: Color4;
  13418. /**
  13419. * The color change of the particle per step.
  13420. */
  13421. colorStep: Color4;
  13422. /**
  13423. * Defines how long will the life of the particle be.
  13424. */
  13425. lifeTime: number;
  13426. /**
  13427. * The current age of the particle.
  13428. */
  13429. age: number;
  13430. /**
  13431. * The current size of the particle.
  13432. */
  13433. size: number;
  13434. /**
  13435. * The current scale of the particle.
  13436. */
  13437. scale: Vector2;
  13438. /**
  13439. * The current angle of the particle.
  13440. */
  13441. angle: number;
  13442. /**
  13443. * Defines how fast is the angle changing.
  13444. */
  13445. angularSpeed: number;
  13446. /**
  13447. * Defines the cell index used by the particle to be rendered from a sprite.
  13448. */
  13449. cellIndex: number;
  13450. /**
  13451. * The information required to support color remapping
  13452. */
  13453. remapData: Vector4;
  13454. /** @hidden */
  13455. _randomCellOffset?: number;
  13456. /** @hidden */
  13457. _initialDirection: Nullable<Vector3>;
  13458. /** @hidden */
  13459. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13460. /** @hidden */
  13461. _initialStartSpriteCellID: number;
  13462. /** @hidden */
  13463. _initialEndSpriteCellID: number;
  13464. /** @hidden */
  13465. _currentColorGradient: Nullable<ColorGradient>;
  13466. /** @hidden */
  13467. _currentColor1: Color4;
  13468. /** @hidden */
  13469. _currentColor2: Color4;
  13470. /** @hidden */
  13471. _currentSizeGradient: Nullable<FactorGradient>;
  13472. /** @hidden */
  13473. _currentSize1: number;
  13474. /** @hidden */
  13475. _currentSize2: number;
  13476. /** @hidden */
  13477. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13478. /** @hidden */
  13479. _currentAngularSpeed1: number;
  13480. /** @hidden */
  13481. _currentAngularSpeed2: number;
  13482. /** @hidden */
  13483. _currentVelocityGradient: Nullable<FactorGradient>;
  13484. /** @hidden */
  13485. _currentVelocity1: number;
  13486. /** @hidden */
  13487. _currentVelocity2: number;
  13488. /** @hidden */
  13489. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13490. /** @hidden */
  13491. _currentLimitVelocity1: number;
  13492. /** @hidden */
  13493. _currentLimitVelocity2: number;
  13494. /** @hidden */
  13495. _currentDragGradient: Nullable<FactorGradient>;
  13496. /** @hidden */
  13497. _currentDrag1: number;
  13498. /** @hidden */
  13499. _currentDrag2: number;
  13500. /** @hidden */
  13501. _randomNoiseCoordinates1: Vector3;
  13502. /** @hidden */
  13503. _randomNoiseCoordinates2: Vector3;
  13504. /** @hidden */
  13505. _localPosition?: Vector3;
  13506. /**
  13507. * Creates a new instance Particle
  13508. * @param particleSystem the particle system the particle belongs to
  13509. */
  13510. constructor(
  13511. /**
  13512. * The particle system the particle belongs to.
  13513. */
  13514. particleSystem: ParticleSystem);
  13515. private updateCellInfoFromSystem;
  13516. /**
  13517. * Defines how the sprite cell index is updated for the particle
  13518. */
  13519. updateCellIndex(): void;
  13520. /** @hidden */
  13521. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13522. /** @hidden */
  13523. _inheritParticleInfoToSubEmitters(): void;
  13524. /** @hidden */
  13525. _reset(): void;
  13526. /**
  13527. * Copy the properties of particle to another one.
  13528. * @param other the particle to copy the information to.
  13529. */
  13530. copyTo(other: Particle): void;
  13531. }
  13532. }
  13533. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13534. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13535. import { Effect } from "babylonjs/Materials/effect";
  13536. import { Particle } from "babylonjs/Particles/particle";
  13537. import { Nullable } from "babylonjs/types";
  13538. import { Scene } from "babylonjs/scene";
  13539. /**
  13540. * Particle emitter represents a volume emitting particles.
  13541. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13542. */
  13543. export interface IParticleEmitterType {
  13544. /**
  13545. * Called by the particle System when the direction is computed for the created particle.
  13546. * @param worldMatrix is the world matrix of the particle system
  13547. * @param directionToUpdate is the direction vector to update with the result
  13548. * @param particle is the particle we are computed the direction for
  13549. * @param isLocal defines if the direction should be set in local space
  13550. */
  13551. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13552. /**
  13553. * Called by the particle System when the position is computed for the created particle.
  13554. * @param worldMatrix is the world matrix of the particle system
  13555. * @param positionToUpdate is the position vector to update with the result
  13556. * @param particle is the particle we are computed the position for
  13557. * @param isLocal defines if the position should be set in local space
  13558. */
  13559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13560. /**
  13561. * Clones the current emitter and returns a copy of it
  13562. * @returns the new emitter
  13563. */
  13564. clone(): IParticleEmitterType;
  13565. /**
  13566. * Called by the GPUParticleSystem to setup the update shader
  13567. * @param effect defines the update shader
  13568. */
  13569. applyToShader(effect: Effect): void;
  13570. /**
  13571. * Returns a string to use to update the GPU particles update shader
  13572. * @returns the effect defines string
  13573. */
  13574. getEffectDefines(): string;
  13575. /**
  13576. * Returns a string representing the class name
  13577. * @returns a string containing the class name
  13578. */
  13579. getClassName(): string;
  13580. /**
  13581. * Serializes the particle system to a JSON object.
  13582. * @returns the JSON object
  13583. */
  13584. serialize(): any;
  13585. /**
  13586. * Parse properties from a JSON object
  13587. * @param serializationObject defines the JSON object
  13588. * @param scene defines the hosting scene
  13589. */
  13590. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13591. }
  13592. }
  13593. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13594. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13595. import { Effect } from "babylonjs/Materials/effect";
  13596. import { Particle } from "babylonjs/Particles/particle";
  13597. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13598. /**
  13599. * Particle emitter emitting particles from the inside of a box.
  13600. * It emits the particles randomly between 2 given directions.
  13601. */
  13602. export class BoxParticleEmitter implements IParticleEmitterType {
  13603. /**
  13604. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13605. */
  13606. direction1: Vector3;
  13607. /**
  13608. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13609. */
  13610. direction2: Vector3;
  13611. /**
  13612. * 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.
  13613. */
  13614. minEmitBox: Vector3;
  13615. /**
  13616. * 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.
  13617. */
  13618. maxEmitBox: Vector3;
  13619. /**
  13620. * Creates a new instance BoxParticleEmitter
  13621. */
  13622. constructor();
  13623. /**
  13624. * Called by the particle System when the direction is computed for the created particle.
  13625. * @param worldMatrix is the world matrix of the particle system
  13626. * @param directionToUpdate is the direction vector to update with the result
  13627. * @param particle is the particle we are computed the direction for
  13628. * @param isLocal defines if the direction should be set in local space
  13629. */
  13630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13631. /**
  13632. * Called by the particle System when the position is computed for the created particle.
  13633. * @param worldMatrix is the world matrix of the particle system
  13634. * @param positionToUpdate is the position vector to update with the result
  13635. * @param particle is the particle we are computed the position for
  13636. * @param isLocal defines if the position should be set in local space
  13637. */
  13638. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13639. /**
  13640. * Clones the current emitter and returns a copy of it
  13641. * @returns the new emitter
  13642. */
  13643. clone(): BoxParticleEmitter;
  13644. /**
  13645. * Called by the GPUParticleSystem to setup the update shader
  13646. * @param effect defines the update shader
  13647. */
  13648. applyToShader(effect: Effect): void;
  13649. /**
  13650. * Returns a string to use to update the GPU particles update shader
  13651. * @returns a string containng the defines string
  13652. */
  13653. getEffectDefines(): string;
  13654. /**
  13655. * Returns the string "BoxParticleEmitter"
  13656. * @returns a string containing the class name
  13657. */
  13658. getClassName(): string;
  13659. /**
  13660. * Serializes the particle system to a JSON object.
  13661. * @returns the JSON object
  13662. */
  13663. serialize(): any;
  13664. /**
  13665. * Parse properties from a JSON object
  13666. * @param serializationObject defines the JSON object
  13667. */
  13668. parse(serializationObject: any): void;
  13669. }
  13670. }
  13671. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13672. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13673. import { Effect } from "babylonjs/Materials/effect";
  13674. import { Particle } from "babylonjs/Particles/particle";
  13675. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a cone.
  13678. * It emits the particles alongside the cone volume from the base to the particle.
  13679. * The emission direction might be randomized.
  13680. */
  13681. export class ConeParticleEmitter implements IParticleEmitterType {
  13682. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13683. directionRandomizer: number;
  13684. private _radius;
  13685. private _angle;
  13686. private _height;
  13687. /**
  13688. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13689. */
  13690. radiusRange: number;
  13691. /**
  13692. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13693. */
  13694. heightRange: number;
  13695. /**
  13696. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13697. */
  13698. emitFromSpawnPointOnly: boolean;
  13699. /**
  13700. * Gets or sets the radius of the emission cone
  13701. */
  13702. get radius(): number;
  13703. set radius(value: number);
  13704. /**
  13705. * Gets or sets the angle of the emission cone
  13706. */
  13707. get angle(): number;
  13708. set angle(value: number);
  13709. private _buildHeight;
  13710. /**
  13711. * Creates a new instance ConeParticleEmitter
  13712. * @param radius the radius of the emission cone (1 by default)
  13713. * @param angle the cone base angle (PI by default)
  13714. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13715. */
  13716. constructor(radius?: number, angle?: number,
  13717. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13718. directionRandomizer?: number);
  13719. /**
  13720. * Called by the particle System when the direction is computed for the created particle.
  13721. * @param worldMatrix is the world matrix of the particle system
  13722. * @param directionToUpdate is the direction vector to update with the result
  13723. * @param particle is the particle we are computed the direction for
  13724. * @param isLocal defines if the direction should be set in local space
  13725. */
  13726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13727. /**
  13728. * Called by the particle System when the position is computed for the created particle.
  13729. * @param worldMatrix is the world matrix of the particle system
  13730. * @param positionToUpdate is the position vector to update with the result
  13731. * @param particle is the particle we are computed the position for
  13732. * @param isLocal defines if the position should be set in local space
  13733. */
  13734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13735. /**
  13736. * Clones the current emitter and returns a copy of it
  13737. * @returns the new emitter
  13738. */
  13739. clone(): ConeParticleEmitter;
  13740. /**
  13741. * Called by the GPUParticleSystem to setup the update shader
  13742. * @param effect defines the update shader
  13743. */
  13744. applyToShader(effect: Effect): void;
  13745. /**
  13746. * Returns a string to use to update the GPU particles update shader
  13747. * @returns a string containng the defines string
  13748. */
  13749. getEffectDefines(): string;
  13750. /**
  13751. * Returns the string "ConeParticleEmitter"
  13752. * @returns a string containing the class name
  13753. */
  13754. getClassName(): string;
  13755. /**
  13756. * Serializes the particle system to a JSON object.
  13757. * @returns the JSON object
  13758. */
  13759. serialize(): any;
  13760. /**
  13761. * Parse properties from a JSON object
  13762. * @param serializationObject defines the JSON object
  13763. */
  13764. parse(serializationObject: any): void;
  13765. }
  13766. }
  13767. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13768. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13769. import { Effect } from "babylonjs/Materials/effect";
  13770. import { Particle } from "babylonjs/Particles/particle";
  13771. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13772. /**
  13773. * Particle emitter emitting particles from the inside of a cylinder.
  13774. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13775. */
  13776. export class CylinderParticleEmitter implements IParticleEmitterType {
  13777. /**
  13778. * The radius of the emission cylinder.
  13779. */
  13780. radius: number;
  13781. /**
  13782. * The height of the emission cylinder.
  13783. */
  13784. height: number;
  13785. /**
  13786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13787. */
  13788. radiusRange: number;
  13789. /**
  13790. * How much to randomize the particle direction [0-1].
  13791. */
  13792. directionRandomizer: number;
  13793. /**
  13794. * Creates a new instance CylinderParticleEmitter
  13795. * @param radius the radius of the emission cylinder (1 by default)
  13796. * @param height the height of the emission cylinder (1 by default)
  13797. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13799. */
  13800. constructor(
  13801. /**
  13802. * The radius of the emission cylinder.
  13803. */
  13804. radius?: number,
  13805. /**
  13806. * The height of the emission cylinder.
  13807. */
  13808. height?: number,
  13809. /**
  13810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13811. */
  13812. radiusRange?: number,
  13813. /**
  13814. * How much to randomize the particle direction [0-1].
  13815. */
  13816. directionRandomizer?: number);
  13817. /**
  13818. * Called by the particle System when the direction is computed for the created particle.
  13819. * @param worldMatrix is the world matrix of the particle system
  13820. * @param directionToUpdate is the direction vector to update with the result
  13821. * @param particle is the particle we are computed the direction for
  13822. * @param isLocal defines if the direction should be set in local space
  13823. */
  13824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13825. /**
  13826. * Called by the particle System when the position is computed for the created particle.
  13827. * @param worldMatrix is the world matrix of the particle system
  13828. * @param positionToUpdate is the position vector to update with the result
  13829. * @param particle is the particle we are computed the position for
  13830. * @param isLocal defines if the position should be set in local space
  13831. */
  13832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13833. /**
  13834. * Clones the current emitter and returns a copy of it
  13835. * @returns the new emitter
  13836. */
  13837. clone(): CylinderParticleEmitter;
  13838. /**
  13839. * Called by the GPUParticleSystem to setup the update shader
  13840. * @param effect defines the update shader
  13841. */
  13842. applyToShader(effect: Effect): void;
  13843. /**
  13844. * Returns a string to use to update the GPU particles update shader
  13845. * @returns a string containng the defines string
  13846. */
  13847. getEffectDefines(): string;
  13848. /**
  13849. * Returns the string "CylinderParticleEmitter"
  13850. * @returns a string containing the class name
  13851. */
  13852. getClassName(): string;
  13853. /**
  13854. * Serializes the particle system to a JSON object.
  13855. * @returns the JSON object
  13856. */
  13857. serialize(): any;
  13858. /**
  13859. * Parse properties from a JSON object
  13860. * @param serializationObject defines the JSON object
  13861. */
  13862. parse(serializationObject: any): void;
  13863. }
  13864. /**
  13865. * Particle emitter emitting particles from the inside of a cylinder.
  13866. * It emits the particles randomly between two vectors.
  13867. */
  13868. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13869. /**
  13870. * The min limit of the emission direction.
  13871. */
  13872. direction1: Vector3;
  13873. /**
  13874. * The max limit of the emission direction.
  13875. */
  13876. direction2: Vector3;
  13877. /**
  13878. * Creates a new instance CylinderDirectedParticleEmitter
  13879. * @param radius the radius of the emission cylinder (1 by default)
  13880. * @param height the height of the emission cylinder (1 by default)
  13881. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13882. * @param direction1 the min limit of the emission direction (up vector by default)
  13883. * @param direction2 the max limit of the emission direction (up vector by default)
  13884. */
  13885. constructor(radius?: number, height?: number, radiusRange?: number,
  13886. /**
  13887. * The min limit of the emission direction.
  13888. */
  13889. direction1?: Vector3,
  13890. /**
  13891. * The max limit of the emission direction.
  13892. */
  13893. direction2?: Vector3);
  13894. /**
  13895. * Called by the particle System when the direction is computed for the created particle.
  13896. * @param worldMatrix is the world matrix of the particle system
  13897. * @param directionToUpdate is the direction vector to update with the result
  13898. * @param particle is the particle we are computed the direction for
  13899. */
  13900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13901. /**
  13902. * Clones the current emitter and returns a copy of it
  13903. * @returns the new emitter
  13904. */
  13905. clone(): CylinderDirectedParticleEmitter;
  13906. /**
  13907. * Called by the GPUParticleSystem to setup the update shader
  13908. * @param effect defines the update shader
  13909. */
  13910. applyToShader(effect: Effect): void;
  13911. /**
  13912. * Returns a string to use to update the GPU particles update shader
  13913. * @returns a string containng the defines string
  13914. */
  13915. getEffectDefines(): string;
  13916. /**
  13917. * Returns the string "CylinderDirectedParticleEmitter"
  13918. * @returns a string containing the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Serializes the particle system to a JSON object.
  13923. * @returns the JSON object
  13924. */
  13925. serialize(): any;
  13926. /**
  13927. * Parse properties from a JSON object
  13928. * @param serializationObject defines the JSON object
  13929. */
  13930. parse(serializationObject: any): void;
  13931. }
  13932. }
  13933. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13934. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13935. import { Effect } from "babylonjs/Materials/effect";
  13936. import { Particle } from "babylonjs/Particles/particle";
  13937. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13938. /**
  13939. * Particle emitter emitting particles from the inside of a hemisphere.
  13940. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13941. */
  13942. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13943. /**
  13944. * The radius of the emission hemisphere.
  13945. */
  13946. radius: number;
  13947. /**
  13948. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13949. */
  13950. radiusRange: number;
  13951. /**
  13952. * How much to randomize the particle direction [0-1].
  13953. */
  13954. directionRandomizer: number;
  13955. /**
  13956. * Creates a new instance HemisphericParticleEmitter
  13957. * @param radius the radius of the emission hemisphere (1 by default)
  13958. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13959. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13960. */
  13961. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  13976. * @param worldMatrix is the world matrix of the particle system
  13977. * @param directionToUpdate is the direction vector to update with the result
  13978. * @param particle is the particle we are computed the direction for
  13979. * @param isLocal defines if the direction should be set in local space
  13980. */
  13981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13982. /**
  13983. * Called by the particle System when the position is computed for the created particle.
  13984. * @param worldMatrix is the world matrix of the particle system
  13985. * @param positionToUpdate is the position vector to update with the result
  13986. * @param particle is the particle we are computed the position for
  13987. * @param isLocal defines if the position should be set in local space
  13988. */
  13989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13990. /**
  13991. * Clones the current emitter and returns a copy of it
  13992. * @returns the new emitter
  13993. */
  13994. clone(): HemisphericParticleEmitter;
  13995. /**
  13996. * Called by the GPUParticleSystem to setup the update shader
  13997. * @param effect defines the update shader
  13998. */
  13999. applyToShader(effect: Effect): void;
  14000. /**
  14001. * Returns a string to use to update the GPU particles update shader
  14002. * @returns a string containng the defines string
  14003. */
  14004. getEffectDefines(): string;
  14005. /**
  14006. * Returns the string "HemisphericParticleEmitter"
  14007. * @returns a string containing the class name
  14008. */
  14009. getClassName(): string;
  14010. /**
  14011. * Serializes the particle system to a JSON object.
  14012. * @returns the JSON object
  14013. */
  14014. serialize(): any;
  14015. /**
  14016. * Parse properties from a JSON object
  14017. * @param serializationObject defines the JSON object
  14018. */
  14019. parse(serializationObject: any): void;
  14020. }
  14021. }
  14022. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14023. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14024. import { Effect } from "babylonjs/Materials/effect";
  14025. import { Particle } from "babylonjs/Particles/particle";
  14026. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14027. /**
  14028. * Particle emitter emitting particles from a point.
  14029. * It emits the particles randomly between 2 given directions.
  14030. */
  14031. export class PointParticleEmitter implements IParticleEmitterType {
  14032. /**
  14033. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14034. */
  14035. direction1: Vector3;
  14036. /**
  14037. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14038. */
  14039. direction2: Vector3;
  14040. /**
  14041. * Creates a new instance PointParticleEmitter
  14042. */
  14043. constructor();
  14044. /**
  14045. * Called by the particle System when the direction is computed for the created particle.
  14046. * @param worldMatrix is the world matrix of the particle system
  14047. * @param directionToUpdate is the direction vector to update with the result
  14048. * @param particle is the particle we are computed the direction for
  14049. * @param isLocal defines if the direction should be set in local space
  14050. */
  14051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14052. /**
  14053. * Called by the particle System when the position is computed for the created particle.
  14054. * @param worldMatrix is the world matrix of the particle system
  14055. * @param positionToUpdate is the position vector to update with the result
  14056. * @param particle is the particle we are computed the position for
  14057. * @param isLocal defines if the position should be set in local space
  14058. */
  14059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14060. /**
  14061. * Clones the current emitter and returns a copy of it
  14062. * @returns the new emitter
  14063. */
  14064. clone(): PointParticleEmitter;
  14065. /**
  14066. * Called by the GPUParticleSystem to setup the update shader
  14067. * @param effect defines the update shader
  14068. */
  14069. applyToShader(effect: Effect): void;
  14070. /**
  14071. * Returns a string to use to update the GPU particles update shader
  14072. * @returns a string containng the defines string
  14073. */
  14074. getEffectDefines(): string;
  14075. /**
  14076. * Returns the string "PointParticleEmitter"
  14077. * @returns a string containing the class name
  14078. */
  14079. getClassName(): string;
  14080. /**
  14081. * Serializes the particle system to a JSON object.
  14082. * @returns the JSON object
  14083. */
  14084. serialize(): any;
  14085. /**
  14086. * Parse properties from a JSON object
  14087. * @param serializationObject defines the JSON object
  14088. */
  14089. parse(serializationObject: any): void;
  14090. }
  14091. }
  14092. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14093. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14094. import { Effect } from "babylonjs/Materials/effect";
  14095. import { Particle } from "babylonjs/Particles/particle";
  14096. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14097. /**
  14098. * Particle emitter emitting particles from the inside of a sphere.
  14099. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14100. */
  14101. export class SphereParticleEmitter implements IParticleEmitterType {
  14102. /**
  14103. * The radius of the emission sphere.
  14104. */
  14105. radius: number;
  14106. /**
  14107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14108. */
  14109. radiusRange: number;
  14110. /**
  14111. * How much to randomize the particle direction [0-1].
  14112. */
  14113. directionRandomizer: number;
  14114. /**
  14115. * Creates a new instance SphereParticleEmitter
  14116. * @param radius the radius of the emission sphere (1 by default)
  14117. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14118. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14119. */
  14120. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  14135. * @param worldMatrix is the world matrix of the particle system
  14136. * @param directionToUpdate is the direction vector to update with the result
  14137. * @param particle is the particle we are computed the direction for
  14138. * @param isLocal defines if the direction should be set in local space
  14139. */
  14140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14141. /**
  14142. * Called by the particle System when the position is computed for the created particle.
  14143. * @param worldMatrix is the world matrix of the particle system
  14144. * @param positionToUpdate is the position vector to update with the result
  14145. * @param particle is the particle we are computed the position for
  14146. * @param isLocal defines if the position should be set in local space
  14147. */
  14148. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14149. /**
  14150. * Clones the current emitter and returns a copy of it
  14151. * @returns the new emitter
  14152. */
  14153. clone(): SphereParticleEmitter;
  14154. /**
  14155. * Called by the GPUParticleSystem to setup the update shader
  14156. * @param effect defines the update shader
  14157. */
  14158. applyToShader(effect: Effect): void;
  14159. /**
  14160. * Returns a string to use to update the GPU particles update shader
  14161. * @returns a string containng the defines string
  14162. */
  14163. getEffectDefines(): string;
  14164. /**
  14165. * Returns the string "SphereParticleEmitter"
  14166. * @returns a string containing the class name
  14167. */
  14168. getClassName(): string;
  14169. /**
  14170. * Serializes the particle system to a JSON object.
  14171. * @returns the JSON object
  14172. */
  14173. serialize(): any;
  14174. /**
  14175. * Parse properties from a JSON object
  14176. * @param serializationObject defines the JSON object
  14177. */
  14178. parse(serializationObject: any): void;
  14179. }
  14180. /**
  14181. * Particle emitter emitting particles from the inside of a sphere.
  14182. * It emits the particles randomly between two vectors.
  14183. */
  14184. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14185. /**
  14186. * The min limit of the emission direction.
  14187. */
  14188. direction1: Vector3;
  14189. /**
  14190. * The max limit of the emission direction.
  14191. */
  14192. direction2: Vector3;
  14193. /**
  14194. * Creates a new instance SphereDirectedParticleEmitter
  14195. * @param radius the radius of the emission sphere (1 by default)
  14196. * @param direction1 the min limit of the emission direction (up vector by default)
  14197. * @param direction2 the max limit of the emission direction (up vector by default)
  14198. */
  14199. constructor(radius?: number,
  14200. /**
  14201. * The min limit of the emission direction.
  14202. */
  14203. direction1?: Vector3,
  14204. /**
  14205. * The max limit of the emission direction.
  14206. */
  14207. direction2?: Vector3);
  14208. /**
  14209. * Called by the particle System when the direction is computed for the created particle.
  14210. * @param worldMatrix is the world matrix of the particle system
  14211. * @param directionToUpdate is the direction vector to update with the result
  14212. * @param particle is the particle we are computed the direction for
  14213. */
  14214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14215. /**
  14216. * Clones the current emitter and returns a copy of it
  14217. * @returns the new emitter
  14218. */
  14219. clone(): SphereDirectedParticleEmitter;
  14220. /**
  14221. * Called by the GPUParticleSystem to setup the update shader
  14222. * @param effect defines the update shader
  14223. */
  14224. applyToShader(effect: Effect): void;
  14225. /**
  14226. * Returns a string to use to update the GPU particles update shader
  14227. * @returns a string containng the defines string
  14228. */
  14229. getEffectDefines(): string;
  14230. /**
  14231. * Returns the string "SphereDirectedParticleEmitter"
  14232. * @returns a string containing the class name
  14233. */
  14234. getClassName(): string;
  14235. /**
  14236. * Serializes the particle system to a JSON object.
  14237. * @returns the JSON object
  14238. */
  14239. serialize(): any;
  14240. /**
  14241. * Parse properties from a JSON object
  14242. * @param serializationObject defines the JSON object
  14243. */
  14244. parse(serializationObject: any): void;
  14245. }
  14246. }
  14247. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14248. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14249. import { Effect } from "babylonjs/Materials/effect";
  14250. import { Particle } from "babylonjs/Particles/particle";
  14251. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14252. import { Nullable } from "babylonjs/types";
  14253. /**
  14254. * Particle emitter emitting particles from a custom list of positions.
  14255. */
  14256. export class CustomParticleEmitter implements IParticleEmitterType {
  14257. /**
  14258. * Gets or sets the position generator that will create the inital position of each particle.
  14259. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14260. */
  14261. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14262. /**
  14263. * Gets or sets the destination generator that will create the final destination of each particle.
  14264. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14265. */
  14266. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14267. /**
  14268. * Creates a new instance CustomParticleEmitter
  14269. */
  14270. constructor();
  14271. /**
  14272. * Called by the particle System when the direction is computed for the created particle.
  14273. * @param worldMatrix is the world matrix of the particle system
  14274. * @param directionToUpdate is the direction vector to update with the result
  14275. * @param particle is the particle we are computed the direction for
  14276. * @param isLocal defines if the direction should be set in local space
  14277. */
  14278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14279. /**
  14280. * Called by the particle System when the position is computed for the created particle.
  14281. * @param worldMatrix is the world matrix of the particle system
  14282. * @param positionToUpdate is the position vector to update with the result
  14283. * @param particle is the particle we are computed the position for
  14284. * @param isLocal defines if the position should be set in local space
  14285. */
  14286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14287. /**
  14288. * Clones the current emitter and returns a copy of it
  14289. * @returns the new emitter
  14290. */
  14291. clone(): CustomParticleEmitter;
  14292. /**
  14293. * Called by the GPUParticleSystem to setup the update shader
  14294. * @param effect defines the update shader
  14295. */
  14296. applyToShader(effect: Effect): void;
  14297. /**
  14298. * Returns a string to use to update the GPU particles update shader
  14299. * @returns a string containng the defines string
  14300. */
  14301. getEffectDefines(): string;
  14302. /**
  14303. * Returns the string "PointParticleEmitter"
  14304. * @returns a string containing the class name
  14305. */
  14306. getClassName(): string;
  14307. /**
  14308. * Serializes the particle system to a JSON object.
  14309. * @returns the JSON object
  14310. */
  14311. serialize(): any;
  14312. /**
  14313. * Parse properties from a JSON object
  14314. * @param serializationObject defines the JSON object
  14315. */
  14316. parse(serializationObject: any): void;
  14317. }
  14318. }
  14319. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14321. import { Effect } from "babylonjs/Materials/effect";
  14322. import { Particle } from "babylonjs/Particles/particle";
  14323. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14324. import { Nullable } from "babylonjs/types";
  14325. import { Scene } from "babylonjs/scene";
  14326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14327. /**
  14328. * Particle emitter emitting particles from the inside of a box.
  14329. * It emits the particles randomly between 2 given directions.
  14330. */
  14331. export class MeshParticleEmitter implements IParticleEmitterType {
  14332. private _indices;
  14333. private _positions;
  14334. private _normals;
  14335. private _storedNormal;
  14336. private _mesh;
  14337. /**
  14338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14339. */
  14340. direction1: Vector3;
  14341. /**
  14342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14343. */
  14344. direction2: Vector3;
  14345. /**
  14346. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14347. */
  14348. useMeshNormalsForDirection: boolean;
  14349. /** Defines the mesh to use as source */
  14350. get mesh(): Nullable<AbstractMesh>;
  14351. set mesh(value: Nullable<AbstractMesh>);
  14352. /**
  14353. * Creates a new instance MeshParticleEmitter
  14354. * @param mesh defines the mesh to use as source
  14355. */
  14356. constructor(mesh?: Nullable<AbstractMesh>);
  14357. /**
  14358. * Called by the particle System when the direction is computed for the created particle.
  14359. * @param worldMatrix is the world matrix of the particle system
  14360. * @param directionToUpdate is the direction vector to update with the result
  14361. * @param particle is the particle we are computed the direction for
  14362. * @param isLocal defines if the direction should be set in local space
  14363. */
  14364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14365. /**
  14366. * Called by the particle System when the position is computed for the created particle.
  14367. * @param worldMatrix is the world matrix of the particle system
  14368. * @param positionToUpdate is the position vector to update with the result
  14369. * @param particle is the particle we are computed the position for
  14370. * @param isLocal defines if the position should be set in local space
  14371. */
  14372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14373. /**
  14374. * Clones the current emitter and returns a copy of it
  14375. * @returns the new emitter
  14376. */
  14377. clone(): MeshParticleEmitter;
  14378. /**
  14379. * Called by the GPUParticleSystem to setup the update shader
  14380. * @param effect defines the update shader
  14381. */
  14382. applyToShader(effect: Effect): void;
  14383. /**
  14384. * Returns a string to use to update the GPU particles update shader
  14385. * @returns a string containng the defines string
  14386. */
  14387. getEffectDefines(): string;
  14388. /**
  14389. * Returns the string "BoxParticleEmitter"
  14390. * @returns a string containing the class name
  14391. */
  14392. getClassName(): string;
  14393. /**
  14394. * Serializes the particle system to a JSON object.
  14395. * @returns the JSON object
  14396. */
  14397. serialize(): any;
  14398. /**
  14399. * Parse properties from a JSON object
  14400. * @param serializationObject defines the JSON object
  14401. * @param scene defines the hosting scene
  14402. */
  14403. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14404. }
  14405. }
  14406. declare module "babylonjs/Particles/EmitterTypes/index" {
  14407. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14408. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14409. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14410. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14411. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14412. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14413. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14414. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14415. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14416. }
  14417. declare module "babylonjs/Particles/IParticleSystem" {
  14418. import { Nullable } from "babylonjs/types";
  14419. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14420. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14422. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14423. import { Scene } from "babylonjs/scene";
  14424. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14425. import { Effect } from "babylonjs/Materials/effect";
  14426. import { Observable } from "babylonjs/Misc/observable";
  14427. import { Animation } from "babylonjs/Animations/animation";
  14428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14429. /**
  14430. * Interface representing a particle system in Babylon.js.
  14431. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14432. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14433. */
  14434. export interface IParticleSystem {
  14435. /**
  14436. * List of animations used by the particle system.
  14437. */
  14438. animations: Animation[];
  14439. /**
  14440. * The id of the Particle system.
  14441. */
  14442. id: string;
  14443. /**
  14444. * The name of the Particle system.
  14445. */
  14446. name: string;
  14447. /**
  14448. * The emitter represents the Mesh or position we are attaching the particle system to.
  14449. */
  14450. emitter: Nullable<AbstractMesh | Vector3>;
  14451. /**
  14452. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14453. */
  14454. isBillboardBased: boolean;
  14455. /**
  14456. * The rendering group used by the Particle system to chose when to render.
  14457. */
  14458. renderingGroupId: number;
  14459. /**
  14460. * The layer mask we are rendering the particles through.
  14461. */
  14462. layerMask: number;
  14463. /**
  14464. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14465. */
  14466. updateSpeed: number;
  14467. /**
  14468. * The amount of time the particle system is running (depends of the overall update speed).
  14469. */
  14470. targetStopDuration: number;
  14471. /**
  14472. * The texture used to render each particle. (this can be a spritesheet)
  14473. */
  14474. particleTexture: Nullable<BaseTexture>;
  14475. /**
  14476. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14477. */
  14478. blendMode: number;
  14479. /**
  14480. * Minimum life time of emitting particles.
  14481. */
  14482. minLifeTime: number;
  14483. /**
  14484. * Maximum life time of emitting particles.
  14485. */
  14486. maxLifeTime: number;
  14487. /**
  14488. * Minimum Size of emitting particles.
  14489. */
  14490. minSize: number;
  14491. /**
  14492. * Maximum Size of emitting particles.
  14493. */
  14494. maxSize: number;
  14495. /**
  14496. * Minimum scale of emitting particles on X axis.
  14497. */
  14498. minScaleX: number;
  14499. /**
  14500. * Maximum scale of emitting particles on X axis.
  14501. */
  14502. maxScaleX: number;
  14503. /**
  14504. * Minimum scale of emitting particles on Y axis.
  14505. */
  14506. minScaleY: number;
  14507. /**
  14508. * Maximum scale of emitting particles on Y axis.
  14509. */
  14510. maxScaleY: number;
  14511. /**
  14512. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14513. */
  14514. color1: Color4;
  14515. /**
  14516. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14517. */
  14518. color2: Color4;
  14519. /**
  14520. * Color the particle will have at the end of its lifetime.
  14521. */
  14522. colorDead: Color4;
  14523. /**
  14524. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14525. */
  14526. emitRate: number;
  14527. /**
  14528. * You can use gravity if you want to give an orientation to your particles.
  14529. */
  14530. gravity: Vector3;
  14531. /**
  14532. * Minimum power of emitting particles.
  14533. */
  14534. minEmitPower: number;
  14535. /**
  14536. * Maximum power of emitting particles.
  14537. */
  14538. maxEmitPower: number;
  14539. /**
  14540. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14541. */
  14542. minAngularSpeed: number;
  14543. /**
  14544. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14545. */
  14546. maxAngularSpeed: number;
  14547. /**
  14548. * Gets or sets the minimal initial rotation in radians.
  14549. */
  14550. minInitialRotation: number;
  14551. /**
  14552. * Gets or sets the maximal initial rotation in radians.
  14553. */
  14554. maxInitialRotation: number;
  14555. /**
  14556. * The particle emitter type defines the emitter used by the particle system.
  14557. * It can be for example box, sphere, or cone...
  14558. */
  14559. particleEmitterType: Nullable<IParticleEmitterType>;
  14560. /**
  14561. * Defines the delay in milliseconds before starting the system (0 by default)
  14562. */
  14563. startDelay: number;
  14564. /**
  14565. * 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
  14566. */
  14567. preWarmCycles: number;
  14568. /**
  14569. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14570. */
  14571. preWarmStepOffset: number;
  14572. /**
  14573. * 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)
  14574. */
  14575. spriteCellChangeSpeed: number;
  14576. /**
  14577. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14578. */
  14579. startSpriteCellID: number;
  14580. /**
  14581. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14582. */
  14583. endSpriteCellID: number;
  14584. /**
  14585. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14586. */
  14587. spriteCellWidth: number;
  14588. /**
  14589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14590. */
  14591. spriteCellHeight: number;
  14592. /**
  14593. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14594. */
  14595. spriteRandomStartCell: boolean;
  14596. /**
  14597. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14598. */
  14599. isAnimationSheetEnabled: boolean;
  14600. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14601. translationPivot: Vector2;
  14602. /**
  14603. * Gets or sets a texture used to add random noise to particle positions
  14604. */
  14605. noiseTexture: Nullable<BaseTexture>;
  14606. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14607. noiseStrength: Vector3;
  14608. /**
  14609. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14610. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14611. */
  14612. billboardMode: number;
  14613. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14614. limitVelocityDamping: number;
  14615. /**
  14616. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14617. */
  14618. beginAnimationOnStart: boolean;
  14619. /**
  14620. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14621. */
  14622. beginAnimationFrom: number;
  14623. /**
  14624. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14625. */
  14626. beginAnimationTo: number;
  14627. /**
  14628. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14629. */
  14630. beginAnimationLoop: boolean;
  14631. /**
  14632. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14633. */
  14634. disposeOnStop: boolean;
  14635. /**
  14636. * Specifies if the particles are updated in emitter local space or world space
  14637. */
  14638. isLocal: boolean;
  14639. /** Snippet ID if the particle system was created from the snippet server */
  14640. snippetId: string;
  14641. /** Gets or sets a matrix to use to compute projection */
  14642. defaultProjectionMatrix: Matrix;
  14643. /**
  14644. * Gets the maximum number of particles active at the same time.
  14645. * @returns The max number of active particles.
  14646. */
  14647. getCapacity(): number;
  14648. /**
  14649. * Gets the number of particles active at the same time.
  14650. * @returns The number of active particles.
  14651. */
  14652. getActiveCount(): number;
  14653. /**
  14654. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14655. * @returns True if it has been started, otherwise false.
  14656. */
  14657. isStarted(): boolean;
  14658. /**
  14659. * Animates the particle system for this frame.
  14660. */
  14661. animate(): void;
  14662. /**
  14663. * Renders the particle system in its current state.
  14664. * @returns the current number of particles
  14665. */
  14666. render(): number;
  14667. /**
  14668. * Dispose the particle system and frees its associated resources.
  14669. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14670. */
  14671. dispose(disposeTexture?: boolean): void;
  14672. /**
  14673. * An event triggered when the system is disposed
  14674. */
  14675. onDisposeObservable: Observable<IParticleSystem>;
  14676. /**
  14677. * Clones the particle system.
  14678. * @param name The name of the cloned object
  14679. * @param newEmitter The new emitter to use
  14680. * @returns the cloned particle system
  14681. */
  14682. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14683. /**
  14684. * Serializes the particle system to a JSON object
  14685. * @param serializeTexture defines if the texture must be serialized as well
  14686. * @returns the JSON object
  14687. */
  14688. serialize(serializeTexture: boolean): any;
  14689. /**
  14690. * Rebuild the particle system
  14691. */
  14692. rebuild(): void;
  14693. /** Force the system to rebuild all gradients that need to be resync */
  14694. forceRefreshGradients(): void;
  14695. /**
  14696. * Starts the particle system and begins to emit
  14697. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14698. */
  14699. start(delay?: number): void;
  14700. /**
  14701. * Stops the particle system.
  14702. */
  14703. stop(): void;
  14704. /**
  14705. * Remove all active particles
  14706. */
  14707. reset(): void;
  14708. /**
  14709. * Gets a boolean indicating that the system is stopping
  14710. * @returns true if the system is currently stopping
  14711. */
  14712. isStopping(): boolean;
  14713. /**
  14714. * Is this system ready to be used/rendered
  14715. * @return true if the system is ready
  14716. */
  14717. isReady(): boolean;
  14718. /**
  14719. * Returns the string "ParticleSystem"
  14720. * @returns a string containing the class name
  14721. */
  14722. getClassName(): string;
  14723. /**
  14724. * Gets the custom effect used to render the particles
  14725. * @param blendMode Blend mode for which the effect should be retrieved
  14726. * @returns The effect
  14727. */
  14728. getCustomEffect(blendMode: number): Nullable<Effect>;
  14729. /**
  14730. * Sets the custom effect used to render the particles
  14731. * @param effect The effect to set
  14732. * @param blendMode Blend mode for which the effect should be set
  14733. */
  14734. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14735. /**
  14736. * Fill the defines array according to the current settings of the particle system
  14737. * @param defines Array to be updated
  14738. * @param blendMode blend mode to take into account when updating the array
  14739. */
  14740. fillDefines(defines: Array<string>, blendMode: number): void;
  14741. /**
  14742. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14743. * @param uniforms Uniforms array to fill
  14744. * @param attributes Attributes array to fill
  14745. * @param samplers Samplers array to fill
  14746. */
  14747. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14748. /**
  14749. * Observable that will be called just before the particles are drawn
  14750. */
  14751. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14752. /**
  14753. * Gets the name of the particle vertex shader
  14754. */
  14755. vertexShaderName: string;
  14756. /**
  14757. * Adds a new color gradient
  14758. * @param gradient defines the gradient to use (between 0 and 1)
  14759. * @param color1 defines the color to affect to the specified gradient
  14760. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14761. * @returns the current particle system
  14762. */
  14763. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14764. /**
  14765. * Remove a specific color gradient
  14766. * @param gradient defines the gradient to remove
  14767. * @returns the current particle system
  14768. */
  14769. removeColorGradient(gradient: number): IParticleSystem;
  14770. /**
  14771. * Adds a new size gradient
  14772. * @param gradient defines the gradient to use (between 0 and 1)
  14773. * @param factor defines the size factor to affect to the specified gradient
  14774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14775. * @returns the current particle system
  14776. */
  14777. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14778. /**
  14779. * Remove a specific size gradient
  14780. * @param gradient defines the gradient to remove
  14781. * @returns the current particle system
  14782. */
  14783. removeSizeGradient(gradient: number): IParticleSystem;
  14784. /**
  14785. * Gets the current list of color gradients.
  14786. * You must use addColorGradient and removeColorGradient to udpate this list
  14787. * @returns the list of color gradients
  14788. */
  14789. getColorGradients(): Nullable<Array<ColorGradient>>;
  14790. /**
  14791. * Gets the current list of size gradients.
  14792. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14793. * @returns the list of size gradients
  14794. */
  14795. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14796. /**
  14797. * Gets the current list of angular speed gradients.
  14798. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14799. * @returns the list of angular speed gradients
  14800. */
  14801. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14802. /**
  14803. * Adds a new angular speed gradient
  14804. * @param gradient defines the gradient to use (between 0 and 1)
  14805. * @param factor defines the angular speed to affect to the specified gradient
  14806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14807. * @returns the current particle system
  14808. */
  14809. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14810. /**
  14811. * Remove a specific angular speed gradient
  14812. * @param gradient defines the gradient to remove
  14813. * @returns the current particle system
  14814. */
  14815. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14816. /**
  14817. * Gets the current list of velocity gradients.
  14818. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14819. * @returns the list of velocity gradients
  14820. */
  14821. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14822. /**
  14823. * Adds a new velocity gradient
  14824. * @param gradient defines the gradient to use (between 0 and 1)
  14825. * @param factor defines the velocity to affect to the specified gradient
  14826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14827. * @returns the current particle system
  14828. */
  14829. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14830. /**
  14831. * Remove a specific velocity gradient
  14832. * @param gradient defines the gradient to remove
  14833. * @returns the current particle system
  14834. */
  14835. removeVelocityGradient(gradient: number): IParticleSystem;
  14836. /**
  14837. * Gets the current list of limit velocity gradients.
  14838. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14839. * @returns the list of limit velocity gradients
  14840. */
  14841. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14842. /**
  14843. * Adds a new limit velocity gradient
  14844. * @param gradient defines the gradient to use (between 0 and 1)
  14845. * @param factor defines the limit velocity to affect to the specified gradient
  14846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14847. * @returns the current particle system
  14848. */
  14849. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14850. /**
  14851. * Remove a specific limit velocity gradient
  14852. * @param gradient defines the gradient to remove
  14853. * @returns the current particle system
  14854. */
  14855. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14856. /**
  14857. * Adds a new drag gradient
  14858. * @param gradient defines the gradient to use (between 0 and 1)
  14859. * @param factor defines the drag to affect to the specified gradient
  14860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14861. * @returns the current particle system
  14862. */
  14863. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14864. /**
  14865. * Remove a specific drag gradient
  14866. * @param gradient defines the gradient to remove
  14867. * @returns the current particle system
  14868. */
  14869. removeDragGradient(gradient: number): IParticleSystem;
  14870. /**
  14871. * Gets the current list of drag gradients.
  14872. * You must use addDragGradient and removeDragGradient to udpate this list
  14873. * @returns the list of drag gradients
  14874. */
  14875. getDragGradients(): Nullable<Array<FactorGradient>>;
  14876. /**
  14877. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14878. * @param gradient defines the gradient to use (between 0 and 1)
  14879. * @param factor defines the emit rate to affect to the specified gradient
  14880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14881. * @returns the current particle system
  14882. */
  14883. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14884. /**
  14885. * Remove a specific emit rate gradient
  14886. * @param gradient defines the gradient to remove
  14887. * @returns the current particle system
  14888. */
  14889. removeEmitRateGradient(gradient: number): IParticleSystem;
  14890. /**
  14891. * Gets the current list of emit rate gradients.
  14892. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14893. * @returns the list of emit rate gradients
  14894. */
  14895. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param factor defines the start size to affect to the specified gradient
  14900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14901. * @returns the current particle system
  14902. */
  14903. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14904. /**
  14905. * Remove a specific start size gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns the current particle system
  14908. */
  14909. removeStartSizeGradient(gradient: number): IParticleSystem;
  14910. /**
  14911. * Gets the current list of start size gradients.
  14912. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14913. * @returns the list of start size gradients
  14914. */
  14915. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14916. /**
  14917. * Adds a new life time gradient
  14918. * @param gradient defines the gradient to use (between 0 and 1)
  14919. * @param factor defines the life time factor to affect to the specified gradient
  14920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14921. * @returns the current particle system
  14922. */
  14923. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14924. /**
  14925. * Remove a specific life time gradient
  14926. * @param gradient defines the gradient to remove
  14927. * @returns the current particle system
  14928. */
  14929. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14930. /**
  14931. * Gets the current list of life time gradients.
  14932. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14933. * @returns the list of life time gradients
  14934. */
  14935. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14936. /**
  14937. * Gets the current list of color gradients.
  14938. * You must use addColorGradient and removeColorGradient to udpate this list
  14939. * @returns the list of color gradients
  14940. */
  14941. getColorGradients(): Nullable<Array<ColorGradient>>;
  14942. /**
  14943. * Adds a new ramp gradient used to remap particle colors
  14944. * @param gradient defines the gradient to use (between 0 and 1)
  14945. * @param color defines the color to affect to the specified gradient
  14946. * @returns the current particle system
  14947. */
  14948. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14949. /**
  14950. * Gets the current list of ramp gradients.
  14951. * You must use addRampGradient and removeRampGradient to udpate this list
  14952. * @returns the list of ramp gradients
  14953. */
  14954. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14955. /** Gets or sets a boolean indicating that ramp gradients must be used
  14956. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14957. */
  14958. useRampGradients: boolean;
  14959. /**
  14960. * Adds a new color remap gradient
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param min defines the color remap minimal range
  14963. * @param max defines the color remap maximal range
  14964. * @returns the current particle system
  14965. */
  14966. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Adds a new alpha remap gradient
  14975. * @param gradient defines the gradient to use (between 0 and 1)
  14976. * @param min defines the alpha remap minimal range
  14977. * @param max defines the alpha remap maximal range
  14978. * @returns the current particle system
  14979. */
  14980. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14981. /**
  14982. * Gets the current list of alpha remap gradients.
  14983. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14984. * @returns the list of alpha remap gradients
  14985. */
  14986. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14987. /**
  14988. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14989. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14990. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14991. * @returns the emitter
  14992. */
  14993. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14994. /**
  14995. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14996. * @param radius The radius of the hemisphere to emit from
  14997. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14998. * @returns the emitter
  14999. */
  15000. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15001. /**
  15002. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15003. * @param radius The radius of the sphere to emit from
  15004. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15005. * @returns the emitter
  15006. */
  15007. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15008. /**
  15009. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15010. * @param radius The radius of the sphere to emit from
  15011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15013. * @returns the emitter
  15014. */
  15015. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15016. /**
  15017. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15018. * @param radius The radius of the emission cylinder
  15019. * @param height The height of the emission cylinder
  15020. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15021. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15022. * @returns the emitter
  15023. */
  15024. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15025. /**
  15026. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15027. * @param radius The radius of the cylinder to emit from
  15028. * @param height The height of the emission cylinder
  15029. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15030. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15031. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15032. * @returns the emitter
  15033. */
  15034. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15035. /**
  15036. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15037. * @param radius The radius of the cone to emit from
  15038. * @param angle The base angle of the cone
  15039. * @returns the emitter
  15040. */
  15041. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15042. /**
  15043. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15044. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15045. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15046. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15047. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15048. * @returns the emitter
  15049. */
  15050. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15051. /**
  15052. * Get hosting scene
  15053. * @returns the scene
  15054. */
  15055. getScene(): Nullable<Scene>;
  15056. }
  15057. }
  15058. declare module "babylonjs/Meshes/transformNode" {
  15059. import { DeepImmutable } from "babylonjs/types";
  15060. import { Observable } from "babylonjs/Misc/observable";
  15061. import { Nullable } from "babylonjs/types";
  15062. import { Camera } from "babylonjs/Cameras/camera";
  15063. import { Scene } from "babylonjs/scene";
  15064. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15065. import { Node } from "babylonjs/node";
  15066. import { Bone } from "babylonjs/Bones/bone";
  15067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15068. import { Space } from "babylonjs/Maths/math.axis";
  15069. /**
  15070. * 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.
  15071. * @see https://doc.babylonjs.com/how_to/transformnode
  15072. */
  15073. export class TransformNode extends Node {
  15074. /**
  15075. * Object will not rotate to face the camera
  15076. */
  15077. static BILLBOARDMODE_NONE: number;
  15078. /**
  15079. * Object will rotate to face the camera but only on the x axis
  15080. */
  15081. static BILLBOARDMODE_X: number;
  15082. /**
  15083. * Object will rotate to face the camera but only on the y axis
  15084. */
  15085. static BILLBOARDMODE_Y: number;
  15086. /**
  15087. * Object will rotate to face the camera but only on the z axis
  15088. */
  15089. static BILLBOARDMODE_Z: number;
  15090. /**
  15091. * Object will rotate to face the camera
  15092. */
  15093. static BILLBOARDMODE_ALL: number;
  15094. /**
  15095. * Object will rotate to face the camera's position instead of orientation
  15096. */
  15097. static BILLBOARDMODE_USE_POSITION: number;
  15098. private static _TmpRotation;
  15099. private static _TmpScaling;
  15100. private static _TmpTranslation;
  15101. private _forward;
  15102. private _forwardInverted;
  15103. private _up;
  15104. private _right;
  15105. private _rightInverted;
  15106. private _position;
  15107. private _rotation;
  15108. private _rotationQuaternion;
  15109. protected _scaling: Vector3;
  15110. protected _isDirty: boolean;
  15111. private _transformToBoneReferal;
  15112. private _isAbsoluteSynced;
  15113. private _billboardMode;
  15114. /**
  15115. * Gets or sets the billboard mode. Default is 0.
  15116. *
  15117. * | Value | Type | Description |
  15118. * | --- | --- | --- |
  15119. * | 0 | BILLBOARDMODE_NONE | |
  15120. * | 1 | BILLBOARDMODE_X | |
  15121. * | 2 | BILLBOARDMODE_Y | |
  15122. * | 4 | BILLBOARDMODE_Z | |
  15123. * | 7 | BILLBOARDMODE_ALL | |
  15124. *
  15125. */
  15126. get billboardMode(): number;
  15127. set billboardMode(value: number);
  15128. private _preserveParentRotationForBillboard;
  15129. /**
  15130. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15131. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15132. */
  15133. get preserveParentRotationForBillboard(): boolean;
  15134. set preserveParentRotationForBillboard(value: boolean);
  15135. /**
  15136. * 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
  15137. */
  15138. scalingDeterminant: number;
  15139. private _infiniteDistance;
  15140. /**
  15141. * Gets or sets the distance of the object to max, often used by skybox
  15142. */
  15143. get infiniteDistance(): boolean;
  15144. set infiniteDistance(value: boolean);
  15145. /**
  15146. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15147. * By default the system will update normals to compensate
  15148. */
  15149. ignoreNonUniformScaling: boolean;
  15150. /**
  15151. * 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
  15152. */
  15153. reIntegrateRotationIntoRotationQuaternion: boolean;
  15154. /** @hidden */
  15155. _poseMatrix: Nullable<Matrix>;
  15156. /** @hidden */
  15157. _localMatrix: Matrix;
  15158. private _usePivotMatrix;
  15159. private _absolutePosition;
  15160. private _absoluteScaling;
  15161. private _absoluteRotationQuaternion;
  15162. private _pivotMatrix;
  15163. private _pivotMatrixInverse;
  15164. /** @hidden */
  15165. _postMultiplyPivotMatrix: boolean;
  15166. protected _isWorldMatrixFrozen: boolean;
  15167. /** @hidden */
  15168. _indexInSceneTransformNodesArray: number;
  15169. /**
  15170. * An event triggered after the world matrix is updated
  15171. */
  15172. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15173. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15174. /**
  15175. * Gets a string identifying the name of the class
  15176. * @returns "TransformNode" string
  15177. */
  15178. getClassName(): string;
  15179. /**
  15180. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15181. */
  15182. get position(): Vector3;
  15183. set position(newPosition: Vector3);
  15184. /**
  15185. * 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)).
  15186. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15187. */
  15188. get rotation(): Vector3;
  15189. set rotation(newRotation: Vector3);
  15190. /**
  15191. * 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)).
  15192. */
  15193. get scaling(): Vector3;
  15194. set scaling(newScaling: Vector3);
  15195. /**
  15196. * 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).
  15197. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15198. */
  15199. get rotationQuaternion(): Nullable<Quaternion>;
  15200. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15201. /**
  15202. * The forward direction of that transform in world space.
  15203. */
  15204. get forward(): Vector3;
  15205. /**
  15206. * The up direction of that transform in world space.
  15207. */
  15208. get up(): Vector3;
  15209. /**
  15210. * The right direction of that transform in world space.
  15211. */
  15212. get right(): Vector3;
  15213. /**
  15214. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15215. * @param matrix the matrix to copy the pose from
  15216. * @returns this TransformNode.
  15217. */
  15218. updatePoseMatrix(matrix: Matrix): TransformNode;
  15219. /**
  15220. * Returns the mesh Pose matrix.
  15221. * @returns the pose matrix
  15222. */
  15223. getPoseMatrix(): Matrix;
  15224. /** @hidden */
  15225. _isSynchronized(): boolean;
  15226. /** @hidden */
  15227. _initCache(): void;
  15228. /**
  15229. * Flag the transform node as dirty (Forcing it to update everything)
  15230. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15231. * @returns this transform node
  15232. */
  15233. markAsDirty(property: string): TransformNode;
  15234. /**
  15235. * Returns the current mesh absolute position.
  15236. * Returns a Vector3.
  15237. */
  15238. get absolutePosition(): Vector3;
  15239. /**
  15240. * Returns the current mesh absolute scaling.
  15241. * Returns a Vector3.
  15242. */
  15243. get absoluteScaling(): Vector3;
  15244. /**
  15245. * Returns the current mesh absolute rotation.
  15246. * Returns a Quaternion.
  15247. */
  15248. get absoluteRotationQuaternion(): Quaternion;
  15249. /**
  15250. * Sets a new matrix to apply before all other transformation
  15251. * @param matrix defines the transform matrix
  15252. * @returns the current TransformNode
  15253. */
  15254. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15255. /**
  15256. * Sets a new pivot matrix to the current node
  15257. * @param matrix defines the new pivot matrix to use
  15258. * @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
  15259. * @returns the current TransformNode
  15260. */
  15261. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15262. /**
  15263. * Returns the mesh pivot matrix.
  15264. * Default : Identity.
  15265. * @returns the matrix
  15266. */
  15267. getPivotMatrix(): Matrix;
  15268. /**
  15269. * Instantiate (when possible) or clone that node with its hierarchy
  15270. * @param newParent defines the new parent to use for the instance (or clone)
  15271. * @param options defines options to configure how copy is done
  15272. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15273. * @returns an instance (or a clone) of the current node with its hiearchy
  15274. */
  15275. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15276. doNotInstantiate: boolean;
  15277. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15278. /**
  15279. * Prevents the World matrix to be computed any longer
  15280. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15281. * @returns the TransformNode.
  15282. */
  15283. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15284. /**
  15285. * Allows back the World matrix computation.
  15286. * @returns the TransformNode.
  15287. */
  15288. unfreezeWorldMatrix(): this;
  15289. /**
  15290. * True if the World matrix has been frozen.
  15291. */
  15292. get isWorldMatrixFrozen(): boolean;
  15293. /**
  15294. * Retuns the mesh absolute position in the World.
  15295. * @returns a Vector3.
  15296. */
  15297. getAbsolutePosition(): Vector3;
  15298. /**
  15299. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15300. * @param absolutePosition the absolute position to set
  15301. * @returns the TransformNode.
  15302. */
  15303. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15304. /**
  15305. * Sets the mesh position in its local space.
  15306. * @param vector3 the position to set in localspace
  15307. * @returns the TransformNode.
  15308. */
  15309. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15310. /**
  15311. * Returns the mesh position in the local space from the current World matrix values.
  15312. * @returns a new Vector3.
  15313. */
  15314. getPositionExpressedInLocalSpace(): Vector3;
  15315. /**
  15316. * Translates the mesh along the passed Vector3 in its local space.
  15317. * @param vector3 the distance to translate in localspace
  15318. * @returns the TransformNode.
  15319. */
  15320. locallyTranslate(vector3: Vector3): TransformNode;
  15321. private static _lookAtVectorCache;
  15322. /**
  15323. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15324. * @param targetPoint the position (must be in same space as current mesh) to look at
  15325. * @param yawCor optional yaw (y-axis) correction in radians
  15326. * @param pitchCor optional pitch (x-axis) correction in radians
  15327. * @param rollCor optional roll (z-axis) correction in radians
  15328. * @param space the choosen space of the target
  15329. * @returns the TransformNode.
  15330. */
  15331. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15332. /**
  15333. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15334. * This Vector3 is expressed in the World space.
  15335. * @param localAxis axis to rotate
  15336. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15337. */
  15338. getDirection(localAxis: Vector3): Vector3;
  15339. /**
  15340. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15341. * localAxis is expressed in the mesh local space.
  15342. * result is computed in the Wordl space from the mesh World matrix.
  15343. * @param localAxis axis to rotate
  15344. * @param result the resulting transformnode
  15345. * @returns this TransformNode.
  15346. */
  15347. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15348. /**
  15349. * Sets this transform node rotation to the given local axis.
  15350. * @param localAxis the axis in local space
  15351. * @param yawCor optional yaw (y-axis) correction in radians
  15352. * @param pitchCor optional pitch (x-axis) correction in radians
  15353. * @param rollCor optional roll (z-axis) correction in radians
  15354. * @returns this TransformNode
  15355. */
  15356. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15357. /**
  15358. * Sets a new pivot point to the current node
  15359. * @param point defines the new pivot point to use
  15360. * @param space defines if the point is in world or local space (local by default)
  15361. * @returns the current TransformNode
  15362. */
  15363. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15364. /**
  15365. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15366. * @returns the pivot point
  15367. */
  15368. getPivotPoint(): Vector3;
  15369. /**
  15370. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15371. * @param result the vector3 to store the result
  15372. * @returns this TransformNode.
  15373. */
  15374. getPivotPointToRef(result: Vector3): TransformNode;
  15375. /**
  15376. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15377. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15378. */
  15379. getAbsolutePivotPoint(): Vector3;
  15380. /**
  15381. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15382. * @param result vector3 to store the result
  15383. * @returns this TransformNode.
  15384. */
  15385. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15386. /**
  15387. * Defines the passed node as the parent of the current node.
  15388. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15389. * @see https://doc.babylonjs.com/how_to/parenting
  15390. * @param node the node ot set as the parent
  15391. * @returns this TransformNode.
  15392. */
  15393. setParent(node: Nullable<Node>): TransformNode;
  15394. private _nonUniformScaling;
  15395. /**
  15396. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15397. */
  15398. get nonUniformScaling(): boolean;
  15399. /** @hidden */
  15400. _updateNonUniformScalingState(value: boolean): boolean;
  15401. /**
  15402. * Attach the current TransformNode to another TransformNode associated with a bone
  15403. * @param bone Bone affecting the TransformNode
  15404. * @param affectedTransformNode TransformNode associated with the bone
  15405. * @returns this object
  15406. */
  15407. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15408. /**
  15409. * Detach the transform node if its associated with a bone
  15410. * @returns this object
  15411. */
  15412. detachFromBone(): TransformNode;
  15413. private static _rotationAxisCache;
  15414. /**
  15415. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15416. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized.
  15419. * @param axis the axis to rotate around
  15420. * @param amount the amount to rotate in radians
  15421. * @param space Space to rotate in (Default: local)
  15422. * @returns the TransformNode.
  15423. */
  15424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15425. /**
  15426. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15427. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15428. * The passed axis is also normalized. .
  15429. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15430. * @param point the point to rotate around
  15431. * @param axis the axis to rotate around
  15432. * @param amount the amount to rotate in radians
  15433. * @returns the TransformNode
  15434. */
  15435. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15436. /**
  15437. * Translates the mesh along the axis vector for the passed distance in the given space.
  15438. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15439. * @param axis the axis to translate in
  15440. * @param distance the distance to translate
  15441. * @param space Space to rotate in (Default: local)
  15442. * @returns the TransformNode.
  15443. */
  15444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15445. /**
  15446. * Adds a rotation step to the mesh current rotation.
  15447. * x, y, z are Euler angles expressed in radians.
  15448. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15449. * This means this rotation is made in the mesh local space only.
  15450. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15451. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15452. * ```javascript
  15453. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15454. * ```
  15455. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15456. * 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.
  15457. * @param x Rotation to add
  15458. * @param y Rotation to add
  15459. * @param z Rotation to add
  15460. * @returns the TransformNode.
  15461. */
  15462. addRotation(x: number, y: number, z: number): TransformNode;
  15463. /**
  15464. * @hidden
  15465. */
  15466. protected _getEffectiveParent(): Nullable<Node>;
  15467. /**
  15468. * Computes the world matrix of the node
  15469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15470. * @returns the world matrix
  15471. */
  15472. computeWorldMatrix(force?: boolean): Matrix;
  15473. /**
  15474. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15475. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15476. */
  15477. resetLocalMatrix(independentOfChildren?: boolean): void;
  15478. protected _afterComputeWorldMatrix(): void;
  15479. /**
  15480. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15481. * @param func callback function to add
  15482. *
  15483. * @returns the TransformNode.
  15484. */
  15485. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15486. /**
  15487. * Removes a registered callback function.
  15488. * @param func callback function to remove
  15489. * @returns the TransformNode.
  15490. */
  15491. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15492. /**
  15493. * Gets the position of the current mesh in camera space
  15494. * @param camera defines the camera to use
  15495. * @returns a position
  15496. */
  15497. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15498. /**
  15499. * Returns the distance from the mesh to the active camera
  15500. * @param camera defines the camera to use
  15501. * @returns the distance
  15502. */
  15503. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15504. /**
  15505. * Clone the current transform node
  15506. * @param name Name of the new clone
  15507. * @param newParent New parent for the clone
  15508. * @param doNotCloneChildren Do not clone children hierarchy
  15509. * @returns the new transform node
  15510. */
  15511. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15512. /**
  15513. * Serializes the objects information.
  15514. * @param currentSerializationObject defines the object to serialize in
  15515. * @returns the serialized object
  15516. */
  15517. serialize(currentSerializationObject?: any): any;
  15518. /**
  15519. * Returns a new TransformNode object parsed from the source provided.
  15520. * @param parsedTransformNode is the source.
  15521. * @param scene the scne the object belongs to
  15522. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15523. * @returns a new TransformNode object parsed from the source provided.
  15524. */
  15525. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15526. /**
  15527. * Get all child-transformNodes of this node
  15528. * @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
  15529. * @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
  15530. * @returns an array of TransformNode
  15531. */
  15532. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15533. /**
  15534. * Releases resources associated with this transform node.
  15535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15537. */
  15538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15539. /**
  15540. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15541. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15542. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15543. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15544. * @returns the current mesh
  15545. */
  15546. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15547. private _syncAbsoluteScalingAndRotation;
  15548. }
  15549. }
  15550. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15551. /**
  15552. * Class used to override all child animations of a given target
  15553. */
  15554. export class AnimationPropertiesOverride {
  15555. /**
  15556. * Gets or sets a value indicating if animation blending must be used
  15557. */
  15558. enableBlending: boolean;
  15559. /**
  15560. * Gets or sets the blending speed to use when enableBlending is true
  15561. */
  15562. blendingSpeed: number;
  15563. /**
  15564. * Gets or sets the default loop mode to use
  15565. */
  15566. loopMode: number;
  15567. }
  15568. }
  15569. declare module "babylonjs/Bones/bone" {
  15570. import { Skeleton } from "babylonjs/Bones/skeleton";
  15571. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15572. import { Nullable } from "babylonjs/types";
  15573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15575. import { Node } from "babylonjs/node";
  15576. import { Space } from "babylonjs/Maths/math.axis";
  15577. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15578. /**
  15579. * Class used to store bone information
  15580. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15581. */
  15582. export class Bone extends Node {
  15583. /**
  15584. * defines the bone name
  15585. */
  15586. name: string;
  15587. private static _tmpVecs;
  15588. private static _tmpQuat;
  15589. private static _tmpMats;
  15590. /**
  15591. * Gets the list of child bones
  15592. */
  15593. children: Bone[];
  15594. /** Gets the animations associated with this bone */
  15595. animations: import("babylonjs/Animations/animation").Animation[];
  15596. /**
  15597. * Gets or sets bone length
  15598. */
  15599. length: number;
  15600. /**
  15601. * @hidden Internal only
  15602. * Set this value to map this bone to a different index in the transform matrices
  15603. * Set this value to -1 to exclude the bone from the transform matrices
  15604. */
  15605. _index: Nullable<number>;
  15606. private _skeleton;
  15607. private _localMatrix;
  15608. private _restPose;
  15609. private _bindPose;
  15610. private _baseMatrix;
  15611. private _absoluteTransform;
  15612. private _invertedAbsoluteTransform;
  15613. private _parent;
  15614. private _scalingDeterminant;
  15615. private _worldTransform;
  15616. private _localScaling;
  15617. private _localRotation;
  15618. private _localPosition;
  15619. private _needToDecompose;
  15620. private _needToCompose;
  15621. /** @hidden */
  15622. _linkedTransformNode: Nullable<TransformNode>;
  15623. /** @hidden */
  15624. _waitingTransformNodeId: Nullable<string>;
  15625. /** @hidden */
  15626. get _matrix(): Matrix;
  15627. /** @hidden */
  15628. set _matrix(value: Matrix);
  15629. /**
  15630. * Create a new bone
  15631. * @param name defines the bone name
  15632. * @param skeleton defines the parent skeleton
  15633. * @param parentBone defines the parent (can be null if the bone is the root)
  15634. * @param localMatrix defines the local matrix
  15635. * @param restPose defines the rest pose matrix
  15636. * @param baseMatrix defines the base matrix
  15637. * @param index defines index of the bone in the hiearchy
  15638. */
  15639. constructor(
  15640. /**
  15641. * defines the bone name
  15642. */
  15643. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15644. /**
  15645. * Gets the current object class name.
  15646. * @return the class name
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Gets the parent skeleton
  15651. * @returns a skeleton
  15652. */
  15653. getSkeleton(): Skeleton;
  15654. /**
  15655. * Gets parent bone
  15656. * @returns a bone or null if the bone is the root of the bone hierarchy
  15657. */
  15658. getParent(): Nullable<Bone>;
  15659. /**
  15660. * Returns an array containing the root bones
  15661. * @returns an array containing the root bones
  15662. */
  15663. getChildren(): Array<Bone>;
  15664. /**
  15665. * Gets the node index in matrix array generated for rendering
  15666. * @returns the node index
  15667. */
  15668. getIndex(): number;
  15669. /**
  15670. * Sets the parent bone
  15671. * @param parent defines the parent (can be null if the bone is the root)
  15672. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15673. */
  15674. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15675. /**
  15676. * Gets the local matrix
  15677. * @returns a matrix
  15678. */
  15679. getLocalMatrix(): Matrix;
  15680. /**
  15681. * Gets the base matrix (initial matrix which remains unchanged)
  15682. * @returns a matrix
  15683. */
  15684. getBaseMatrix(): Matrix;
  15685. /**
  15686. * Gets the rest pose matrix
  15687. * @returns a matrix
  15688. */
  15689. getRestPose(): Matrix;
  15690. /**
  15691. * Sets the rest pose matrix
  15692. * @param matrix the local-space rest pose to set for this bone
  15693. */
  15694. setRestPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets the bind pose matrix
  15697. * @returns the bind pose matrix
  15698. */
  15699. getBindPose(): Matrix;
  15700. /**
  15701. * Sets the bind pose matrix
  15702. * @param matrix the local-space bind pose to set for this bone
  15703. */
  15704. setBindPose(matrix: Matrix): void;
  15705. /**
  15706. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15707. */
  15708. getWorldMatrix(): Matrix;
  15709. /**
  15710. * Sets the local matrix to rest pose matrix
  15711. */
  15712. returnToRest(): void;
  15713. /**
  15714. * Gets the inverse of the absolute transform matrix.
  15715. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15716. * @returns a matrix
  15717. */
  15718. getInvertedAbsoluteTransform(): Matrix;
  15719. /**
  15720. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15721. * @returns a matrix
  15722. */
  15723. getAbsoluteTransform(): Matrix;
  15724. /**
  15725. * Links with the given transform node.
  15726. * The local matrix of this bone is copied from the transform node every frame.
  15727. * @param transformNode defines the transform node to link to
  15728. */
  15729. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15730. /**
  15731. * Gets the node used to drive the bone's transformation
  15732. * @returns a transform node or null
  15733. */
  15734. getTransformNode(): Nullable<TransformNode>;
  15735. /** Gets or sets current position (in local space) */
  15736. get position(): Vector3;
  15737. set position(newPosition: Vector3);
  15738. /** Gets or sets current rotation (in local space) */
  15739. get rotation(): Vector3;
  15740. set rotation(newRotation: Vector3);
  15741. /** Gets or sets current rotation quaternion (in local space) */
  15742. get rotationQuaternion(): Quaternion;
  15743. set rotationQuaternion(newRotation: Quaternion);
  15744. /** Gets or sets current scaling (in local space) */
  15745. get scaling(): Vector3;
  15746. set scaling(newScaling: Vector3);
  15747. /**
  15748. * Gets the animation properties override
  15749. */
  15750. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15751. private _decompose;
  15752. private _compose;
  15753. /**
  15754. * Update the base and local matrices
  15755. * @param matrix defines the new base or local matrix
  15756. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15757. * @param updateLocalMatrix defines if the local matrix should be updated
  15758. */
  15759. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15760. /** @hidden */
  15761. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15762. /**
  15763. * Flag the bone as dirty (Forcing it to update everything)
  15764. */
  15765. markAsDirty(): void;
  15766. /** @hidden */
  15767. _markAsDirtyAndCompose(): void;
  15768. private _markAsDirtyAndDecompose;
  15769. /**
  15770. * Translate the bone in local or world space
  15771. * @param vec The amount to translate the bone
  15772. * @param space The space that the translation is in
  15773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15774. */
  15775. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15776. /**
  15777. * Set the postion of the bone in local or world space
  15778. * @param position The position to set the bone
  15779. * @param space The space that the position is in
  15780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15781. */
  15782. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15783. /**
  15784. * Set the absolute position of the bone (world space)
  15785. * @param position The position to set the bone
  15786. * @param mesh The mesh that this bone is attached to
  15787. */
  15788. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15789. /**
  15790. * Scale the bone on the x, y and z axes (in local space)
  15791. * @param x The amount to scale the bone on the x axis
  15792. * @param y The amount to scale the bone on the y axis
  15793. * @param z The amount to scale the bone on the z axis
  15794. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15795. */
  15796. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15797. /**
  15798. * Set the bone scaling in local space
  15799. * @param scale defines the scaling vector
  15800. */
  15801. setScale(scale: Vector3): void;
  15802. /**
  15803. * Gets the current scaling in local space
  15804. * @returns the current scaling vector
  15805. */
  15806. getScale(): Vector3;
  15807. /**
  15808. * Gets the current scaling in local space and stores it in a target vector
  15809. * @param result defines the target vector
  15810. */
  15811. getScaleToRef(result: Vector3): void;
  15812. /**
  15813. * Set the yaw, pitch, and roll of the bone in local or world space
  15814. * @param yaw The rotation of the bone on the y axis
  15815. * @param pitch The rotation of the bone on the x axis
  15816. * @param roll The rotation of the bone on the z axis
  15817. * @param space The space that the axes of rotation are in
  15818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15819. */
  15820. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15821. /**
  15822. * Add a rotation to the bone on an axis in local or world space
  15823. * @param axis The axis to rotate the bone on
  15824. * @param amount The amount to rotate the bone
  15825. * @param space The space that the axis is in
  15826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15827. */
  15828. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15829. /**
  15830. * Set the rotation of the bone to a particular axis angle in local or world space
  15831. * @param axis The axis to rotate the bone on
  15832. * @param angle The angle that the bone should be rotated to
  15833. * @param space The space that the axis is in
  15834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15835. */
  15836. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15837. /**
  15838. * Set the euler rotation of the bone in local or world space
  15839. * @param rotation The euler rotation that the bone should be set to
  15840. * @param space The space that the rotation is in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. */
  15843. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15844. /**
  15845. * Set the quaternion rotation of the bone in local or world space
  15846. * @param quat The quaternion rotation that the bone should be set to
  15847. * @param space The space that the rotation is in
  15848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15849. */
  15850. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15851. /**
  15852. * Set the rotation matrix of the bone in local or world space
  15853. * @param rotMat The rotation matrix that the bone should be set to
  15854. * @param space The space that the rotation is in
  15855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15856. */
  15857. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15858. private _rotateWithMatrix;
  15859. private _getNegativeRotationToRef;
  15860. /**
  15861. * Get the position of the bone in local or world space
  15862. * @param space The space that the returned position is in
  15863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15864. * @returns The position of the bone
  15865. */
  15866. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15867. /**
  15868. * Copy the position of the bone to a vector3 in local or world space
  15869. * @param space The space that the returned position is in
  15870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15871. * @param result The vector3 to copy the position to
  15872. */
  15873. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15874. /**
  15875. * Get the absolute position of the bone (world space)
  15876. * @param mesh The mesh that this bone is attached to
  15877. * @returns The absolute position of the bone
  15878. */
  15879. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15880. /**
  15881. * Copy the absolute position of the bone (world space) to the result param
  15882. * @param mesh The mesh that this bone is attached to
  15883. * @param result The vector3 to copy the absolute position to
  15884. */
  15885. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15886. /**
  15887. * Compute the absolute transforms of this bone and its children
  15888. */
  15889. computeAbsoluteTransforms(): void;
  15890. /**
  15891. * Get the world direction from an axis that is in the local space of the bone
  15892. * @param localAxis The local direction that is used to compute the world direction
  15893. * @param mesh The mesh that this bone is attached to
  15894. * @returns The world direction
  15895. */
  15896. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15897. /**
  15898. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15899. * @param localAxis The local direction that is used to compute the world direction
  15900. * @param mesh The mesh that this bone is attached to
  15901. * @param result The vector3 that the world direction will be copied to
  15902. */
  15903. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15904. /**
  15905. * Get the euler rotation of the bone in local or world space
  15906. * @param space The space that the rotation should be in
  15907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15908. * @returns The euler rotation
  15909. */
  15910. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15911. /**
  15912. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15913. * @param space The space that the rotation should be in
  15914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15915. * @param result The vector3 that the rotation should be copied to
  15916. */
  15917. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15918. /**
  15919. * Get the quaternion rotation of the bone in either local or world space
  15920. * @param space The space that the rotation should be in
  15921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15922. * @returns The quaternion rotation
  15923. */
  15924. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15925. /**
  15926. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15927. * @param space The space that the rotation should be in
  15928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15929. * @param result The quaternion that the rotation should be copied to
  15930. */
  15931. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15932. /**
  15933. * Get the rotation matrix of the bone in local or world space
  15934. * @param space The space that the rotation should be in
  15935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15936. * @returns The rotation matrix
  15937. */
  15938. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15939. /**
  15940. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15941. * @param space The space that the rotation should be in
  15942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15943. * @param result The quaternion that the rotation should be copied to
  15944. */
  15945. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15946. /**
  15947. * Get the world position of a point that is in the local space of the bone
  15948. * @param position The local position
  15949. * @param mesh The mesh that this bone is attached to
  15950. * @returns The world position
  15951. */
  15952. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15953. /**
  15954. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15955. * @param position The local position
  15956. * @param mesh The mesh that this bone is attached to
  15957. * @param result The vector3 that the world position should be copied to
  15958. */
  15959. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15960. /**
  15961. * Get the local position of a point that is in world space
  15962. * @param position The world position
  15963. * @param mesh The mesh that this bone is attached to
  15964. * @returns The local position
  15965. */
  15966. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15967. /**
  15968. * Get the local position of a point that is in world space and copy it to the result param
  15969. * @param position The world position
  15970. * @param mesh The mesh that this bone is attached to
  15971. * @param result The vector3 that the local position should be copied to
  15972. */
  15973. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15974. /**
  15975. * Set the current local matrix as the restPose for this bone.
  15976. */
  15977. setCurrentPoseAsRest(): void;
  15978. }
  15979. }
  15980. declare module "babylonjs/Animations/runtimeAnimation" {
  15981. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15982. import { Animatable } from "babylonjs/Animations/animatable";
  15983. import { Scene } from "babylonjs/scene";
  15984. /**
  15985. * Defines a runtime animation
  15986. */
  15987. export class RuntimeAnimation {
  15988. private _events;
  15989. /**
  15990. * The current frame of the runtime animation
  15991. */
  15992. private _currentFrame;
  15993. /**
  15994. * The animation used by the runtime animation
  15995. */
  15996. private _animation;
  15997. /**
  15998. * The target of the runtime animation
  15999. */
  16000. private _target;
  16001. /**
  16002. * The initiating animatable
  16003. */
  16004. private _host;
  16005. /**
  16006. * The original value of the runtime animation
  16007. */
  16008. private _originalValue;
  16009. /**
  16010. * The original blend value of the runtime animation
  16011. */
  16012. private _originalBlendValue;
  16013. /**
  16014. * The offsets cache of the runtime animation
  16015. */
  16016. private _offsetsCache;
  16017. /**
  16018. * The high limits cache of the runtime animation
  16019. */
  16020. private _highLimitsCache;
  16021. /**
  16022. * Specifies if the runtime animation has been stopped
  16023. */
  16024. private _stopped;
  16025. /**
  16026. * The blending factor of the runtime animation
  16027. */
  16028. private _blendingFactor;
  16029. /**
  16030. * The BabylonJS scene
  16031. */
  16032. private _scene;
  16033. /**
  16034. * The current value of the runtime animation
  16035. */
  16036. private _currentValue;
  16037. /** @hidden */
  16038. _animationState: _IAnimationState;
  16039. /**
  16040. * The active target of the runtime animation
  16041. */
  16042. private _activeTargets;
  16043. private _currentActiveTarget;
  16044. private _directTarget;
  16045. /**
  16046. * The target path of the runtime animation
  16047. */
  16048. private _targetPath;
  16049. /**
  16050. * The weight of the runtime animation
  16051. */
  16052. private _weight;
  16053. /**
  16054. * The ratio offset of the runtime animation
  16055. */
  16056. private _ratioOffset;
  16057. /**
  16058. * The previous delay of the runtime animation
  16059. */
  16060. private _previousDelay;
  16061. /**
  16062. * The previous ratio of the runtime animation
  16063. */
  16064. private _previousRatio;
  16065. private _enableBlending;
  16066. private _keys;
  16067. private _minFrame;
  16068. private _maxFrame;
  16069. private _minValue;
  16070. private _maxValue;
  16071. private _targetIsArray;
  16072. /**
  16073. * Gets the current frame of the runtime animation
  16074. */
  16075. get currentFrame(): number;
  16076. /**
  16077. * Gets the weight of the runtime animation
  16078. */
  16079. get weight(): number;
  16080. /**
  16081. * Gets the current value of the runtime animation
  16082. */
  16083. get currentValue(): any;
  16084. /**
  16085. * Gets the target path of the runtime animation
  16086. */
  16087. get targetPath(): string;
  16088. /**
  16089. * Gets the actual target of the runtime animation
  16090. */
  16091. get target(): any;
  16092. /**
  16093. * Gets the additive state of the runtime animation
  16094. */
  16095. get isAdditive(): boolean;
  16096. /** @hidden */
  16097. _onLoop: () => void;
  16098. /**
  16099. * Create a new RuntimeAnimation object
  16100. * @param target defines the target of the animation
  16101. * @param animation defines the source animation object
  16102. * @param scene defines the hosting scene
  16103. * @param host defines the initiating Animatable
  16104. */
  16105. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16106. private _preparePath;
  16107. /**
  16108. * Gets the animation from the runtime animation
  16109. */
  16110. get animation(): Animation;
  16111. /**
  16112. * Resets the runtime animation to the beginning
  16113. * @param restoreOriginal defines whether to restore the target property to the original value
  16114. */
  16115. reset(restoreOriginal?: boolean): void;
  16116. /**
  16117. * Specifies if the runtime animation is stopped
  16118. * @returns Boolean specifying if the runtime animation is stopped
  16119. */
  16120. isStopped(): boolean;
  16121. /**
  16122. * Disposes of the runtime animation
  16123. */
  16124. dispose(): void;
  16125. /**
  16126. * Apply the interpolated value to the target
  16127. * @param currentValue defines the value computed by the animation
  16128. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16129. */
  16130. setValue(currentValue: any, weight: number): void;
  16131. private _getOriginalValues;
  16132. private _setValue;
  16133. /**
  16134. * Gets the loop pmode of the runtime animation
  16135. * @returns Loop Mode
  16136. */
  16137. private _getCorrectLoopMode;
  16138. /**
  16139. * Move the current animation to a given frame
  16140. * @param frame defines the frame to move to
  16141. */
  16142. goToFrame(frame: number): void;
  16143. /**
  16144. * @hidden Internal use only
  16145. */
  16146. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16147. /**
  16148. * Execute the current animation
  16149. * @param delay defines the delay to add to the current frame
  16150. * @param from defines the lower bound of the animation range
  16151. * @param to defines the upper bound of the animation range
  16152. * @param loop defines if the current animation must loop
  16153. * @param speedRatio defines the current speed ratio
  16154. * @param weight defines the weight of the animation (default is -1 so no weight)
  16155. * @param onLoop optional callback called when animation loops
  16156. * @returns a boolean indicating if the animation is running
  16157. */
  16158. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16159. }
  16160. }
  16161. declare module "babylonjs/Animations/animatable" {
  16162. import { Animation } from "babylonjs/Animations/animation";
  16163. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16164. import { Nullable } from "babylonjs/types";
  16165. import { Observable } from "babylonjs/Misc/observable";
  16166. import { Scene } from "babylonjs/scene";
  16167. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16168. import { Node } from "babylonjs/node";
  16169. /**
  16170. * Class used to store an actual running animation
  16171. */
  16172. export class Animatable {
  16173. /** defines the target object */
  16174. target: any;
  16175. /** defines the starting frame number (default is 0) */
  16176. fromFrame: number;
  16177. /** defines the ending frame number (default is 100) */
  16178. toFrame: number;
  16179. /** defines if the animation must loop (default is false) */
  16180. loopAnimation: boolean;
  16181. /** defines a callback to call when animation ends if it is not looping */
  16182. onAnimationEnd?: (() => void) | null | undefined;
  16183. /** defines a callback to call when animation loops */
  16184. onAnimationLoop?: (() => void) | null | undefined;
  16185. /** defines whether the animation should be evaluated additively */
  16186. isAdditive: boolean;
  16187. private _localDelayOffset;
  16188. private _pausedDelay;
  16189. private _runtimeAnimations;
  16190. private _paused;
  16191. private _scene;
  16192. private _speedRatio;
  16193. private _weight;
  16194. private _syncRoot;
  16195. /**
  16196. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16197. * This will only apply for non looping animation (default is true)
  16198. */
  16199. disposeOnEnd: boolean;
  16200. /**
  16201. * Gets a boolean indicating if the animation has started
  16202. */
  16203. animationStarted: boolean;
  16204. /**
  16205. * Observer raised when the animation ends
  16206. */
  16207. onAnimationEndObservable: Observable<Animatable>;
  16208. /**
  16209. * Observer raised when the animation loops
  16210. */
  16211. onAnimationLoopObservable: Observable<Animatable>;
  16212. /**
  16213. * Gets the root Animatable used to synchronize and normalize animations
  16214. */
  16215. get syncRoot(): Nullable<Animatable>;
  16216. /**
  16217. * Gets the current frame of the first RuntimeAnimation
  16218. * Used to synchronize Animatables
  16219. */
  16220. get masterFrame(): number;
  16221. /**
  16222. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16223. */
  16224. get weight(): number;
  16225. set weight(value: number);
  16226. /**
  16227. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16228. */
  16229. get speedRatio(): number;
  16230. set speedRatio(value: number);
  16231. /**
  16232. * Creates a new Animatable
  16233. * @param scene defines the hosting scene
  16234. * @param target defines the target object
  16235. * @param fromFrame defines the starting frame number (default is 0)
  16236. * @param toFrame defines the ending frame number (default is 100)
  16237. * @param loopAnimation defines if the animation must loop (default is false)
  16238. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16239. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16240. * @param animations defines a group of animation to add to the new Animatable
  16241. * @param onAnimationLoop defines a callback to call when animation loops
  16242. * @param isAdditive defines whether the animation should be evaluated additively
  16243. */
  16244. constructor(scene: Scene,
  16245. /** defines the target object */
  16246. target: any,
  16247. /** defines the starting frame number (default is 0) */
  16248. fromFrame?: number,
  16249. /** defines the ending frame number (default is 100) */
  16250. toFrame?: number,
  16251. /** defines if the animation must loop (default is false) */
  16252. loopAnimation?: boolean, speedRatio?: number,
  16253. /** defines a callback to call when animation ends if it is not looping */
  16254. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16255. /** defines a callback to call when animation loops */
  16256. onAnimationLoop?: (() => void) | null | undefined,
  16257. /** defines whether the animation should be evaluated additively */
  16258. isAdditive?: boolean);
  16259. /**
  16260. * Synchronize and normalize current Animatable with a source Animatable
  16261. * This is useful when using animation weights and when animations are not of the same length
  16262. * @param root defines the root Animatable to synchronize with
  16263. * @returns the current Animatable
  16264. */
  16265. syncWith(root: Animatable): Animatable;
  16266. /**
  16267. * Gets the list of runtime animations
  16268. * @returns an array of RuntimeAnimation
  16269. */
  16270. getAnimations(): RuntimeAnimation[];
  16271. /**
  16272. * Adds more animations to the current animatable
  16273. * @param target defines the target of the animations
  16274. * @param animations defines the new animations to add
  16275. */
  16276. appendAnimations(target: any, animations: Animation[]): void;
  16277. /**
  16278. * Gets the source animation for a specific property
  16279. * @param property defines the propertyu to look for
  16280. * @returns null or the source animation for the given property
  16281. */
  16282. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16283. /**
  16284. * Gets the runtime animation for a specific property
  16285. * @param property defines the propertyu to look for
  16286. * @returns null or the runtime animation for the given property
  16287. */
  16288. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16289. /**
  16290. * Resets the animatable to its original state
  16291. */
  16292. reset(): void;
  16293. /**
  16294. * Allows the animatable to blend with current running animations
  16295. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16296. * @param blendingSpeed defines the blending speed to use
  16297. */
  16298. enableBlending(blendingSpeed: number): void;
  16299. /**
  16300. * Disable animation blending
  16301. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16302. */
  16303. disableBlending(): void;
  16304. /**
  16305. * Jump directly to a given frame
  16306. * @param frame defines the frame to jump to
  16307. */
  16308. goToFrame(frame: number): void;
  16309. /**
  16310. * Pause the animation
  16311. */
  16312. pause(): void;
  16313. /**
  16314. * Restart the animation
  16315. */
  16316. restart(): void;
  16317. private _raiseOnAnimationEnd;
  16318. /**
  16319. * Stop and delete the current animation
  16320. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16321. * @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)
  16322. */
  16323. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16324. /**
  16325. * Wait asynchronously for the animation to end
  16326. * @returns a promise which will be fullfilled when the animation ends
  16327. */
  16328. waitAsync(): Promise<Animatable>;
  16329. /** @hidden */
  16330. _animate(delay: number): boolean;
  16331. }
  16332. module "babylonjs/scene" {
  16333. interface Scene {
  16334. /** @hidden */
  16335. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16336. /** @hidden */
  16337. _processLateAnimationBindingsForMatrices(holder: {
  16338. totalWeight: number;
  16339. totalAdditiveWeight: number;
  16340. animations: RuntimeAnimation[];
  16341. additiveAnimations: RuntimeAnimation[];
  16342. originalValue: Matrix;
  16343. }): any;
  16344. /** @hidden */
  16345. _processLateAnimationBindingsForQuaternions(holder: {
  16346. totalWeight: number;
  16347. totalAdditiveWeight: number;
  16348. animations: RuntimeAnimation[];
  16349. additiveAnimations: RuntimeAnimation[];
  16350. originalValue: Quaternion;
  16351. }, refQuaternion: Quaternion): Quaternion;
  16352. /** @hidden */
  16353. _processLateAnimationBindings(): void;
  16354. /**
  16355. * Will start the animation sequence of a given target
  16356. * @param target defines the target
  16357. * @param from defines from which frame should animation start
  16358. * @param to defines until which frame should animation run.
  16359. * @param weight defines the weight to apply to the animation (1.0 by default)
  16360. * @param loop defines if the animation loops
  16361. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16362. * @param onAnimationEnd defines the function to be executed when the animation ends
  16363. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16364. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16365. * @param onAnimationLoop defines the callback to call when an animation loops
  16366. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16367. * @returns the animatable object created for this animation
  16368. */
  16369. 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;
  16370. /**
  16371. * Will start the animation sequence of a given target
  16372. * @param target defines the target
  16373. * @param from defines from which frame should animation start
  16374. * @param to defines until which frame should animation run.
  16375. * @param loop defines if the animation loops
  16376. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16377. * @param onAnimationEnd defines the function to be executed when the animation ends
  16378. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16379. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16380. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16381. * @param onAnimationLoop defines the callback to call when an animation loops
  16382. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16383. * @returns the animatable object created for this animation
  16384. */
  16385. 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;
  16386. /**
  16387. * Will start the animation sequence of a given target and its hierarchy
  16388. * @param target defines the target
  16389. * @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.
  16390. * @param from defines from which frame should animation start
  16391. * @param to defines until which frame should animation run.
  16392. * @param loop defines if the animation loops
  16393. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16394. * @param onAnimationEnd defines the function to be executed when the animation ends
  16395. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16396. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16397. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16398. * @param onAnimationLoop defines the callback to call when an animation loops
  16399. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16400. * @returns the list of created animatables
  16401. */
  16402. 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[];
  16403. /**
  16404. * Begin a new animation on a given node
  16405. * @param target defines the target where the animation will take place
  16406. * @param animations defines the list of animations to start
  16407. * @param from defines the initial value
  16408. * @param to defines the final value
  16409. * @param loop defines if you want animation to loop (off by default)
  16410. * @param speedRatio defines the speed ratio to apply to all animations
  16411. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16412. * @param onAnimationLoop defines the callback to call when an animation loops
  16413. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16414. * @returns the list of created animatables
  16415. */
  16416. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16417. /**
  16418. * Begin a new animation on a given node and its hierarchy
  16419. * @param target defines the root node where the animation will take place
  16420. * @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.
  16421. * @param animations defines the list of animations to start
  16422. * @param from defines the initial value
  16423. * @param to defines the final value
  16424. * @param loop defines if you want animation to loop (off by default)
  16425. * @param speedRatio defines the speed ratio to apply to all animations
  16426. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16427. * @param onAnimationLoop defines the callback to call when an animation loops
  16428. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16429. * @returns the list of animatables created for all nodes
  16430. */
  16431. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16432. /**
  16433. * Gets the animatable associated with a specific target
  16434. * @param target defines the target of the animatable
  16435. * @returns the required animatable if found
  16436. */
  16437. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16438. /**
  16439. * Gets all animatables associated with a given target
  16440. * @param target defines the target to look animatables for
  16441. * @returns an array of Animatables
  16442. */
  16443. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16444. /**
  16445. * Stops and removes all animations that have been applied to the scene
  16446. */
  16447. stopAllAnimations(): void;
  16448. /**
  16449. * Gets the current delta time used by animation engine
  16450. */
  16451. deltaTime: number;
  16452. }
  16453. }
  16454. module "babylonjs/Bones/bone" {
  16455. interface Bone {
  16456. /**
  16457. * Copy an animation range from another bone
  16458. * @param source defines the source bone
  16459. * @param rangeName defines the range name to copy
  16460. * @param frameOffset defines the frame offset
  16461. * @param rescaleAsRequired defines if rescaling must be applied if required
  16462. * @param skelDimensionsRatio defines the scaling ratio
  16463. * @returns true if operation was successful
  16464. */
  16465. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16466. }
  16467. }
  16468. }
  16469. declare module "babylonjs/Bones/skeleton" {
  16470. import { Bone } from "babylonjs/Bones/bone";
  16471. import { Observable } from "babylonjs/Misc/observable";
  16472. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16473. import { Scene } from "babylonjs/scene";
  16474. import { Nullable } from "babylonjs/types";
  16475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16476. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16477. import { Animatable } from "babylonjs/Animations/animatable";
  16478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16479. import { Animation } from "babylonjs/Animations/animation";
  16480. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16481. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16483. /**
  16484. * Class used to handle skinning animations
  16485. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16486. */
  16487. export class Skeleton implements IAnimatable {
  16488. /** defines the skeleton name */
  16489. name: string;
  16490. /** defines the skeleton Id */
  16491. id: string;
  16492. /**
  16493. * Defines the list of child bones
  16494. */
  16495. bones: Bone[];
  16496. /**
  16497. * Defines an estimate of the dimension of the skeleton at rest
  16498. */
  16499. dimensionsAtRest: Vector3;
  16500. /**
  16501. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16502. */
  16503. needInitialSkinMatrix: boolean;
  16504. /**
  16505. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16506. */
  16507. overrideMesh: Nullable<AbstractMesh>;
  16508. /**
  16509. * Gets the list of animations attached to this skeleton
  16510. */
  16511. animations: Array<Animation>;
  16512. private _scene;
  16513. private _isDirty;
  16514. private _transformMatrices;
  16515. private _transformMatrixTexture;
  16516. private _meshesWithPoseMatrix;
  16517. private _animatables;
  16518. private _identity;
  16519. private _synchronizedWithMesh;
  16520. private _ranges;
  16521. private _lastAbsoluteTransformsUpdateId;
  16522. private _canUseTextureForBones;
  16523. private _uniqueId;
  16524. /** @hidden */
  16525. _numBonesWithLinkedTransformNode: number;
  16526. /** @hidden */
  16527. _hasWaitingData: Nullable<boolean>;
  16528. /** @hidden */
  16529. _waitingOverrideMeshId: Nullable<string>;
  16530. /**
  16531. * Specifies if the skeleton should be serialized
  16532. */
  16533. doNotSerialize: boolean;
  16534. private _useTextureToStoreBoneMatrices;
  16535. /**
  16536. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16537. * Please note that this option is not available if the hardware does not support it
  16538. */
  16539. get useTextureToStoreBoneMatrices(): boolean;
  16540. set useTextureToStoreBoneMatrices(value: boolean);
  16541. private _animationPropertiesOverride;
  16542. /**
  16543. * Gets or sets the animation properties override
  16544. */
  16545. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16546. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16547. /**
  16548. * List of inspectable custom properties (used by the Inspector)
  16549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16550. */
  16551. inspectableCustomProperties: IInspectable[];
  16552. /**
  16553. * An observable triggered before computing the skeleton's matrices
  16554. */
  16555. onBeforeComputeObservable: Observable<Skeleton>;
  16556. /**
  16557. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16558. */
  16559. get isUsingTextureForMatrices(): boolean;
  16560. /**
  16561. * Gets the unique ID of this skeleton
  16562. */
  16563. get uniqueId(): number;
  16564. /**
  16565. * Creates a new skeleton
  16566. * @param name defines the skeleton name
  16567. * @param id defines the skeleton Id
  16568. * @param scene defines the hosting scene
  16569. */
  16570. constructor(
  16571. /** defines the skeleton name */
  16572. name: string,
  16573. /** defines the skeleton Id */
  16574. id: string, scene: Scene);
  16575. /**
  16576. * Gets the current object class name.
  16577. * @return the class name
  16578. */
  16579. getClassName(): string;
  16580. /**
  16581. * Returns an array containing the root bones
  16582. * @returns an array containing the root bones
  16583. */
  16584. getChildren(): Array<Bone>;
  16585. /**
  16586. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16587. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16588. * @returns a Float32Array containing matrices data
  16589. */
  16590. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16591. /**
  16592. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16593. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16594. * @returns a raw texture containing the data
  16595. */
  16596. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16597. /**
  16598. * Gets the current hosting scene
  16599. * @returns a scene object
  16600. */
  16601. getScene(): Scene;
  16602. /**
  16603. * Gets a string representing the current skeleton data
  16604. * @param fullDetails defines a boolean indicating if we want a verbose version
  16605. * @returns a string representing the current skeleton data
  16606. */
  16607. toString(fullDetails?: boolean): string;
  16608. /**
  16609. * Get bone's index searching by name
  16610. * @param name defines bone's name to search for
  16611. * @return the indice of the bone. Returns -1 if not found
  16612. */
  16613. getBoneIndexByName(name: string): number;
  16614. /**
  16615. * Creater a new animation range
  16616. * @param name defines the name of the range
  16617. * @param from defines the start key
  16618. * @param to defines the end key
  16619. */
  16620. createAnimationRange(name: string, from: number, to: number): void;
  16621. /**
  16622. * Delete a specific animation range
  16623. * @param name defines the name of the range
  16624. * @param deleteFrames defines if frames must be removed as well
  16625. */
  16626. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16627. /**
  16628. * Gets a specific animation range
  16629. * @param name defines the name of the range to look for
  16630. * @returns the requested animation range or null if not found
  16631. */
  16632. getAnimationRange(name: string): Nullable<AnimationRange>;
  16633. /**
  16634. * Gets the list of all animation ranges defined on this skeleton
  16635. * @returns an array
  16636. */
  16637. getAnimationRanges(): Nullable<AnimationRange>[];
  16638. /**
  16639. * Copy animation range from a source skeleton.
  16640. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16641. * @param source defines the source skeleton
  16642. * @param name defines the name of the range to copy
  16643. * @param rescaleAsRequired defines if rescaling must be applied if required
  16644. * @returns true if operation was successful
  16645. */
  16646. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16647. /**
  16648. * Forces the skeleton to go to rest pose
  16649. */
  16650. returnToRest(): void;
  16651. private _getHighestAnimationFrame;
  16652. /**
  16653. * Begin a specific animation range
  16654. * @param name defines the name of the range to start
  16655. * @param loop defines if looping must be turned on (false by default)
  16656. * @param speedRatio defines the speed ratio to apply (1 by default)
  16657. * @param onAnimationEnd defines a callback which will be called when animation will end
  16658. * @returns a new animatable
  16659. */
  16660. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16661. /**
  16662. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16663. * @param skeleton defines the Skeleton containing the animation range to convert
  16664. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16665. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16666. * @returns the original skeleton
  16667. */
  16668. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16669. /** @hidden */
  16670. _markAsDirty(): void;
  16671. /** @hidden */
  16672. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16673. /** @hidden */
  16674. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16675. private _computeTransformMatrices;
  16676. /**
  16677. * Build all resources required to render a skeleton
  16678. */
  16679. prepare(): void;
  16680. /**
  16681. * Gets the list of animatables currently running for this skeleton
  16682. * @returns an array of animatables
  16683. */
  16684. getAnimatables(): IAnimatable[];
  16685. /**
  16686. * Clone the current skeleton
  16687. * @param name defines the name of the new skeleton
  16688. * @param id defines the id of the new skeleton
  16689. * @returns the new skeleton
  16690. */
  16691. clone(name: string, id?: string): Skeleton;
  16692. /**
  16693. * Enable animation blending for this skeleton
  16694. * @param blendingSpeed defines the blending speed to apply
  16695. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16696. */
  16697. enableBlending(blendingSpeed?: number): void;
  16698. /**
  16699. * Releases all resources associated with the current skeleton
  16700. */
  16701. dispose(): void;
  16702. /**
  16703. * Serialize the skeleton in a JSON object
  16704. * @returns a JSON object
  16705. */
  16706. serialize(): any;
  16707. /**
  16708. * Creates a new skeleton from serialized data
  16709. * @param parsedSkeleton defines the serialized data
  16710. * @param scene defines the hosting scene
  16711. * @returns a new skeleton
  16712. */
  16713. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16714. /**
  16715. * Compute all node absolute transforms
  16716. * @param forceUpdate defines if computation must be done even if cache is up to date
  16717. */
  16718. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16719. /**
  16720. * Gets the root pose matrix
  16721. * @returns a matrix
  16722. */
  16723. getPoseMatrix(): Nullable<Matrix>;
  16724. /**
  16725. * Sorts bones per internal index
  16726. */
  16727. sortBones(): void;
  16728. private _sortBones;
  16729. /**
  16730. * Set the current local matrix as the restPose for all bones in the skeleton.
  16731. */
  16732. setCurrentPoseAsRest(): void;
  16733. }
  16734. }
  16735. declare module "babylonjs/Meshes/instancedMesh" {
  16736. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16737. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16738. import { Camera } from "babylonjs/Cameras/camera";
  16739. import { Node } from "babylonjs/node";
  16740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16741. import { Mesh } from "babylonjs/Meshes/mesh";
  16742. import { Material } from "babylonjs/Materials/material";
  16743. import { Skeleton } from "babylonjs/Bones/skeleton";
  16744. import { Light } from "babylonjs/Lights/light";
  16745. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16746. /**
  16747. * Creates an instance based on a source mesh.
  16748. */
  16749. export class InstancedMesh extends AbstractMesh {
  16750. private _sourceMesh;
  16751. private _currentLOD;
  16752. /** @hidden */
  16753. _indexInSourceMeshInstanceArray: number;
  16754. constructor(name: string, source: Mesh);
  16755. /**
  16756. * Returns the string "InstancedMesh".
  16757. */
  16758. getClassName(): string;
  16759. /** Gets the list of lights affecting that mesh */
  16760. get lightSources(): Light[];
  16761. _resyncLightSources(): void;
  16762. _resyncLightSource(light: Light): void;
  16763. _removeLightSource(light: Light, dispose: boolean): void;
  16764. /**
  16765. * If the source mesh receives shadows
  16766. */
  16767. get receiveShadows(): boolean;
  16768. /**
  16769. * The material of the source mesh
  16770. */
  16771. get material(): Nullable<Material>;
  16772. /**
  16773. * Visibility of the source mesh
  16774. */
  16775. get visibility(): number;
  16776. /**
  16777. * Skeleton of the source mesh
  16778. */
  16779. get skeleton(): Nullable<Skeleton>;
  16780. /**
  16781. * Rendering ground id of the source mesh
  16782. */
  16783. get renderingGroupId(): number;
  16784. set renderingGroupId(value: number);
  16785. /**
  16786. * Returns the total number of vertices (integer).
  16787. */
  16788. getTotalVertices(): number;
  16789. /**
  16790. * Returns a positive integer : the total number of indices in this mesh geometry.
  16791. * @returns the numner of indices or zero if the mesh has no geometry.
  16792. */
  16793. getTotalIndices(): number;
  16794. /**
  16795. * The source mesh of the instance
  16796. */
  16797. get sourceMesh(): Mesh;
  16798. /**
  16799. * Creates a new InstancedMesh object from the mesh model.
  16800. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16801. * @param name defines the name of the new instance
  16802. * @returns a new InstancedMesh
  16803. */
  16804. createInstance(name: string): InstancedMesh;
  16805. /**
  16806. * Is this node ready to be used/rendered
  16807. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16808. * @return {boolean} is it ready
  16809. */
  16810. isReady(completeCheck?: boolean): boolean;
  16811. /**
  16812. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16813. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16814. * @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.
  16815. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16816. */
  16817. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16818. /**
  16819. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16820. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16821. * The `data` are either a numeric array either a Float32Array.
  16822. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16823. * 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).
  16824. * Note that a new underlying VertexBuffer object is created each call.
  16825. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16826. *
  16827. * Possible `kind` values :
  16828. * - VertexBuffer.PositionKind
  16829. * - VertexBuffer.UVKind
  16830. * - VertexBuffer.UV2Kind
  16831. * - VertexBuffer.UV3Kind
  16832. * - VertexBuffer.UV4Kind
  16833. * - VertexBuffer.UV5Kind
  16834. * - VertexBuffer.UV6Kind
  16835. * - VertexBuffer.ColorKind
  16836. * - VertexBuffer.MatricesIndicesKind
  16837. * - VertexBuffer.MatricesIndicesExtraKind
  16838. * - VertexBuffer.MatricesWeightsKind
  16839. * - VertexBuffer.MatricesWeightsExtraKind
  16840. *
  16841. * Returns the Mesh.
  16842. */
  16843. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16844. /**
  16845. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16846. * If the mesh has no geometry, it is simply returned as it is.
  16847. * The `data` are either a numeric array either a Float32Array.
  16848. * No new underlying VertexBuffer object is created.
  16849. * 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.
  16850. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16851. *
  16852. * Possible `kind` values :
  16853. * - VertexBuffer.PositionKind
  16854. * - VertexBuffer.UVKind
  16855. * - VertexBuffer.UV2Kind
  16856. * - VertexBuffer.UV3Kind
  16857. * - VertexBuffer.UV4Kind
  16858. * - VertexBuffer.UV5Kind
  16859. * - VertexBuffer.UV6Kind
  16860. * - VertexBuffer.ColorKind
  16861. * - VertexBuffer.MatricesIndicesKind
  16862. * - VertexBuffer.MatricesIndicesExtraKind
  16863. * - VertexBuffer.MatricesWeightsKind
  16864. * - VertexBuffer.MatricesWeightsExtraKind
  16865. *
  16866. * Returns the Mesh.
  16867. */
  16868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16869. /**
  16870. * Sets the mesh indices.
  16871. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16872. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16873. * This method creates a new index buffer each call.
  16874. * Returns the Mesh.
  16875. */
  16876. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16877. /**
  16878. * Boolean : True if the mesh owns the requested kind of data.
  16879. */
  16880. isVerticesDataPresent(kind: string): boolean;
  16881. /**
  16882. * Returns an array of indices (IndicesArray).
  16883. */
  16884. getIndices(): Nullable<IndicesArray>;
  16885. get _positions(): Nullable<Vector3[]>;
  16886. /**
  16887. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16888. * This means the mesh underlying bounding box and sphere are recomputed.
  16889. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16890. * @returns the current mesh
  16891. */
  16892. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16893. /** @hidden */
  16894. _preActivate(): InstancedMesh;
  16895. /** @hidden */
  16896. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16897. /** @hidden */
  16898. _postActivate(): void;
  16899. getWorldMatrix(): Matrix;
  16900. get isAnInstance(): boolean;
  16901. /**
  16902. * Returns the current associated LOD AbstractMesh.
  16903. */
  16904. getLOD(camera: Camera): AbstractMesh;
  16905. /** @hidden */
  16906. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16907. /** @hidden */
  16908. _syncSubMeshes(): InstancedMesh;
  16909. /** @hidden */
  16910. _generatePointsArray(): boolean;
  16911. /** @hidden */
  16912. _updateBoundingInfo(): AbstractMesh;
  16913. /**
  16914. * Creates a new InstancedMesh from the current mesh.
  16915. * - name (string) : the cloned mesh name
  16916. * - newParent (optional Node) : the optional Node to parent the clone to.
  16917. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16918. *
  16919. * Returns the clone.
  16920. */
  16921. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16922. /**
  16923. * Disposes the InstancedMesh.
  16924. * Returns nothing.
  16925. */
  16926. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16927. }
  16928. module "babylonjs/Meshes/mesh" {
  16929. interface Mesh {
  16930. /**
  16931. * Register a custom buffer that will be instanced
  16932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16933. * @param kind defines the buffer kind
  16934. * @param stride defines the stride in floats
  16935. */
  16936. registerInstancedBuffer(kind: string, stride: number): void;
  16937. /**
  16938. * true to use the edge renderer for all instances of this mesh
  16939. */
  16940. edgesShareWithInstances: boolean;
  16941. /** @hidden */
  16942. _userInstancedBuffersStorage: {
  16943. data: {
  16944. [key: string]: Float32Array;
  16945. };
  16946. sizes: {
  16947. [key: string]: number;
  16948. };
  16949. vertexBuffers: {
  16950. [key: string]: Nullable<VertexBuffer>;
  16951. };
  16952. strides: {
  16953. [key: string]: number;
  16954. };
  16955. };
  16956. }
  16957. }
  16958. module "babylonjs/Meshes/abstractMesh" {
  16959. interface AbstractMesh {
  16960. /**
  16961. * Object used to store instanced buffers defined by user
  16962. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16963. */
  16964. instancedBuffers: {
  16965. [key: string]: any;
  16966. };
  16967. }
  16968. }
  16969. }
  16970. declare module "babylonjs/Materials/shaderMaterial" {
  16971. import { Nullable } from "babylonjs/types";
  16972. import { Scene } from "babylonjs/scene";
  16973. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16975. import { Mesh } from "babylonjs/Meshes/mesh";
  16976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16978. import { Effect } from "babylonjs/Materials/effect";
  16979. import { Material } from "babylonjs/Materials/material";
  16980. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16981. /**
  16982. * Defines the options associated with the creation of a shader material.
  16983. */
  16984. export interface IShaderMaterialOptions {
  16985. /**
  16986. * Does the material work in alpha blend mode
  16987. */
  16988. needAlphaBlending: boolean;
  16989. /**
  16990. * Does the material work in alpha test mode
  16991. */
  16992. needAlphaTesting: boolean;
  16993. /**
  16994. * The list of attribute names used in the shader
  16995. */
  16996. attributes: string[];
  16997. /**
  16998. * The list of unifrom names used in the shader
  16999. */
  17000. uniforms: string[];
  17001. /**
  17002. * The list of UBO names used in the shader
  17003. */
  17004. uniformBuffers: string[];
  17005. /**
  17006. * The list of sampler names used in the shader
  17007. */
  17008. samplers: string[];
  17009. /**
  17010. * The list of defines used in the shader
  17011. */
  17012. defines: string[];
  17013. }
  17014. /**
  17015. * 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.
  17016. *
  17017. * This returned material effects how the mesh will look based on the code in the shaders.
  17018. *
  17019. * @see https://doc.babylonjs.com/how_to/shader_material
  17020. */
  17021. export class ShaderMaterial extends Material {
  17022. private _shaderPath;
  17023. private _options;
  17024. private _textures;
  17025. private _textureArrays;
  17026. private _floats;
  17027. private _ints;
  17028. private _floatsArrays;
  17029. private _colors3;
  17030. private _colors3Arrays;
  17031. private _colors4;
  17032. private _colors4Arrays;
  17033. private _vectors2;
  17034. private _vectors3;
  17035. private _vectors4;
  17036. private _matrices;
  17037. private _matrixArrays;
  17038. private _matrices3x3;
  17039. private _matrices2x2;
  17040. private _vectors2Arrays;
  17041. private _vectors3Arrays;
  17042. private _vectors4Arrays;
  17043. private _cachedWorldViewMatrix;
  17044. private _cachedWorldViewProjectionMatrix;
  17045. private _renderId;
  17046. private _multiview;
  17047. private _cachedDefines;
  17048. /** Define the Url to load snippets */
  17049. static SnippetUrl: string;
  17050. /** Snippet ID if the material was created from the snippet server */
  17051. snippetId: string;
  17052. /**
  17053. * Instantiate a new shader material.
  17054. * 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.
  17055. * This returned material effects how the mesh will look based on the code in the shaders.
  17056. * @see https://doc.babylonjs.com/how_to/shader_material
  17057. * @param name Define the name of the material in the scene
  17058. * @param scene Define the scene the material belongs to
  17059. * @param shaderPath Defines the route to the shader code in one of three ways:
  17060. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17061. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17062. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17063. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17064. * @param options Define the options used to create the shader
  17065. */
  17066. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17067. /**
  17068. * Gets the shader path used to define the shader code
  17069. * It can be modified to trigger a new compilation
  17070. */
  17071. get shaderPath(): any;
  17072. /**
  17073. * Sets the shader path used to define the shader code
  17074. * It can be modified to trigger a new compilation
  17075. */
  17076. set shaderPath(shaderPath: any);
  17077. /**
  17078. * Gets the options used to compile the shader.
  17079. * They can be modified to trigger a new compilation
  17080. */
  17081. get options(): IShaderMaterialOptions;
  17082. /**
  17083. * Gets the current class name of the material e.g. "ShaderMaterial"
  17084. * Mainly use in serialization.
  17085. * @returns the class name
  17086. */
  17087. getClassName(): string;
  17088. /**
  17089. * Specifies if the material will require alpha blending
  17090. * @returns a boolean specifying if alpha blending is needed
  17091. */
  17092. needAlphaBlending(): boolean;
  17093. /**
  17094. * Specifies if this material should be rendered in alpha test mode
  17095. * @returns a boolean specifying if an alpha test is needed.
  17096. */
  17097. needAlphaTesting(): boolean;
  17098. private _checkUniform;
  17099. /**
  17100. * Set a texture in the shader.
  17101. * @param name Define the name of the uniform samplers as defined in the shader
  17102. * @param texture Define the texture to bind to this sampler
  17103. * @return the material itself allowing "fluent" like uniform updates
  17104. */
  17105. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17106. /**
  17107. * Set a texture array in the shader.
  17108. * @param name Define the name of the uniform sampler array as defined in the shader
  17109. * @param textures Define the list of textures to bind to this sampler
  17110. * @return the material itself allowing "fluent" like uniform updates
  17111. */
  17112. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17113. /**
  17114. * Set a float in the shader.
  17115. * @param name Define the name of the uniform as defined in the shader
  17116. * @param value Define the value to give to the uniform
  17117. * @return the material itself allowing "fluent" like uniform updates
  17118. */
  17119. setFloat(name: string, value: number): ShaderMaterial;
  17120. /**
  17121. * Set a int in the shader.
  17122. * @param name Define the name of the uniform as defined in the shader
  17123. * @param value Define the value to give to the uniform
  17124. * @return the material itself allowing "fluent" like uniform updates
  17125. */
  17126. setInt(name: string, value: number): ShaderMaterial;
  17127. /**
  17128. * Set an array of floats in the shader.
  17129. * @param name Define the name of the uniform as defined in the shader
  17130. * @param value Define the value to give to the uniform
  17131. * @return the material itself allowing "fluent" like uniform updates
  17132. */
  17133. setFloats(name: string, value: number[]): ShaderMaterial;
  17134. /**
  17135. * Set a vec3 in the shader from a Color3.
  17136. * @param name Define the name of the uniform as defined in the shader
  17137. * @param value Define the value to give to the uniform
  17138. * @return the material itself allowing "fluent" like uniform updates
  17139. */
  17140. setColor3(name: string, value: Color3): ShaderMaterial;
  17141. /**
  17142. * Set a vec3 array in the shader from a Color3 array.
  17143. * @param name Define the name of the uniform as defined in the shader
  17144. * @param value Define the value to give to the uniform
  17145. * @return the material itself allowing "fluent" like uniform updates
  17146. */
  17147. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17148. /**
  17149. * Set a vec4 in the shader from a Color4.
  17150. * @param name Define the name of the uniform as defined in the shader
  17151. * @param value Define the value to give to the uniform
  17152. * @return the material itself allowing "fluent" like uniform updates
  17153. */
  17154. setColor4(name: string, value: Color4): ShaderMaterial;
  17155. /**
  17156. * Set a vec4 array in the shader from a Color4 array.
  17157. * @param name Define the name of the uniform as defined in the shader
  17158. * @param value Define the value to give to the uniform
  17159. * @return the material itself allowing "fluent" like uniform updates
  17160. */
  17161. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17162. /**
  17163. * Set a vec2 in the shader from a Vector2.
  17164. * @param name Define the name of the uniform as defined in the shader
  17165. * @param value Define the value to give to the uniform
  17166. * @return the material itself allowing "fluent" like uniform updates
  17167. */
  17168. setVector2(name: string, value: Vector2): ShaderMaterial;
  17169. /**
  17170. * Set a vec3 in the shader from a Vector3.
  17171. * @param name Define the name of the uniform as defined in the shader
  17172. * @param value Define the value to give to the uniform
  17173. * @return the material itself allowing "fluent" like uniform updates
  17174. */
  17175. setVector3(name: string, value: Vector3): ShaderMaterial;
  17176. /**
  17177. * Set a vec4 in the shader from a Vector4.
  17178. * @param name Define the name of the uniform as defined in the shader
  17179. * @param value Define the value to give to the uniform
  17180. * @return the material itself allowing "fluent" like uniform updates
  17181. */
  17182. setVector4(name: string, value: Vector4): ShaderMaterial;
  17183. /**
  17184. * Set a mat4 in the shader from a Matrix.
  17185. * @param name Define the name of the uniform as defined in the shader
  17186. * @param value Define the value to give to the uniform
  17187. * @return the material itself allowing "fluent" like uniform updates
  17188. */
  17189. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17190. /**
  17191. * Set a float32Array in the shader from a matrix array.
  17192. * @param name Define the name of the uniform as defined in the shader
  17193. * @param value Define the value to give to the uniform
  17194. * @return the material itself allowing "fluent" like uniform updates
  17195. */
  17196. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17197. /**
  17198. * Set a mat3 in the shader from a Float32Array.
  17199. * @param name Define the name of the uniform as defined in the shader
  17200. * @param value Define the value to give to the uniform
  17201. * @return the material itself allowing "fluent" like uniform updates
  17202. */
  17203. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17204. /**
  17205. * Set a mat2 in the shader from a Float32Array.
  17206. * @param name Define the name of the uniform as defined in the shader
  17207. * @param value Define the value to give to the uniform
  17208. * @return the material itself allowing "fluent" like uniform updates
  17209. */
  17210. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17211. /**
  17212. * Set a vec2 array in the shader from a number array.
  17213. * @param name Define the name of the uniform as defined in the shader
  17214. * @param value Define the value to give to the uniform
  17215. * @return the material itself allowing "fluent" like uniform updates
  17216. */
  17217. setArray2(name: string, value: number[]): ShaderMaterial;
  17218. /**
  17219. * Set a vec3 array in the shader from a number array.
  17220. * @param name Define the name of the uniform as defined in the shader
  17221. * @param value Define the value to give to the uniform
  17222. * @return the material itself allowing "fluent" like uniform updates
  17223. */
  17224. setArray3(name: string, value: number[]): ShaderMaterial;
  17225. /**
  17226. * Set a vec4 array in the shader from a number array.
  17227. * @param name Define the name of the uniform as defined in the shader
  17228. * @param value Define the value to give to the uniform
  17229. * @return the material itself allowing "fluent" like uniform updates
  17230. */
  17231. setArray4(name: string, value: number[]): ShaderMaterial;
  17232. private _checkCache;
  17233. /**
  17234. * Specifies that the submesh is ready to be used
  17235. * @param mesh defines the mesh to check
  17236. * @param subMesh defines which submesh to check
  17237. * @param useInstances specifies that instances should be used
  17238. * @returns a boolean indicating that the submesh is ready or not
  17239. */
  17240. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17241. /**
  17242. * Checks if the material is ready to render the requested mesh
  17243. * @param mesh Define the mesh to render
  17244. * @param useInstances Define whether or not the material is used with instances
  17245. * @returns true if ready, otherwise false
  17246. */
  17247. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17248. /**
  17249. * Binds the world matrix to the material
  17250. * @param world defines the world transformation matrix
  17251. * @param effectOverride - If provided, use this effect instead of internal effect
  17252. */
  17253. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17254. /**
  17255. * Binds the submesh to this material by preparing the effect and shader to draw
  17256. * @param world defines the world transformation matrix
  17257. * @param mesh defines the mesh containing the submesh
  17258. * @param subMesh defines the submesh to bind the material to
  17259. */
  17260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17261. /**
  17262. * Binds the material to the mesh
  17263. * @param world defines the world transformation matrix
  17264. * @param mesh defines the mesh to bind the material to
  17265. * @param effectOverride - If provided, use this effect instead of internal effect
  17266. */
  17267. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17268. protected _afterBind(mesh?: Mesh): void;
  17269. /**
  17270. * Gets the active textures from the material
  17271. * @returns an array of textures
  17272. */
  17273. getActiveTextures(): BaseTexture[];
  17274. /**
  17275. * Specifies if the material uses a texture
  17276. * @param texture defines the texture to check against the material
  17277. * @returns a boolean specifying if the material uses the texture
  17278. */
  17279. hasTexture(texture: BaseTexture): boolean;
  17280. /**
  17281. * Makes a duplicate of the material, and gives it a new name
  17282. * @param name defines the new name for the duplicated material
  17283. * @returns the cloned material
  17284. */
  17285. clone(name: string): ShaderMaterial;
  17286. /**
  17287. * Disposes the material
  17288. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17289. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17290. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17291. */
  17292. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17293. /**
  17294. * Serializes this material in a JSON representation
  17295. * @returns the serialized material object
  17296. */
  17297. serialize(): any;
  17298. /**
  17299. * Creates a shader material from parsed shader material data
  17300. * @param source defines the JSON represnetation of the material
  17301. * @param scene defines the hosting scene
  17302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17303. * @returns a new material
  17304. */
  17305. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17306. /**
  17307. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17308. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17309. * @param url defines the url to load from
  17310. * @param scene defines the hosting scene
  17311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17312. * @returns a promise that will resolve to the new ShaderMaterial
  17313. */
  17314. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17315. /**
  17316. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17317. * @param snippetId defines the snippet to load
  17318. * @param scene defines the hosting scene
  17319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17320. * @returns a promise that will resolve to the new ShaderMaterial
  17321. */
  17322. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17323. }
  17324. }
  17325. declare module "babylonjs/Shaders/color.fragment" {
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17328. /** @hidden */
  17329. export var colorPixelShader: {
  17330. name: string;
  17331. shader: string;
  17332. };
  17333. }
  17334. declare module "babylonjs/Shaders/color.vertex" {
  17335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17336. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17337. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17338. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17339. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17340. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17341. /** @hidden */
  17342. export var colorVertexShader: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Meshes/linesMesh" {
  17348. import { Nullable } from "babylonjs/types";
  17349. import { Scene } from "babylonjs/scene";
  17350. import { Color3 } from "babylonjs/Maths/math.color";
  17351. import { Node } from "babylonjs/node";
  17352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17353. import { Mesh } from "babylonjs/Meshes/mesh";
  17354. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17355. import { Effect } from "babylonjs/Materials/effect";
  17356. import { Material } from "babylonjs/Materials/material";
  17357. import "babylonjs/Shaders/color.fragment";
  17358. import "babylonjs/Shaders/color.vertex";
  17359. /**
  17360. * Line mesh
  17361. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17362. */
  17363. export class LinesMesh extends Mesh {
  17364. /**
  17365. * If vertex color should be applied to the mesh
  17366. */
  17367. readonly useVertexColor?: boolean | undefined;
  17368. /**
  17369. * If vertex alpha should be applied to the mesh
  17370. */
  17371. readonly useVertexAlpha?: boolean | undefined;
  17372. /**
  17373. * Color of the line (Default: White)
  17374. */
  17375. color: Color3;
  17376. /**
  17377. * Alpha of the line (Default: 1)
  17378. */
  17379. alpha: number;
  17380. /**
  17381. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17382. * This margin is expressed in world space coordinates, so its value may vary.
  17383. * Default value is 0.1
  17384. */
  17385. intersectionThreshold: number;
  17386. private _colorShader;
  17387. private color4;
  17388. /**
  17389. * Creates a new LinesMesh
  17390. * @param name defines the name
  17391. * @param scene defines the hosting scene
  17392. * @param parent defines the parent mesh if any
  17393. * @param source defines the optional source LinesMesh used to clone data from
  17394. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17395. * When false, achieved by calling a clone(), also passing False.
  17396. * This will make creation of children, recursive.
  17397. * @param useVertexColor defines if this LinesMesh supports vertex color
  17398. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17399. */
  17400. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17401. /**
  17402. * If vertex color should be applied to the mesh
  17403. */
  17404. useVertexColor?: boolean | undefined,
  17405. /**
  17406. * If vertex alpha should be applied to the mesh
  17407. */
  17408. useVertexAlpha?: boolean | undefined);
  17409. private _addClipPlaneDefine;
  17410. private _removeClipPlaneDefine;
  17411. isReady(): boolean;
  17412. /**
  17413. * Returns the string "LineMesh"
  17414. */
  17415. getClassName(): string;
  17416. /**
  17417. * @hidden
  17418. */
  17419. get material(): Material;
  17420. /**
  17421. * @hidden
  17422. */
  17423. set material(value: Material);
  17424. /**
  17425. * @hidden
  17426. */
  17427. get checkCollisions(): boolean;
  17428. /** @hidden */
  17429. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17430. /** @hidden */
  17431. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17432. /**
  17433. * Disposes of the line mesh
  17434. * @param doNotRecurse If children should be disposed
  17435. */
  17436. dispose(doNotRecurse?: boolean): void;
  17437. /**
  17438. * Returns a new LineMesh object cloned from the current one.
  17439. */
  17440. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17441. /**
  17442. * Creates a new InstancedLinesMesh object from the mesh model.
  17443. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17444. * @param name defines the name of the new instance
  17445. * @returns a new InstancedLinesMesh
  17446. */
  17447. createInstance(name: string): InstancedLinesMesh;
  17448. }
  17449. /**
  17450. * Creates an instance based on a source LinesMesh
  17451. */
  17452. export class InstancedLinesMesh extends InstancedMesh {
  17453. /**
  17454. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17455. * This margin is expressed in world space coordinates, so its value may vary.
  17456. * Initilized with the intersectionThreshold value of the source LinesMesh
  17457. */
  17458. intersectionThreshold: number;
  17459. constructor(name: string, source: LinesMesh);
  17460. /**
  17461. * Returns the string "InstancedLinesMesh".
  17462. */
  17463. getClassName(): string;
  17464. }
  17465. }
  17466. declare module "babylonjs/Shaders/line.fragment" {
  17467. /** @hidden */
  17468. export var linePixelShader: {
  17469. name: string;
  17470. shader: string;
  17471. };
  17472. }
  17473. declare module "babylonjs/Shaders/line.vertex" {
  17474. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17475. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17476. /** @hidden */
  17477. export var lineVertexShader: {
  17478. name: string;
  17479. shader: string;
  17480. };
  17481. }
  17482. declare module "babylonjs/Rendering/edgesRenderer" {
  17483. import { Nullable } from "babylonjs/types";
  17484. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17486. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17487. import { IDisposable } from "babylonjs/scene";
  17488. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17489. import "babylonjs/Shaders/line.fragment";
  17490. import "babylonjs/Shaders/line.vertex";
  17491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17492. import { SmartArray } from "babylonjs/Misc/smartArray";
  17493. module "babylonjs/scene" {
  17494. interface Scene {
  17495. /** @hidden */
  17496. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17497. }
  17498. }
  17499. module "babylonjs/Meshes/abstractMesh" {
  17500. interface AbstractMesh {
  17501. /**
  17502. * Gets the edgesRenderer associated with the mesh
  17503. */
  17504. edgesRenderer: Nullable<EdgesRenderer>;
  17505. }
  17506. }
  17507. module "babylonjs/Meshes/linesMesh" {
  17508. interface LinesMesh {
  17509. /**
  17510. * Enables the edge rendering mode on the mesh.
  17511. * This mode makes the mesh edges visible
  17512. * @param epsilon defines the maximal distance between two angles to detect a face
  17513. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17514. * @returns the currentAbstractMesh
  17515. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17516. */
  17517. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17518. }
  17519. }
  17520. module "babylonjs/Meshes/linesMesh" {
  17521. interface InstancedLinesMesh {
  17522. /**
  17523. * Enables the edge rendering mode on the mesh.
  17524. * This mode makes the mesh edges visible
  17525. * @param epsilon defines the maximal distance between two angles to detect a face
  17526. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17527. * @returns the current InstancedLinesMesh
  17528. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17529. */
  17530. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17531. }
  17532. }
  17533. /**
  17534. * Defines the minimum contract an Edges renderer should follow.
  17535. */
  17536. export interface IEdgesRenderer extends IDisposable {
  17537. /**
  17538. * Gets or sets a boolean indicating if the edgesRenderer is active
  17539. */
  17540. isEnabled: boolean;
  17541. /**
  17542. * Renders the edges of the attached mesh,
  17543. */
  17544. render(): void;
  17545. /**
  17546. * Checks wether or not the edges renderer is ready to render.
  17547. * @return true if ready, otherwise false.
  17548. */
  17549. isReady(): boolean;
  17550. /**
  17551. * List of instances to render in case the source mesh has instances
  17552. */
  17553. customInstances: SmartArray<Matrix>;
  17554. }
  17555. /**
  17556. * Defines the additional options of the edges renderer
  17557. */
  17558. export interface IEdgesRendererOptions {
  17559. /**
  17560. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17561. * If not defined, the default value is true
  17562. */
  17563. useAlternateEdgeFinder?: boolean;
  17564. /**
  17565. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17566. * If not defined, the default value is true.
  17567. * 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)
  17568. * This option is used only if useAlternateEdgeFinder = true
  17569. */
  17570. useFastVertexMerger?: boolean;
  17571. /**
  17572. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17573. * The default value is 1e-6
  17574. * This option is used only if useAlternateEdgeFinder = true
  17575. */
  17576. epsilonVertexMerge?: number;
  17577. /**
  17578. * 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
  17579. * 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.
  17580. * This option is used only if useAlternateEdgeFinder = true
  17581. */
  17582. applyTessellation?: boolean;
  17583. /**
  17584. * 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
  17585. * The default value is 1e-6
  17586. * This option is used only if useAlternateEdgeFinder = true
  17587. */
  17588. epsilonVertexAligned?: number;
  17589. }
  17590. /**
  17591. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17592. */
  17593. export class EdgesRenderer implements IEdgesRenderer {
  17594. /**
  17595. * Define the size of the edges with an orthographic camera
  17596. */
  17597. edgesWidthScalerForOrthographic: number;
  17598. /**
  17599. * Define the size of the edges with a perspective camera
  17600. */
  17601. edgesWidthScalerForPerspective: number;
  17602. protected _source: AbstractMesh;
  17603. protected _linesPositions: number[];
  17604. protected _linesNormals: number[];
  17605. protected _linesIndices: number[];
  17606. protected _epsilon: number;
  17607. protected _indicesCount: number;
  17608. protected _lineShader: ShaderMaterial;
  17609. protected _ib: DataBuffer;
  17610. protected _buffers: {
  17611. [key: string]: Nullable<VertexBuffer>;
  17612. };
  17613. protected _buffersForInstances: {
  17614. [key: string]: Nullable<VertexBuffer>;
  17615. };
  17616. protected _checkVerticesInsteadOfIndices: boolean;
  17617. protected _options: Nullable<IEdgesRendererOptions>;
  17618. private _meshRebuildObserver;
  17619. private _meshDisposeObserver;
  17620. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17621. isEnabled: boolean;
  17622. /**
  17623. * List of instances to render in case the source mesh has instances
  17624. */
  17625. customInstances: SmartArray<Matrix>;
  17626. private static GetShader;
  17627. /**
  17628. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17629. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17630. * @param source Mesh used to create edges
  17631. * @param epsilon sum of angles in adjacency to check for edge
  17632. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17633. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17634. * @param options The options to apply when generating the edges
  17635. */
  17636. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17637. protected _prepareRessources(): void;
  17638. /** @hidden */
  17639. _rebuild(): void;
  17640. /**
  17641. * Releases the required resources for the edges renderer
  17642. */
  17643. dispose(): void;
  17644. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17645. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17646. /**
  17647. * Checks if the pair of p0 and p1 is en edge
  17648. * @param faceIndex
  17649. * @param edge
  17650. * @param faceNormals
  17651. * @param p0
  17652. * @param p1
  17653. * @private
  17654. */
  17655. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17656. /**
  17657. * push line into the position, normal and index buffer
  17658. * @protected
  17659. */
  17660. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17661. /**
  17662. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17663. */
  17664. private _tessellateTriangle;
  17665. private _generateEdgesLinesAlternate;
  17666. /**
  17667. * Generates lines edges from adjacencjes
  17668. * @private
  17669. */
  17670. _generateEdgesLines(): void;
  17671. /**
  17672. * Checks wether or not the edges renderer is ready to render.
  17673. * @return true if ready, otherwise false.
  17674. */
  17675. isReady(): boolean;
  17676. /**
  17677. * Renders the edges of the attached mesh,
  17678. */
  17679. render(): void;
  17680. }
  17681. /**
  17682. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17683. */
  17684. export class LineEdgesRenderer extends EdgesRenderer {
  17685. /**
  17686. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17687. * @param source LineMesh used to generate edges
  17688. * @param epsilon not important (specified angle for edge detection)
  17689. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17690. */
  17691. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17692. /**
  17693. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17694. */
  17695. _generateEdgesLines(): void;
  17696. }
  17697. }
  17698. declare module "babylonjs/Rendering/renderingGroup" {
  17699. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17700. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17702. import { Nullable } from "babylonjs/types";
  17703. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17704. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17705. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17706. import { Material } from "babylonjs/Materials/material";
  17707. import { Scene } from "babylonjs/scene";
  17708. /**
  17709. * This represents the object necessary to create a rendering group.
  17710. * This is exclusively used and created by the rendering manager.
  17711. * To modify the behavior, you use the available helpers in your scene or meshes.
  17712. * @hidden
  17713. */
  17714. export class RenderingGroup {
  17715. index: number;
  17716. private static _zeroVector;
  17717. private _scene;
  17718. private _opaqueSubMeshes;
  17719. private _transparentSubMeshes;
  17720. private _alphaTestSubMeshes;
  17721. private _depthOnlySubMeshes;
  17722. private _particleSystems;
  17723. private _spriteManagers;
  17724. private _opaqueSortCompareFn;
  17725. private _alphaTestSortCompareFn;
  17726. private _transparentSortCompareFn;
  17727. private _renderOpaque;
  17728. private _renderAlphaTest;
  17729. private _renderTransparent;
  17730. /** @hidden */
  17731. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17732. onBeforeTransparentRendering: () => void;
  17733. /**
  17734. * Set the opaque sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Set the alpha test sort comparison function.
  17740. * If null the sub meshes will be render in the order they were created
  17741. */
  17742. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17743. /**
  17744. * Set the transparent sort comparison function.
  17745. * If null the sub meshes will be render in the order they were created
  17746. */
  17747. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17748. /**
  17749. * Creates a new rendering group.
  17750. * @param index The rendering group index
  17751. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17752. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17753. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17754. */
  17755. 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>);
  17756. /**
  17757. * Render all the sub meshes contained in the group.
  17758. * @param customRenderFunction Used to override the default render behaviour of the group.
  17759. * @returns true if rendered some submeshes.
  17760. */
  17761. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderOpaqueSorted;
  17767. /**
  17768. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17769. * @param subMeshes The submeshes to render
  17770. */
  17771. private renderAlphaTestSorted;
  17772. /**
  17773. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17774. * @param subMeshes The submeshes to render
  17775. */
  17776. private renderTransparentSorted;
  17777. /**
  17778. * Renders the submeshes in a specified order.
  17779. * @param subMeshes The submeshes to sort before render
  17780. * @param sortCompareFn The comparison function use to sort
  17781. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17782. * @param transparent Specifies to activate blending if true
  17783. */
  17784. private static renderSorted;
  17785. /**
  17786. * Renders the submeshes in the order they were dispatched (no sort applied).
  17787. * @param subMeshes The submeshes to render
  17788. */
  17789. private static renderUnsorted;
  17790. /**
  17791. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17792. * are rendered back to front if in the same alpha index.
  17793. *
  17794. * @param a The first submesh
  17795. * @param b The second submesh
  17796. * @returns The result of the comparison
  17797. */
  17798. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17799. /**
  17800. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17801. * are rendered back to front.
  17802. *
  17803. * @param a The first submesh
  17804. * @param b The second submesh
  17805. * @returns The result of the comparison
  17806. */
  17807. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17808. /**
  17809. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17810. * are rendered front to back (prevent overdraw).
  17811. *
  17812. * @param a The first submesh
  17813. * @param b The second submesh
  17814. * @returns The result of the comparison
  17815. */
  17816. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17817. /**
  17818. * Resets the different lists of submeshes to prepare a new frame.
  17819. */
  17820. prepare(): void;
  17821. dispose(): void;
  17822. /**
  17823. * Inserts the submesh in its correct queue depending on its material.
  17824. * @param subMesh The submesh to dispatch
  17825. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17826. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17827. */
  17828. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17829. dispatchSprites(spriteManager: ISpriteManager): void;
  17830. dispatchParticles(particleSystem: IParticleSystem): void;
  17831. private _renderParticles;
  17832. private _renderSprites;
  17833. }
  17834. }
  17835. declare module "babylonjs/Rendering/renderingManager" {
  17836. import { Nullable } from "babylonjs/types";
  17837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17839. import { SmartArray } from "babylonjs/Misc/smartArray";
  17840. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17841. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17842. import { Material } from "babylonjs/Materials/material";
  17843. import { Scene } from "babylonjs/scene";
  17844. import { Camera } from "babylonjs/Cameras/camera";
  17845. /**
  17846. * Interface describing the different options available in the rendering manager
  17847. * regarding Auto Clear between groups.
  17848. */
  17849. export interface IRenderingManagerAutoClearSetup {
  17850. /**
  17851. * Defines whether or not autoclear is enable.
  17852. */
  17853. autoClear: boolean;
  17854. /**
  17855. * Defines whether or not to autoclear the depth buffer.
  17856. */
  17857. depth: boolean;
  17858. /**
  17859. * Defines whether or not to autoclear the stencil buffer.
  17860. */
  17861. stencil: boolean;
  17862. }
  17863. /**
  17864. * This class is used by the onRenderingGroupObservable
  17865. */
  17866. export class RenderingGroupInfo {
  17867. /**
  17868. * The Scene that being rendered
  17869. */
  17870. scene: Scene;
  17871. /**
  17872. * The camera currently used for the rendering pass
  17873. */
  17874. camera: Nullable<Camera>;
  17875. /**
  17876. * The ID of the renderingGroup being processed
  17877. */
  17878. renderingGroupId: number;
  17879. }
  17880. /**
  17881. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17882. * It is enable to manage the different groups as well as the different necessary sort functions.
  17883. * This should not be used directly aside of the few static configurations
  17884. */
  17885. export class RenderingManager {
  17886. /**
  17887. * The max id used for rendering groups (not included)
  17888. */
  17889. static MAX_RENDERINGGROUPS: number;
  17890. /**
  17891. * The min id used for rendering groups (included)
  17892. */
  17893. static MIN_RENDERINGGROUPS: number;
  17894. /**
  17895. * Used to globally prevent autoclearing scenes.
  17896. */
  17897. static AUTOCLEAR: boolean;
  17898. /**
  17899. * @hidden
  17900. */
  17901. _useSceneAutoClearSetup: boolean;
  17902. private _scene;
  17903. private _renderingGroups;
  17904. private _depthStencilBufferAlreadyCleaned;
  17905. private _autoClearDepthStencil;
  17906. private _customOpaqueSortCompareFn;
  17907. private _customAlphaTestSortCompareFn;
  17908. private _customTransparentSortCompareFn;
  17909. private _renderingGroupInfo;
  17910. /**
  17911. * Instantiates a new rendering group for a particular scene
  17912. * @param scene Defines the scene the groups belongs to
  17913. */
  17914. constructor(scene: Scene);
  17915. private _clearDepthStencilBuffer;
  17916. /**
  17917. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17918. * @hidden
  17919. */
  17920. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17921. /**
  17922. * Resets the different information of the group to prepare a new frame
  17923. * @hidden
  17924. */
  17925. reset(): void;
  17926. /**
  17927. * Dispose and release the group and its associated resources.
  17928. * @hidden
  17929. */
  17930. dispose(): void;
  17931. /**
  17932. * Clear the info related to rendering groups preventing retention points during dispose.
  17933. */
  17934. freeRenderingGroups(): void;
  17935. private _prepareRenderingGroup;
  17936. /**
  17937. * Add a sprite manager to the rendering manager in order to render it this frame.
  17938. * @param spriteManager Define the sprite manager to render
  17939. */
  17940. dispatchSprites(spriteManager: ISpriteManager): void;
  17941. /**
  17942. * Add a particle system to the rendering manager in order to render it this frame.
  17943. * @param particleSystem Define the particle system to render
  17944. */
  17945. dispatchParticles(particleSystem: IParticleSystem): void;
  17946. /**
  17947. * Add a submesh to the manager in order to render it this frame
  17948. * @param subMesh The submesh to dispatch
  17949. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17950. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17951. */
  17952. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17953. /**
  17954. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17955. * This allowed control for front to back rendering or reversly depending of the special needs.
  17956. *
  17957. * @param renderingGroupId The rendering group id corresponding to its index
  17958. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17959. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17960. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17961. */
  17962. 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;
  17963. /**
  17964. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17965. *
  17966. * @param renderingGroupId The rendering group id corresponding to its index
  17967. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17968. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17969. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17970. */
  17971. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17972. /**
  17973. * Gets the current auto clear configuration for one rendering group of the rendering
  17974. * manager.
  17975. * @param index the rendering group index to get the information for
  17976. * @returns The auto clear setup for the requested rendering group
  17977. */
  17978. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17979. }
  17980. }
  17981. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17982. import { SmartArray } from "babylonjs/Misc/smartArray";
  17983. import { Nullable } from "babylonjs/types";
  17984. import { Scene } from "babylonjs/scene";
  17985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17988. import { Mesh } from "babylonjs/Meshes/mesh";
  17989. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17990. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17991. import { Effect } from "babylonjs/Materials/effect";
  17992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17993. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17994. import "babylonjs/Shaders/shadowMap.fragment";
  17995. import "babylonjs/Shaders/shadowMap.vertex";
  17996. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17997. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17998. import { Observable } from "babylonjs/Misc/observable";
  17999. /**
  18000. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18001. */
  18002. export interface ICustomShaderOptions {
  18003. /**
  18004. * Gets or sets the custom shader name to use
  18005. */
  18006. shaderName: string;
  18007. /**
  18008. * The list of attribute names used in the shader
  18009. */
  18010. attributes?: string[];
  18011. /**
  18012. * The list of unifrom names used in the shader
  18013. */
  18014. uniforms?: string[];
  18015. /**
  18016. * The list of sampler names used in the shader
  18017. */
  18018. samplers?: string[];
  18019. /**
  18020. * The list of defines used in the shader
  18021. */
  18022. defines?: string[];
  18023. }
  18024. /**
  18025. * Interface to implement to create a shadow generator compatible with BJS.
  18026. */
  18027. export interface IShadowGenerator {
  18028. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18029. id: string;
  18030. /**
  18031. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18032. * @returns The render target texture if present otherwise, null
  18033. */
  18034. getShadowMap(): Nullable<RenderTargetTexture>;
  18035. /**
  18036. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18037. * @param subMesh The submesh we want to render in the shadow map
  18038. * @param useInstances Defines wether will draw in the map using instances
  18039. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18040. * @returns true if ready otherwise, false
  18041. */
  18042. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18043. /**
  18044. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18045. * @param defines Defines of the material we want to update
  18046. * @param lightIndex Index of the light in the enabled light list of the material
  18047. */
  18048. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18049. /**
  18050. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18051. * defined in the generator but impacting the effect).
  18052. * It implies the unifroms available on the materials are the standard BJS ones.
  18053. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18054. * @param effect The effect we are binfing the information for
  18055. */
  18056. bindShadowLight(lightIndex: string, effect: Effect): void;
  18057. /**
  18058. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18059. * (eq to shadow prjection matrix * light transform matrix)
  18060. * @returns The transform matrix used to create the shadow map
  18061. */
  18062. getTransformMatrix(): Matrix;
  18063. /**
  18064. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18065. * Cube and 2D textures for instance.
  18066. */
  18067. recreateShadowMap(): void;
  18068. /**
  18069. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18070. * @param onCompiled Callback triggered at the and of the effects compilation
  18071. * @param options Sets of optional options forcing the compilation with different modes
  18072. */
  18073. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18074. useInstances: boolean;
  18075. }>): void;
  18076. /**
  18077. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18078. * @param options Sets of optional options forcing the compilation with different modes
  18079. * @returns A promise that resolves when the compilation completes
  18080. */
  18081. forceCompilationAsync(options?: Partial<{
  18082. useInstances: boolean;
  18083. }>): Promise<void>;
  18084. /**
  18085. * Serializes the shadow generator setup to a json object.
  18086. * @returns The serialized JSON object
  18087. */
  18088. serialize(): any;
  18089. /**
  18090. * Disposes the Shadow map and related Textures and effects.
  18091. */
  18092. dispose(): void;
  18093. }
  18094. /**
  18095. * Default implementation IShadowGenerator.
  18096. * This is the main object responsible of generating shadows in the framework.
  18097. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18098. */
  18099. export class ShadowGenerator implements IShadowGenerator {
  18100. /**
  18101. * Name of the shadow generator class
  18102. */
  18103. static CLASSNAME: string;
  18104. /**
  18105. * Shadow generator mode None: no filtering applied.
  18106. */
  18107. static readonly FILTER_NONE: number;
  18108. /**
  18109. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18115. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18116. */
  18117. static readonly FILTER_POISSONSAMPLING: number;
  18118. /**
  18119. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18120. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18121. */
  18122. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18123. /**
  18124. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18125. * edge artifacts on steep falloff.
  18126. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18127. */
  18128. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18129. /**
  18130. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18131. * edge artifacts on steep falloff.
  18132. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18133. */
  18134. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18135. /**
  18136. * Shadow generator mode PCF: Percentage Closer Filtering
  18137. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18138. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18139. */
  18140. static readonly FILTER_PCF: number;
  18141. /**
  18142. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18143. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18144. * Contact Hardening
  18145. */
  18146. static readonly FILTER_PCSS: number;
  18147. /**
  18148. * Reserved for PCF and PCSS
  18149. * Highest Quality.
  18150. *
  18151. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18152. *
  18153. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18154. */
  18155. static readonly QUALITY_HIGH: number;
  18156. /**
  18157. * Reserved for PCF and PCSS
  18158. * Good tradeoff for quality/perf cross devices
  18159. *
  18160. * Execute PCF on a 3*3 kernel.
  18161. *
  18162. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18163. */
  18164. static readonly QUALITY_MEDIUM: number;
  18165. /**
  18166. * Reserved for PCF and PCSS
  18167. * The lowest quality but the fastest.
  18168. *
  18169. * Execute PCF on a 1*1 kernel.
  18170. *
  18171. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18172. */
  18173. static readonly QUALITY_LOW: number;
  18174. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18175. id: string;
  18176. /** Gets or sets the custom shader name to use */
  18177. customShaderOptions: ICustomShaderOptions;
  18178. /**
  18179. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18180. */
  18181. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18182. /**
  18183. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18184. */
  18185. onAfterShadowMapRenderObservable: Observable<Effect>;
  18186. /**
  18187. * Observable triggered before a mesh is rendered in the shadow map.
  18188. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18189. */
  18190. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18191. /**
  18192. * Observable triggered after a mesh is rendered in the shadow map.
  18193. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18194. */
  18195. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18196. protected _bias: number;
  18197. /**
  18198. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18199. */
  18200. get bias(): number;
  18201. /**
  18202. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18203. */
  18204. set bias(bias: number);
  18205. protected _normalBias: number;
  18206. /**
  18207. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18208. */
  18209. get normalBias(): number;
  18210. /**
  18211. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18212. */
  18213. set normalBias(normalBias: number);
  18214. protected _blurBoxOffset: number;
  18215. /**
  18216. * Gets the blur box offset: offset applied during the blur pass.
  18217. * Only useful if useKernelBlur = false
  18218. */
  18219. get blurBoxOffset(): number;
  18220. /**
  18221. * Sets the blur box offset: offset applied during the blur pass.
  18222. * Only useful if useKernelBlur = false
  18223. */
  18224. set blurBoxOffset(value: number);
  18225. protected _blurScale: number;
  18226. /**
  18227. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18228. * 2 means half of the size.
  18229. */
  18230. get blurScale(): number;
  18231. /**
  18232. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18233. * 2 means half of the size.
  18234. */
  18235. set blurScale(value: number);
  18236. protected _blurKernel: number;
  18237. /**
  18238. * Gets the blur kernel: kernel size of the blur pass.
  18239. * Only useful if useKernelBlur = true
  18240. */
  18241. get blurKernel(): number;
  18242. /**
  18243. * Sets the blur kernel: kernel size of the blur pass.
  18244. * Only useful if useKernelBlur = true
  18245. */
  18246. set blurKernel(value: number);
  18247. protected _useKernelBlur: boolean;
  18248. /**
  18249. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18250. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18251. */
  18252. get useKernelBlur(): boolean;
  18253. /**
  18254. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18255. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18256. */
  18257. set useKernelBlur(value: boolean);
  18258. protected _depthScale: number;
  18259. /**
  18260. * Gets the depth scale used in ESM mode.
  18261. */
  18262. get depthScale(): number;
  18263. /**
  18264. * Sets the depth scale used in ESM mode.
  18265. * This can override the scale stored on the light.
  18266. */
  18267. set depthScale(value: number);
  18268. protected _validateFilter(filter: number): number;
  18269. protected _filter: number;
  18270. /**
  18271. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18272. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18273. */
  18274. get filter(): number;
  18275. /**
  18276. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18277. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18278. */
  18279. set filter(value: number);
  18280. /**
  18281. * Gets if the current filter is set to Poisson Sampling.
  18282. */
  18283. get usePoissonSampling(): boolean;
  18284. /**
  18285. * Sets the current filter to Poisson Sampling.
  18286. */
  18287. set usePoissonSampling(value: boolean);
  18288. /**
  18289. * Gets if the current filter is set to ESM.
  18290. */
  18291. get useExponentialShadowMap(): boolean;
  18292. /**
  18293. * Sets the current filter is to ESM.
  18294. */
  18295. set useExponentialShadowMap(value: boolean);
  18296. /**
  18297. * Gets if the current filter is set to filtered ESM.
  18298. */
  18299. get useBlurExponentialShadowMap(): boolean;
  18300. /**
  18301. * Gets if the current filter is set to filtered ESM.
  18302. */
  18303. set useBlurExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18316. * exponential to prevent steep falloff artifacts).
  18317. */
  18318. get useBlurCloseExponentialShadowMap(): boolean;
  18319. /**
  18320. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18321. * exponential to prevent steep falloff artifacts).
  18322. */
  18323. set useBlurCloseExponentialShadowMap(value: boolean);
  18324. /**
  18325. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18326. */
  18327. get usePercentageCloserFiltering(): boolean;
  18328. /**
  18329. * Sets the current filter to "PCF" (percentage closer filtering).
  18330. */
  18331. set usePercentageCloserFiltering(value: boolean);
  18332. protected _filteringQuality: number;
  18333. /**
  18334. * Gets the PCF or PCSS Quality.
  18335. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18336. */
  18337. get filteringQuality(): number;
  18338. /**
  18339. * Sets the PCF or PCSS Quality.
  18340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18341. */
  18342. set filteringQuality(filteringQuality: number);
  18343. /**
  18344. * Gets if the current filter is set to "PCSS" (contact hardening).
  18345. */
  18346. get useContactHardeningShadow(): boolean;
  18347. /**
  18348. * Sets the current filter to "PCSS" (contact hardening).
  18349. */
  18350. set useContactHardeningShadow(value: boolean);
  18351. protected _contactHardeningLightSizeUVRatio: number;
  18352. /**
  18353. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. get contactHardeningLightSizeUVRatio(): number;
  18362. /**
  18363. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18364. * Using a ratio helps keeping shape stability independently of the map size.
  18365. *
  18366. * It does not account for the light projection as it was having too much
  18367. * instability during the light setup or during light position changes.
  18368. *
  18369. * Only valid if useContactHardeningShadow is true.
  18370. */
  18371. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18372. protected _darkness: number;
  18373. /** Gets or sets the actual darkness of a shadow */
  18374. get darkness(): number;
  18375. set darkness(value: number);
  18376. /**
  18377. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18378. * 0 means strongest and 1 would means no shadow.
  18379. * @returns the darkness.
  18380. */
  18381. getDarkness(): number;
  18382. /**
  18383. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18384. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18385. * @returns the shadow generator allowing fluent coding.
  18386. */
  18387. setDarkness(darkness: number): ShadowGenerator;
  18388. protected _transparencyShadow: boolean;
  18389. /** Gets or sets the ability to have transparent shadow */
  18390. get transparencyShadow(): boolean;
  18391. set transparencyShadow(value: boolean);
  18392. /**
  18393. * Sets the ability to have transparent shadow (boolean).
  18394. * @param transparent True if transparent else False
  18395. * @returns the shadow generator allowing fluent coding
  18396. */
  18397. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18398. /**
  18399. * Enables or disables shadows with varying strength based on the transparency
  18400. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18401. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18402. * mesh.visibility * alphaTexture.a
  18403. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18404. */
  18405. enableSoftTransparentShadow: boolean;
  18406. protected _shadowMap: Nullable<RenderTargetTexture>;
  18407. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18410. * @returns The render target texture if present otherwise, null
  18411. */
  18412. getShadowMap(): Nullable<RenderTargetTexture>;
  18413. /**
  18414. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18415. * @returns The render target texture if the shadow map is present otherwise, null
  18416. */
  18417. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18418. /**
  18419. * Gets the class name of that object
  18420. * @returns "ShadowGenerator"
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18425. * @param mesh Mesh to add
  18426. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18427. * @returns the Shadow Generator itself
  18428. */
  18429. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18430. /**
  18431. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18432. * @param mesh Mesh to remove
  18433. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18434. * @returns the Shadow Generator itself
  18435. */
  18436. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18437. /**
  18438. * Controls the extent to which the shadows fade out at the edge of the frustum
  18439. */
  18440. frustumEdgeFalloff: number;
  18441. protected _light: IShadowLight;
  18442. /**
  18443. * Returns the associated light object.
  18444. * @returns the light generating the shadow
  18445. */
  18446. getLight(): IShadowLight;
  18447. /**
  18448. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18449. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18450. * It might on the other hand introduce peter panning.
  18451. */
  18452. forceBackFacesOnly: boolean;
  18453. protected _scene: Scene;
  18454. protected _lightDirection: Vector3;
  18455. protected _effect: Effect;
  18456. protected _viewMatrix: Matrix;
  18457. protected _projectionMatrix: Matrix;
  18458. protected _transformMatrix: Matrix;
  18459. protected _cachedPosition: Vector3;
  18460. protected _cachedDirection: Vector3;
  18461. protected _cachedDefines: string;
  18462. protected _currentRenderID: number;
  18463. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18464. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18465. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18466. protected _blurPostProcesses: PostProcess[];
  18467. protected _mapSize: number;
  18468. protected _currentFaceIndex: number;
  18469. protected _currentFaceIndexCache: number;
  18470. protected _textureType: number;
  18471. protected _defaultTextureMatrix: Matrix;
  18472. protected _storedUniqueId: Nullable<number>;
  18473. /** @hidden */
  18474. static _SceneComponentInitialization: (scene: Scene) => void;
  18475. /**
  18476. * Creates a ShadowGenerator object.
  18477. * A ShadowGenerator is the required tool to use the shadows.
  18478. * Each light casting shadows needs to use its own ShadowGenerator.
  18479. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18480. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18481. * @param light The light object generating the shadows.
  18482. * @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.
  18483. */
  18484. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18485. protected _initializeGenerator(): void;
  18486. protected _createTargetRenderTexture(): void;
  18487. protected _initializeShadowMap(): void;
  18488. protected _initializeBlurRTTAndPostProcesses(): void;
  18489. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18490. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18491. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18492. protected _applyFilterValues(): void;
  18493. /**
  18494. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18495. * @param onCompiled Callback triggered at the and of the effects compilation
  18496. * @param options Sets of optional options forcing the compilation with different modes
  18497. */
  18498. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18499. useInstances: boolean;
  18500. }>): void;
  18501. /**
  18502. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18503. * @param options Sets of optional options forcing the compilation with different modes
  18504. * @returns A promise that resolves when the compilation completes
  18505. */
  18506. forceCompilationAsync(options?: Partial<{
  18507. useInstances: boolean;
  18508. }>): Promise<void>;
  18509. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18510. private _prepareShadowDefines;
  18511. /**
  18512. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18513. * @param subMesh The submesh we want to render in the shadow map
  18514. * @param useInstances Defines wether will draw in the map using instances
  18515. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18516. * @returns true if ready otherwise, false
  18517. */
  18518. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18519. /**
  18520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18521. * @param defines Defines of the material we want to update
  18522. * @param lightIndex Index of the light in the enabled light list of the material
  18523. */
  18524. prepareDefines(defines: any, lightIndex: number): void;
  18525. /**
  18526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18527. * defined in the generator but impacting the effect).
  18528. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18529. * @param effect The effect we are binfing the information for
  18530. */
  18531. bindShadowLight(lightIndex: string, effect: Effect): void;
  18532. /**
  18533. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18534. * (eq to shadow prjection matrix * light transform matrix)
  18535. * @returns The transform matrix used to create the shadow map
  18536. */
  18537. getTransformMatrix(): Matrix;
  18538. /**
  18539. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18540. * Cube and 2D textures for instance.
  18541. */
  18542. recreateShadowMap(): void;
  18543. protected _disposeBlurPostProcesses(): void;
  18544. protected _disposeRTTandPostProcesses(): void;
  18545. /**
  18546. * Disposes the ShadowGenerator.
  18547. * Returns nothing.
  18548. */
  18549. dispose(): void;
  18550. /**
  18551. * Serializes the shadow generator setup to a json object.
  18552. * @returns The serialized JSON object
  18553. */
  18554. serialize(): any;
  18555. /**
  18556. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18557. * @param parsedShadowGenerator The JSON object to parse
  18558. * @param scene The scene to create the shadow map for
  18559. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18560. * @returns The parsed shadow generator
  18561. */
  18562. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18563. }
  18564. }
  18565. declare module "babylonjs/Lights/light" {
  18566. import { Nullable } from "babylonjs/types";
  18567. import { Scene } from "babylonjs/scene";
  18568. import { Vector3 } from "babylonjs/Maths/math.vector";
  18569. import { Color3 } from "babylonjs/Maths/math.color";
  18570. import { Node } from "babylonjs/node";
  18571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18572. import { Effect } from "babylonjs/Materials/effect";
  18573. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18574. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18575. /**
  18576. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18577. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18578. * 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.
  18579. */
  18580. export abstract class Light extends Node {
  18581. /**
  18582. * Falloff Default: light is falling off following the material specification:
  18583. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18584. */
  18585. static readonly FALLOFF_DEFAULT: number;
  18586. /**
  18587. * Falloff Physical: light is falling off following the inverse squared distance law.
  18588. */
  18589. static readonly FALLOFF_PHYSICAL: number;
  18590. /**
  18591. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18592. * to enhance interoperability with other engines.
  18593. */
  18594. static readonly FALLOFF_GLTF: number;
  18595. /**
  18596. * Falloff Standard: light is falling off like in the standard material
  18597. * to enhance interoperability with other materials.
  18598. */
  18599. static readonly FALLOFF_STANDARD: number;
  18600. /**
  18601. * If every light affecting the material is in this lightmapMode,
  18602. * material.lightmapTexture adds or multiplies
  18603. * (depends on material.useLightmapAsShadowmap)
  18604. * after every other light calculations.
  18605. */
  18606. static readonly LIGHTMAP_DEFAULT: number;
  18607. /**
  18608. * material.lightmapTexture as only diffuse lighting from this light
  18609. * adds only specular lighting from this light
  18610. * adds dynamic shadows
  18611. */
  18612. static readonly LIGHTMAP_SPECULAR: number;
  18613. /**
  18614. * material.lightmapTexture as only lighting
  18615. * no light calculation from this light
  18616. * only adds dynamic shadows from this light
  18617. */
  18618. static readonly LIGHTMAP_SHADOWSONLY: number;
  18619. /**
  18620. * Each light type uses the default quantity according to its type:
  18621. * point/spot lights use luminous intensity
  18622. * directional lights use illuminance
  18623. */
  18624. static readonly INTENSITYMODE_AUTOMATIC: number;
  18625. /**
  18626. * lumen (lm)
  18627. */
  18628. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18629. /**
  18630. * candela (lm/sr)
  18631. */
  18632. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18633. /**
  18634. * lux (lm/m^2)
  18635. */
  18636. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18637. /**
  18638. * nit (cd/m^2)
  18639. */
  18640. static readonly INTENSITYMODE_LUMINANCE: number;
  18641. /**
  18642. * Light type const id of the point light.
  18643. */
  18644. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18645. /**
  18646. * Light type const id of the directional light.
  18647. */
  18648. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18649. /**
  18650. * Light type const id of the spot light.
  18651. */
  18652. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18653. /**
  18654. * Light type const id of the hemispheric light.
  18655. */
  18656. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18657. /**
  18658. * Diffuse gives the basic color to an object.
  18659. */
  18660. diffuse: Color3;
  18661. /**
  18662. * Specular produces a highlight color on an object.
  18663. * Note: This is note affecting PBR materials.
  18664. */
  18665. specular: Color3;
  18666. /**
  18667. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18668. * falling off base on range or angle.
  18669. * This can be set to any values in Light.FALLOFF_x.
  18670. *
  18671. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18672. * other types of materials.
  18673. */
  18674. falloffType: number;
  18675. /**
  18676. * Strength of the light.
  18677. * Note: By default it is define in the framework own unit.
  18678. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18679. */
  18680. intensity: number;
  18681. private _range;
  18682. protected _inverseSquaredRange: number;
  18683. /**
  18684. * Defines how far from the source the light is impacting in scene units.
  18685. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18686. */
  18687. get range(): number;
  18688. /**
  18689. * Defines how far from the source the light is impacting in scene units.
  18690. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18691. */
  18692. set range(value: number);
  18693. /**
  18694. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18695. * of light.
  18696. */
  18697. private _photometricScale;
  18698. private _intensityMode;
  18699. /**
  18700. * Gets the photometric scale used to interpret the intensity.
  18701. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18702. */
  18703. get intensityMode(): number;
  18704. /**
  18705. * Sets the photometric scale used to interpret the intensity.
  18706. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18707. */
  18708. set intensityMode(value: number);
  18709. private _radius;
  18710. /**
  18711. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18712. */
  18713. get radius(): number;
  18714. /**
  18715. * sets the light radius used by PBR Materials to simulate soft area lights.
  18716. */
  18717. set radius(value: number);
  18718. private _renderPriority;
  18719. /**
  18720. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18721. * exceeding the number allowed of the materials.
  18722. */
  18723. renderPriority: number;
  18724. private _shadowEnabled;
  18725. /**
  18726. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18727. * the current shadow generator.
  18728. */
  18729. get shadowEnabled(): boolean;
  18730. /**
  18731. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18732. * the current shadow generator.
  18733. */
  18734. set shadowEnabled(value: boolean);
  18735. private _includedOnlyMeshes;
  18736. /**
  18737. * Gets the only meshes impacted by this light.
  18738. */
  18739. get includedOnlyMeshes(): AbstractMesh[];
  18740. /**
  18741. * Sets the only meshes impacted by this light.
  18742. */
  18743. set includedOnlyMeshes(value: AbstractMesh[]);
  18744. private _excludedMeshes;
  18745. /**
  18746. * Gets the meshes not impacted by this light.
  18747. */
  18748. get excludedMeshes(): AbstractMesh[];
  18749. /**
  18750. * Sets the meshes not impacted by this light.
  18751. */
  18752. set excludedMeshes(value: AbstractMesh[]);
  18753. private _excludeWithLayerMask;
  18754. /**
  18755. * Gets the layer id use to find what meshes are not impacted by the light.
  18756. * Inactive if 0
  18757. */
  18758. get excludeWithLayerMask(): number;
  18759. /**
  18760. * Sets the layer id use to find what meshes are not impacted by the light.
  18761. * Inactive if 0
  18762. */
  18763. set excludeWithLayerMask(value: number);
  18764. private _includeOnlyWithLayerMask;
  18765. /**
  18766. * Gets the layer id use to find what meshes are impacted by the light.
  18767. * Inactive if 0
  18768. */
  18769. get includeOnlyWithLayerMask(): number;
  18770. /**
  18771. * Sets the layer id use to find what meshes are impacted by the light.
  18772. * Inactive if 0
  18773. */
  18774. set includeOnlyWithLayerMask(value: number);
  18775. private _lightmapMode;
  18776. /**
  18777. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18778. */
  18779. get lightmapMode(): number;
  18780. /**
  18781. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18782. */
  18783. set lightmapMode(value: number);
  18784. /**
  18785. * Shadow generator associted to the light.
  18786. * @hidden Internal use only.
  18787. */
  18788. _shadowGenerator: Nullable<IShadowGenerator>;
  18789. /**
  18790. * @hidden Internal use only.
  18791. */
  18792. _excludedMeshesIds: string[];
  18793. /**
  18794. * @hidden Internal use only.
  18795. */
  18796. _includedOnlyMeshesIds: string[];
  18797. /**
  18798. * The current light unifom buffer.
  18799. * @hidden Internal use only.
  18800. */
  18801. _uniformBuffer: UniformBuffer;
  18802. /** @hidden */
  18803. _renderId: number;
  18804. /**
  18805. * Creates a Light object in the scene.
  18806. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18807. * @param name The firendly name of the light
  18808. * @param scene The scene the light belongs too
  18809. */
  18810. constructor(name: string, scene: Scene);
  18811. protected abstract _buildUniformLayout(): void;
  18812. /**
  18813. * Sets the passed Effect "effect" with the Light information.
  18814. * @param effect The effect to update
  18815. * @param lightIndex The index of the light in the effect to update
  18816. * @returns The light
  18817. */
  18818. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18819. /**
  18820. * Sets the passed Effect "effect" with the Light textures.
  18821. * @param effect The effect to update
  18822. * @param lightIndex The index of the light in the effect to update
  18823. * @returns The light
  18824. */
  18825. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18826. /**
  18827. * Binds the lights information from the scene to the effect for the given mesh.
  18828. * @param lightIndex Light index
  18829. * @param scene The scene where the light belongs to
  18830. * @param effect The effect we are binding the data to
  18831. * @param useSpecular Defines if specular is supported
  18832. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18833. */
  18834. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18835. /**
  18836. * Sets the passed Effect "effect" with the Light information.
  18837. * @param effect The effect to update
  18838. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18839. * @returns The light
  18840. */
  18841. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18842. /**
  18843. * Returns the string "Light".
  18844. * @returns the class name
  18845. */
  18846. getClassName(): string;
  18847. /** @hidden */
  18848. readonly _isLight: boolean;
  18849. /**
  18850. * Converts the light information to a readable string for debug purpose.
  18851. * @param fullDetails Supports for multiple levels of logging within scene loading
  18852. * @returns the human readable light info
  18853. */
  18854. toString(fullDetails?: boolean): string;
  18855. /** @hidden */
  18856. protected _syncParentEnabledState(): void;
  18857. /**
  18858. * Set the enabled state of this node.
  18859. * @param value - the new enabled state
  18860. */
  18861. setEnabled(value: boolean): void;
  18862. /**
  18863. * Returns the Light associated shadow generator if any.
  18864. * @return the associated shadow generator.
  18865. */
  18866. getShadowGenerator(): Nullable<IShadowGenerator>;
  18867. /**
  18868. * Returns a Vector3, the absolute light position in the World.
  18869. * @returns the world space position of the light
  18870. */
  18871. getAbsolutePosition(): Vector3;
  18872. /**
  18873. * Specifies if the light will affect the passed mesh.
  18874. * @param mesh The mesh to test against the light
  18875. * @return true the mesh is affected otherwise, false.
  18876. */
  18877. canAffectMesh(mesh: AbstractMesh): boolean;
  18878. /**
  18879. * Sort function to order lights for rendering.
  18880. * @param a First Light object to compare to second.
  18881. * @param b Second Light object to compare first.
  18882. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18883. */
  18884. static CompareLightsPriority(a: Light, b: Light): number;
  18885. /**
  18886. * Releases resources associated with this node.
  18887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18889. */
  18890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18891. /**
  18892. * Returns the light type ID (integer).
  18893. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18894. */
  18895. getTypeID(): number;
  18896. /**
  18897. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18898. * @returns the scaled intensity in intensity mode unit
  18899. */
  18900. getScaledIntensity(): number;
  18901. /**
  18902. * Returns a new Light object, named "name", from the current one.
  18903. * @param name The name of the cloned light
  18904. * @param newParent The parent of this light, if it has one
  18905. * @returns the new created light
  18906. */
  18907. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18908. /**
  18909. * Serializes the current light into a Serialization object.
  18910. * @returns the serialized object.
  18911. */
  18912. serialize(): any;
  18913. /**
  18914. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18915. * This new light is named "name" and added to the passed scene.
  18916. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18917. * @param name The friendly name of the light
  18918. * @param scene The scene the new light will belong to
  18919. * @returns the constructor function
  18920. */
  18921. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18922. /**
  18923. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18924. * @param parsedLight The JSON representation of the light
  18925. * @param scene The scene to create the parsed light in
  18926. * @returns the created light after parsing
  18927. */
  18928. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18929. private _hookArrayForExcluded;
  18930. private _hookArrayForIncludedOnly;
  18931. private _resyncMeshes;
  18932. /**
  18933. * Forces the meshes to update their light related information in their rendering used effects
  18934. * @hidden Internal Use Only
  18935. */
  18936. _markMeshesAsLightDirty(): void;
  18937. /**
  18938. * Recomputes the cached photometric scale if needed.
  18939. */
  18940. private _computePhotometricScale;
  18941. /**
  18942. * Returns the Photometric Scale according to the light type and intensity mode.
  18943. */
  18944. private _getPhotometricScale;
  18945. /**
  18946. * Reorder the light in the scene according to their defined priority.
  18947. * @hidden Internal Use Only
  18948. */
  18949. _reorderLightsInScene(): void;
  18950. /**
  18951. * Prepares the list of defines specific to the light type.
  18952. * @param defines the list of defines
  18953. * @param lightIndex defines the index of the light for the effect
  18954. */
  18955. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18956. }
  18957. }
  18958. declare module "babylonjs/Materials/prePassConfiguration" {
  18959. import { Matrix } from "babylonjs/Maths/math.vector";
  18960. import { Mesh } from "babylonjs/Meshes/mesh";
  18961. import { Scene } from "babylonjs/scene";
  18962. import { Effect } from "babylonjs/Materials/effect";
  18963. /**
  18964. * Configuration needed for prepass-capable materials
  18965. */
  18966. export class PrePassConfiguration {
  18967. /**
  18968. * Previous world matrices of meshes carrying this material
  18969. * Used for computing velocity
  18970. */
  18971. previousWorldMatrices: {
  18972. [index: number]: Matrix;
  18973. };
  18974. /**
  18975. * Previous view project matrix
  18976. * Used for computing velocity
  18977. */
  18978. previousViewProjection: Matrix;
  18979. /**
  18980. * Previous bones of meshes carrying this material
  18981. * Used for computing velocity
  18982. */
  18983. previousBones: {
  18984. [index: number]: Float32Array;
  18985. };
  18986. /**
  18987. * Add the required uniforms to the current list.
  18988. * @param uniforms defines the current uniform list.
  18989. */
  18990. static AddUniforms(uniforms: string[]): void;
  18991. /**
  18992. * Add the required samplers to the current list.
  18993. * @param samplers defines the current sampler list.
  18994. */
  18995. static AddSamplers(samplers: string[]): void;
  18996. /**
  18997. * Binds the material data.
  18998. * @param effect defines the effect to update
  18999. * @param scene defines the scene the material belongs to.
  19000. * @param mesh The mesh
  19001. * @param world World matrix of this mesh
  19002. * @param isFrozen Is the material frozen
  19003. */
  19004. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19005. }
  19006. }
  19007. declare module "babylonjs/Cameras/targetCamera" {
  19008. import { Nullable } from "babylonjs/types";
  19009. import { Camera } from "babylonjs/Cameras/camera";
  19010. import { Scene } from "babylonjs/scene";
  19011. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19012. /**
  19013. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19014. * This is the base of the follow, arc rotate cameras and Free camera
  19015. * @see https://doc.babylonjs.com/features/cameras
  19016. */
  19017. export class TargetCamera extends Camera {
  19018. private static _RigCamTransformMatrix;
  19019. private static _TargetTransformMatrix;
  19020. private static _TargetFocalPoint;
  19021. private _tmpUpVector;
  19022. private _tmpTargetVector;
  19023. /**
  19024. * Define the current direction the camera is moving to
  19025. */
  19026. cameraDirection: Vector3;
  19027. /**
  19028. * Define the current rotation the camera is rotating to
  19029. */
  19030. cameraRotation: Vector2;
  19031. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19032. ignoreParentScaling: boolean;
  19033. /**
  19034. * When set, the up vector of the camera will be updated by the rotation of the camera
  19035. */
  19036. updateUpVectorFromRotation: boolean;
  19037. private _tmpQuaternion;
  19038. /**
  19039. * Define the current rotation of the camera
  19040. */
  19041. rotation: Vector3;
  19042. /**
  19043. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19044. */
  19045. rotationQuaternion: Quaternion;
  19046. /**
  19047. * Define the current speed of the camera
  19048. */
  19049. speed: number;
  19050. /**
  19051. * Add constraint to the camera to prevent it to move freely in all directions and
  19052. * around all axis.
  19053. */
  19054. noRotationConstraint: boolean;
  19055. /**
  19056. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19057. * panning
  19058. */
  19059. invertRotation: boolean;
  19060. /**
  19061. * Speed multiplier for inverse camera panning
  19062. */
  19063. inverseRotationSpeed: number;
  19064. /**
  19065. * Define the current target of the camera as an object or a position.
  19066. */
  19067. lockedTarget: any;
  19068. /** @hidden */
  19069. _currentTarget: Vector3;
  19070. /** @hidden */
  19071. _initialFocalDistance: number;
  19072. /** @hidden */
  19073. _viewMatrix: Matrix;
  19074. /** @hidden */
  19075. _camMatrix: Matrix;
  19076. /** @hidden */
  19077. _cameraTransformMatrix: Matrix;
  19078. /** @hidden */
  19079. _cameraRotationMatrix: Matrix;
  19080. /** @hidden */
  19081. _referencePoint: Vector3;
  19082. /** @hidden */
  19083. _transformedReferencePoint: Vector3;
  19084. /** @hidden */
  19085. _reset: () => void;
  19086. private _defaultUp;
  19087. /**
  19088. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19089. * This is the base of the follow, arc rotate cameras and Free camera
  19090. * @see https://doc.babylonjs.com/features/cameras
  19091. * @param name Defines the name of the camera in the scene
  19092. * @param position Defines the start position of the camera in the scene
  19093. * @param scene Defines the scene the camera belongs to
  19094. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19095. */
  19096. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19097. /**
  19098. * Gets the position in front of the camera at a given distance.
  19099. * @param distance The distance from the camera we want the position to be
  19100. * @returns the position
  19101. */
  19102. getFrontPosition(distance: number): Vector3;
  19103. /** @hidden */
  19104. _getLockedTargetPosition(): Nullable<Vector3>;
  19105. private _storedPosition;
  19106. private _storedRotation;
  19107. private _storedRotationQuaternion;
  19108. /**
  19109. * Store current camera state of the camera (fov, position, rotation, etc..)
  19110. * @returns the camera
  19111. */
  19112. storeState(): Camera;
  19113. /**
  19114. * Restored camera state. You must call storeState() first
  19115. * @returns whether it was successful or not
  19116. * @hidden
  19117. */
  19118. _restoreStateValues(): boolean;
  19119. /** @hidden */
  19120. _initCache(): void;
  19121. /** @hidden */
  19122. _updateCache(ignoreParentClass?: boolean): void;
  19123. /** @hidden */
  19124. _isSynchronizedViewMatrix(): boolean;
  19125. /** @hidden */
  19126. _computeLocalCameraSpeed(): number;
  19127. /**
  19128. * Defines the target the camera should look at.
  19129. * @param target Defines the new target as a Vector or a mesh
  19130. */
  19131. setTarget(target: Vector3): void;
  19132. /**
  19133. * Defines the target point of the camera.
  19134. * The camera looks towards it form the radius distance.
  19135. */
  19136. get target(): Vector3;
  19137. set target(value: Vector3);
  19138. /**
  19139. * Return the current target position of the camera. This value is expressed in local space.
  19140. * @returns the target position
  19141. */
  19142. getTarget(): Vector3;
  19143. /** @hidden */
  19144. _decideIfNeedsToMove(): boolean;
  19145. /** @hidden */
  19146. _updatePosition(): void;
  19147. /** @hidden */
  19148. _checkInputs(): void;
  19149. protected _updateCameraRotationMatrix(): void;
  19150. /**
  19151. * 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)
  19152. * @returns the current camera
  19153. */
  19154. private _rotateUpVectorWithCameraRotationMatrix;
  19155. private _cachedRotationZ;
  19156. private _cachedQuaternionRotationZ;
  19157. /** @hidden */
  19158. _getViewMatrix(): Matrix;
  19159. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19160. /**
  19161. * @hidden
  19162. */
  19163. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19164. /**
  19165. * @hidden
  19166. */
  19167. _updateRigCameras(): void;
  19168. private _getRigCamPositionAndTarget;
  19169. /**
  19170. * Gets the current object class name.
  19171. * @return the class name
  19172. */
  19173. getClassName(): string;
  19174. }
  19175. }
  19176. declare module "babylonjs/Events/keyboardEvents" {
  19177. /**
  19178. * Gather the list of keyboard event types as constants.
  19179. */
  19180. export class KeyboardEventTypes {
  19181. /**
  19182. * The keydown event is fired when a key becomes active (pressed).
  19183. */
  19184. static readonly KEYDOWN: number;
  19185. /**
  19186. * The keyup event is fired when a key has been released.
  19187. */
  19188. static readonly KEYUP: number;
  19189. }
  19190. /**
  19191. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19192. */
  19193. export class KeyboardInfo {
  19194. /**
  19195. * Defines the type of event (KeyboardEventTypes)
  19196. */
  19197. type: number;
  19198. /**
  19199. * Defines the related dom event
  19200. */
  19201. event: KeyboardEvent;
  19202. /**
  19203. * Instantiates a new keyboard info.
  19204. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19205. * @param type Defines the type of event (KeyboardEventTypes)
  19206. * @param event Defines the related dom event
  19207. */
  19208. constructor(
  19209. /**
  19210. * Defines the type of event (KeyboardEventTypes)
  19211. */
  19212. type: number,
  19213. /**
  19214. * Defines the related dom event
  19215. */
  19216. event: KeyboardEvent);
  19217. }
  19218. /**
  19219. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19220. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19221. */
  19222. export class KeyboardInfoPre extends KeyboardInfo {
  19223. /**
  19224. * Defines the type of event (KeyboardEventTypes)
  19225. */
  19226. type: number;
  19227. /**
  19228. * Defines the related dom event
  19229. */
  19230. event: KeyboardEvent;
  19231. /**
  19232. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19233. */
  19234. skipOnPointerObservable: boolean;
  19235. /**
  19236. * Instantiates a new keyboard pre info.
  19237. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19238. * @param type Defines the type of event (KeyboardEventTypes)
  19239. * @param event Defines the related dom event
  19240. */
  19241. constructor(
  19242. /**
  19243. * Defines the type of event (KeyboardEventTypes)
  19244. */
  19245. type: number,
  19246. /**
  19247. * Defines the related dom event
  19248. */
  19249. event: KeyboardEvent);
  19250. }
  19251. }
  19252. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19253. import { Nullable } from "babylonjs/types";
  19254. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19255. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19256. /**
  19257. * Manage the keyboard inputs to control the movement of a free camera.
  19258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19259. */
  19260. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19261. /**
  19262. * Defines the camera the input is attached to.
  19263. */
  19264. camera: FreeCamera;
  19265. /**
  19266. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19267. */
  19268. keysUp: number[];
  19269. /**
  19270. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19271. */
  19272. keysUpward: number[];
  19273. /**
  19274. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19275. */
  19276. keysDown: number[];
  19277. /**
  19278. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19279. */
  19280. keysDownward: number[];
  19281. /**
  19282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19283. */
  19284. keysLeft: number[];
  19285. /**
  19286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19287. */
  19288. keysRight: number[];
  19289. private _keys;
  19290. private _onCanvasBlurObserver;
  19291. private _onKeyboardObserver;
  19292. private _engine;
  19293. private _scene;
  19294. /**
  19295. * Attach the input controls to a specific dom element to get the input from.
  19296. * @param element Defines the element the controls should be listened from
  19297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19298. */
  19299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19300. /**
  19301. * Detach the current controls from the specified dom element.
  19302. * @param element Defines the element to stop listening the inputs from
  19303. */
  19304. detachControl(element: Nullable<HTMLElement>): void;
  19305. /**
  19306. * Update the current camera state depending on the inputs that have been used this frame.
  19307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19308. */
  19309. checkInputs(): void;
  19310. /**
  19311. * Gets the class name of the current intput.
  19312. * @returns the class name
  19313. */
  19314. getClassName(): string;
  19315. /** @hidden */
  19316. _onLostFocus(): void;
  19317. /**
  19318. * Get the friendly name associated with the input class.
  19319. * @returns the input friendly name
  19320. */
  19321. getSimpleName(): string;
  19322. }
  19323. }
  19324. declare module "babylonjs/Events/pointerEvents" {
  19325. import { Nullable } from "babylonjs/types";
  19326. import { Vector2 } from "babylonjs/Maths/math.vector";
  19327. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19328. import { Ray } from "babylonjs/Culling/ray";
  19329. /**
  19330. * Gather the list of pointer event types as constants.
  19331. */
  19332. export class PointerEventTypes {
  19333. /**
  19334. * 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.
  19335. */
  19336. static readonly POINTERDOWN: number;
  19337. /**
  19338. * The pointerup event is fired when a pointer is no longer active.
  19339. */
  19340. static readonly POINTERUP: number;
  19341. /**
  19342. * The pointermove event is fired when a pointer changes coordinates.
  19343. */
  19344. static readonly POINTERMOVE: number;
  19345. /**
  19346. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19347. */
  19348. static readonly POINTERWHEEL: number;
  19349. /**
  19350. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19351. */
  19352. static readonly POINTERPICK: number;
  19353. /**
  19354. * The pointertap event is fired when a the object has been touched and released without drag.
  19355. */
  19356. static readonly POINTERTAP: number;
  19357. /**
  19358. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19359. */
  19360. static readonly POINTERDOUBLETAP: number;
  19361. }
  19362. /**
  19363. * Base class of pointer info types.
  19364. */
  19365. export class PointerInfoBase {
  19366. /**
  19367. * Defines the type of event (PointerEventTypes)
  19368. */
  19369. type: number;
  19370. /**
  19371. * Defines the related dom event
  19372. */
  19373. event: PointerEvent | MouseWheelEvent;
  19374. /**
  19375. * Instantiates the base class of pointers info.
  19376. * @param type Defines the type of event (PointerEventTypes)
  19377. * @param event Defines the related dom event
  19378. */
  19379. constructor(
  19380. /**
  19381. * Defines the type of event (PointerEventTypes)
  19382. */
  19383. type: number,
  19384. /**
  19385. * Defines the related dom event
  19386. */
  19387. event: PointerEvent | MouseWheelEvent);
  19388. }
  19389. /**
  19390. * This class is used to store pointer related info for the onPrePointerObservable event.
  19391. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19392. */
  19393. export class PointerInfoPre extends PointerInfoBase {
  19394. /**
  19395. * Ray from a pointer if availible (eg. 6dof controller)
  19396. */
  19397. ray: Nullable<Ray>;
  19398. /**
  19399. * Defines the local position of the pointer on the canvas.
  19400. */
  19401. localPosition: Vector2;
  19402. /**
  19403. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19404. */
  19405. skipOnPointerObservable: boolean;
  19406. /**
  19407. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19408. * @param type Defines the type of event (PointerEventTypes)
  19409. * @param event Defines the related dom event
  19410. * @param localX Defines the local x coordinates of the pointer when the event occured
  19411. * @param localY Defines the local y coordinates of the pointer when the event occured
  19412. */
  19413. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19414. }
  19415. /**
  19416. * This type contains all the data related to a pointer event in Babylon.js.
  19417. * 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.
  19418. */
  19419. export class PointerInfo extends PointerInfoBase {
  19420. /**
  19421. * Defines the picking info associated to the info (if any)\
  19422. */
  19423. pickInfo: Nullable<PickingInfo>;
  19424. /**
  19425. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19426. * @param type Defines the type of event (PointerEventTypes)
  19427. * @param event Defines the related dom event
  19428. * @param pickInfo Defines the picking info associated to the info (if any)\
  19429. */
  19430. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19431. /**
  19432. * Defines the picking info associated to the info (if any)\
  19433. */
  19434. pickInfo: Nullable<PickingInfo>);
  19435. }
  19436. /**
  19437. * Data relating to a touch event on the screen.
  19438. */
  19439. export interface PointerTouch {
  19440. /**
  19441. * X coordinate of touch.
  19442. */
  19443. x: number;
  19444. /**
  19445. * Y coordinate of touch.
  19446. */
  19447. y: number;
  19448. /**
  19449. * Id of touch. Unique for each finger.
  19450. */
  19451. pointerId: number;
  19452. /**
  19453. * Event type passed from DOM.
  19454. */
  19455. type: any;
  19456. }
  19457. }
  19458. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19459. import { Observable } from "babylonjs/Misc/observable";
  19460. import { Nullable } from "babylonjs/types";
  19461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19462. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19463. /**
  19464. * Manage the mouse inputs to control the movement of a free camera.
  19465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19466. */
  19467. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19468. /**
  19469. * Define if touch is enabled in the mouse input
  19470. */
  19471. touchEnabled: boolean;
  19472. /**
  19473. * Defines the camera the input is attached to.
  19474. */
  19475. camera: FreeCamera;
  19476. /**
  19477. * Defines the buttons associated with the input to handle camera move.
  19478. */
  19479. buttons: number[];
  19480. /**
  19481. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19482. */
  19483. angularSensibility: number;
  19484. private _pointerInput;
  19485. private _onMouseMove;
  19486. private _observer;
  19487. private previousPosition;
  19488. /**
  19489. * Observable for when a pointer move event occurs containing the move offset
  19490. */
  19491. onPointerMovedObservable: Observable<{
  19492. offsetX: number;
  19493. offsetY: number;
  19494. }>;
  19495. /**
  19496. * @hidden
  19497. * If the camera should be rotated automatically based on pointer movement
  19498. */
  19499. _allowCameraRotation: boolean;
  19500. /**
  19501. * Manage the mouse inputs to control the movement of a free camera.
  19502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19503. * @param touchEnabled Defines if touch is enabled or not
  19504. */
  19505. constructor(
  19506. /**
  19507. * Define if touch is enabled in the mouse input
  19508. */
  19509. touchEnabled?: boolean);
  19510. /**
  19511. * Attach the input controls to a specific dom element to get the input from.
  19512. * @param element Defines the element the controls should be listened from
  19513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19514. */
  19515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19516. /**
  19517. * Called on JS contextmenu event.
  19518. * Override this method to provide functionality.
  19519. */
  19520. protected onContextMenu(evt: PointerEvent): void;
  19521. /**
  19522. * Detach the current controls from the specified dom element.
  19523. * @param element Defines the element to stop listening the inputs from
  19524. */
  19525. detachControl(element: Nullable<HTMLElement>): void;
  19526. /**
  19527. * Gets the class name of the current intput.
  19528. * @returns the class name
  19529. */
  19530. getClassName(): string;
  19531. /**
  19532. * Get the friendly name associated with the input class.
  19533. * @returns the input friendly name
  19534. */
  19535. getSimpleName(): string;
  19536. }
  19537. }
  19538. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19539. import { Nullable } from "babylonjs/types";
  19540. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19541. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19542. /**
  19543. * Manage the touch inputs to control the movement of a free camera.
  19544. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19545. */
  19546. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19547. /**
  19548. * Define if mouse events can be treated as touch events
  19549. */
  19550. allowMouse: boolean;
  19551. /**
  19552. * Defines the camera the input is attached to.
  19553. */
  19554. camera: FreeCamera;
  19555. /**
  19556. * Defines the touch sensibility for rotation.
  19557. * The higher the faster.
  19558. */
  19559. touchAngularSensibility: number;
  19560. /**
  19561. * Defines the touch sensibility for move.
  19562. * The higher the faster.
  19563. */
  19564. touchMoveSensibility: number;
  19565. private _offsetX;
  19566. private _offsetY;
  19567. private _pointerPressed;
  19568. private _pointerInput;
  19569. private _observer;
  19570. private _onLostFocus;
  19571. /**
  19572. * Manage the touch inputs to control the movement of a free camera.
  19573. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19574. * @param allowMouse Defines if mouse events can be treated as touch events
  19575. */
  19576. constructor(
  19577. /**
  19578. * Define if mouse events can be treated as touch events
  19579. */
  19580. allowMouse?: boolean);
  19581. /**
  19582. * Attach the input controls to a specific dom element to get the input from.
  19583. * @param element Defines the element the controls should be listened from
  19584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19585. */
  19586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19587. /**
  19588. * Detach the current controls from the specified dom element.
  19589. * @param element Defines the element to stop listening the inputs from
  19590. */
  19591. detachControl(element: Nullable<HTMLElement>): void;
  19592. /**
  19593. * Update the current camera state depending on the inputs that have been used this frame.
  19594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19595. */
  19596. checkInputs(): void;
  19597. /**
  19598. * Gets the class name of the current intput.
  19599. * @returns the class name
  19600. */
  19601. getClassName(): string;
  19602. /**
  19603. * Get the friendly name associated with the input class.
  19604. * @returns the input friendly name
  19605. */
  19606. getSimpleName(): string;
  19607. }
  19608. }
  19609. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19610. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19611. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19612. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19613. import { Nullable } from "babylonjs/types";
  19614. /**
  19615. * Default Inputs manager for the FreeCamera.
  19616. * It groups all the default supported inputs for ease of use.
  19617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19618. */
  19619. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19620. /**
  19621. * @hidden
  19622. */
  19623. _mouseInput: Nullable<FreeCameraMouseInput>;
  19624. /**
  19625. * Instantiates a new FreeCameraInputsManager.
  19626. * @param camera Defines the camera the inputs belong to
  19627. */
  19628. constructor(camera: FreeCamera);
  19629. /**
  19630. * Add keyboard input support to the input manager.
  19631. * @returns the current input manager
  19632. */
  19633. addKeyboard(): FreeCameraInputsManager;
  19634. /**
  19635. * Add mouse input support to the input manager.
  19636. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19637. * @returns the current input manager
  19638. */
  19639. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19640. /**
  19641. * Removes the mouse input support from the manager
  19642. * @returns the current input manager
  19643. */
  19644. removeMouse(): FreeCameraInputsManager;
  19645. /**
  19646. * Add touch input support to the input manager.
  19647. * @returns the current input manager
  19648. */
  19649. addTouch(): FreeCameraInputsManager;
  19650. /**
  19651. * Remove all attached input methods from a camera
  19652. */
  19653. clear(): void;
  19654. }
  19655. }
  19656. declare module "babylonjs/Cameras/freeCamera" {
  19657. import { Vector3 } from "babylonjs/Maths/math.vector";
  19658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19659. import { Scene } from "babylonjs/scene";
  19660. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19661. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19662. /**
  19663. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19664. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19665. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19666. */
  19667. export class FreeCamera extends TargetCamera {
  19668. /**
  19669. * Define the collision ellipsoid of the camera.
  19670. * This is helpful to simulate a camera body like the player body around the camera
  19671. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19672. */
  19673. ellipsoid: Vector3;
  19674. /**
  19675. * Define an offset for the position of the ellipsoid around the camera.
  19676. * This can be helpful to determine the center of the body near the gravity center of the body
  19677. * instead of its head.
  19678. */
  19679. ellipsoidOffset: Vector3;
  19680. /**
  19681. * Enable or disable collisions of the camera with the rest of the scene objects.
  19682. */
  19683. checkCollisions: boolean;
  19684. /**
  19685. * Enable or disable gravity on the camera.
  19686. */
  19687. applyGravity: boolean;
  19688. /**
  19689. * Define the input manager associated to the camera.
  19690. */
  19691. inputs: FreeCameraInputsManager;
  19692. /**
  19693. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19694. * Higher values reduce sensitivity.
  19695. */
  19696. get angularSensibility(): number;
  19697. /**
  19698. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19699. * Higher values reduce sensitivity.
  19700. */
  19701. set angularSensibility(value: number);
  19702. /**
  19703. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19704. */
  19705. get keysUp(): number[];
  19706. set keysUp(value: number[]);
  19707. /**
  19708. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19709. */
  19710. get keysUpward(): number[];
  19711. set keysUpward(value: number[]);
  19712. /**
  19713. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19714. */
  19715. get keysDown(): number[];
  19716. set keysDown(value: number[]);
  19717. /**
  19718. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19719. */
  19720. get keysDownward(): number[];
  19721. set keysDownward(value: number[]);
  19722. /**
  19723. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19724. */
  19725. get keysLeft(): number[];
  19726. set keysLeft(value: number[]);
  19727. /**
  19728. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19729. */
  19730. get keysRight(): number[];
  19731. set keysRight(value: number[]);
  19732. /**
  19733. * Event raised when the camera collide with a mesh in the scene.
  19734. */
  19735. onCollide: (collidedMesh: AbstractMesh) => void;
  19736. private _collider;
  19737. private _needMoveForGravity;
  19738. private _oldPosition;
  19739. private _diffPosition;
  19740. private _newPosition;
  19741. /** @hidden */
  19742. _localDirection: Vector3;
  19743. /** @hidden */
  19744. _transformedDirection: Vector3;
  19745. /**
  19746. * Instantiates a Free Camera.
  19747. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19748. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19749. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19750. * @param name Define the name of the camera in the scene
  19751. * @param position Define the start position of the camera in the scene
  19752. * @param scene Define the scene the camera belongs to
  19753. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19754. */
  19755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19756. /**
  19757. * Attached controls to the current camera.
  19758. * @param element Defines the element the controls should be listened from
  19759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19760. */
  19761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19762. /**
  19763. * Detach the current controls from the camera.
  19764. * The camera will stop reacting to inputs.
  19765. * @param element Defines the element to stop listening the inputs from
  19766. */
  19767. detachControl(element: HTMLElement): void;
  19768. private _collisionMask;
  19769. /**
  19770. * Define a collision mask to limit the list of object the camera can collide with
  19771. */
  19772. get collisionMask(): number;
  19773. set collisionMask(mask: number);
  19774. /** @hidden */
  19775. _collideWithWorld(displacement: Vector3): void;
  19776. private _onCollisionPositionChange;
  19777. /** @hidden */
  19778. _checkInputs(): void;
  19779. /** @hidden */
  19780. _decideIfNeedsToMove(): boolean;
  19781. /** @hidden */
  19782. _updatePosition(): void;
  19783. /**
  19784. * Destroy the camera and release the current resources hold by it.
  19785. */
  19786. dispose(): void;
  19787. /**
  19788. * Gets the current object class name.
  19789. * @return the class name
  19790. */
  19791. getClassName(): string;
  19792. }
  19793. }
  19794. declare module "babylonjs/Gamepads/gamepad" {
  19795. import { Observable } from "babylonjs/Misc/observable";
  19796. /**
  19797. * Represents a gamepad control stick position
  19798. */
  19799. export class StickValues {
  19800. /**
  19801. * The x component of the control stick
  19802. */
  19803. x: number;
  19804. /**
  19805. * The y component of the control stick
  19806. */
  19807. y: number;
  19808. /**
  19809. * Initializes the gamepad x and y control stick values
  19810. * @param x The x component of the gamepad control stick value
  19811. * @param y The y component of the gamepad control stick value
  19812. */
  19813. constructor(
  19814. /**
  19815. * The x component of the control stick
  19816. */
  19817. x: number,
  19818. /**
  19819. * The y component of the control stick
  19820. */
  19821. y: number);
  19822. }
  19823. /**
  19824. * An interface which manages callbacks for gamepad button changes
  19825. */
  19826. export interface GamepadButtonChanges {
  19827. /**
  19828. * Called when a gamepad has been changed
  19829. */
  19830. changed: boolean;
  19831. /**
  19832. * Called when a gamepad press event has been triggered
  19833. */
  19834. pressChanged: boolean;
  19835. /**
  19836. * Called when a touch event has been triggered
  19837. */
  19838. touchChanged: boolean;
  19839. /**
  19840. * Called when a value has changed
  19841. */
  19842. valueChanged: boolean;
  19843. }
  19844. /**
  19845. * Represents a gamepad
  19846. */
  19847. export class Gamepad {
  19848. /**
  19849. * The id of the gamepad
  19850. */
  19851. id: string;
  19852. /**
  19853. * The index of the gamepad
  19854. */
  19855. index: number;
  19856. /**
  19857. * The browser gamepad
  19858. */
  19859. browserGamepad: any;
  19860. /**
  19861. * Specifies what type of gamepad this represents
  19862. */
  19863. type: number;
  19864. private _leftStick;
  19865. private _rightStick;
  19866. /** @hidden */
  19867. _isConnected: boolean;
  19868. private _leftStickAxisX;
  19869. private _leftStickAxisY;
  19870. private _rightStickAxisX;
  19871. private _rightStickAxisY;
  19872. /**
  19873. * Triggered when the left control stick has been changed
  19874. */
  19875. private _onleftstickchanged;
  19876. /**
  19877. * Triggered when the right control stick has been changed
  19878. */
  19879. private _onrightstickchanged;
  19880. /**
  19881. * Represents a gamepad controller
  19882. */
  19883. static GAMEPAD: number;
  19884. /**
  19885. * Represents a generic controller
  19886. */
  19887. static GENERIC: number;
  19888. /**
  19889. * Represents an XBox controller
  19890. */
  19891. static XBOX: number;
  19892. /**
  19893. * Represents a pose-enabled controller
  19894. */
  19895. static POSE_ENABLED: number;
  19896. /**
  19897. * Represents an Dual Shock controller
  19898. */
  19899. static DUALSHOCK: number;
  19900. /**
  19901. * Specifies whether the left control stick should be Y-inverted
  19902. */
  19903. protected _invertLeftStickY: boolean;
  19904. /**
  19905. * Specifies if the gamepad has been connected
  19906. */
  19907. get isConnected(): boolean;
  19908. /**
  19909. * Initializes the gamepad
  19910. * @param id The id of the gamepad
  19911. * @param index The index of the gamepad
  19912. * @param browserGamepad The browser gamepad
  19913. * @param leftStickX The x component of the left joystick
  19914. * @param leftStickY The y component of the left joystick
  19915. * @param rightStickX The x component of the right joystick
  19916. * @param rightStickY The y component of the right joystick
  19917. */
  19918. constructor(
  19919. /**
  19920. * The id of the gamepad
  19921. */
  19922. id: string,
  19923. /**
  19924. * The index of the gamepad
  19925. */
  19926. index: number,
  19927. /**
  19928. * The browser gamepad
  19929. */
  19930. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19931. /**
  19932. * Callback triggered when the left joystick has changed
  19933. * @param callback
  19934. */
  19935. onleftstickchanged(callback: (values: StickValues) => void): void;
  19936. /**
  19937. * Callback triggered when the right joystick has changed
  19938. * @param callback
  19939. */
  19940. onrightstickchanged(callback: (values: StickValues) => void): void;
  19941. /**
  19942. * Gets the left joystick
  19943. */
  19944. get leftStick(): StickValues;
  19945. /**
  19946. * Sets the left joystick values
  19947. */
  19948. set leftStick(newValues: StickValues);
  19949. /**
  19950. * Gets the right joystick
  19951. */
  19952. get rightStick(): StickValues;
  19953. /**
  19954. * Sets the right joystick value
  19955. */
  19956. set rightStick(newValues: StickValues);
  19957. /**
  19958. * Updates the gamepad joystick positions
  19959. */
  19960. update(): void;
  19961. /**
  19962. * Disposes the gamepad
  19963. */
  19964. dispose(): void;
  19965. }
  19966. /**
  19967. * Represents a generic gamepad
  19968. */
  19969. export class GenericPad extends Gamepad {
  19970. private _buttons;
  19971. private _onbuttondown;
  19972. private _onbuttonup;
  19973. /**
  19974. * Observable triggered when a button has been pressed
  19975. */
  19976. onButtonDownObservable: Observable<number>;
  19977. /**
  19978. * Observable triggered when a button has been released
  19979. */
  19980. onButtonUpObservable: Observable<number>;
  19981. /**
  19982. * Callback triggered when a button has been pressed
  19983. * @param callback Called when a button has been pressed
  19984. */
  19985. onbuttondown(callback: (buttonPressed: number) => void): void;
  19986. /**
  19987. * Callback triggered when a button has been released
  19988. * @param callback Called when a button has been released
  19989. */
  19990. onbuttonup(callback: (buttonReleased: number) => void): void;
  19991. /**
  19992. * Initializes the generic gamepad
  19993. * @param id The id of the generic gamepad
  19994. * @param index The index of the generic gamepad
  19995. * @param browserGamepad The browser gamepad
  19996. */
  19997. constructor(id: string, index: number, browserGamepad: any);
  19998. private _setButtonValue;
  19999. /**
  20000. * Updates the generic gamepad
  20001. */
  20002. update(): void;
  20003. /**
  20004. * Disposes the generic gamepad
  20005. */
  20006. dispose(): void;
  20007. }
  20008. }
  20009. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20010. import { Observable } from "babylonjs/Misc/observable";
  20011. import { Nullable } from "babylonjs/types";
  20012. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20013. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20015. import { Ray } from "babylonjs/Culling/ray";
  20016. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20017. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20018. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20019. /**
  20020. * Defines the types of pose enabled controllers that are supported
  20021. */
  20022. export enum PoseEnabledControllerType {
  20023. /**
  20024. * HTC Vive
  20025. */
  20026. VIVE = 0,
  20027. /**
  20028. * Oculus Rift
  20029. */
  20030. OCULUS = 1,
  20031. /**
  20032. * Windows mixed reality
  20033. */
  20034. WINDOWS = 2,
  20035. /**
  20036. * Samsung gear VR
  20037. */
  20038. GEAR_VR = 3,
  20039. /**
  20040. * Google Daydream
  20041. */
  20042. DAYDREAM = 4,
  20043. /**
  20044. * Generic
  20045. */
  20046. GENERIC = 5
  20047. }
  20048. /**
  20049. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20050. */
  20051. export interface MutableGamepadButton {
  20052. /**
  20053. * Value of the button/trigger
  20054. */
  20055. value: number;
  20056. /**
  20057. * If the button/trigger is currently touched
  20058. */
  20059. touched: boolean;
  20060. /**
  20061. * If the button/trigger is currently pressed
  20062. */
  20063. pressed: boolean;
  20064. }
  20065. /**
  20066. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20067. * @hidden
  20068. */
  20069. export interface ExtendedGamepadButton extends GamepadButton {
  20070. /**
  20071. * If the button/trigger is currently pressed
  20072. */
  20073. readonly pressed: boolean;
  20074. /**
  20075. * If the button/trigger is currently touched
  20076. */
  20077. readonly touched: boolean;
  20078. /**
  20079. * Value of the button/trigger
  20080. */
  20081. readonly value: number;
  20082. }
  20083. /** @hidden */
  20084. export interface _GamePadFactory {
  20085. /**
  20086. * Returns whether or not the current gamepad can be created for this type of controller.
  20087. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20088. * @returns true if it can be created, otherwise false
  20089. */
  20090. canCreate(gamepadInfo: any): boolean;
  20091. /**
  20092. * Creates a new instance of the Gamepad.
  20093. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20094. * @returns the new gamepad instance
  20095. */
  20096. create(gamepadInfo: any): Gamepad;
  20097. }
  20098. /**
  20099. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20100. */
  20101. export class PoseEnabledControllerHelper {
  20102. /** @hidden */
  20103. static _ControllerFactories: _GamePadFactory[];
  20104. /** @hidden */
  20105. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20106. /**
  20107. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20108. * @param vrGamepad the gamepad to initialized
  20109. * @returns a vr controller of the type the gamepad identified as
  20110. */
  20111. static InitiateController(vrGamepad: any): Gamepad;
  20112. }
  20113. /**
  20114. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20115. */
  20116. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20117. /**
  20118. * If the controller is used in a webXR session
  20119. */
  20120. isXR: boolean;
  20121. private _deviceRoomPosition;
  20122. private _deviceRoomRotationQuaternion;
  20123. /**
  20124. * The device position in babylon space
  20125. */
  20126. devicePosition: Vector3;
  20127. /**
  20128. * The device rotation in babylon space
  20129. */
  20130. deviceRotationQuaternion: Quaternion;
  20131. /**
  20132. * The scale factor of the device in babylon space
  20133. */
  20134. deviceScaleFactor: number;
  20135. /**
  20136. * (Likely devicePosition should be used instead) The device position in its room space
  20137. */
  20138. position: Vector3;
  20139. /**
  20140. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20141. */
  20142. rotationQuaternion: Quaternion;
  20143. /**
  20144. * The type of controller (Eg. Windows mixed reality)
  20145. */
  20146. controllerType: PoseEnabledControllerType;
  20147. protected _calculatedPosition: Vector3;
  20148. private _calculatedRotation;
  20149. /**
  20150. * The raw pose from the device
  20151. */
  20152. rawPose: DevicePose;
  20153. private _trackPosition;
  20154. private _maxRotationDistFromHeadset;
  20155. private _draggedRoomRotation;
  20156. /**
  20157. * @hidden
  20158. */
  20159. _disableTrackPosition(fixedPosition: Vector3): void;
  20160. /**
  20161. * Internal, the mesh attached to the controller
  20162. * @hidden
  20163. */
  20164. _mesh: Nullable<AbstractMesh>;
  20165. private _poseControlledCamera;
  20166. private _leftHandSystemQuaternion;
  20167. /**
  20168. * Internal, matrix used to convert room space to babylon space
  20169. * @hidden
  20170. */
  20171. _deviceToWorld: Matrix;
  20172. /**
  20173. * Node to be used when casting a ray from the controller
  20174. * @hidden
  20175. */
  20176. _pointingPoseNode: Nullable<TransformNode>;
  20177. /**
  20178. * Name of the child mesh that can be used to cast a ray from the controller
  20179. */
  20180. static readonly POINTING_POSE: string;
  20181. /**
  20182. * Creates a new PoseEnabledController from a gamepad
  20183. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20184. */
  20185. constructor(browserGamepad: any);
  20186. private _workingMatrix;
  20187. /**
  20188. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20189. */
  20190. update(): void;
  20191. /**
  20192. * Updates only the pose device and mesh without doing any button event checking
  20193. */
  20194. protected _updatePoseAndMesh(): void;
  20195. /**
  20196. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20197. * @param poseData raw pose fromthe device
  20198. */
  20199. updateFromDevice(poseData: DevicePose): void;
  20200. /**
  20201. * @hidden
  20202. */
  20203. _meshAttachedObservable: Observable<AbstractMesh>;
  20204. /**
  20205. * Attaches a mesh to the controller
  20206. * @param mesh the mesh to be attached
  20207. */
  20208. attachToMesh(mesh: AbstractMesh): void;
  20209. /**
  20210. * Attaches the controllers mesh to a camera
  20211. * @param camera the camera the mesh should be attached to
  20212. */
  20213. attachToPoseControlledCamera(camera: TargetCamera): void;
  20214. /**
  20215. * Disposes of the controller
  20216. */
  20217. dispose(): void;
  20218. /**
  20219. * The mesh that is attached to the controller
  20220. */
  20221. get mesh(): Nullable<AbstractMesh>;
  20222. /**
  20223. * Gets the ray of the controller in the direction the controller is pointing
  20224. * @param length the length the resulting ray should be
  20225. * @returns a ray in the direction the controller is pointing
  20226. */
  20227. getForwardRay(length?: number): Ray;
  20228. }
  20229. }
  20230. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20231. import { Observable } from "babylonjs/Misc/observable";
  20232. import { Scene } from "babylonjs/scene";
  20233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20234. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20235. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20236. import { Nullable } from "babylonjs/types";
  20237. /**
  20238. * Defines the WebVRController object that represents controllers tracked in 3D space
  20239. */
  20240. export abstract class WebVRController extends PoseEnabledController {
  20241. /**
  20242. * Internal, the default controller model for the controller
  20243. */
  20244. protected _defaultModel: Nullable<AbstractMesh>;
  20245. /**
  20246. * Fired when the trigger state has changed
  20247. */
  20248. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20249. /**
  20250. * Fired when the main button state has changed
  20251. */
  20252. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20253. /**
  20254. * Fired when the secondary button state has changed
  20255. */
  20256. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20257. /**
  20258. * Fired when the pad state has changed
  20259. */
  20260. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20261. /**
  20262. * Fired when controllers stick values have changed
  20263. */
  20264. onPadValuesChangedObservable: Observable<StickValues>;
  20265. /**
  20266. * Array of button availible on the controller
  20267. */
  20268. protected _buttons: Array<MutableGamepadButton>;
  20269. private _onButtonStateChange;
  20270. /**
  20271. * Fired when a controller button's state has changed
  20272. * @param callback the callback containing the button that was modified
  20273. */
  20274. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20275. /**
  20276. * X and Y axis corresponding to the controllers joystick
  20277. */
  20278. pad: StickValues;
  20279. /**
  20280. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20281. */
  20282. hand: string;
  20283. /**
  20284. * The default controller model for the controller
  20285. */
  20286. get defaultModel(): Nullable<AbstractMesh>;
  20287. /**
  20288. * Creates a new WebVRController from a gamepad
  20289. * @param vrGamepad the gamepad that the WebVRController should be created from
  20290. */
  20291. constructor(vrGamepad: any);
  20292. /**
  20293. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20294. */
  20295. update(): void;
  20296. /**
  20297. * Function to be called when a button is modified
  20298. */
  20299. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20300. /**
  20301. * Loads a mesh and attaches it to the controller
  20302. * @param scene the scene the mesh should be added to
  20303. * @param meshLoaded callback for when the mesh has been loaded
  20304. */
  20305. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20306. private _setButtonValue;
  20307. private _changes;
  20308. private _checkChanges;
  20309. /**
  20310. * Disposes of th webVRCOntroller
  20311. */
  20312. dispose(): void;
  20313. }
  20314. }
  20315. declare module "babylonjs/Lights/hemisphericLight" {
  20316. import { Nullable } from "babylonjs/types";
  20317. import { Scene } from "babylonjs/scene";
  20318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20319. import { Color3 } from "babylonjs/Maths/math.color";
  20320. import { Effect } from "babylonjs/Materials/effect";
  20321. import { Light } from "babylonjs/Lights/light";
  20322. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20323. /**
  20324. * The HemisphericLight simulates the ambient environment light,
  20325. * so the passed direction is the light reflection direction, not the incoming direction.
  20326. */
  20327. export class HemisphericLight extends Light {
  20328. /**
  20329. * The groundColor is the light in the opposite direction to the one specified during creation.
  20330. * 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.
  20331. */
  20332. groundColor: Color3;
  20333. /**
  20334. * The light reflection direction, not the incoming direction.
  20335. */
  20336. direction: Vector3;
  20337. /**
  20338. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20339. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20340. * The HemisphericLight can't cast shadows.
  20341. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20342. * @param name The friendly name of the light
  20343. * @param direction The direction of the light reflection
  20344. * @param scene The scene the light belongs to
  20345. */
  20346. constructor(name: string, direction: Vector3, scene: Scene);
  20347. protected _buildUniformLayout(): void;
  20348. /**
  20349. * Returns the string "HemisphericLight".
  20350. * @return The class name
  20351. */
  20352. getClassName(): string;
  20353. /**
  20354. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20355. * Returns the updated direction.
  20356. * @param target The target the direction should point to
  20357. * @return The computed direction
  20358. */
  20359. setDirectionToTarget(target: Vector3): Vector3;
  20360. /**
  20361. * Returns the shadow generator associated to the light.
  20362. * @returns Always null for hemispheric lights because it does not support shadows.
  20363. */
  20364. getShadowGenerator(): Nullable<IShadowGenerator>;
  20365. /**
  20366. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20367. * @param effect The effect to update
  20368. * @param lightIndex The index of the light in the effect to update
  20369. * @returns The hemispheric light
  20370. */
  20371. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20373. /**
  20374. * Computes the world matrix of the node
  20375. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20376. * @param useWasUpdatedFlag defines a reserved property
  20377. * @returns the world matrix
  20378. */
  20379. computeWorldMatrix(): Matrix;
  20380. /**
  20381. * Returns the integer 3.
  20382. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20383. */
  20384. getTypeID(): number;
  20385. /**
  20386. * Prepares the list of defines specific to the light type.
  20387. * @param defines the list of defines
  20388. * @param lightIndex defines the index of the light for the effect
  20389. */
  20390. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20391. }
  20392. }
  20393. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20394. /** @hidden */
  20395. export var vrMultiviewToSingleviewPixelShader: {
  20396. name: string;
  20397. shader: string;
  20398. };
  20399. }
  20400. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20402. import { Scene } from "babylonjs/scene";
  20403. /**
  20404. * Renders to multiple views with a single draw call
  20405. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20406. */
  20407. export class MultiviewRenderTarget extends RenderTargetTexture {
  20408. /**
  20409. * Creates a multiview render target
  20410. * @param scene scene used with the render target
  20411. * @param size the size of the render target (used for each view)
  20412. */
  20413. constructor(scene: Scene, size?: number | {
  20414. width: number;
  20415. height: number;
  20416. } | {
  20417. ratio: number;
  20418. });
  20419. /**
  20420. * @hidden
  20421. * @param faceIndex the face index, if its a cube texture
  20422. */
  20423. _bindFrameBuffer(faceIndex?: number): void;
  20424. /**
  20425. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20426. * @returns the view count
  20427. */
  20428. getViewCount(): number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20434. import { Nullable } from "babylonjs/types";
  20435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20436. import { Matrix } from "babylonjs/Maths/math.vector";
  20437. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20438. module "babylonjs/Engines/engine" {
  20439. interface Engine {
  20440. /**
  20441. * Creates a new multiview render target
  20442. * @param width defines the width of the texture
  20443. * @param height defines the height of the texture
  20444. * @returns the created multiview texture
  20445. */
  20446. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20447. /**
  20448. * Binds a multiview framebuffer to be drawn to
  20449. * @param multiviewTexture texture to bind
  20450. */
  20451. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20452. }
  20453. }
  20454. module "babylonjs/Cameras/camera" {
  20455. interface Camera {
  20456. /**
  20457. * @hidden
  20458. * 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)
  20459. */
  20460. _useMultiviewToSingleView: boolean;
  20461. /**
  20462. * @hidden
  20463. * 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)
  20464. */
  20465. _multiviewTexture: Nullable<RenderTargetTexture>;
  20466. /**
  20467. * @hidden
  20468. * ensures the multiview texture of the camera exists and has the specified width/height
  20469. * @param width height to set on the multiview texture
  20470. * @param height width to set on the multiview texture
  20471. */
  20472. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20473. }
  20474. }
  20475. module "babylonjs/scene" {
  20476. interface Scene {
  20477. /** @hidden */
  20478. _transformMatrixR: Matrix;
  20479. /** @hidden */
  20480. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20481. /** @hidden */
  20482. _createMultiviewUbo(): void;
  20483. /** @hidden */
  20484. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20485. /** @hidden */
  20486. _renderMultiviewToSingleView(camera: Camera): void;
  20487. }
  20488. }
  20489. }
  20490. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20491. import { Camera } from "babylonjs/Cameras/camera";
  20492. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20493. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20494. import "babylonjs/Engines/Extensions/engine.multiview";
  20495. /**
  20496. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20497. * This will not be used for webXR as it supports displaying texture arrays directly
  20498. */
  20499. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20500. /**
  20501. * Gets a string identifying the name of the class
  20502. * @returns "VRMultiviewToSingleviewPostProcess" string
  20503. */
  20504. getClassName(): string;
  20505. /**
  20506. * Initializes a VRMultiviewToSingleview
  20507. * @param name name of the post process
  20508. * @param camera camera to be applied to
  20509. * @param scaleFactor scaling factor to the size of the output texture
  20510. */
  20511. constructor(name: string, camera: Camera, scaleFactor: number);
  20512. }
  20513. }
  20514. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20515. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20516. import { Nullable } from "babylonjs/types";
  20517. import { Size } from "babylonjs/Maths/math.size";
  20518. import { Observable } from "babylonjs/Misc/observable";
  20519. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20520. /**
  20521. * Interface used to define additional presentation attributes
  20522. */
  20523. export interface IVRPresentationAttributes {
  20524. /**
  20525. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20526. */
  20527. highRefreshRate: boolean;
  20528. /**
  20529. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20530. */
  20531. foveationLevel: number;
  20532. }
  20533. module "babylonjs/Engines/engine" {
  20534. interface Engine {
  20535. /** @hidden */
  20536. _vrDisplay: any;
  20537. /** @hidden */
  20538. _vrSupported: boolean;
  20539. /** @hidden */
  20540. _oldSize: Size;
  20541. /** @hidden */
  20542. _oldHardwareScaleFactor: number;
  20543. /** @hidden */
  20544. _vrExclusivePointerMode: boolean;
  20545. /** @hidden */
  20546. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20547. /** @hidden */
  20548. _onVRDisplayPointerRestricted: () => void;
  20549. /** @hidden */
  20550. _onVRDisplayPointerUnrestricted: () => void;
  20551. /** @hidden */
  20552. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20553. /** @hidden */
  20554. _onVrDisplayDisconnect: Nullable<() => void>;
  20555. /** @hidden */
  20556. _onVrDisplayPresentChange: Nullable<() => void>;
  20557. /**
  20558. * Observable signaled when VR display mode changes
  20559. */
  20560. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20561. /**
  20562. * Observable signaled when VR request present is complete
  20563. */
  20564. onVRRequestPresentComplete: Observable<boolean>;
  20565. /**
  20566. * Observable signaled when VR request present starts
  20567. */
  20568. onVRRequestPresentStart: Observable<Engine>;
  20569. /**
  20570. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20571. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20572. */
  20573. isInVRExclusivePointerMode: boolean;
  20574. /**
  20575. * Gets a boolean indicating if a webVR device was detected
  20576. * @returns true if a webVR device was detected
  20577. */
  20578. isVRDevicePresent(): boolean;
  20579. /**
  20580. * Gets the current webVR device
  20581. * @returns the current webVR device (or null)
  20582. */
  20583. getVRDevice(): any;
  20584. /**
  20585. * Initializes a webVR display and starts listening to display change events
  20586. * The onVRDisplayChangedObservable will be notified upon these changes
  20587. * @returns A promise containing a VRDisplay and if vr is supported
  20588. */
  20589. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20590. /** @hidden */
  20591. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20592. /**
  20593. * Gets or sets the presentation attributes used to configure VR rendering
  20594. */
  20595. vrPresentationAttributes?: IVRPresentationAttributes;
  20596. /**
  20597. * Call this function to switch to webVR mode
  20598. * Will do nothing if webVR is not supported or if there is no webVR device
  20599. * @param options the webvr options provided to the camera. mainly used for multiview
  20600. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20601. */
  20602. enableVR(options: WebVROptions): void;
  20603. /** @hidden */
  20604. _onVRFullScreenTriggered(): void;
  20605. }
  20606. }
  20607. }
  20608. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20609. import { Nullable } from "babylonjs/types";
  20610. import { Observable } from "babylonjs/Misc/observable";
  20611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20612. import { Scene } from "babylonjs/scene";
  20613. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20614. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20615. import { Node } from "babylonjs/node";
  20616. import { Ray } from "babylonjs/Culling/ray";
  20617. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20618. import "babylonjs/Engines/Extensions/engine.webVR";
  20619. /**
  20620. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20621. * IMPORTANT!! The data is right-hand data.
  20622. * @export
  20623. * @interface DevicePose
  20624. */
  20625. export interface DevicePose {
  20626. /**
  20627. * The position of the device, values in array are [x,y,z].
  20628. */
  20629. readonly position: Nullable<Float32Array>;
  20630. /**
  20631. * The linearVelocity of the device, values in array are [x,y,z].
  20632. */
  20633. readonly linearVelocity: Nullable<Float32Array>;
  20634. /**
  20635. * The linearAcceleration of the device, values in array are [x,y,z].
  20636. */
  20637. readonly linearAcceleration: Nullable<Float32Array>;
  20638. /**
  20639. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20640. */
  20641. readonly orientation: Nullable<Float32Array>;
  20642. /**
  20643. * The angularVelocity of the device, values in array are [x,y,z].
  20644. */
  20645. readonly angularVelocity: Nullable<Float32Array>;
  20646. /**
  20647. * The angularAcceleration of the device, values in array are [x,y,z].
  20648. */
  20649. readonly angularAcceleration: Nullable<Float32Array>;
  20650. }
  20651. /**
  20652. * Interface representing a pose controlled object in Babylon.
  20653. * A pose controlled object has both regular pose values as well as pose values
  20654. * from an external device such as a VR head mounted display
  20655. */
  20656. export interface PoseControlled {
  20657. /**
  20658. * The position of the object in babylon space.
  20659. */
  20660. position: Vector3;
  20661. /**
  20662. * The rotation quaternion of the object in babylon space.
  20663. */
  20664. rotationQuaternion: Quaternion;
  20665. /**
  20666. * The position of the device in babylon space.
  20667. */
  20668. devicePosition?: Vector3;
  20669. /**
  20670. * The rotation quaternion of the device in babylon space.
  20671. */
  20672. deviceRotationQuaternion: Quaternion;
  20673. /**
  20674. * The raw pose coming from the device.
  20675. */
  20676. rawPose: Nullable<DevicePose>;
  20677. /**
  20678. * The scale of the device to be used when translating from device space to babylon space.
  20679. */
  20680. deviceScaleFactor: number;
  20681. /**
  20682. * Updates the poseControlled values based on the input device pose.
  20683. * @param poseData the pose data to update the object with
  20684. */
  20685. updateFromDevice(poseData: DevicePose): void;
  20686. }
  20687. /**
  20688. * Set of options to customize the webVRCamera
  20689. */
  20690. export interface WebVROptions {
  20691. /**
  20692. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20693. */
  20694. trackPosition?: boolean;
  20695. /**
  20696. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20697. */
  20698. positionScale?: number;
  20699. /**
  20700. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20701. */
  20702. displayName?: string;
  20703. /**
  20704. * Should the native controller meshes be initialized. (default: true)
  20705. */
  20706. controllerMeshes?: boolean;
  20707. /**
  20708. * Creating a default HemiLight only on controllers. (default: true)
  20709. */
  20710. defaultLightingOnControllers?: boolean;
  20711. /**
  20712. * If you don't want to use the default VR button of the helper. (default: false)
  20713. */
  20714. useCustomVRButton?: boolean;
  20715. /**
  20716. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20717. */
  20718. customVRButton?: HTMLButtonElement;
  20719. /**
  20720. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20721. */
  20722. rayLength?: number;
  20723. /**
  20724. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20725. */
  20726. defaultHeight?: number;
  20727. /**
  20728. * If multiview should be used if availible (default: false)
  20729. */
  20730. useMultiview?: boolean;
  20731. }
  20732. /**
  20733. * This represents a WebVR camera.
  20734. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20735. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20736. */
  20737. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20738. private webVROptions;
  20739. /**
  20740. * @hidden
  20741. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20742. */
  20743. _vrDevice: any;
  20744. /**
  20745. * The rawPose of the vrDevice.
  20746. */
  20747. rawPose: Nullable<DevicePose>;
  20748. private _onVREnabled;
  20749. private _specsVersion;
  20750. private _attached;
  20751. private _frameData;
  20752. protected _descendants: Array<Node>;
  20753. private _deviceRoomPosition;
  20754. /** @hidden */
  20755. _deviceRoomRotationQuaternion: Quaternion;
  20756. private _standingMatrix;
  20757. /**
  20758. * Represents device position in babylon space.
  20759. */
  20760. devicePosition: Vector3;
  20761. /**
  20762. * Represents device rotation in babylon space.
  20763. */
  20764. deviceRotationQuaternion: Quaternion;
  20765. /**
  20766. * The scale of the device to be used when translating from device space to babylon space.
  20767. */
  20768. deviceScaleFactor: number;
  20769. private _deviceToWorld;
  20770. private _worldToDevice;
  20771. /**
  20772. * References to the webVR controllers for the vrDevice.
  20773. */
  20774. controllers: Array<WebVRController>;
  20775. /**
  20776. * Emits an event when a controller is attached.
  20777. */
  20778. onControllersAttachedObservable: Observable<WebVRController[]>;
  20779. /**
  20780. * Emits an event when a controller's mesh has been loaded;
  20781. */
  20782. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20783. /**
  20784. * Emits an event when the HMD's pose has been updated.
  20785. */
  20786. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20787. private _poseSet;
  20788. /**
  20789. * If the rig cameras be used as parent instead of this camera.
  20790. */
  20791. rigParenting: boolean;
  20792. private _lightOnControllers;
  20793. private _defaultHeight?;
  20794. /**
  20795. * Instantiates a WebVRFreeCamera.
  20796. * @param name The name of the WebVRFreeCamera
  20797. * @param position The starting anchor position for the camera
  20798. * @param scene The scene the camera belongs to
  20799. * @param webVROptions a set of customizable options for the webVRCamera
  20800. */
  20801. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20802. /**
  20803. * Gets the device distance from the ground in meters.
  20804. * @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.
  20805. */
  20806. deviceDistanceToRoomGround(): number;
  20807. /**
  20808. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20809. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20810. */
  20811. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20812. /**
  20813. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20814. * @returns A promise with a boolean set to if the standing matrix is supported.
  20815. */
  20816. useStandingMatrixAsync(): Promise<boolean>;
  20817. /**
  20818. * Disposes the camera
  20819. */
  20820. dispose(): void;
  20821. /**
  20822. * Gets a vrController by name.
  20823. * @param name The name of the controller to retreive
  20824. * @returns the controller matching the name specified or null if not found
  20825. */
  20826. getControllerByName(name: string): Nullable<WebVRController>;
  20827. private _leftController;
  20828. /**
  20829. * The controller corresponding to the users left hand.
  20830. */
  20831. get leftController(): Nullable<WebVRController>;
  20832. private _rightController;
  20833. /**
  20834. * The controller corresponding to the users right hand.
  20835. */
  20836. get rightController(): Nullable<WebVRController>;
  20837. /**
  20838. * Casts a ray forward from the vrCamera's gaze.
  20839. * @param length Length of the ray (default: 100)
  20840. * @returns the ray corresponding to the gaze
  20841. */
  20842. getForwardRay(length?: number): Ray;
  20843. /**
  20844. * @hidden
  20845. * Updates the camera based on device's frame data
  20846. */
  20847. _checkInputs(): void;
  20848. /**
  20849. * Updates the poseControlled values based on the input device pose.
  20850. * @param poseData Pose coming from the device
  20851. */
  20852. updateFromDevice(poseData: DevicePose): void;
  20853. private _htmlElementAttached;
  20854. private _detachIfAttached;
  20855. /**
  20856. * WebVR's attach control will start broadcasting frames to the device.
  20857. * Note that in certain browsers (chrome for example) this function must be called
  20858. * within a user-interaction callback. Example:
  20859. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20860. *
  20861. * @param element html element to attach the vrDevice to
  20862. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20863. */
  20864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20865. /**
  20866. * Detaches the camera from the html element and disables VR
  20867. *
  20868. * @param element html element to detach from
  20869. */
  20870. detachControl(element: HTMLElement): void;
  20871. /**
  20872. * @returns the name of this class
  20873. */
  20874. getClassName(): string;
  20875. /**
  20876. * Calls resetPose on the vrDisplay
  20877. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20878. */
  20879. resetToCurrentRotation(): void;
  20880. /**
  20881. * @hidden
  20882. * Updates the rig cameras (left and right eye)
  20883. */
  20884. _updateRigCameras(): void;
  20885. private _workingVector;
  20886. private _oneVector;
  20887. private _workingMatrix;
  20888. private updateCacheCalled;
  20889. private _correctPositionIfNotTrackPosition;
  20890. /**
  20891. * @hidden
  20892. * Updates the cached values of the camera
  20893. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20894. */
  20895. _updateCache(ignoreParentClass?: boolean): void;
  20896. /**
  20897. * @hidden
  20898. * Get current device position in babylon world
  20899. */
  20900. _computeDevicePosition(): void;
  20901. /**
  20902. * Updates the current device position and rotation in the babylon world
  20903. */
  20904. update(): void;
  20905. /**
  20906. * @hidden
  20907. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20908. * @returns an identity matrix
  20909. */
  20910. _getViewMatrix(): Matrix;
  20911. private _tmpMatrix;
  20912. /**
  20913. * This function is called by the two RIG cameras.
  20914. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20915. * @hidden
  20916. */
  20917. _getWebVRViewMatrix(): Matrix;
  20918. /** @hidden */
  20919. _getWebVRProjectionMatrix(): Matrix;
  20920. private _onGamepadConnectedObserver;
  20921. private _onGamepadDisconnectedObserver;
  20922. private _updateCacheWhenTrackingDisabledObserver;
  20923. /**
  20924. * Initializes the controllers and their meshes
  20925. */
  20926. initControllers(): void;
  20927. }
  20928. }
  20929. declare module "babylonjs/Materials/materialHelper" {
  20930. import { Nullable } from "babylonjs/types";
  20931. import { Scene } from "babylonjs/scene";
  20932. import { Engine } from "babylonjs/Engines/engine";
  20933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20934. import { Light } from "babylonjs/Lights/light";
  20935. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20936. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20937. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20939. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20940. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20941. /**
  20942. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20943. *
  20944. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20945. *
  20946. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20947. */
  20948. export class MaterialHelper {
  20949. /**
  20950. * Bind the current view position to an effect.
  20951. * @param effect The effect to be bound
  20952. * @param scene The scene the eyes position is used from
  20953. * @param variableName name of the shader variable that will hold the eye position
  20954. */
  20955. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20956. /**
  20957. * Helps preparing the defines values about the UVs in used in the effect.
  20958. * UVs are shared as much as we can accross channels in the shaders.
  20959. * @param texture The texture we are preparing the UVs for
  20960. * @param defines The defines to update
  20961. * @param key The channel key "diffuse", "specular"... used in the shader
  20962. */
  20963. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20964. /**
  20965. * Binds a texture matrix value to its corrsponding uniform
  20966. * @param texture The texture to bind the matrix for
  20967. * @param uniformBuffer The uniform buffer receivin the data
  20968. * @param key The channel key "diffuse", "specular"... used in the shader
  20969. */
  20970. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20971. /**
  20972. * Gets the current status of the fog (should it be enabled?)
  20973. * @param mesh defines the mesh to evaluate for fog support
  20974. * @param scene defines the hosting scene
  20975. * @returns true if fog must be enabled
  20976. */
  20977. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20978. /**
  20979. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20980. * @param mesh defines the current mesh
  20981. * @param scene defines the current scene
  20982. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20983. * @param pointsCloud defines if point cloud rendering has to be turned on
  20984. * @param fogEnabled defines if fog has to be turned on
  20985. * @param alphaTest defines if alpha testing has to be turned on
  20986. * @param defines defines the current list of defines
  20987. */
  20988. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20989. /**
  20990. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20991. * @param scene defines the current scene
  20992. * @param engine defines the current engine
  20993. * @param defines specifies the list of active defines
  20994. * @param useInstances defines if instances have to be turned on
  20995. * @param useClipPlane defines if clip plane have to be turned on
  20996. * @param useInstances defines if instances have to be turned on
  20997. * @param useThinInstances defines if thin instances have to be turned on
  20998. */
  20999. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21000. /**
  21001. * Prepares the defines for bones
  21002. * @param mesh The mesh containing the geometry data we will draw
  21003. * @param defines The defines to update
  21004. */
  21005. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21006. /**
  21007. * Prepares the defines for morph targets
  21008. * @param mesh The mesh containing the geometry data we will draw
  21009. * @param defines The defines to update
  21010. */
  21011. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21012. /**
  21013. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21014. * @param mesh The mesh containing the geometry data we will draw
  21015. * @param defines The defines to update
  21016. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21017. * @param useBones Precise whether bones should be used or not (override mesh info)
  21018. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21019. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21020. * @returns false if defines are considered not dirty and have not been checked
  21021. */
  21022. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21023. /**
  21024. * Prepares the defines related to multiview
  21025. * @param scene The scene we are intending to draw
  21026. * @param defines The defines to update
  21027. */
  21028. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21029. /**
  21030. * Prepares the defines related to the prepass
  21031. * @param scene The scene we are intending to draw
  21032. * @param defines The defines to update
  21033. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21034. */
  21035. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21036. /**
  21037. * Prepares the defines related to the light information passed in parameter
  21038. * @param scene The scene we are intending to draw
  21039. * @param mesh The mesh the effect is compiling for
  21040. * @param light The light the effect is compiling for
  21041. * @param lightIndex The index of the light
  21042. * @param defines The defines to update
  21043. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21044. * @param state Defines the current state regarding what is needed (normals, etc...)
  21045. */
  21046. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21047. needNormals: boolean;
  21048. needRebuild: boolean;
  21049. shadowEnabled: boolean;
  21050. specularEnabled: boolean;
  21051. lightmapMode: boolean;
  21052. }): void;
  21053. /**
  21054. * Prepares the defines related to the light information passed in parameter
  21055. * @param scene The scene we are intending to draw
  21056. * @param mesh The mesh the effect is compiling for
  21057. * @param defines The defines to update
  21058. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21059. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21060. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21061. * @returns true if normals will be required for the rest of the effect
  21062. */
  21063. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21064. /**
  21065. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21066. * @param lightIndex defines the light index
  21067. * @param uniformsList The uniform list
  21068. * @param samplersList The sampler list
  21069. * @param projectedLightTexture defines if projected texture must be used
  21070. * @param uniformBuffersList defines an optional list of uniform buffers
  21071. */
  21072. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21073. /**
  21074. * Prepares the uniforms and samplers list to be used in the effect
  21075. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21076. * @param samplersList The sampler list
  21077. * @param defines The defines helping in the list generation
  21078. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21079. */
  21080. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21081. /**
  21082. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21083. * @param defines The defines to update while falling back
  21084. * @param fallbacks The authorized effect fallbacks
  21085. * @param maxSimultaneousLights The maximum number of lights allowed
  21086. * @param rank the current rank of the Effect
  21087. * @returns The newly affected rank
  21088. */
  21089. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21090. private static _TmpMorphInfluencers;
  21091. /**
  21092. * Prepares the list of attributes required for morph targets according to the effect defines.
  21093. * @param attribs The current list of supported attribs
  21094. * @param mesh The mesh to prepare the morph targets attributes for
  21095. * @param influencers The number of influencers
  21096. */
  21097. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21098. /**
  21099. * Prepares the list of attributes required for morph targets according to the effect defines.
  21100. * @param attribs The current list of supported attribs
  21101. * @param mesh The mesh to prepare the morph targets attributes for
  21102. * @param defines The current Defines of the effect
  21103. */
  21104. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21105. /**
  21106. * Prepares the list of attributes required for bones according to the effect defines.
  21107. * @param attribs The current list of supported attribs
  21108. * @param mesh The mesh to prepare the bones attributes for
  21109. * @param defines The current Defines of the effect
  21110. * @param fallbacks The current efffect fallback strategy
  21111. */
  21112. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21113. /**
  21114. * Check and prepare the list of attributes required for instances according to the effect defines.
  21115. * @param attribs The current list of supported attribs
  21116. * @param defines The current MaterialDefines of the effect
  21117. */
  21118. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21119. /**
  21120. * Add the list of attributes required for instances to the attribs array.
  21121. * @param attribs The current list of supported attribs
  21122. */
  21123. static PushAttributesForInstances(attribs: string[]): void;
  21124. /**
  21125. * Binds the light information to the effect.
  21126. * @param light The light containing the generator
  21127. * @param effect The effect we are binding the data to
  21128. * @param lightIndex The light index in the effect used to render
  21129. */
  21130. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21131. /**
  21132. * Binds the lights information from the scene to the effect for the given mesh.
  21133. * @param light Light to bind
  21134. * @param lightIndex Light index
  21135. * @param scene The scene where the light belongs to
  21136. * @param effect The effect we are binding the data to
  21137. * @param useSpecular Defines if specular is supported
  21138. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21139. */
  21140. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21141. /**
  21142. * Binds the lights information from the scene to the effect for the given mesh.
  21143. * @param scene The scene the lights belongs to
  21144. * @param mesh The mesh we are binding the information to render
  21145. * @param effect The effect we are binding the data to
  21146. * @param defines The generated defines for the effect
  21147. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21148. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21149. */
  21150. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21151. private static _tempFogColor;
  21152. /**
  21153. * Binds the fog information from the scene to the effect for the given mesh.
  21154. * @param scene The scene the lights belongs to
  21155. * @param mesh The mesh we are binding the information to render
  21156. * @param effect The effect we are binding the data to
  21157. * @param linearSpace Defines if the fog effect is applied in linear space
  21158. */
  21159. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21160. /**
  21161. * Binds the bones information from the mesh to the effect.
  21162. * @param mesh The mesh we are binding the information to render
  21163. * @param effect The effect we are binding the data to
  21164. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21165. */
  21166. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21167. private static _CopyBonesTransformationMatrices;
  21168. /**
  21169. * Binds the morph targets information from the mesh to the effect.
  21170. * @param abstractMesh The mesh we are binding the information to render
  21171. * @param effect The effect we are binding the data to
  21172. */
  21173. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21174. /**
  21175. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21176. * @param defines The generated defines used in the effect
  21177. * @param effect The effect we are binding the data to
  21178. * @param scene The scene we are willing to render with logarithmic scale for
  21179. */
  21180. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21181. /**
  21182. * Binds the clip plane information from the scene to the effect.
  21183. * @param scene The scene the clip plane information are extracted from
  21184. * @param effect The effect we are binding the data to
  21185. */
  21186. static BindClipPlane(effect: Effect, scene: Scene): void;
  21187. }
  21188. }
  21189. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21191. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21192. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21193. import { Nullable } from "babylonjs/types";
  21194. import { Effect } from "babylonjs/Materials/effect";
  21195. import { Matrix } from "babylonjs/Maths/math.vector";
  21196. import { Scene } from "babylonjs/scene";
  21197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21199. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21200. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21201. import { Observable } from "babylonjs/Misc/observable";
  21202. /**
  21203. * Block used to expose an input value
  21204. */
  21205. export class InputBlock extends NodeMaterialBlock {
  21206. private _mode;
  21207. private _associatedVariableName;
  21208. private _storedValue;
  21209. private _valueCallback;
  21210. private _type;
  21211. private _animationType;
  21212. /** Gets or set a value used to limit the range of float values */
  21213. min: number;
  21214. /** Gets or set a value used to limit the range of float values */
  21215. max: number;
  21216. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21217. isBoolean: boolean;
  21218. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21219. matrixMode: number;
  21220. /** @hidden */
  21221. _systemValue: Nullable<NodeMaterialSystemValues>;
  21222. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21223. isConstant: boolean;
  21224. /** Gets or sets the group to use to display this block in the Inspector */
  21225. groupInInspector: string;
  21226. /** Gets an observable raised when the value is changed */
  21227. onValueChangedObservable: Observable<InputBlock>;
  21228. /**
  21229. * Gets or sets the connection point type (default is float)
  21230. */
  21231. get type(): NodeMaterialBlockConnectionPointTypes;
  21232. /**
  21233. * Creates a new InputBlock
  21234. * @param name defines the block name
  21235. * @param target defines the target of that block (Vertex by default)
  21236. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21237. */
  21238. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21239. /**
  21240. * Validates if a name is a reserve word.
  21241. * @param newName the new name to be given to the node.
  21242. * @returns false if the name is a reserve word, else true.
  21243. */
  21244. validateBlockName(newName: string): boolean;
  21245. /**
  21246. * Gets the output component
  21247. */
  21248. get output(): NodeMaterialConnectionPoint;
  21249. /**
  21250. * Set the source of this connection point to a vertex attribute
  21251. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21252. * @returns the current connection point
  21253. */
  21254. setAsAttribute(attributeName?: string): InputBlock;
  21255. /**
  21256. * Set the source of this connection point to a system value
  21257. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21258. * @returns the current connection point
  21259. */
  21260. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21261. /**
  21262. * Gets or sets the value of that point.
  21263. * Please note that this value will be ignored if valueCallback is defined
  21264. */
  21265. get value(): any;
  21266. set value(value: any);
  21267. /**
  21268. * Gets or sets a callback used to get the value of that point.
  21269. * Please note that setting this value will force the connection point to ignore the value property
  21270. */
  21271. get valueCallback(): () => any;
  21272. set valueCallback(value: () => any);
  21273. /**
  21274. * Gets or sets the associated variable name in the shader
  21275. */
  21276. get associatedVariableName(): string;
  21277. set associatedVariableName(value: string);
  21278. /** Gets or sets the type of animation applied to the input */
  21279. get animationType(): AnimatedInputBlockTypes;
  21280. set animationType(value: AnimatedInputBlockTypes);
  21281. /**
  21282. * Gets a boolean indicating that this connection point not defined yet
  21283. */
  21284. get isUndefined(): boolean;
  21285. /**
  21286. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21287. * In this case the connection point name must be the name of the uniform to use.
  21288. * Can only be set on inputs
  21289. */
  21290. get isUniform(): boolean;
  21291. set isUniform(value: boolean);
  21292. /**
  21293. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21294. * In this case the connection point name must be the name of the attribute to use
  21295. * Can only be set on inputs
  21296. */
  21297. get isAttribute(): boolean;
  21298. set isAttribute(value: boolean);
  21299. /**
  21300. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21301. * Can only be set on exit points
  21302. */
  21303. get isVarying(): boolean;
  21304. set isVarying(value: boolean);
  21305. /**
  21306. * Gets a boolean indicating that the current connection point is a system value
  21307. */
  21308. get isSystemValue(): boolean;
  21309. /**
  21310. * Gets or sets the current well known value or null if not defined as a system value
  21311. */
  21312. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21313. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21314. /**
  21315. * Gets the current class name
  21316. * @returns the class name
  21317. */
  21318. getClassName(): string;
  21319. /**
  21320. * Animate the input if animationType !== None
  21321. * @param scene defines the rendering scene
  21322. */
  21323. animate(scene: Scene): void;
  21324. private _emitDefine;
  21325. initialize(state: NodeMaterialBuildState): void;
  21326. /**
  21327. * Set the input block to its default value (based on its type)
  21328. */
  21329. setDefaultValue(): void;
  21330. private _emitConstant;
  21331. /** @hidden */
  21332. get _noContextSwitch(): boolean;
  21333. private _emit;
  21334. /** @hidden */
  21335. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21336. /** @hidden */
  21337. _transmit(effect: Effect, scene: Scene): void;
  21338. protected _buildBlock(state: NodeMaterialBuildState): void;
  21339. protected _dumpPropertiesCode(): string;
  21340. dispose(): void;
  21341. serialize(): any;
  21342. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21343. }
  21344. }
  21345. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21346. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21347. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21348. import { Nullable } from "babylonjs/types";
  21349. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21350. import { Observable } from "babylonjs/Misc/observable";
  21351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21352. /**
  21353. * Enum used to define the compatibility state between two connection points
  21354. */
  21355. export enum NodeMaterialConnectionPointCompatibilityStates {
  21356. /** Points are compatibles */
  21357. Compatible = 0,
  21358. /** Points are incompatible because of their types */
  21359. TypeIncompatible = 1,
  21360. /** Points are incompatible because of their targets (vertex vs fragment) */
  21361. TargetIncompatible = 2
  21362. }
  21363. /**
  21364. * Defines the direction of a connection point
  21365. */
  21366. export enum NodeMaterialConnectionPointDirection {
  21367. /** Input */
  21368. Input = 0,
  21369. /** Output */
  21370. Output = 1
  21371. }
  21372. /**
  21373. * Defines a connection point for a block
  21374. */
  21375. export class NodeMaterialConnectionPoint {
  21376. /** @hidden */
  21377. _ownerBlock: NodeMaterialBlock;
  21378. /** @hidden */
  21379. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21380. private _endpoints;
  21381. private _associatedVariableName;
  21382. private _direction;
  21383. /** @hidden */
  21384. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21385. /** @hidden */
  21386. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21387. private _type;
  21388. /** @hidden */
  21389. _enforceAssociatedVariableName: boolean;
  21390. /** Gets the direction of the point */
  21391. get direction(): NodeMaterialConnectionPointDirection;
  21392. /** Indicates that this connection point needs dual validation before being connected to another point */
  21393. needDualDirectionValidation: boolean;
  21394. /**
  21395. * Gets or sets the additional types supported by this connection point
  21396. */
  21397. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21398. /**
  21399. * Gets or sets the additional types excluded by this connection point
  21400. */
  21401. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21402. /**
  21403. * Observable triggered when this point is connected
  21404. */
  21405. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21406. /**
  21407. * Gets or sets the associated variable name in the shader
  21408. */
  21409. get associatedVariableName(): string;
  21410. set associatedVariableName(value: string);
  21411. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21412. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21413. /**
  21414. * Gets or sets the connection point type (default is float)
  21415. */
  21416. get type(): NodeMaterialBlockConnectionPointTypes;
  21417. set type(value: NodeMaterialBlockConnectionPointTypes);
  21418. /**
  21419. * Gets or sets the connection point name
  21420. */
  21421. name: string;
  21422. /**
  21423. * Gets or sets the connection point name
  21424. */
  21425. displayName: string;
  21426. /**
  21427. * Gets or sets a boolean indicating that this connection point can be omitted
  21428. */
  21429. isOptional: boolean;
  21430. /**
  21431. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21432. */
  21433. isExposedOnFrame: boolean;
  21434. /**
  21435. * Gets or sets number indicating the position that the port is exposed to on a frame
  21436. */
  21437. exposedPortPosition: number;
  21438. /**
  21439. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21440. */
  21441. define: string;
  21442. /** @hidden */
  21443. _prioritizeVertex: boolean;
  21444. private _target;
  21445. /** Gets or sets the target of that connection point */
  21446. get target(): NodeMaterialBlockTargets;
  21447. set target(value: NodeMaterialBlockTargets);
  21448. /**
  21449. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21450. */
  21451. get isConnected(): boolean;
  21452. /**
  21453. * Gets a boolean indicating that the current point is connected to an input block
  21454. */
  21455. get isConnectedToInputBlock(): boolean;
  21456. /**
  21457. * Gets a the connected input block (if any)
  21458. */
  21459. get connectInputBlock(): Nullable<InputBlock>;
  21460. /** Get the other side of the connection (if any) */
  21461. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21462. /** Get the block that owns this connection point */
  21463. get ownerBlock(): NodeMaterialBlock;
  21464. /** Get the block connected on the other side of this connection (if any) */
  21465. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21466. /** Get the block connected on the endpoints of this connection (if any) */
  21467. get connectedBlocks(): Array<NodeMaterialBlock>;
  21468. /** Gets the list of connected endpoints */
  21469. get endpoints(): NodeMaterialConnectionPoint[];
  21470. /** Gets a boolean indicating if that output point is connected to at least one input */
  21471. get hasEndpoints(): boolean;
  21472. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21473. get isConnectedInVertexShader(): boolean;
  21474. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21475. get isConnectedInFragmentShader(): boolean;
  21476. /**
  21477. * Creates a block suitable to be used as an input for this input point.
  21478. * If null is returned, a block based on the point type will be created.
  21479. * @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
  21480. */
  21481. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21482. /**
  21483. * Creates a new connection point
  21484. * @param name defines the connection point name
  21485. * @param ownerBlock defines the block hosting this connection point
  21486. * @param direction defines the direction of the connection point
  21487. */
  21488. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21489. /**
  21490. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21491. * @returns the class name
  21492. */
  21493. getClassName(): string;
  21494. /**
  21495. * Gets a boolean indicating if the current point can be connected to another point
  21496. * @param connectionPoint defines the other connection point
  21497. * @returns a boolean
  21498. */
  21499. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21500. /**
  21501. * Gets a number indicating if the current point can be connected to another point
  21502. * @param connectionPoint defines the other connection point
  21503. * @returns a number defining the compatibility state
  21504. */
  21505. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21506. /**
  21507. * Connect this point to another connection point
  21508. * @param connectionPoint defines the other connection point
  21509. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21510. * @returns the current connection point
  21511. */
  21512. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21513. /**
  21514. * Disconnect this point from one of his endpoint
  21515. * @param endpoint defines the other connection point
  21516. * @returns the current connection point
  21517. */
  21518. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21519. /**
  21520. * Serializes this point in a JSON representation
  21521. * @param isInput defines if the connection point is an input (default is true)
  21522. * @returns the serialized point object
  21523. */
  21524. serialize(isInput?: boolean): any;
  21525. /**
  21526. * Release resources
  21527. */
  21528. dispose(): void;
  21529. }
  21530. }
  21531. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21532. /**
  21533. * Enum used to define the material modes
  21534. */
  21535. export enum NodeMaterialModes {
  21536. /** Regular material */
  21537. Material = 0,
  21538. /** For post process */
  21539. PostProcess = 1,
  21540. /** For particle system */
  21541. Particle = 2,
  21542. /** For procedural texture */
  21543. ProceduralTexture = 3
  21544. }
  21545. }
  21546. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21549. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21553. import { Effect } from "babylonjs/Materials/effect";
  21554. import { Mesh } from "babylonjs/Meshes/mesh";
  21555. import { Nullable } from "babylonjs/types";
  21556. import { Texture } from "babylonjs/Materials/Textures/texture";
  21557. import { Scene } from "babylonjs/scene";
  21558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21559. /**
  21560. * Block used to read a texture from a sampler
  21561. */
  21562. export class TextureBlock extends NodeMaterialBlock {
  21563. private _defineName;
  21564. private _linearDefineName;
  21565. private _gammaDefineName;
  21566. private _tempTextureRead;
  21567. private _samplerName;
  21568. private _transformedUVName;
  21569. private _textureTransformName;
  21570. private _textureInfoName;
  21571. private _mainUVName;
  21572. private _mainUVDefineName;
  21573. private _fragmentOnly;
  21574. /**
  21575. * Gets or sets the texture associated with the node
  21576. */
  21577. texture: Nullable<Texture>;
  21578. /**
  21579. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21580. */
  21581. convertToGammaSpace: boolean;
  21582. /**
  21583. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21584. */
  21585. convertToLinearSpace: boolean;
  21586. /**
  21587. * Create a new TextureBlock
  21588. * @param name defines the block name
  21589. */
  21590. constructor(name: string, fragmentOnly?: boolean);
  21591. /**
  21592. * Gets the current class name
  21593. * @returns the class name
  21594. */
  21595. getClassName(): string;
  21596. /**
  21597. * Gets the uv input component
  21598. */
  21599. get uv(): NodeMaterialConnectionPoint;
  21600. /**
  21601. * Gets the rgba output component
  21602. */
  21603. get rgba(): NodeMaterialConnectionPoint;
  21604. /**
  21605. * Gets the rgb output component
  21606. */
  21607. get rgb(): NodeMaterialConnectionPoint;
  21608. /**
  21609. * Gets the r output component
  21610. */
  21611. get r(): NodeMaterialConnectionPoint;
  21612. /**
  21613. * Gets the g output component
  21614. */
  21615. get g(): NodeMaterialConnectionPoint;
  21616. /**
  21617. * Gets the b output component
  21618. */
  21619. get b(): NodeMaterialConnectionPoint;
  21620. /**
  21621. * Gets the a output component
  21622. */
  21623. get a(): NodeMaterialConnectionPoint;
  21624. get target(): NodeMaterialBlockTargets;
  21625. autoConfigure(material: NodeMaterial): void;
  21626. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21628. isReady(): boolean;
  21629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21630. private get _isMixed();
  21631. private _injectVertexCode;
  21632. private _writeTextureRead;
  21633. private _writeOutput;
  21634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21635. protected _dumpPropertiesCode(): string;
  21636. serialize(): any;
  21637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21638. }
  21639. }
  21640. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21641. /** @hidden */
  21642. export var reflectionFunction: {
  21643. name: string;
  21644. shader: string;
  21645. };
  21646. }
  21647. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21653. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21654. import { Effect } from "babylonjs/Materials/effect";
  21655. import { Mesh } from "babylonjs/Meshes/mesh";
  21656. import { Nullable } from "babylonjs/types";
  21657. import { Scene } from "babylonjs/scene";
  21658. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21659. /**
  21660. * Base block used to read a reflection texture from a sampler
  21661. */
  21662. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21663. /** @hidden */
  21664. _define3DName: string;
  21665. /** @hidden */
  21666. _defineCubicName: string;
  21667. /** @hidden */
  21668. _defineExplicitName: string;
  21669. /** @hidden */
  21670. _defineProjectionName: string;
  21671. /** @hidden */
  21672. _defineLocalCubicName: string;
  21673. /** @hidden */
  21674. _defineSphericalName: string;
  21675. /** @hidden */
  21676. _definePlanarName: string;
  21677. /** @hidden */
  21678. _defineEquirectangularName: string;
  21679. /** @hidden */
  21680. _defineMirroredEquirectangularFixedName: string;
  21681. /** @hidden */
  21682. _defineEquirectangularFixedName: string;
  21683. /** @hidden */
  21684. _defineSkyboxName: string;
  21685. /** @hidden */
  21686. _defineOppositeZ: string;
  21687. /** @hidden */
  21688. _cubeSamplerName: string;
  21689. /** @hidden */
  21690. _2DSamplerName: string;
  21691. protected _positionUVWName: string;
  21692. protected _directionWName: string;
  21693. protected _reflectionVectorName: string;
  21694. /** @hidden */
  21695. _reflectionCoordsName: string;
  21696. /** @hidden */
  21697. _reflectionMatrixName: string;
  21698. protected _reflectionColorName: string;
  21699. /**
  21700. * Gets or sets the texture associated with the node
  21701. */
  21702. texture: Nullable<BaseTexture>;
  21703. /**
  21704. * Create a new ReflectionTextureBaseBlock
  21705. * @param name defines the block name
  21706. */
  21707. constructor(name: string);
  21708. /**
  21709. * Gets the current class name
  21710. * @returns the class name
  21711. */
  21712. getClassName(): string;
  21713. /**
  21714. * Gets the world position input component
  21715. */
  21716. abstract get position(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the world position input component
  21719. */
  21720. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the world normal input component
  21723. */
  21724. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Gets the world input component
  21727. */
  21728. abstract get world(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Gets the camera (or eye) position component
  21731. */
  21732. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21733. /**
  21734. * Gets the view input component
  21735. */
  21736. abstract get view(): NodeMaterialConnectionPoint;
  21737. protected _getTexture(): Nullable<BaseTexture>;
  21738. autoConfigure(material: NodeMaterial): void;
  21739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21740. isReady(): boolean;
  21741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21742. /**
  21743. * Gets the code to inject in the vertex shader
  21744. * @param state current state of the node material building
  21745. * @returns the shader code
  21746. */
  21747. handleVertexSide(state: NodeMaterialBuildState): string;
  21748. /**
  21749. * Handles the inits for the fragment code path
  21750. * @param state node material build state
  21751. */
  21752. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21753. /**
  21754. * Generates the reflection coords code for the fragment code path
  21755. * @param worldNormalVarName name of the world normal variable
  21756. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21757. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21758. * @returns the shader code
  21759. */
  21760. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21761. /**
  21762. * Generates the reflection color code for the fragment code path
  21763. * @param lodVarName name of the lod variable
  21764. * @param swizzleLookupTexture swizzle to use for the final color variable
  21765. * @returns the shader code
  21766. */
  21767. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21768. /**
  21769. * Generates the code corresponding to the connected output points
  21770. * @param state node material build state
  21771. * @param varName name of the variable to output
  21772. * @returns the shader code
  21773. */
  21774. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21775. protected _buildBlock(state: NodeMaterialBuildState): this;
  21776. protected _dumpPropertiesCode(): string;
  21777. serialize(): any;
  21778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21779. }
  21780. }
  21781. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21783. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21784. import { Nullable } from "babylonjs/types";
  21785. /**
  21786. * Defines a connection point to be used for points with a custom object type
  21787. */
  21788. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21789. private _blockType;
  21790. private _blockName;
  21791. private _nameForCheking?;
  21792. /**
  21793. * Creates a new connection point
  21794. * @param name defines the connection point name
  21795. * @param ownerBlock defines the block hosting this connection point
  21796. * @param direction defines the direction of the connection point
  21797. */
  21798. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21799. /**
  21800. * Gets a number indicating if the current point can be connected to another point
  21801. * @param connectionPoint defines the other connection point
  21802. * @returns a number defining the compatibility state
  21803. */
  21804. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21805. /**
  21806. * Creates a block suitable to be used as an input for this input point.
  21807. * If null is returned, a block based on the point type will be created.
  21808. * @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
  21809. */
  21810. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21811. }
  21812. }
  21813. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21814. /**
  21815. * Enum defining the type of properties that can be edited in the property pages in the NME
  21816. */
  21817. export enum PropertyTypeForEdition {
  21818. /** property is a boolean */
  21819. Boolean = 0,
  21820. /** property is a float */
  21821. Float = 1,
  21822. /** property is a Vector2 */
  21823. Vector2 = 2,
  21824. /** property is a list of values */
  21825. List = 3
  21826. }
  21827. /**
  21828. * Interface that defines an option in a variable of type list
  21829. */
  21830. export interface IEditablePropertyListOption {
  21831. /** label of the option */
  21832. "label": string;
  21833. /** value of the option */
  21834. "value": number;
  21835. }
  21836. /**
  21837. * Interface that defines the options available for an editable property
  21838. */
  21839. export interface IEditablePropertyOption {
  21840. /** min value */
  21841. "min"?: number;
  21842. /** max value */
  21843. "max"?: number;
  21844. /** notifiers: indicates which actions to take when the property is changed */
  21845. "notifiers"?: {
  21846. /** the material should be rebuilt */
  21847. "rebuild"?: boolean;
  21848. /** the preview should be updated */
  21849. "update"?: boolean;
  21850. };
  21851. /** list of the options for a variable of type list */
  21852. "options"?: IEditablePropertyListOption[];
  21853. }
  21854. /**
  21855. * Interface that describes an editable property
  21856. */
  21857. export interface IPropertyDescriptionForEdition {
  21858. /** name of the property */
  21859. "propertyName": string;
  21860. /** display name of the property */
  21861. "displayName": string;
  21862. /** type of the property */
  21863. "type": PropertyTypeForEdition;
  21864. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21865. "groupName": string;
  21866. /** options for the property */
  21867. "options": IEditablePropertyOption;
  21868. }
  21869. /**
  21870. * Decorator that flags a property in a node material block as being editable
  21871. */
  21872. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21873. }
  21874. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21877. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21879. import { Nullable } from "babylonjs/types";
  21880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21881. import { Mesh } from "babylonjs/Meshes/mesh";
  21882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21883. import { Effect } from "babylonjs/Materials/effect";
  21884. import { Scene } from "babylonjs/scene";
  21885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21886. /**
  21887. * Block used to implement the refraction part of the sub surface module of the PBR material
  21888. */
  21889. export class RefractionBlock extends NodeMaterialBlock {
  21890. /** @hidden */
  21891. _define3DName: string;
  21892. /** @hidden */
  21893. _refractionMatrixName: string;
  21894. /** @hidden */
  21895. _defineLODRefractionAlpha: string;
  21896. /** @hidden */
  21897. _defineLinearSpecularRefraction: string;
  21898. /** @hidden */
  21899. _defineOppositeZ: string;
  21900. /** @hidden */
  21901. _cubeSamplerName: string;
  21902. /** @hidden */
  21903. _2DSamplerName: string;
  21904. /** @hidden */
  21905. _vRefractionMicrosurfaceInfosName: string;
  21906. /** @hidden */
  21907. _vRefractionInfosName: string;
  21908. private _scene;
  21909. /**
  21910. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21911. * Materials half opaque for instance using refraction could benefit from this control.
  21912. */
  21913. linkRefractionWithTransparency: boolean;
  21914. /**
  21915. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21916. */
  21917. invertRefractionY: boolean;
  21918. /**
  21919. * Gets or sets the texture associated with the node
  21920. */
  21921. texture: Nullable<BaseTexture>;
  21922. /**
  21923. * Create a new RefractionBlock
  21924. * @param name defines the block name
  21925. */
  21926. constructor(name: string);
  21927. /**
  21928. * Gets the current class name
  21929. * @returns the class name
  21930. */
  21931. getClassName(): string;
  21932. /**
  21933. * Gets the intensity input component
  21934. */
  21935. get intensity(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the index of refraction input component
  21938. */
  21939. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21940. /**
  21941. * Gets the tint at distance input component
  21942. */
  21943. get tintAtDistance(): NodeMaterialConnectionPoint;
  21944. /**
  21945. * Gets the view input component
  21946. */
  21947. get view(): NodeMaterialConnectionPoint;
  21948. /**
  21949. * Gets the refraction object output component
  21950. */
  21951. get refraction(): NodeMaterialConnectionPoint;
  21952. /**
  21953. * Returns true if the block has a texture
  21954. */
  21955. get hasTexture(): boolean;
  21956. protected _getTexture(): Nullable<BaseTexture>;
  21957. autoConfigure(material: NodeMaterial): void;
  21958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21959. isReady(): boolean;
  21960. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21961. /**
  21962. * Gets the main code of the block (fragment side)
  21963. * @param state current state of the node material building
  21964. * @returns the shader code
  21965. */
  21966. getCode(state: NodeMaterialBuildState): string;
  21967. protected _buildBlock(state: NodeMaterialBuildState): this;
  21968. protected _dumpPropertiesCode(): string;
  21969. serialize(): any;
  21970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21971. }
  21972. }
  21973. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21976. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21979. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21981. import { Nullable } from "babylonjs/types";
  21982. import { Scene } from "babylonjs/scene";
  21983. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21984. /**
  21985. * Base block used as input for post process
  21986. */
  21987. export class CurrentScreenBlock extends NodeMaterialBlock {
  21988. private _samplerName;
  21989. private _linearDefineName;
  21990. private _gammaDefineName;
  21991. private _mainUVName;
  21992. private _tempTextureRead;
  21993. /**
  21994. * Gets or sets the texture associated with the node
  21995. */
  21996. texture: Nullable<BaseTexture>;
  21997. /**
  21998. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21999. */
  22000. convertToGammaSpace: boolean;
  22001. /**
  22002. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22003. */
  22004. convertToLinearSpace: boolean;
  22005. /**
  22006. * Create a new CurrentScreenBlock
  22007. * @param name defines the block name
  22008. */
  22009. constructor(name: string);
  22010. /**
  22011. * Gets the current class name
  22012. * @returns the class name
  22013. */
  22014. getClassName(): string;
  22015. /**
  22016. * Gets the uv input component
  22017. */
  22018. get uv(): NodeMaterialConnectionPoint;
  22019. /**
  22020. * Gets the rgba output component
  22021. */
  22022. get rgba(): NodeMaterialConnectionPoint;
  22023. /**
  22024. * Gets the rgb output component
  22025. */
  22026. get rgb(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the r output component
  22029. */
  22030. get r(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Gets the g output component
  22033. */
  22034. get g(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the b output component
  22037. */
  22038. get b(): NodeMaterialConnectionPoint;
  22039. /**
  22040. * Gets the a output component
  22041. */
  22042. get a(): NodeMaterialConnectionPoint;
  22043. /**
  22044. * Initialize the block and prepare the context for build
  22045. * @param state defines the state that will be used for the build
  22046. */
  22047. initialize(state: NodeMaterialBuildState): void;
  22048. get target(): NodeMaterialBlockTargets;
  22049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22050. isReady(): boolean;
  22051. private _injectVertexCode;
  22052. private _writeTextureRead;
  22053. private _writeOutput;
  22054. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22055. serialize(): any;
  22056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22057. }
  22058. }
  22059. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22064. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22066. import { Nullable } from "babylonjs/types";
  22067. import { Scene } from "babylonjs/scene";
  22068. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22069. /**
  22070. * Base block used for the particle texture
  22071. */
  22072. export class ParticleTextureBlock extends NodeMaterialBlock {
  22073. private _samplerName;
  22074. private _linearDefineName;
  22075. private _gammaDefineName;
  22076. private _tempTextureRead;
  22077. /**
  22078. * Gets or sets the texture associated with the node
  22079. */
  22080. texture: Nullable<BaseTexture>;
  22081. /**
  22082. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22083. */
  22084. convertToGammaSpace: boolean;
  22085. /**
  22086. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22087. */
  22088. convertToLinearSpace: boolean;
  22089. /**
  22090. * Create a new ParticleTextureBlock
  22091. * @param name defines the block name
  22092. */
  22093. constructor(name: string);
  22094. /**
  22095. * Gets the current class name
  22096. * @returns the class name
  22097. */
  22098. getClassName(): string;
  22099. /**
  22100. * Gets the uv input component
  22101. */
  22102. get uv(): NodeMaterialConnectionPoint;
  22103. /**
  22104. * Gets the rgba output component
  22105. */
  22106. get rgba(): NodeMaterialConnectionPoint;
  22107. /**
  22108. * Gets the rgb output component
  22109. */
  22110. get rgb(): NodeMaterialConnectionPoint;
  22111. /**
  22112. * Gets the r output component
  22113. */
  22114. get r(): NodeMaterialConnectionPoint;
  22115. /**
  22116. * Gets the g output component
  22117. */
  22118. get g(): NodeMaterialConnectionPoint;
  22119. /**
  22120. * Gets the b output component
  22121. */
  22122. get b(): NodeMaterialConnectionPoint;
  22123. /**
  22124. * Gets the a output component
  22125. */
  22126. get a(): NodeMaterialConnectionPoint;
  22127. /**
  22128. * Initialize the block and prepare the context for build
  22129. * @param state defines the state that will be used for the build
  22130. */
  22131. initialize(state: NodeMaterialBuildState): void;
  22132. autoConfigure(material: NodeMaterial): void;
  22133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22134. isReady(): boolean;
  22135. private _writeOutput;
  22136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22137. serialize(): any;
  22138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22139. }
  22140. }
  22141. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22144. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22145. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22146. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22147. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22148. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22149. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22150. import { Scene } from "babylonjs/scene";
  22151. /**
  22152. * Class used to store shared data between 2 NodeMaterialBuildState
  22153. */
  22154. export class NodeMaterialBuildStateSharedData {
  22155. /**
  22156. * Gets the list of emitted varyings
  22157. */
  22158. temps: string[];
  22159. /**
  22160. * Gets the list of emitted varyings
  22161. */
  22162. varyings: string[];
  22163. /**
  22164. * Gets the varying declaration string
  22165. */
  22166. varyingDeclaration: string;
  22167. /**
  22168. * Input blocks
  22169. */
  22170. inputBlocks: InputBlock[];
  22171. /**
  22172. * Input blocks
  22173. */
  22174. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22175. /**
  22176. * Bindable blocks (Blocks that need to set data to the effect)
  22177. */
  22178. bindableBlocks: NodeMaterialBlock[];
  22179. /**
  22180. * List of blocks that can provide a compilation fallback
  22181. */
  22182. blocksWithFallbacks: NodeMaterialBlock[];
  22183. /**
  22184. * List of blocks that can provide a define update
  22185. */
  22186. blocksWithDefines: NodeMaterialBlock[];
  22187. /**
  22188. * List of blocks that can provide a repeatable content
  22189. */
  22190. repeatableContentBlocks: NodeMaterialBlock[];
  22191. /**
  22192. * List of blocks that can provide a dynamic list of uniforms
  22193. */
  22194. dynamicUniformBlocks: NodeMaterialBlock[];
  22195. /**
  22196. * List of blocks that can block the isReady function for the material
  22197. */
  22198. blockingBlocks: NodeMaterialBlock[];
  22199. /**
  22200. * Gets the list of animated inputs
  22201. */
  22202. animatedInputs: InputBlock[];
  22203. /**
  22204. * Build Id used to avoid multiple recompilations
  22205. */
  22206. buildId: number;
  22207. /** List of emitted variables */
  22208. variableNames: {
  22209. [key: string]: number;
  22210. };
  22211. /** List of emitted defines */
  22212. defineNames: {
  22213. [key: string]: number;
  22214. };
  22215. /** Should emit comments? */
  22216. emitComments: boolean;
  22217. /** Emit build activity */
  22218. verbose: boolean;
  22219. /** Gets or sets the hosting scene */
  22220. scene: Scene;
  22221. /**
  22222. * Gets the compilation hints emitted at compilation time
  22223. */
  22224. hints: {
  22225. needWorldViewMatrix: boolean;
  22226. needWorldViewProjectionMatrix: boolean;
  22227. needAlphaBlending: boolean;
  22228. needAlphaTesting: boolean;
  22229. };
  22230. /**
  22231. * List of compilation checks
  22232. */
  22233. checks: {
  22234. emitVertex: boolean;
  22235. emitFragment: boolean;
  22236. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22237. };
  22238. /**
  22239. * Is vertex program allowed to be empty?
  22240. */
  22241. allowEmptyVertexProgram: boolean;
  22242. /** Creates a new shared data */
  22243. constructor();
  22244. /**
  22245. * Emits console errors and exceptions if there is a failing check
  22246. */
  22247. emitErrors(): void;
  22248. }
  22249. }
  22250. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22251. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22252. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22253. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22254. /**
  22255. * Class used to store node based material build state
  22256. */
  22257. export class NodeMaterialBuildState {
  22258. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22259. supportUniformBuffers: boolean;
  22260. /**
  22261. * Gets the list of emitted attributes
  22262. */
  22263. attributes: string[];
  22264. /**
  22265. * Gets the list of emitted uniforms
  22266. */
  22267. uniforms: string[];
  22268. /**
  22269. * Gets the list of emitted constants
  22270. */
  22271. constants: string[];
  22272. /**
  22273. * Gets the list of emitted samplers
  22274. */
  22275. samplers: string[];
  22276. /**
  22277. * Gets the list of emitted functions
  22278. */
  22279. functions: {
  22280. [key: string]: string;
  22281. };
  22282. /**
  22283. * Gets the list of emitted extensions
  22284. */
  22285. extensions: {
  22286. [key: string]: string;
  22287. };
  22288. /**
  22289. * Gets the target of the compilation state
  22290. */
  22291. target: NodeMaterialBlockTargets;
  22292. /**
  22293. * Gets the list of emitted counters
  22294. */
  22295. counters: {
  22296. [key: string]: number;
  22297. };
  22298. /**
  22299. * Shared data between multiple NodeMaterialBuildState instances
  22300. */
  22301. sharedData: NodeMaterialBuildStateSharedData;
  22302. /** @hidden */
  22303. _vertexState: NodeMaterialBuildState;
  22304. /** @hidden */
  22305. _attributeDeclaration: string;
  22306. /** @hidden */
  22307. _uniformDeclaration: string;
  22308. /** @hidden */
  22309. _constantDeclaration: string;
  22310. /** @hidden */
  22311. _samplerDeclaration: string;
  22312. /** @hidden */
  22313. _varyingTransfer: string;
  22314. /** @hidden */
  22315. _injectAtEnd: string;
  22316. private _repeatableContentAnchorIndex;
  22317. /** @hidden */
  22318. _builtCompilationString: string;
  22319. /**
  22320. * Gets the emitted compilation strings
  22321. */
  22322. compilationString: string;
  22323. /**
  22324. * Finalize the compilation strings
  22325. * @param state defines the current compilation state
  22326. */
  22327. finalize(state: NodeMaterialBuildState): void;
  22328. /** @hidden */
  22329. get _repeatableContentAnchor(): string;
  22330. /** @hidden */
  22331. _getFreeVariableName(prefix: string): string;
  22332. /** @hidden */
  22333. _getFreeDefineName(prefix: string): string;
  22334. /** @hidden */
  22335. _excludeVariableName(name: string): void;
  22336. /** @hidden */
  22337. _emit2DSampler(name: string): void;
  22338. /** @hidden */
  22339. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22340. /** @hidden */
  22341. _emitExtension(name: string, extension: string, define?: string): void;
  22342. /** @hidden */
  22343. _emitFunction(name: string, code: string, comments: string): void;
  22344. /** @hidden */
  22345. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22346. replaceStrings?: {
  22347. search: RegExp;
  22348. replace: string;
  22349. }[];
  22350. repeatKey?: string;
  22351. }): string;
  22352. /** @hidden */
  22353. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22354. repeatKey?: string;
  22355. removeAttributes?: boolean;
  22356. removeUniforms?: boolean;
  22357. removeVaryings?: boolean;
  22358. removeIfDef?: boolean;
  22359. replaceStrings?: {
  22360. search: RegExp;
  22361. replace: string;
  22362. }[];
  22363. }, storeKey?: string): void;
  22364. /** @hidden */
  22365. _registerTempVariable(name: string): boolean;
  22366. /** @hidden */
  22367. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22368. /** @hidden */
  22369. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22370. /** @hidden */
  22371. _emitFloat(value: number): string;
  22372. }
  22373. }
  22374. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22375. /**
  22376. * Helper class used to generate session unique ID
  22377. */
  22378. export class UniqueIdGenerator {
  22379. private static _UniqueIdCounter;
  22380. /**
  22381. * Gets an unique (relatively to the current scene) Id
  22382. */
  22383. static get UniqueId(): number;
  22384. }
  22385. }
  22386. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22387. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22389. import { Nullable } from "babylonjs/types";
  22390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22391. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22392. import { Effect } from "babylonjs/Materials/effect";
  22393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22394. import { Mesh } from "babylonjs/Meshes/mesh";
  22395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22396. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22397. import { Scene } from "babylonjs/scene";
  22398. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22399. /**
  22400. * Defines a block that can be used inside a node based material
  22401. */
  22402. export class NodeMaterialBlock {
  22403. private _buildId;
  22404. private _buildTarget;
  22405. private _target;
  22406. private _isFinalMerger;
  22407. private _isInput;
  22408. private _name;
  22409. protected _isUnique: boolean;
  22410. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22411. inputsAreExclusive: boolean;
  22412. /** @hidden */
  22413. _codeVariableName: string;
  22414. /** @hidden */
  22415. _inputs: NodeMaterialConnectionPoint[];
  22416. /** @hidden */
  22417. _outputs: NodeMaterialConnectionPoint[];
  22418. /** @hidden */
  22419. _preparationId: number;
  22420. /**
  22421. * Gets the name of the block
  22422. */
  22423. get name(): string;
  22424. /**
  22425. * Sets the name of the block. Will check if the name is valid.
  22426. */
  22427. set name(newName: string);
  22428. /**
  22429. * Gets or sets the unique id of the node
  22430. */
  22431. uniqueId: number;
  22432. /**
  22433. * Gets or sets the comments associated with this block
  22434. */
  22435. comments: string;
  22436. /**
  22437. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22438. */
  22439. get isUnique(): boolean;
  22440. /**
  22441. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22442. */
  22443. get isFinalMerger(): boolean;
  22444. /**
  22445. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22446. */
  22447. get isInput(): boolean;
  22448. /**
  22449. * Gets or sets the build Id
  22450. */
  22451. get buildId(): number;
  22452. set buildId(value: number);
  22453. /**
  22454. * Gets or sets the target of the block
  22455. */
  22456. get target(): NodeMaterialBlockTargets;
  22457. set target(value: NodeMaterialBlockTargets);
  22458. /**
  22459. * Gets the list of input points
  22460. */
  22461. get inputs(): NodeMaterialConnectionPoint[];
  22462. /** Gets the list of output points */
  22463. get outputs(): NodeMaterialConnectionPoint[];
  22464. /**
  22465. * Find an input by its name
  22466. * @param name defines the name of the input to look for
  22467. * @returns the input or null if not found
  22468. */
  22469. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22470. /**
  22471. * Find an output by its name
  22472. * @param name defines the name of the outputto look for
  22473. * @returns the output or null if not found
  22474. */
  22475. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22476. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22477. visibleInInspector: boolean;
  22478. /**
  22479. * Creates a new NodeMaterialBlock
  22480. * @param name defines the block name
  22481. * @param target defines the target of that block (Vertex by default)
  22482. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22483. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22484. */
  22485. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22486. /**
  22487. * Initialize the block and prepare the context for build
  22488. * @param state defines the state that will be used for the build
  22489. */
  22490. initialize(state: NodeMaterialBuildState): void;
  22491. /**
  22492. * Bind data to effect. Will only be called for blocks with isBindable === true
  22493. * @param effect defines the effect to bind data to
  22494. * @param nodeMaterial defines the hosting NodeMaterial
  22495. * @param mesh defines the mesh that will be rendered
  22496. * @param subMesh defines the submesh that will be rendered
  22497. */
  22498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22499. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22500. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22501. protected _writeFloat(value: number): string;
  22502. /**
  22503. * Gets the current class name e.g. "NodeMaterialBlock"
  22504. * @returns the class name
  22505. */
  22506. getClassName(): string;
  22507. /**
  22508. * Register a new input. Must be called inside a block constructor
  22509. * @param name defines the connection point name
  22510. * @param type defines the connection point type
  22511. * @param isOptional defines a boolean indicating that this input can be omitted
  22512. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22513. * @param point an already created connection point. If not provided, create a new one
  22514. * @returns the current block
  22515. */
  22516. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22517. /**
  22518. * Register a new output. Must be called inside a block constructor
  22519. * @param name defines the connection point name
  22520. * @param type defines the connection point type
  22521. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22522. * @param point an already created connection point. If not provided, create a new one
  22523. * @returns the current block
  22524. */
  22525. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22526. /**
  22527. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22528. * @param forOutput defines an optional connection point to check compatibility with
  22529. * @returns the first available input or null
  22530. */
  22531. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22532. /**
  22533. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22534. * @param forBlock defines an optional block to check compatibility with
  22535. * @returns the first available input or null
  22536. */
  22537. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22538. /**
  22539. * Gets the sibling of the given output
  22540. * @param current defines the current output
  22541. * @returns the next output in the list or null
  22542. */
  22543. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22544. /**
  22545. * Connect current block with another block
  22546. * @param other defines the block to connect with
  22547. * @param options define the various options to help pick the right connections
  22548. * @returns the current block
  22549. */
  22550. connectTo(other: NodeMaterialBlock, options?: {
  22551. input?: string;
  22552. output?: string;
  22553. outputSwizzle?: string;
  22554. }): this | undefined;
  22555. protected _buildBlock(state: NodeMaterialBuildState): void;
  22556. /**
  22557. * Add uniforms, samplers and uniform buffers at compilation time
  22558. * @param state defines the state to update
  22559. * @param nodeMaterial defines the node material requesting the update
  22560. * @param defines defines the material defines to update
  22561. * @param uniformBuffers defines the list of uniform buffer names
  22562. */
  22563. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22564. /**
  22565. * Add potential fallbacks if shader compilation fails
  22566. * @param mesh defines the mesh to be rendered
  22567. * @param fallbacks defines the current prioritized list of fallbacks
  22568. */
  22569. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22570. /**
  22571. * Initialize defines for shader compilation
  22572. * @param mesh defines the mesh to be rendered
  22573. * @param nodeMaterial defines the node material requesting the update
  22574. * @param defines defines the material defines to update
  22575. * @param useInstances specifies that instances should be used
  22576. */
  22577. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22578. /**
  22579. * Update defines for shader compilation
  22580. * @param mesh defines the mesh to be rendered
  22581. * @param nodeMaterial defines the node material requesting the update
  22582. * @param defines defines the material defines to update
  22583. * @param useInstances specifies that instances should be used
  22584. * @param subMesh defines which submesh to render
  22585. */
  22586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22587. /**
  22588. * Lets the block try to connect some inputs automatically
  22589. * @param material defines the hosting NodeMaterial
  22590. */
  22591. autoConfigure(material: NodeMaterial): void;
  22592. /**
  22593. * Function called when a block is declared as repeatable content generator
  22594. * @param vertexShaderState defines the current compilation state for the vertex shader
  22595. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22596. * @param mesh defines the mesh to be rendered
  22597. * @param defines defines the material defines to update
  22598. */
  22599. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22600. /**
  22601. * Checks if the block is ready
  22602. * @param mesh defines the mesh to be rendered
  22603. * @param nodeMaterial defines the node material requesting the update
  22604. * @param defines defines the material defines to update
  22605. * @param useInstances specifies that instances should be used
  22606. * @returns true if the block is ready
  22607. */
  22608. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22609. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22610. private _processBuild;
  22611. /**
  22612. * Validates the new name for the block node.
  22613. * @param newName the new name to be given to the node.
  22614. * @returns false if the name is a reserve word, else true.
  22615. */
  22616. validateBlockName(newName: string): boolean;
  22617. /**
  22618. * Compile the current node and generate the shader code
  22619. * @param state defines the current compilation state (uniforms, samplers, current string)
  22620. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22621. * @returns true if already built
  22622. */
  22623. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22624. protected _inputRename(name: string): string;
  22625. protected _outputRename(name: string): string;
  22626. protected _dumpPropertiesCode(): string;
  22627. /** @hidden */
  22628. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22629. /** @hidden */
  22630. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22631. /**
  22632. * Clone the current block to a new identical block
  22633. * @param scene defines the hosting scene
  22634. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22635. * @returns a copy of the current block
  22636. */
  22637. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22638. /**
  22639. * Serializes this block in a JSON representation
  22640. * @returns the serialized block object
  22641. */
  22642. serialize(): any;
  22643. /** @hidden */
  22644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22645. private _deserializePortDisplayNamesAndExposedOnFrame;
  22646. /**
  22647. * Release resources
  22648. */
  22649. dispose(): void;
  22650. }
  22651. }
  22652. declare module "babylonjs/Materials/pushMaterial" {
  22653. import { Nullable } from "babylonjs/types";
  22654. import { Scene } from "babylonjs/scene";
  22655. import { Matrix } from "babylonjs/Maths/math.vector";
  22656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22657. import { Mesh } from "babylonjs/Meshes/mesh";
  22658. import { Material } from "babylonjs/Materials/material";
  22659. import { Effect } from "babylonjs/Materials/effect";
  22660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22661. /**
  22662. * Base class of materials working in push mode in babylon JS
  22663. * @hidden
  22664. */
  22665. export class PushMaterial extends Material {
  22666. protected _activeEffect: Effect;
  22667. protected _normalMatrix: Matrix;
  22668. constructor(name: string, scene: Scene);
  22669. getEffect(): Effect;
  22670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22671. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22672. /**
  22673. * Binds the given world matrix to the active effect
  22674. *
  22675. * @param world the matrix to bind
  22676. */
  22677. bindOnlyWorldMatrix(world: Matrix): void;
  22678. /**
  22679. * Binds the given normal matrix to the active effect
  22680. *
  22681. * @param normalMatrix the matrix to bind
  22682. */
  22683. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22684. bind(world: Matrix, mesh?: Mesh): void;
  22685. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22686. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22687. }
  22688. }
  22689. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22691. /**
  22692. * Root class for all node material optimizers
  22693. */
  22694. export class NodeMaterialOptimizer {
  22695. /**
  22696. * Function used to optimize a NodeMaterial graph
  22697. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22698. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22699. */
  22700. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22701. }
  22702. }
  22703. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22707. import { Scene } from "babylonjs/scene";
  22708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22709. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22711. /**
  22712. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22713. */
  22714. export class TransformBlock extends NodeMaterialBlock {
  22715. /**
  22716. * Defines the value to use to complement W value to transform it to a Vector4
  22717. */
  22718. complementW: number;
  22719. /**
  22720. * Defines the value to use to complement z value to transform it to a Vector4
  22721. */
  22722. complementZ: number;
  22723. /**
  22724. * Creates a new TransformBlock
  22725. * @param name defines the block name
  22726. */
  22727. constructor(name: string);
  22728. /**
  22729. * Gets the current class name
  22730. * @returns the class name
  22731. */
  22732. getClassName(): string;
  22733. /**
  22734. * Gets the vector input
  22735. */
  22736. get vector(): NodeMaterialConnectionPoint;
  22737. /**
  22738. * Gets the output component
  22739. */
  22740. get output(): NodeMaterialConnectionPoint;
  22741. /**
  22742. * Gets the xyz output component
  22743. */
  22744. get xyz(): NodeMaterialConnectionPoint;
  22745. /**
  22746. * Gets the matrix transform input
  22747. */
  22748. get transform(): NodeMaterialConnectionPoint;
  22749. protected _buildBlock(state: NodeMaterialBuildState): this;
  22750. /**
  22751. * Update defines for shader compilation
  22752. * @param mesh defines the mesh to be rendered
  22753. * @param nodeMaterial defines the node material requesting the update
  22754. * @param defines defines the material defines to update
  22755. * @param useInstances specifies that instances should be used
  22756. * @param subMesh defines which submesh to render
  22757. */
  22758. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22759. serialize(): any;
  22760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22761. protected _dumpPropertiesCode(): string;
  22762. }
  22763. }
  22764. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22768. /**
  22769. * Block used to output the vertex position
  22770. */
  22771. export class VertexOutputBlock extends NodeMaterialBlock {
  22772. /**
  22773. * Creates a new VertexOutputBlock
  22774. * @param name defines the block name
  22775. */
  22776. constructor(name: string);
  22777. /**
  22778. * Gets the current class name
  22779. * @returns the class name
  22780. */
  22781. getClassName(): string;
  22782. /**
  22783. * Gets the vector input component
  22784. */
  22785. get vector(): NodeMaterialConnectionPoint;
  22786. protected _buildBlock(state: NodeMaterialBuildState): this;
  22787. }
  22788. }
  22789. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22793. /**
  22794. * Block used to output the final color
  22795. */
  22796. export class FragmentOutputBlock extends NodeMaterialBlock {
  22797. /**
  22798. * Create a new FragmentOutputBlock
  22799. * @param name defines the block name
  22800. */
  22801. constructor(name: string);
  22802. /**
  22803. * Gets the current class name
  22804. * @returns the class name
  22805. */
  22806. getClassName(): string;
  22807. /**
  22808. * Gets the rgba input component
  22809. */
  22810. get rgba(): NodeMaterialConnectionPoint;
  22811. /**
  22812. * Gets the rgb input component
  22813. */
  22814. get rgb(): NodeMaterialConnectionPoint;
  22815. /**
  22816. * Gets the a input component
  22817. */
  22818. get a(): NodeMaterialConnectionPoint;
  22819. protected _buildBlock(state: NodeMaterialBuildState): this;
  22820. }
  22821. }
  22822. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22826. /**
  22827. * Block used for the particle ramp gradient section
  22828. */
  22829. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22830. /**
  22831. * Create a new ParticleRampGradientBlock
  22832. * @param name defines the block name
  22833. */
  22834. constructor(name: string);
  22835. /**
  22836. * Gets the current class name
  22837. * @returns the class name
  22838. */
  22839. getClassName(): string;
  22840. /**
  22841. * Gets the color input component
  22842. */
  22843. get color(): NodeMaterialConnectionPoint;
  22844. /**
  22845. * Gets the rampColor output component
  22846. */
  22847. get rampColor(): NodeMaterialConnectionPoint;
  22848. /**
  22849. * Initialize the block and prepare the context for build
  22850. * @param state defines the state that will be used for the build
  22851. */
  22852. initialize(state: NodeMaterialBuildState): void;
  22853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22854. }
  22855. }
  22856. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22860. /**
  22861. * Block used for the particle blend multiply section
  22862. */
  22863. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22864. /**
  22865. * Create a new ParticleBlendMultiplyBlock
  22866. * @param name defines the block name
  22867. */
  22868. constructor(name: string);
  22869. /**
  22870. * Gets the current class name
  22871. * @returns the class name
  22872. */
  22873. getClassName(): string;
  22874. /**
  22875. * Gets the color input component
  22876. */
  22877. get color(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the alphaTexture input component
  22880. */
  22881. get alphaTexture(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the alphaColor input component
  22884. */
  22885. get alphaColor(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the blendColor output component
  22888. */
  22889. get blendColor(): NodeMaterialConnectionPoint;
  22890. /**
  22891. * Initialize the block and prepare the context for build
  22892. * @param state defines the state that will be used for the build
  22893. */
  22894. initialize(state: NodeMaterialBuildState): void;
  22895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22896. }
  22897. }
  22898. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22902. /**
  22903. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22904. */
  22905. export class VectorMergerBlock extends NodeMaterialBlock {
  22906. /**
  22907. * Create a new VectorMergerBlock
  22908. * @param name defines the block name
  22909. */
  22910. constructor(name: string);
  22911. /**
  22912. * Gets the current class name
  22913. * @returns the class name
  22914. */
  22915. getClassName(): string;
  22916. /**
  22917. * Gets the xyz component (input)
  22918. */
  22919. get xyzIn(): NodeMaterialConnectionPoint;
  22920. /**
  22921. * Gets the xy component (input)
  22922. */
  22923. get xyIn(): NodeMaterialConnectionPoint;
  22924. /**
  22925. * Gets the x component (input)
  22926. */
  22927. get x(): NodeMaterialConnectionPoint;
  22928. /**
  22929. * Gets the y component (input)
  22930. */
  22931. get y(): NodeMaterialConnectionPoint;
  22932. /**
  22933. * Gets the z component (input)
  22934. */
  22935. get z(): NodeMaterialConnectionPoint;
  22936. /**
  22937. * Gets the w component (input)
  22938. */
  22939. get w(): NodeMaterialConnectionPoint;
  22940. /**
  22941. * Gets the xyzw component (output)
  22942. */
  22943. get xyzw(): NodeMaterialConnectionPoint;
  22944. /**
  22945. * Gets the xyz component (output)
  22946. */
  22947. get xyzOut(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the xy component (output)
  22950. */
  22951. get xyOut(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the xy component (output)
  22954. * @deprecated Please use xyOut instead.
  22955. */
  22956. get xy(): NodeMaterialConnectionPoint;
  22957. /**
  22958. * Gets the xyz component (output)
  22959. * @deprecated Please use xyzOut instead.
  22960. */
  22961. get xyz(): NodeMaterialConnectionPoint;
  22962. protected _buildBlock(state: NodeMaterialBuildState): this;
  22963. }
  22964. }
  22965. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22969. import { Vector2 } from "babylonjs/Maths/math.vector";
  22970. import { Scene } from "babylonjs/scene";
  22971. /**
  22972. * Block used to remap a float from a range to a new one
  22973. */
  22974. export class RemapBlock extends NodeMaterialBlock {
  22975. /**
  22976. * Gets or sets the source range
  22977. */
  22978. sourceRange: Vector2;
  22979. /**
  22980. * Gets or sets the target range
  22981. */
  22982. targetRange: Vector2;
  22983. /**
  22984. * Creates a new RemapBlock
  22985. * @param name defines the block name
  22986. */
  22987. constructor(name: string);
  22988. /**
  22989. * Gets the current class name
  22990. * @returns the class name
  22991. */
  22992. getClassName(): string;
  22993. /**
  22994. * Gets the input component
  22995. */
  22996. get input(): NodeMaterialConnectionPoint;
  22997. /**
  22998. * Gets the source min input component
  22999. */
  23000. get sourceMin(): NodeMaterialConnectionPoint;
  23001. /**
  23002. * Gets the source max input component
  23003. */
  23004. get sourceMax(): NodeMaterialConnectionPoint;
  23005. /**
  23006. * Gets the target min input component
  23007. */
  23008. get targetMin(): NodeMaterialConnectionPoint;
  23009. /**
  23010. * Gets the target max input component
  23011. */
  23012. get targetMax(): NodeMaterialConnectionPoint;
  23013. /**
  23014. * Gets the output component
  23015. */
  23016. get output(): NodeMaterialConnectionPoint;
  23017. protected _buildBlock(state: NodeMaterialBuildState): this;
  23018. protected _dumpPropertiesCode(): string;
  23019. serialize(): any;
  23020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23021. }
  23022. }
  23023. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23027. /**
  23028. * Block used to multiply 2 values
  23029. */
  23030. export class MultiplyBlock extends NodeMaterialBlock {
  23031. /**
  23032. * Creates a new MultiplyBlock
  23033. * @param name defines the block name
  23034. */
  23035. constructor(name: string);
  23036. /**
  23037. * Gets the current class name
  23038. * @returns the class name
  23039. */
  23040. getClassName(): string;
  23041. /**
  23042. * Gets the left operand input component
  23043. */
  23044. get left(): NodeMaterialConnectionPoint;
  23045. /**
  23046. * Gets the right operand input component
  23047. */
  23048. get right(): NodeMaterialConnectionPoint;
  23049. /**
  23050. * Gets the output component
  23051. */
  23052. get output(): NodeMaterialConnectionPoint;
  23053. protected _buildBlock(state: NodeMaterialBuildState): this;
  23054. }
  23055. }
  23056. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23060. /**
  23061. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23062. */
  23063. export class ColorSplitterBlock extends NodeMaterialBlock {
  23064. /**
  23065. * Create a new ColorSplitterBlock
  23066. * @param name defines the block name
  23067. */
  23068. constructor(name: string);
  23069. /**
  23070. * Gets the current class name
  23071. * @returns the class name
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Gets the rgba component (input)
  23076. */
  23077. get rgba(): NodeMaterialConnectionPoint;
  23078. /**
  23079. * Gets the rgb component (input)
  23080. */
  23081. get rgbIn(): NodeMaterialConnectionPoint;
  23082. /**
  23083. * Gets the rgb component (output)
  23084. */
  23085. get rgbOut(): NodeMaterialConnectionPoint;
  23086. /**
  23087. * Gets the r component (output)
  23088. */
  23089. get r(): NodeMaterialConnectionPoint;
  23090. /**
  23091. * Gets the g component (output)
  23092. */
  23093. get g(): NodeMaterialConnectionPoint;
  23094. /**
  23095. * Gets the b component (output)
  23096. */
  23097. get b(): NodeMaterialConnectionPoint;
  23098. /**
  23099. * Gets the a component (output)
  23100. */
  23101. get a(): NodeMaterialConnectionPoint;
  23102. protected _inputRename(name: string): string;
  23103. protected _outputRename(name: string): string;
  23104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23105. }
  23106. }
  23107. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23111. import { Scene } from "babylonjs/scene";
  23112. /**
  23113. * Operations supported by the Trigonometry block
  23114. */
  23115. export enum TrigonometryBlockOperations {
  23116. /** Cos */
  23117. Cos = 0,
  23118. /** Sin */
  23119. Sin = 1,
  23120. /** Abs */
  23121. Abs = 2,
  23122. /** Exp */
  23123. Exp = 3,
  23124. /** Exp2 */
  23125. Exp2 = 4,
  23126. /** Round */
  23127. Round = 5,
  23128. /** Floor */
  23129. Floor = 6,
  23130. /** Ceiling */
  23131. Ceiling = 7,
  23132. /** Square root */
  23133. Sqrt = 8,
  23134. /** Log */
  23135. Log = 9,
  23136. /** Tangent */
  23137. Tan = 10,
  23138. /** Arc tangent */
  23139. ArcTan = 11,
  23140. /** Arc cosinus */
  23141. ArcCos = 12,
  23142. /** Arc sinus */
  23143. ArcSin = 13,
  23144. /** Fraction */
  23145. Fract = 14,
  23146. /** Sign */
  23147. Sign = 15,
  23148. /** To radians (from degrees) */
  23149. Radians = 16,
  23150. /** To degrees (from radians) */
  23151. Degrees = 17
  23152. }
  23153. /**
  23154. * Block used to apply trigonometry operation to floats
  23155. */
  23156. export class TrigonometryBlock extends NodeMaterialBlock {
  23157. /**
  23158. * Gets or sets the operation applied by the block
  23159. */
  23160. operation: TrigonometryBlockOperations;
  23161. /**
  23162. * Creates a new TrigonometryBlock
  23163. * @param name defines the block name
  23164. */
  23165. constructor(name: string);
  23166. /**
  23167. * Gets the current class name
  23168. * @returns the class name
  23169. */
  23170. getClassName(): string;
  23171. /**
  23172. * Gets the input component
  23173. */
  23174. get input(): NodeMaterialConnectionPoint;
  23175. /**
  23176. * Gets the output component
  23177. */
  23178. get output(): NodeMaterialConnectionPoint;
  23179. protected _buildBlock(state: NodeMaterialBuildState): this;
  23180. serialize(): any;
  23181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23182. protected _dumpPropertiesCode(): string;
  23183. }
  23184. }
  23185. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23187. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23188. import { Scene } from "babylonjs/scene";
  23189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23190. import { Matrix } from "babylonjs/Maths/math.vector";
  23191. import { Mesh } from "babylonjs/Meshes/mesh";
  23192. import { Engine } from "babylonjs/Engines/engine";
  23193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23194. import { Observable } from "babylonjs/Misc/observable";
  23195. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23196. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23197. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23198. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23199. import { Nullable } from "babylonjs/types";
  23200. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23201. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23202. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23203. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23204. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23205. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23206. import { Effect } from "babylonjs/Materials/effect";
  23207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23208. import { Camera } from "babylonjs/Cameras/camera";
  23209. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23210. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23211. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23212. /**
  23213. * Interface used to configure the node material editor
  23214. */
  23215. export interface INodeMaterialEditorOptions {
  23216. /** Define the URl to load node editor script */
  23217. editorURL?: string;
  23218. }
  23219. /** @hidden */
  23220. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23221. NORMAL: boolean;
  23222. TANGENT: boolean;
  23223. UV1: boolean;
  23224. /** BONES */
  23225. NUM_BONE_INFLUENCERS: number;
  23226. BonesPerMesh: number;
  23227. BONETEXTURE: boolean;
  23228. /** MORPH TARGETS */
  23229. MORPHTARGETS: boolean;
  23230. MORPHTARGETS_NORMAL: boolean;
  23231. MORPHTARGETS_TANGENT: boolean;
  23232. MORPHTARGETS_UV: boolean;
  23233. NUM_MORPH_INFLUENCERS: number;
  23234. /** IMAGE PROCESSING */
  23235. IMAGEPROCESSING: boolean;
  23236. VIGNETTE: boolean;
  23237. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23238. VIGNETTEBLENDMODEOPAQUE: boolean;
  23239. TONEMAPPING: boolean;
  23240. TONEMAPPING_ACES: boolean;
  23241. CONTRAST: boolean;
  23242. EXPOSURE: boolean;
  23243. COLORCURVES: boolean;
  23244. COLORGRADING: boolean;
  23245. COLORGRADING3D: boolean;
  23246. SAMPLER3DGREENDEPTH: boolean;
  23247. SAMPLER3DBGRMAP: boolean;
  23248. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23249. /** MISC. */
  23250. BUMPDIRECTUV: number;
  23251. constructor();
  23252. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23253. }
  23254. /**
  23255. * Class used to configure NodeMaterial
  23256. */
  23257. export interface INodeMaterialOptions {
  23258. /**
  23259. * Defines if blocks should emit comments
  23260. */
  23261. emitComments: boolean;
  23262. }
  23263. /**
  23264. * Class used to create a node based material built by assembling shader blocks
  23265. */
  23266. export class NodeMaterial extends PushMaterial {
  23267. private static _BuildIdGenerator;
  23268. private _options;
  23269. private _vertexCompilationState;
  23270. private _fragmentCompilationState;
  23271. private _sharedData;
  23272. private _buildId;
  23273. private _buildWasSuccessful;
  23274. private _cachedWorldViewMatrix;
  23275. private _cachedWorldViewProjectionMatrix;
  23276. private _optimizers;
  23277. private _animationFrame;
  23278. /** Define the Url to load node editor script */
  23279. static EditorURL: string;
  23280. /** Define the Url to load snippets */
  23281. static SnippetUrl: string;
  23282. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23283. static IgnoreTexturesAtLoadTime: boolean;
  23284. private BJSNODEMATERIALEDITOR;
  23285. /** Get the inspector from bundle or global */
  23286. private _getGlobalNodeMaterialEditor;
  23287. /**
  23288. * Snippet ID if the material was created from the snippet server
  23289. */
  23290. snippetId: string;
  23291. /**
  23292. * Gets or sets data used by visual editor
  23293. * @see https://nme.babylonjs.com
  23294. */
  23295. editorData: any;
  23296. /**
  23297. * 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)
  23298. */
  23299. ignoreAlpha: boolean;
  23300. /**
  23301. * Defines the maximum number of lights that can be used in the material
  23302. */
  23303. maxSimultaneousLights: number;
  23304. /**
  23305. * Observable raised when the material is built
  23306. */
  23307. onBuildObservable: Observable<NodeMaterial>;
  23308. /**
  23309. * Gets or sets the root nodes of the material vertex shader
  23310. */
  23311. _vertexOutputNodes: NodeMaterialBlock[];
  23312. /**
  23313. * Gets or sets the root nodes of the material fragment (pixel) shader
  23314. */
  23315. _fragmentOutputNodes: NodeMaterialBlock[];
  23316. /** Gets or sets options to control the node material overall behavior */
  23317. get options(): INodeMaterialOptions;
  23318. set options(options: INodeMaterialOptions);
  23319. /**
  23320. * Default configuration related to image processing available in the standard Material.
  23321. */
  23322. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23323. /**
  23324. * Gets the image processing configuration used either in this material.
  23325. */
  23326. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23327. /**
  23328. * Sets the Default image processing configuration used either in the this material.
  23329. *
  23330. * If sets to null, the scene one is in use.
  23331. */
  23332. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23333. /**
  23334. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23335. */
  23336. attachedBlocks: NodeMaterialBlock[];
  23337. /**
  23338. * Specifies the mode of the node material
  23339. * @hidden
  23340. */
  23341. _mode: NodeMaterialModes;
  23342. /**
  23343. * Gets the mode property
  23344. */
  23345. get mode(): NodeMaterialModes;
  23346. /**
  23347. * Create a new node based material
  23348. * @param name defines the material name
  23349. * @param scene defines the hosting scene
  23350. * @param options defines creation option
  23351. */
  23352. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23353. /**
  23354. * Gets the current class name of the material e.g. "NodeMaterial"
  23355. * @returns the class name
  23356. */
  23357. getClassName(): string;
  23358. /**
  23359. * Keep track of the image processing observer to allow dispose and replace.
  23360. */
  23361. private _imageProcessingObserver;
  23362. /**
  23363. * Attaches a new image processing configuration to the Standard Material.
  23364. * @param configuration
  23365. */
  23366. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23367. /**
  23368. * Get a block by its name
  23369. * @param name defines the name of the block to retrieve
  23370. * @returns the required block or null if not found
  23371. */
  23372. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23373. /**
  23374. * Get a block by its name
  23375. * @param predicate defines the predicate used to find the good candidate
  23376. * @returns the required block or null if not found
  23377. */
  23378. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23379. /**
  23380. * Get an input block by its name
  23381. * @param predicate defines the predicate used to find the good candidate
  23382. * @returns the required input block or null if not found
  23383. */
  23384. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23385. /**
  23386. * Gets the list of input blocks attached to this material
  23387. * @returns an array of InputBlocks
  23388. */
  23389. getInputBlocks(): InputBlock[];
  23390. /**
  23391. * Adds a new optimizer to the list of optimizers
  23392. * @param optimizer defines the optimizers to add
  23393. * @returns the current material
  23394. */
  23395. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23396. /**
  23397. * Remove an optimizer from the list of optimizers
  23398. * @param optimizer defines the optimizers to remove
  23399. * @returns the current material
  23400. */
  23401. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23402. /**
  23403. * Add a new block to the list of output nodes
  23404. * @param node defines the node to add
  23405. * @returns the current material
  23406. */
  23407. addOutputNode(node: NodeMaterialBlock): this;
  23408. /**
  23409. * Remove a block from the list of root nodes
  23410. * @param node defines the node to remove
  23411. * @returns the current material
  23412. */
  23413. removeOutputNode(node: NodeMaterialBlock): this;
  23414. private _addVertexOutputNode;
  23415. private _removeVertexOutputNode;
  23416. private _addFragmentOutputNode;
  23417. private _removeFragmentOutputNode;
  23418. /**
  23419. * Specifies if the material will require alpha blending
  23420. * @returns a boolean specifying if alpha blending is needed
  23421. */
  23422. needAlphaBlending(): boolean;
  23423. /**
  23424. * Specifies if this material should be rendered in alpha test mode
  23425. * @returns a boolean specifying if an alpha test is needed.
  23426. */
  23427. needAlphaTesting(): boolean;
  23428. private _initializeBlock;
  23429. private _resetDualBlocks;
  23430. /**
  23431. * Remove a block from the current node material
  23432. * @param block defines the block to remove
  23433. */
  23434. removeBlock(block: NodeMaterialBlock): void;
  23435. /**
  23436. * Build the material and generates the inner effect
  23437. * @param verbose defines if the build should log activity
  23438. */
  23439. build(verbose?: boolean): void;
  23440. /**
  23441. * Runs an otpimization phase to try to improve the shader code
  23442. */
  23443. optimize(): void;
  23444. private _prepareDefinesForAttributes;
  23445. /**
  23446. * Create a post process from the material
  23447. * @param camera The camera to apply the render pass to.
  23448. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23450. * @param engine The engine which the post process will be applied. (default: current engine)
  23451. * @param reusable If the post process can be reused on the same frame. (default: false)
  23452. * @param textureType Type of textures used when performing the post process. (default: 0)
  23453. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23454. * @returns the post process created
  23455. */
  23456. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23457. /**
  23458. * Create the post process effect from the material
  23459. * @param postProcess The post process to create the effect for
  23460. */
  23461. createEffectForPostProcess(postProcess: PostProcess): void;
  23462. private _createEffectForPostProcess;
  23463. /**
  23464. * Create a new procedural texture based on this node material
  23465. * @param size defines the size of the texture
  23466. * @param scene defines the hosting scene
  23467. * @returns the new procedural texture attached to this node material
  23468. */
  23469. createProceduralTexture(size: number | {
  23470. width: number;
  23471. height: number;
  23472. layers?: number;
  23473. }, scene: Scene): Nullable<ProceduralTexture>;
  23474. private _createEffectForParticles;
  23475. private _checkInternals;
  23476. /**
  23477. * Create the effect to be used as the custom effect for a particle system
  23478. * @param particleSystem Particle system to create the effect for
  23479. * @param onCompiled defines a function to call when the effect creation is successful
  23480. * @param onError defines a function to call when the effect creation has failed
  23481. */
  23482. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23483. private _processDefines;
  23484. /**
  23485. * Get if the submesh is ready to be used and all its information available.
  23486. * Child classes can use it to update shaders
  23487. * @param mesh defines the mesh to check
  23488. * @param subMesh defines which submesh to check
  23489. * @param useInstances specifies that instances should be used
  23490. * @returns a boolean indicating that the submesh is ready or not
  23491. */
  23492. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23493. /**
  23494. * Get a string representing the shaders built by the current node graph
  23495. */
  23496. get compiledShaders(): string;
  23497. /**
  23498. * Binds the world matrix to the material
  23499. * @param world defines the world transformation matrix
  23500. */
  23501. bindOnlyWorldMatrix(world: Matrix): void;
  23502. /**
  23503. * Binds the submesh to this material by preparing the effect and shader to draw
  23504. * @param world defines the world transformation matrix
  23505. * @param mesh defines the mesh containing the submesh
  23506. * @param subMesh defines the submesh to bind the material to
  23507. */
  23508. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23509. /**
  23510. * Gets the active textures from the material
  23511. * @returns an array of textures
  23512. */
  23513. getActiveTextures(): BaseTexture[];
  23514. /**
  23515. * Gets the list of texture blocks
  23516. * @returns an array of texture blocks
  23517. */
  23518. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23519. /**
  23520. * Specifies if the material uses a texture
  23521. * @param texture defines the texture to check against the material
  23522. * @returns a boolean specifying if the material uses the texture
  23523. */
  23524. hasTexture(texture: BaseTexture): boolean;
  23525. /**
  23526. * Disposes the material
  23527. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23528. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23529. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23530. */
  23531. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23532. /** Creates the node editor window. */
  23533. private _createNodeEditor;
  23534. /**
  23535. * Launch the node material editor
  23536. * @param config Define the configuration of the editor
  23537. * @return a promise fulfilled when the node editor is visible
  23538. */
  23539. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23540. /**
  23541. * Clear the current material
  23542. */
  23543. clear(): void;
  23544. /**
  23545. * Clear the current material and set it to a default state
  23546. */
  23547. setToDefault(): void;
  23548. /**
  23549. * Clear the current material and set it to a default state for post process
  23550. */
  23551. setToDefaultPostProcess(): void;
  23552. /**
  23553. * Clear the current material and set it to a default state for procedural texture
  23554. */
  23555. setToDefaultProceduralTexture(): void;
  23556. /**
  23557. * Clear the current material and set it to a default state for particle
  23558. */
  23559. setToDefaultParticle(): void;
  23560. /**
  23561. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23562. * @param url defines the url to load from
  23563. * @returns a promise that will fullfil when the material is fully loaded
  23564. */
  23565. loadAsync(url: string): Promise<void>;
  23566. private _gatherBlocks;
  23567. /**
  23568. * Generate a string containing the code declaration required to create an equivalent of this material
  23569. * @returns a string
  23570. */
  23571. generateCode(): string;
  23572. /**
  23573. * Serializes this material in a JSON representation
  23574. * @returns the serialized material object
  23575. */
  23576. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23577. private _restoreConnections;
  23578. /**
  23579. * Clear the current graph and load a new one from a serialization object
  23580. * @param source defines the JSON representation of the material
  23581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23582. * @param merge defines whether or not the source must be merged or replace the current content
  23583. */
  23584. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23585. /**
  23586. * Makes a duplicate of the current material.
  23587. * @param name - name to use for the new material.
  23588. */
  23589. clone(name: string): NodeMaterial;
  23590. /**
  23591. * Creates a node material from parsed material data
  23592. * @param source defines the JSON representation of the material
  23593. * @param scene defines the hosting scene
  23594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23595. * @returns a new node material
  23596. */
  23597. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23598. /**
  23599. * Creates a node material from a snippet saved in a remote file
  23600. * @param name defines the name of the material to create
  23601. * @param url defines the url to load from
  23602. * @param scene defines the hosting scene
  23603. * @returns a promise that will resolve to the new node material
  23604. */
  23605. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23606. /**
  23607. * Creates a node material from a snippet saved by the node material editor
  23608. * @param snippetId defines the snippet to load
  23609. * @param scene defines the hosting scene
  23610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23611. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23612. * @returns a promise that will resolve to the new node material
  23613. */
  23614. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23615. /**
  23616. * Creates a new node material set to default basic configuration
  23617. * @param name defines the name of the material
  23618. * @param scene defines the hosting scene
  23619. * @returns a new NodeMaterial
  23620. */
  23621. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23622. }
  23623. }
  23624. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23626. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23627. import { Nullable } from "babylonjs/types";
  23628. module "babylonjs/Engines/thinEngine" {
  23629. interface ThinEngine {
  23630. /**
  23631. * Unbind a list of render target textures from the webGL context
  23632. * This is used only when drawBuffer extension or webGL2 are active
  23633. * @param textures defines the render target textures to unbind
  23634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23636. */
  23637. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23638. /**
  23639. * Create a multi render target texture
  23640. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23641. * @param size defines the size of the texture
  23642. * @param options defines the creation options
  23643. * @returns the cube texture as an InternalTexture
  23644. */
  23645. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23646. /**
  23647. * Update the sample count for a given multiple render target texture
  23648. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23649. * @param textures defines the textures to update
  23650. * @param samples defines the sample count to set
  23651. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23652. */
  23653. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23654. /**
  23655. * Select a subsets of attachments to draw to.
  23656. * @param attachments gl attachments
  23657. */
  23658. bindAttachments(attachments: number[]): void;
  23659. }
  23660. }
  23661. }
  23662. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23663. import { Scene } from "babylonjs/scene";
  23664. import { Engine } from "babylonjs/Engines/engine";
  23665. import { Texture } from "babylonjs/Materials/Textures/texture";
  23666. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23667. import "babylonjs/Engines/Extensions/engine.multiRender";
  23668. /**
  23669. * Creation options of the multi render target texture.
  23670. */
  23671. export interface IMultiRenderTargetOptions {
  23672. /**
  23673. * Define if the texture needs to create mip maps after render.
  23674. */
  23675. generateMipMaps?: boolean;
  23676. /**
  23677. * Define the types of all the draw buffers we want to create
  23678. */
  23679. types?: number[];
  23680. /**
  23681. * Define the sampling modes of all the draw buffers we want to create
  23682. */
  23683. samplingModes?: number[];
  23684. /**
  23685. * Define if a depth buffer is required
  23686. */
  23687. generateDepthBuffer?: boolean;
  23688. /**
  23689. * Define if a stencil buffer is required
  23690. */
  23691. generateStencilBuffer?: boolean;
  23692. /**
  23693. * Define if a depth texture is required instead of a depth buffer
  23694. */
  23695. generateDepthTexture?: boolean;
  23696. /**
  23697. * Define the number of desired draw buffers
  23698. */
  23699. textureCount?: number;
  23700. /**
  23701. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23702. */
  23703. doNotChangeAspectRatio?: boolean;
  23704. /**
  23705. * Define the default type of the buffers we are creating
  23706. */
  23707. defaultType?: number;
  23708. }
  23709. /**
  23710. * A multi render target, like a render target provides the ability to render to a texture.
  23711. * Unlike the render target, it can render to several draw buffers in one draw.
  23712. * This is specially interesting in deferred rendering or for any effects requiring more than
  23713. * just one color from a single pass.
  23714. */
  23715. export class MultiRenderTarget extends RenderTargetTexture {
  23716. private _internalTextures;
  23717. private _textures;
  23718. private _multiRenderTargetOptions;
  23719. private _count;
  23720. /**
  23721. * Get if draw buffers are currently supported by the used hardware and browser.
  23722. */
  23723. get isSupported(): boolean;
  23724. /**
  23725. * Get the list of textures generated by the multi render target.
  23726. */
  23727. get textures(): Texture[];
  23728. /**
  23729. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23730. */
  23731. get count(): number;
  23732. /**
  23733. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23734. */
  23735. get depthTexture(): Texture;
  23736. /**
  23737. * Set the wrapping mode on U of all the textures we are rendering to.
  23738. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23739. */
  23740. set wrapU(wrap: number);
  23741. /**
  23742. * Set the wrapping mode on V of all the textures we are rendering to.
  23743. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23744. */
  23745. set wrapV(wrap: number);
  23746. /**
  23747. * Instantiate a new multi render target texture.
  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. * @param name Define the name of the texture
  23753. * @param size Define the size of the buffers to render to
  23754. * @param count Define the number of target we are rendering into
  23755. * @param scene Define the scene the texture belongs to
  23756. * @param options Define the options used to create the multi render target
  23757. */
  23758. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23759. private _initTypes;
  23760. /** @hidden */
  23761. _rebuild(forceFullRebuild?: boolean): void;
  23762. private _createInternalTextures;
  23763. private _createTextures;
  23764. /**
  23765. * Define the number of samples used if MSAA is enabled.
  23766. */
  23767. get samples(): number;
  23768. set samples(value: number);
  23769. /**
  23770. * Resize all the textures in the multi render target.
  23771. * Be careful as it will recreate all the data in the new texture.
  23772. * @param size Define the new size
  23773. */
  23774. resize(size: any): void;
  23775. /**
  23776. * Changes the number of render targets in this MRT
  23777. * Be careful as it will recreate all the data in the new texture.
  23778. * @param count new texture count
  23779. * @param options Specifies texture types and sampling modes for new textures
  23780. */
  23781. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23782. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23783. /**
  23784. * Dispose the render targets and their associated resources
  23785. */
  23786. dispose(): void;
  23787. /**
  23788. * Release all the underlying texture used as draw buffers.
  23789. */
  23790. releaseInternalTextures(): void;
  23791. }
  23792. }
  23793. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23794. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23795. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23796. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23797. /** @hidden */
  23798. export var imageProcessingPixelShader: {
  23799. name: string;
  23800. shader: string;
  23801. };
  23802. }
  23803. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23804. import { Nullable } from "babylonjs/types";
  23805. import { Color4 } from "babylonjs/Maths/math.color";
  23806. import { Camera } from "babylonjs/Cameras/camera";
  23807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23808. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23809. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23810. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23811. import { Engine } from "babylonjs/Engines/engine";
  23812. import "babylonjs/Shaders/imageProcessing.fragment";
  23813. import "babylonjs/Shaders/postprocess.vertex";
  23814. /**
  23815. * ImageProcessingPostProcess
  23816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23817. */
  23818. export class ImageProcessingPostProcess extends PostProcess {
  23819. /**
  23820. * Default configuration related to image processing available in the PBR Material.
  23821. */
  23822. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23823. /**
  23824. * Gets the image processing configuration used either in this material.
  23825. */
  23826. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23827. /**
  23828. * Sets the Default image processing configuration used either in the this material.
  23829. *
  23830. * If sets to null, the scene one is in use.
  23831. */
  23832. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23833. /**
  23834. * Keep track of the image processing observer to allow dispose and replace.
  23835. */
  23836. private _imageProcessingObserver;
  23837. /**
  23838. * Attaches a new image processing configuration to the PBR Material.
  23839. * @param configuration
  23840. */
  23841. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23842. /**
  23843. * If the post process is supported.
  23844. */
  23845. get isSupported(): boolean;
  23846. /**
  23847. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23848. */
  23849. get colorCurves(): Nullable<ColorCurves>;
  23850. /**
  23851. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23852. */
  23853. set colorCurves(value: Nullable<ColorCurves>);
  23854. /**
  23855. * Gets wether the color curves effect is enabled.
  23856. */
  23857. get colorCurvesEnabled(): boolean;
  23858. /**
  23859. * Sets wether the color curves effect is enabled.
  23860. */
  23861. set colorCurvesEnabled(value: boolean);
  23862. /**
  23863. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23864. */
  23865. get colorGradingTexture(): Nullable<BaseTexture>;
  23866. /**
  23867. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23868. */
  23869. set colorGradingTexture(value: Nullable<BaseTexture>);
  23870. /**
  23871. * Gets wether the color grading effect is enabled.
  23872. */
  23873. get colorGradingEnabled(): boolean;
  23874. /**
  23875. * Gets wether the color grading effect is enabled.
  23876. */
  23877. set colorGradingEnabled(value: boolean);
  23878. /**
  23879. * Gets exposure used in the effect.
  23880. */
  23881. get exposure(): number;
  23882. /**
  23883. * Sets exposure used in the effect.
  23884. */
  23885. set exposure(value: number);
  23886. /**
  23887. * Gets wether tonemapping is enabled or not.
  23888. */
  23889. get toneMappingEnabled(): boolean;
  23890. /**
  23891. * Sets wether tonemapping is enabled or not
  23892. */
  23893. set toneMappingEnabled(value: boolean);
  23894. /**
  23895. * Gets the type of tone mapping effect.
  23896. */
  23897. get toneMappingType(): number;
  23898. /**
  23899. * Sets the type of tone mapping effect.
  23900. */
  23901. set toneMappingType(value: number);
  23902. /**
  23903. * Gets contrast used in the effect.
  23904. */
  23905. get contrast(): number;
  23906. /**
  23907. * Sets contrast used in the effect.
  23908. */
  23909. set contrast(value: number);
  23910. /**
  23911. * Gets Vignette stretch size.
  23912. */
  23913. get vignetteStretch(): number;
  23914. /**
  23915. * Sets Vignette stretch size.
  23916. */
  23917. set vignetteStretch(value: number);
  23918. /**
  23919. * Gets Vignette centre X Offset.
  23920. */
  23921. get vignetteCentreX(): number;
  23922. /**
  23923. * Sets Vignette centre X Offset.
  23924. */
  23925. set vignetteCentreX(value: number);
  23926. /**
  23927. * Gets Vignette centre Y Offset.
  23928. */
  23929. get vignetteCentreY(): number;
  23930. /**
  23931. * Sets Vignette centre Y Offset.
  23932. */
  23933. set vignetteCentreY(value: number);
  23934. /**
  23935. * Gets Vignette weight or intensity of the vignette effect.
  23936. */
  23937. get vignetteWeight(): number;
  23938. /**
  23939. * Sets Vignette weight or intensity of the vignette effect.
  23940. */
  23941. set vignetteWeight(value: number);
  23942. /**
  23943. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23944. * if vignetteEnabled is set to true.
  23945. */
  23946. get vignetteColor(): Color4;
  23947. /**
  23948. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23949. * if vignetteEnabled is set to true.
  23950. */
  23951. set vignetteColor(value: Color4);
  23952. /**
  23953. * Gets Camera field of view used by the Vignette effect.
  23954. */
  23955. get vignetteCameraFov(): number;
  23956. /**
  23957. * Sets Camera field of view used by the Vignette effect.
  23958. */
  23959. set vignetteCameraFov(value: number);
  23960. /**
  23961. * Gets the vignette blend mode allowing different kind of effect.
  23962. */
  23963. get vignetteBlendMode(): number;
  23964. /**
  23965. * Sets the vignette blend mode allowing different kind of effect.
  23966. */
  23967. set vignetteBlendMode(value: number);
  23968. /**
  23969. * Gets wether the vignette effect is enabled.
  23970. */
  23971. get vignetteEnabled(): boolean;
  23972. /**
  23973. * Sets wether the vignette effect is enabled.
  23974. */
  23975. set vignetteEnabled(value: boolean);
  23976. private _fromLinearSpace;
  23977. /**
  23978. * Gets wether the input of the processing is in Gamma or Linear Space.
  23979. */
  23980. get fromLinearSpace(): boolean;
  23981. /**
  23982. * Sets wether the input of the processing is in Gamma or Linear Space.
  23983. */
  23984. set fromLinearSpace(value: boolean);
  23985. /**
  23986. * Defines cache preventing GC.
  23987. */
  23988. private _defines;
  23989. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23990. /**
  23991. * "ImageProcessingPostProcess"
  23992. * @returns "ImageProcessingPostProcess"
  23993. */
  23994. getClassName(): string;
  23995. /**
  23996. * @hidden
  23997. */
  23998. _updateParameters(): void;
  23999. dispose(camera?: Camera): void;
  24000. }
  24001. }
  24002. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24003. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24004. /**
  24005. * Interface for defining prepass effects in the prepass post-process pipeline
  24006. */
  24007. export interface PrePassEffectConfiguration {
  24008. /**
  24009. * Name of the effect
  24010. */
  24011. name: string;
  24012. /**
  24013. * Post process to attach for this effect
  24014. */
  24015. postProcess?: PostProcess;
  24016. /**
  24017. * Textures required in the MRT
  24018. */
  24019. texturesRequired: number[];
  24020. /**
  24021. * Is the effect enabled
  24022. */
  24023. enabled: boolean;
  24024. /**
  24025. * Disposes the effect configuration
  24026. */
  24027. dispose?: () => void;
  24028. /**
  24029. * Creates the associated post process
  24030. */
  24031. createPostProcess?: () => PostProcess;
  24032. }
  24033. }
  24034. declare module "babylonjs/Rendering/prePassRenderer" {
  24035. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  24036. import { Scene } from "babylonjs/scene";
  24037. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  24038. import { Effect } from "babylonjs/Materials/effect";
  24039. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24041. /**
  24042. * Renders a pre pass of the scene
  24043. * This means every mesh in the scene will be rendered to a render target texture
  24044. * And then this texture will be composited to the rendering canvas with post processes
  24045. * It is necessary for effects like subsurface scattering or deferred shading
  24046. */
  24047. export class PrePassRenderer {
  24048. /** @hidden */
  24049. static _SceneComponentInitialization: (scene: Scene) => void;
  24050. private _textureFormats;
  24051. /**
  24052. * To save performance, we can excluded skinned meshes from the prepass
  24053. */
  24054. excludedSkinnedMesh: AbstractMesh[];
  24055. private _textureIndices;
  24056. private _scene;
  24057. private _engine;
  24058. private _isDirty;
  24059. /**
  24060. * Number of textures in the multi render target texture where the scene is directly rendered
  24061. */
  24062. mrtCount: number;
  24063. /**
  24064. * The render target where the scene is directly rendered
  24065. */
  24066. prePassRT: MultiRenderTarget;
  24067. private _multiRenderAttachments;
  24068. private _defaultAttachments;
  24069. private _clearAttachments;
  24070. private _postProcesses;
  24071. private readonly _clearColor;
  24072. /**
  24073. * Image processing post process for composition
  24074. */
  24075. imageProcessingPostProcess: ImageProcessingPostProcess;
  24076. /**
  24077. * Configuration for prepass effects
  24078. */
  24079. private _effectConfigurations;
  24080. private _mrtFormats;
  24081. private _mrtLayout;
  24082. private _enabled;
  24083. /**
  24084. * Indicates if the prepass is enabled
  24085. */
  24086. get enabled(): boolean;
  24087. /**
  24088. * How many samples are used for MSAA of the scene render target
  24089. */
  24090. get samples(): number;
  24091. set samples(n: number);
  24092. /**
  24093. * Instanciates a prepass renderer
  24094. * @param scene The scene
  24095. */
  24096. constructor(scene: Scene);
  24097. private _initializeAttachments;
  24098. private _createCompositionEffect;
  24099. /**
  24100. * Indicates if rendering a prepass is supported
  24101. */
  24102. get isSupported(): boolean;
  24103. /**
  24104. * Sets the proper output textures to draw in the engine.
  24105. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24106. */
  24107. bindAttachmentsForEffect(effect: Effect): void;
  24108. /**
  24109. * @hidden
  24110. */
  24111. _beforeCameraDraw(): void;
  24112. /**
  24113. * @hidden
  24114. */
  24115. _afterCameraDraw(): void;
  24116. private _checkRTSize;
  24117. private _bindFrameBuffer;
  24118. /**
  24119. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24120. */
  24121. clear(): void;
  24122. private _setState;
  24123. /**
  24124. * Adds an effect configuration to the prepass.
  24125. * If an effect has already been added, it won't add it twice and will return the configuration
  24126. * already present.
  24127. * @param cfg the effect configuration
  24128. * @return the effect configuration now used by the prepass
  24129. */
  24130. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24131. /**
  24132. * Returns the index of a texture in the multi render target texture array.
  24133. * @param type Texture type
  24134. * @return The index
  24135. */
  24136. getIndex(type: number): number;
  24137. private _enable;
  24138. private _disable;
  24139. private _resetLayout;
  24140. private _resetPostProcessChain;
  24141. private _bindPostProcessChain;
  24142. /**
  24143. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24144. */
  24145. markAsDirty(): void;
  24146. /**
  24147. * Enables a texture on the MultiRenderTarget for prepass
  24148. */
  24149. private _enableTextures;
  24150. private _update;
  24151. private _markAllMaterialsAsPrePassDirty;
  24152. /**
  24153. * Disposes the prepass renderer.
  24154. */
  24155. dispose(): void;
  24156. }
  24157. }
  24158. declare module "babylonjs/PostProcesses/postProcess" {
  24159. import { Nullable } from "babylonjs/types";
  24160. import { SmartArray } from "babylonjs/Misc/smartArray";
  24161. import { Observable } from "babylonjs/Misc/observable";
  24162. import { Vector2 } from "babylonjs/Maths/math.vector";
  24163. import { Camera } from "babylonjs/Cameras/camera";
  24164. import { Effect } from "babylonjs/Materials/effect";
  24165. import "babylonjs/Shaders/postprocess.vertex";
  24166. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24167. import { Engine } from "babylonjs/Engines/engine";
  24168. import { Color4 } from "babylonjs/Maths/math.color";
  24169. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24170. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  24171. import { Scene } from "babylonjs/scene";
  24172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24173. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  24174. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24175. /**
  24176. * Size options for a post process
  24177. */
  24178. export type PostProcessOptions = {
  24179. width: number;
  24180. height: number;
  24181. };
  24182. /**
  24183. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24184. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24185. */
  24186. export class PostProcess {
  24187. /**
  24188. * Gets or sets the unique id of the post process
  24189. */
  24190. uniqueId: number;
  24191. /** Name of the PostProcess. */
  24192. name: string;
  24193. /**
  24194. * Width of the texture to apply the post process on
  24195. */
  24196. width: number;
  24197. /**
  24198. * Height of the texture to apply the post process on
  24199. */
  24200. height: number;
  24201. /**
  24202. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  24203. */
  24204. nodeMaterialSource: Nullable<NodeMaterial>;
  24205. /**
  24206. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24207. * @hidden
  24208. */
  24209. _outputTexture: Nullable<InternalTexture>;
  24210. /**
  24211. * Sampling mode used by the shader
  24212. * See https://doc.babylonjs.com/classes/3.1/texture
  24213. */
  24214. renderTargetSamplingMode: number;
  24215. /**
  24216. * Clear color to use when screen clearing
  24217. */
  24218. clearColor: Color4;
  24219. /**
  24220. * If the buffer needs to be cleared before applying the post process. (default: true)
  24221. * Should be set to false if shader will overwrite all previous pixels.
  24222. */
  24223. autoClear: boolean;
  24224. /**
  24225. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24226. */
  24227. alphaMode: number;
  24228. /**
  24229. * Sets the setAlphaBlendConstants of the babylon engine
  24230. */
  24231. alphaConstants: Color4;
  24232. /**
  24233. * Animations to be used for the post processing
  24234. */
  24235. animations: import("babylonjs/Animations/animation").Animation[];
  24236. /**
  24237. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24238. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24239. */
  24240. enablePixelPerfectMode: boolean;
  24241. /**
  24242. * Force the postprocess to be applied without taking in account viewport
  24243. */
  24244. forceFullscreenViewport: boolean;
  24245. /**
  24246. * List of inspectable custom properties (used by the Inspector)
  24247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24248. */
  24249. inspectableCustomProperties: IInspectable[];
  24250. /**
  24251. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24252. *
  24253. * | Value | Type | Description |
  24254. * | ----- | ----------------------------------- | ----------- |
  24255. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24256. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24257. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24258. *
  24259. */
  24260. scaleMode: number;
  24261. /**
  24262. * Force textures to be a power of two (default: false)
  24263. */
  24264. alwaysForcePOT: boolean;
  24265. private _samples;
  24266. /**
  24267. * Number of sample textures (default: 1)
  24268. */
  24269. get samples(): number;
  24270. set samples(n: number);
  24271. /**
  24272. * Modify the scale of the post process to be the same as the viewport (default: false)
  24273. */
  24274. adaptScaleToCurrentViewport: boolean;
  24275. private _camera;
  24276. protected _scene: Scene;
  24277. private _engine;
  24278. private _options;
  24279. private _reusable;
  24280. private _textureType;
  24281. private _textureFormat;
  24282. /**
  24283. * Smart array of input and output textures for the post process.
  24284. * @hidden
  24285. */
  24286. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24287. /**
  24288. * The index in _textures that corresponds to the output texture.
  24289. * @hidden
  24290. */
  24291. _currentRenderTextureInd: number;
  24292. private _effect;
  24293. private _samplers;
  24294. private _fragmentUrl;
  24295. private _vertexUrl;
  24296. private _parameters;
  24297. private _scaleRatio;
  24298. protected _indexParameters: any;
  24299. private _shareOutputWithPostProcess;
  24300. private _texelSize;
  24301. private _forcedOutputTexture;
  24302. /**
  24303. * Prepass configuration in case this post process needs a texture from prepass
  24304. * @hidden
  24305. */
  24306. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24307. /**
  24308. * Returns the fragment url or shader name used in the post process.
  24309. * @returns the fragment url or name in the shader store.
  24310. */
  24311. getEffectName(): string;
  24312. /**
  24313. * An event triggered when the postprocess is activated.
  24314. */
  24315. onActivateObservable: Observable<Camera>;
  24316. private _onActivateObserver;
  24317. /**
  24318. * A function that is added to the onActivateObservable
  24319. */
  24320. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24321. /**
  24322. * An event triggered when the postprocess changes its size.
  24323. */
  24324. onSizeChangedObservable: Observable<PostProcess>;
  24325. private _onSizeChangedObserver;
  24326. /**
  24327. * A function that is added to the onSizeChangedObservable
  24328. */
  24329. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24330. /**
  24331. * An event triggered when the postprocess applies its effect.
  24332. */
  24333. onApplyObservable: Observable<Effect>;
  24334. private _onApplyObserver;
  24335. /**
  24336. * A function that is added to the onApplyObservable
  24337. */
  24338. set onApply(callback: (effect: Effect) => void);
  24339. /**
  24340. * An event triggered before rendering the postprocess
  24341. */
  24342. onBeforeRenderObservable: Observable<Effect>;
  24343. private _onBeforeRenderObserver;
  24344. /**
  24345. * A function that is added to the onBeforeRenderObservable
  24346. */
  24347. set onBeforeRender(callback: (effect: Effect) => void);
  24348. /**
  24349. * An event triggered after rendering the postprocess
  24350. */
  24351. onAfterRenderObservable: Observable<Effect>;
  24352. private _onAfterRenderObserver;
  24353. /**
  24354. * A function that is added to the onAfterRenderObservable
  24355. */
  24356. set onAfterRender(callback: (efect: Effect) => void);
  24357. /**
  24358. * 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
  24359. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24360. */
  24361. get inputTexture(): InternalTexture;
  24362. set inputTexture(value: InternalTexture);
  24363. /**
  24364. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24365. * the only way to unset it is to use this function to restore its internal state
  24366. */
  24367. restoreDefaultInputTexture(): void;
  24368. /**
  24369. * Gets the camera which post process is applied to.
  24370. * @returns The camera the post process is applied to.
  24371. */
  24372. getCamera(): Camera;
  24373. /**
  24374. * Gets the texel size of the postprocess.
  24375. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24376. */
  24377. get texelSize(): Vector2;
  24378. /**
  24379. * Creates a new instance PostProcess
  24380. * @param name The name of the PostProcess.
  24381. * @param fragmentUrl The url of the fragment shader to be used.
  24382. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24383. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24384. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24385. * @param camera The camera to apply the render pass to.
  24386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24387. * @param engine The engine which the post process will be applied. (default: current engine)
  24388. * @param reusable If the post process can be reused on the same frame. (default: false)
  24389. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24390. * @param textureType Type of textures used when performing the post process. (default: 0)
  24391. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24392. * @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
  24393. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24394. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24395. */
  24396. 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);
  24397. /**
  24398. * Gets a string identifying the name of the class
  24399. * @returns "PostProcess" string
  24400. */
  24401. getClassName(): string;
  24402. /**
  24403. * Gets the engine which this post process belongs to.
  24404. * @returns The engine the post process was enabled with.
  24405. */
  24406. getEngine(): Engine;
  24407. /**
  24408. * The effect that is created when initializing the post process.
  24409. * @returns The created effect corresponding the the postprocess.
  24410. */
  24411. getEffect(): Effect;
  24412. /**
  24413. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24414. * @param postProcess The post process to share the output with.
  24415. * @returns This post process.
  24416. */
  24417. shareOutputWith(postProcess: PostProcess): PostProcess;
  24418. /**
  24419. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24420. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24421. */
  24422. useOwnOutput(): void;
  24423. /**
  24424. * Updates the effect with the current post process compile time values and recompiles the shader.
  24425. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24426. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24427. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24428. * @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
  24429. * @param onCompiled Called when the shader has been compiled.
  24430. * @param onError Called if there is an error when compiling a shader.
  24431. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24432. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24433. */
  24434. 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;
  24435. /**
  24436. * The post process is reusable if it can be used multiple times within one frame.
  24437. * @returns If the post process is reusable
  24438. */
  24439. isReusable(): boolean;
  24440. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24441. markTextureDirty(): void;
  24442. /**
  24443. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24444. * 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.
  24445. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24446. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24447. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24448. * @returns The target texture that was bound to be written to.
  24449. */
  24450. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24451. /**
  24452. * If the post process is supported.
  24453. */
  24454. get isSupported(): boolean;
  24455. /**
  24456. * The aspect ratio of the output texture.
  24457. */
  24458. get aspectRatio(): number;
  24459. /**
  24460. * Get a value indicating if the post-process is ready to be used
  24461. * @returns true if the post-process is ready (shader is compiled)
  24462. */
  24463. isReady(): boolean;
  24464. /**
  24465. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24466. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24467. */
  24468. apply(): Nullable<Effect>;
  24469. private _disposeTextures;
  24470. /**
  24471. * Sets the required values to the prepass renderer.
  24472. * @param prePassRenderer defines the prepass renderer to setup.
  24473. * @returns true if the pre pass is needed.
  24474. */
  24475. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24476. /**
  24477. * Disposes the post process.
  24478. * @param camera The camera to dispose the post process on.
  24479. */
  24480. dispose(camera?: Camera): void;
  24481. /**
  24482. * Serializes the particle system to a JSON object
  24483. * @returns the JSON object
  24484. */
  24485. serialize(): any;
  24486. /**
  24487. * Creates a material from parsed material data
  24488. * @param parsedPostProcess defines parsed post process data
  24489. * @param scene defines the hosting scene
  24490. * @param rootUrl defines the root URL to use to load textures
  24491. * @returns a new post process
  24492. */
  24493. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24494. }
  24495. }
  24496. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24497. /** @hidden */
  24498. export var kernelBlurVaryingDeclaration: {
  24499. name: string;
  24500. shader: string;
  24501. };
  24502. }
  24503. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24504. /** @hidden */
  24505. export var kernelBlurFragment: {
  24506. name: string;
  24507. shader: string;
  24508. };
  24509. }
  24510. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24511. /** @hidden */
  24512. export var kernelBlurFragment2: {
  24513. name: string;
  24514. shader: string;
  24515. };
  24516. }
  24517. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24518. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24519. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24521. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24522. /** @hidden */
  24523. export var kernelBlurPixelShader: {
  24524. name: string;
  24525. shader: string;
  24526. };
  24527. }
  24528. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24529. /** @hidden */
  24530. export var kernelBlurVertex: {
  24531. name: string;
  24532. shader: string;
  24533. };
  24534. }
  24535. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24537. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24538. /** @hidden */
  24539. export var kernelBlurVertexShader: {
  24540. name: string;
  24541. shader: string;
  24542. };
  24543. }
  24544. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24545. import { Vector2 } from "babylonjs/Maths/math.vector";
  24546. import { Nullable } from "babylonjs/types";
  24547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24548. import { Camera } from "babylonjs/Cameras/camera";
  24549. import { Effect } from "babylonjs/Materials/effect";
  24550. import { Engine } from "babylonjs/Engines/engine";
  24551. import "babylonjs/Shaders/kernelBlur.fragment";
  24552. import "babylonjs/Shaders/kernelBlur.vertex";
  24553. import { Scene } from "babylonjs/scene";
  24554. /**
  24555. * The Blur Post Process which blurs an image based on a kernel and direction.
  24556. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24557. */
  24558. export class BlurPostProcess extends PostProcess {
  24559. private blockCompilation;
  24560. protected _kernel: number;
  24561. protected _idealKernel: number;
  24562. protected _packedFloat: boolean;
  24563. private _staticDefines;
  24564. /** The direction in which to blur the image. */
  24565. direction: Vector2;
  24566. /**
  24567. * Sets the length in pixels of the blur sample region
  24568. */
  24569. set kernel(v: number);
  24570. /**
  24571. * Gets the length in pixels of the blur sample region
  24572. */
  24573. get kernel(): number;
  24574. /**
  24575. * Sets wether or not the blur needs to unpack/repack floats
  24576. */
  24577. set packedFloat(v: boolean);
  24578. /**
  24579. * Gets wether or not the blur is unpacking/repacking floats
  24580. */
  24581. get packedFloat(): boolean;
  24582. /**
  24583. * Gets a string identifying the name of the class
  24584. * @returns "BlurPostProcess" string
  24585. */
  24586. getClassName(): string;
  24587. /**
  24588. * Creates a new instance BlurPostProcess
  24589. * @param name The name of the effect.
  24590. * @param direction The direction in which to blur the image.
  24591. * @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.
  24592. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24593. * @param camera The camera to apply the render pass to.
  24594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24595. * @param engine The engine which the post process will be applied. (default: current engine)
  24596. * @param reusable If the post process can be reused on the same frame. (default: false)
  24597. * @param textureType Type of textures used when performing the post process. (default: 0)
  24598. * @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)
  24599. */
  24600. 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);
  24601. /**
  24602. * Updates the effect with the current post process compile time values and recompiles the shader.
  24603. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24604. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24605. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24606. * @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
  24607. * @param onCompiled Called when the shader has been compiled.
  24608. * @param onError Called if there is an error when compiling a shader.
  24609. */
  24610. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24611. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24612. /**
  24613. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24614. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24615. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24616. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24617. * The gaps between physical kernels are compensated for in the weighting of the samples
  24618. * @param idealKernel Ideal blur kernel.
  24619. * @return Nearest best kernel.
  24620. */
  24621. protected _nearestBestKernel(idealKernel: number): number;
  24622. /**
  24623. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24624. * @param x The point on the Gaussian distribution to sample.
  24625. * @return the value of the Gaussian function at x.
  24626. */
  24627. protected _gaussianWeight(x: number): number;
  24628. /**
  24629. * Generates a string that can be used as a floating point number in GLSL.
  24630. * @param x Value to print.
  24631. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24632. * @return GLSL float string.
  24633. */
  24634. protected _glslFloat(x: number, decimalFigures?: number): string;
  24635. /** @hidden */
  24636. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24637. }
  24638. }
  24639. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24640. import { Scene } from "babylonjs/scene";
  24641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24642. import { Plane } from "babylonjs/Maths/math.plane";
  24643. /**
  24644. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24645. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24646. * You can then easily use it as a reflectionTexture on a flat surface.
  24647. * In case the surface is not a plane, please consider relying on reflection probes.
  24648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24649. */
  24650. export class MirrorTexture extends RenderTargetTexture {
  24651. private scene;
  24652. /**
  24653. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24654. * 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.
  24655. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24656. */
  24657. mirrorPlane: Plane;
  24658. /**
  24659. * Define the blur ratio used to blur the reflection if needed.
  24660. */
  24661. set blurRatio(value: number);
  24662. get blurRatio(): number;
  24663. /**
  24664. * Define the adaptive blur kernel used to blur the reflection if needed.
  24665. * This will autocompute the closest best match for the `blurKernel`
  24666. */
  24667. set adaptiveBlurKernel(value: number);
  24668. /**
  24669. * Define the blur kernel used to blur the reflection if needed.
  24670. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24671. */
  24672. set blurKernel(value: number);
  24673. /**
  24674. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24675. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24676. */
  24677. set blurKernelX(value: number);
  24678. get blurKernelX(): number;
  24679. /**
  24680. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24682. */
  24683. set blurKernelY(value: number);
  24684. get blurKernelY(): number;
  24685. private _autoComputeBlurKernel;
  24686. protected _onRatioRescale(): void;
  24687. private _updateGammaSpace;
  24688. private _imageProcessingConfigChangeObserver;
  24689. private _transformMatrix;
  24690. private _mirrorMatrix;
  24691. private _savedViewMatrix;
  24692. private _blurX;
  24693. private _blurY;
  24694. private _adaptiveBlurKernel;
  24695. private _blurKernelX;
  24696. private _blurKernelY;
  24697. private _blurRatio;
  24698. /**
  24699. * Instantiates a Mirror Texture.
  24700. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24701. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24702. * You can then easily use it as a reflectionTexture on a flat surface.
  24703. * In case the surface is not a plane, please consider relying on reflection probes.
  24704. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24705. * @param name
  24706. * @param size
  24707. * @param scene
  24708. * @param generateMipMaps
  24709. * @param type
  24710. * @param samplingMode
  24711. * @param generateDepthBuffer
  24712. */
  24713. constructor(name: string, size: number | {
  24714. width: number;
  24715. height: number;
  24716. } | {
  24717. ratio: number;
  24718. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24719. private _preparePostProcesses;
  24720. /**
  24721. * Clone the mirror texture.
  24722. * @returns the cloned texture
  24723. */
  24724. clone(): MirrorTexture;
  24725. /**
  24726. * Serialize the texture to a JSON representation you could use in Parse later on
  24727. * @returns the serialized JSON representation
  24728. */
  24729. serialize(): any;
  24730. /**
  24731. * Dispose the texture and release its associated resources.
  24732. */
  24733. dispose(): void;
  24734. }
  24735. }
  24736. declare module "babylonjs/Materials/Textures/texture" {
  24737. import { Observable } from "babylonjs/Misc/observable";
  24738. import { Nullable } from "babylonjs/types";
  24739. import { Matrix } from "babylonjs/Maths/math.vector";
  24740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24741. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24742. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24743. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24744. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24746. import { Scene } from "babylonjs/scene";
  24747. /**
  24748. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24749. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24750. */
  24751. export class Texture extends BaseTexture {
  24752. /**
  24753. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24754. */
  24755. static SerializeBuffers: boolean;
  24756. /** @hidden */
  24757. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24758. /** @hidden */
  24759. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24760. /** @hidden */
  24761. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24762. /** nearest is mag = nearest and min = nearest and mip = linear */
  24763. static readonly NEAREST_SAMPLINGMODE: number;
  24764. /** nearest is mag = nearest and min = nearest and mip = linear */
  24765. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24767. static readonly BILINEAR_SAMPLINGMODE: number;
  24768. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24769. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24770. /** Trilinear is mag = linear and min = linear and mip = linear */
  24771. static readonly TRILINEAR_SAMPLINGMODE: number;
  24772. /** Trilinear is mag = linear and min = linear and mip = linear */
  24773. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24774. /** mag = nearest and min = nearest and mip = nearest */
  24775. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24776. /** mag = nearest and min = linear and mip = nearest */
  24777. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24778. /** mag = nearest and min = linear and mip = linear */
  24779. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24780. /** mag = nearest and min = linear and mip = none */
  24781. static readonly NEAREST_LINEAR: number;
  24782. /** mag = nearest and min = nearest and mip = none */
  24783. static readonly NEAREST_NEAREST: number;
  24784. /** mag = linear and min = nearest and mip = nearest */
  24785. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24786. /** mag = linear and min = nearest and mip = linear */
  24787. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24788. /** mag = linear and min = linear and mip = none */
  24789. static readonly LINEAR_LINEAR: number;
  24790. /** mag = linear and min = nearest and mip = none */
  24791. static readonly LINEAR_NEAREST: number;
  24792. /** Explicit coordinates mode */
  24793. static readonly EXPLICIT_MODE: number;
  24794. /** Spherical coordinates mode */
  24795. static readonly SPHERICAL_MODE: number;
  24796. /** Planar coordinates mode */
  24797. static readonly PLANAR_MODE: number;
  24798. /** Cubic coordinates mode */
  24799. static readonly CUBIC_MODE: number;
  24800. /** Projection coordinates mode */
  24801. static readonly PROJECTION_MODE: number;
  24802. /** Inverse Cubic coordinates mode */
  24803. static readonly SKYBOX_MODE: number;
  24804. /** Inverse Cubic coordinates mode */
  24805. static readonly INVCUBIC_MODE: number;
  24806. /** Equirectangular coordinates mode */
  24807. static readonly EQUIRECTANGULAR_MODE: number;
  24808. /** Equirectangular Fixed coordinates mode */
  24809. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24810. /** Equirectangular Fixed Mirrored coordinates mode */
  24811. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24812. /** Texture is not repeating outside of 0..1 UVs */
  24813. static readonly CLAMP_ADDRESSMODE: number;
  24814. /** Texture is repeating outside of 0..1 UVs */
  24815. static readonly WRAP_ADDRESSMODE: number;
  24816. /** Texture is repeating and mirrored */
  24817. static readonly MIRROR_ADDRESSMODE: number;
  24818. /**
  24819. * 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
  24820. */
  24821. static UseSerializedUrlIfAny: boolean;
  24822. /**
  24823. * Define the url of the texture.
  24824. */
  24825. url: Nullable<string>;
  24826. /**
  24827. * Define an offset on the texture to offset the u coordinates of the UVs
  24828. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24829. */
  24830. uOffset: number;
  24831. /**
  24832. * Define an offset on the texture to offset the v coordinates of the UVs
  24833. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24834. */
  24835. vOffset: number;
  24836. /**
  24837. * Define an offset on the texture to scale the u coordinates of the UVs
  24838. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24839. */
  24840. uScale: number;
  24841. /**
  24842. * Define an offset on the texture to scale the v coordinates of the UVs
  24843. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24844. */
  24845. vScale: number;
  24846. /**
  24847. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24848. * @see https://doc.babylonjs.com/how_to/more_materials
  24849. */
  24850. uAng: number;
  24851. /**
  24852. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24853. * @see https://doc.babylonjs.com/how_to/more_materials
  24854. */
  24855. vAng: number;
  24856. /**
  24857. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24858. * @see https://doc.babylonjs.com/how_to/more_materials
  24859. */
  24860. wAng: number;
  24861. /**
  24862. * Defines the center of rotation (U)
  24863. */
  24864. uRotationCenter: number;
  24865. /**
  24866. * Defines the center of rotation (V)
  24867. */
  24868. vRotationCenter: number;
  24869. /**
  24870. * Defines the center of rotation (W)
  24871. */
  24872. wRotationCenter: number;
  24873. /**
  24874. * Are mip maps generated for this texture or not.
  24875. */
  24876. get noMipmap(): boolean;
  24877. /**
  24878. * List of inspectable custom properties (used by the Inspector)
  24879. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24880. */
  24881. inspectableCustomProperties: Nullable<IInspectable[]>;
  24882. private _noMipmap;
  24883. /** @hidden */
  24884. _invertY: boolean;
  24885. private _rowGenerationMatrix;
  24886. private _cachedTextureMatrix;
  24887. private _projectionModeMatrix;
  24888. private _t0;
  24889. private _t1;
  24890. private _t2;
  24891. private _cachedUOffset;
  24892. private _cachedVOffset;
  24893. private _cachedUScale;
  24894. private _cachedVScale;
  24895. private _cachedUAng;
  24896. private _cachedVAng;
  24897. private _cachedWAng;
  24898. private _cachedProjectionMatrixId;
  24899. private _cachedCoordinatesMode;
  24900. /** @hidden */
  24901. protected _initialSamplingMode: number;
  24902. /** @hidden */
  24903. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24904. private _deleteBuffer;
  24905. protected _format: Nullable<number>;
  24906. private _delayedOnLoad;
  24907. private _delayedOnError;
  24908. private _mimeType?;
  24909. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24910. get mimeType(): string | undefined;
  24911. /**
  24912. * Observable triggered once the texture has been loaded.
  24913. */
  24914. onLoadObservable: Observable<Texture>;
  24915. protected _isBlocking: boolean;
  24916. /**
  24917. * Is the texture preventing material to render while loading.
  24918. * If false, a default texture will be used instead of the loading one during the preparation step.
  24919. */
  24920. set isBlocking(value: boolean);
  24921. get isBlocking(): boolean;
  24922. /**
  24923. * Get the current sampling mode associated with the texture.
  24924. */
  24925. get samplingMode(): number;
  24926. /**
  24927. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24928. */
  24929. get invertY(): boolean;
  24930. /**
  24931. * Instantiates a new texture.
  24932. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24933. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24934. * @param url defines the url of the picture to load as a texture
  24935. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24936. * @param noMipmap defines if the texture will require mip maps or not
  24937. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24938. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24939. * @param onLoad defines a callback triggered when the texture has been loaded
  24940. * @param onError defines a callback triggered when an error occurred during the loading session
  24941. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24942. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24943. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24944. * @param mimeType defines an optional mime type information
  24945. */
  24946. 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);
  24947. /**
  24948. * Update the url (and optional buffer) of this texture if url was null during construction.
  24949. * @param url the url of the texture
  24950. * @param buffer the buffer of the texture (defaults to null)
  24951. * @param onLoad callback called when the texture is loaded (defaults to null)
  24952. */
  24953. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24954. /**
  24955. * Finish the loading sequence of a texture flagged as delayed load.
  24956. * @hidden
  24957. */
  24958. delayLoad(): void;
  24959. private _prepareRowForTextureGeneration;
  24960. /**
  24961. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24962. * @returns the transform matrix of the texture.
  24963. */
  24964. getTextureMatrix(uBase?: number): Matrix;
  24965. /**
  24966. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24967. * @returns The reflection texture transform
  24968. */
  24969. getReflectionTextureMatrix(): Matrix;
  24970. /**
  24971. * Clones the texture.
  24972. * @returns the cloned texture
  24973. */
  24974. clone(): Texture;
  24975. /**
  24976. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24977. * @returns The JSON representation of the texture
  24978. */
  24979. serialize(): any;
  24980. /**
  24981. * Get the current class name of the texture useful for serialization or dynamic coding.
  24982. * @returns "Texture"
  24983. */
  24984. getClassName(): string;
  24985. /**
  24986. * Dispose the texture and release its associated resources.
  24987. */
  24988. dispose(): void;
  24989. /**
  24990. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24991. * @param parsedTexture Define the JSON representation of the texture
  24992. * @param scene Define the scene the parsed texture should be instantiated in
  24993. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24994. * @returns The parsed texture if successful
  24995. */
  24996. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24997. /**
  24998. * Creates a texture from its base 64 representation.
  24999. * @param data Define the base64 payload without the data: prefix
  25000. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25001. * @param scene Define the scene the texture should belong to
  25002. * @param noMipmap Forces the texture to not create mip map information if true
  25003. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25004. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25005. * @param onLoad define a callback triggered when the texture has been loaded
  25006. * @param onError define a callback triggered when an error occurred during the loading session
  25007. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25008. * @returns the created texture
  25009. */
  25010. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  25011. /**
  25012. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  25013. * @param data Define the base64 payload without the data: prefix
  25014. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25015. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  25016. * @param scene Define the scene the texture should belong to
  25017. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  25018. * @param noMipmap Forces the texture to not create mip map information if true
  25019. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25020. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25021. * @param onLoad define a callback triggered when the texture has been loaded
  25022. * @param onError define a callback triggered when an error occurred during the loading session
  25023. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25024. * @returns the created texture
  25025. */
  25026. 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;
  25027. }
  25028. }
  25029. declare module "babylonjs/PostProcesses/postProcessManager" {
  25030. import { Nullable } from "babylonjs/types";
  25031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25033. import { Scene } from "babylonjs/scene";
  25034. /**
  25035. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25036. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25037. */
  25038. export class PostProcessManager {
  25039. private _scene;
  25040. private _indexBuffer;
  25041. private _vertexBuffers;
  25042. /**
  25043. * Creates a new instance PostProcess
  25044. * @param scene The scene that the post process is associated with.
  25045. */
  25046. constructor(scene: Scene);
  25047. private _prepareBuffers;
  25048. private _buildIndexBuffer;
  25049. /**
  25050. * Rebuilds the vertex buffers of the manager.
  25051. * @hidden
  25052. */
  25053. _rebuild(): void;
  25054. /**
  25055. * Prepares a frame to be run through a post process.
  25056. * @param sourceTexture The input texture to the post procesess. (default: null)
  25057. * @param postProcesses An array of post processes to be run. (default: null)
  25058. * @returns True if the post processes were able to be run.
  25059. * @hidden
  25060. */
  25061. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  25062. /**
  25063. * Manually render a set of post processes to a texture.
  25064. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  25065. * @param postProcesses An array of post processes to be run.
  25066. * @param targetTexture The target texture to render to.
  25067. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25068. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  25069. * @param lodLevel defines which lod of the texture to render to
  25070. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  25071. */
  25072. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  25073. /**
  25074. * Finalize the result of the output of the postprocesses.
  25075. * @param doNotPresent If true the result will not be displayed to the screen.
  25076. * @param targetTexture The target texture to render to.
  25077. * @param faceIndex The index of the face to bind the target texture to.
  25078. * @param postProcesses The array of post processes to render.
  25079. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25080. * @hidden
  25081. */
  25082. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25083. /**
  25084. * Disposes of the post process manager.
  25085. */
  25086. dispose(): void;
  25087. }
  25088. }
  25089. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  25090. import { Observable } from "babylonjs/Misc/observable";
  25091. import { SmartArray } from "babylonjs/Misc/smartArray";
  25092. import { Nullable, Immutable } from "babylonjs/types";
  25093. import { Camera } from "babylonjs/Cameras/camera";
  25094. import { Scene } from "babylonjs/scene";
  25095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25096. import { Color4 } from "babylonjs/Maths/math.color";
  25097. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  25098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25100. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25101. import { Texture } from "babylonjs/Materials/Textures/texture";
  25102. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25103. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  25104. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25105. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  25106. import { Engine } from "babylonjs/Engines/engine";
  25107. /**
  25108. * This Helps creating a texture that will be created from a camera in your scene.
  25109. * It is basically a dynamic texture that could be used to create special effects for instance.
  25110. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  25111. */
  25112. export class RenderTargetTexture extends Texture {
  25113. /**
  25114. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  25115. */
  25116. static readonly REFRESHRATE_RENDER_ONCE: number;
  25117. /**
  25118. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  25119. */
  25120. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  25121. /**
  25122. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  25123. * the central point of your effect and can save a lot of performances.
  25124. */
  25125. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  25126. /**
  25127. * Use this predicate to dynamically define the list of mesh you want to render.
  25128. * If set, the renderList property will be overwritten.
  25129. */
  25130. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  25131. private _renderList;
  25132. /**
  25133. * Use this list to define the list of mesh you want to render.
  25134. */
  25135. get renderList(): Nullable<Array<AbstractMesh>>;
  25136. set renderList(value: Nullable<Array<AbstractMesh>>);
  25137. /**
  25138. * Use this function to overload the renderList array at rendering time.
  25139. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  25140. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  25141. * the cube (if the RTT is a cube, else layerOrFace=0).
  25142. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  25143. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  25144. * hold dummy elements!
  25145. */
  25146. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  25147. private _hookArray;
  25148. /**
  25149. * Define if particles should be rendered in your texture.
  25150. */
  25151. renderParticles: boolean;
  25152. /**
  25153. * Define if sprites should be rendered in your texture.
  25154. */
  25155. renderSprites: boolean;
  25156. /**
  25157. * Define the camera used to render the texture.
  25158. */
  25159. activeCamera: Nullable<Camera>;
  25160. /**
  25161. * Override the mesh isReady function with your own one.
  25162. */
  25163. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  25164. /**
  25165. * Override the render function of the texture with your own one.
  25166. */
  25167. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  25168. /**
  25169. * Define if camera post processes should be use while rendering the texture.
  25170. */
  25171. useCameraPostProcesses: boolean;
  25172. /**
  25173. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  25174. */
  25175. ignoreCameraViewport: boolean;
  25176. private _postProcessManager;
  25177. private _postProcesses;
  25178. private _resizeObserver;
  25179. /**
  25180. * An event triggered when the texture is unbind.
  25181. */
  25182. onBeforeBindObservable: Observable<RenderTargetTexture>;
  25183. /**
  25184. * An event triggered when the texture is unbind.
  25185. */
  25186. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  25187. private _onAfterUnbindObserver;
  25188. /**
  25189. * Set a after unbind callback in the texture.
  25190. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  25191. */
  25192. set onAfterUnbind(callback: () => void);
  25193. /**
  25194. * An event triggered before rendering the texture
  25195. */
  25196. onBeforeRenderObservable: Observable<number>;
  25197. private _onBeforeRenderObserver;
  25198. /**
  25199. * Set a before render callback in the texture.
  25200. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  25201. */
  25202. set onBeforeRender(callback: (faceIndex: number) => void);
  25203. /**
  25204. * An event triggered after rendering the texture
  25205. */
  25206. onAfterRenderObservable: Observable<number>;
  25207. private _onAfterRenderObserver;
  25208. /**
  25209. * Set a after render callback in the texture.
  25210. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  25211. */
  25212. set onAfterRender(callback: (faceIndex: number) => void);
  25213. /**
  25214. * An event triggered after the texture clear
  25215. */
  25216. onClearObservable: Observable<Engine>;
  25217. private _onClearObserver;
  25218. /**
  25219. * Set a clear callback in the texture.
  25220. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  25221. */
  25222. set onClear(callback: (Engine: Engine) => void);
  25223. /**
  25224. * An event triggered when the texture is resized.
  25225. */
  25226. onResizeObservable: Observable<RenderTargetTexture>;
  25227. /**
  25228. * Define the clear color of the Render Target if it should be different from the scene.
  25229. */
  25230. clearColor: Color4;
  25231. protected _size: number | {
  25232. width: number;
  25233. height: number;
  25234. layers?: number;
  25235. };
  25236. protected _initialSizeParameter: number | {
  25237. width: number;
  25238. height: number;
  25239. } | {
  25240. ratio: number;
  25241. };
  25242. protected _sizeRatio: Nullable<number>;
  25243. /** @hidden */
  25244. _generateMipMaps: boolean;
  25245. protected _renderingManager: RenderingManager;
  25246. /** @hidden */
  25247. _waitingRenderList?: string[];
  25248. protected _doNotChangeAspectRatio: boolean;
  25249. protected _currentRefreshId: number;
  25250. protected _refreshRate: number;
  25251. protected _textureMatrix: Matrix;
  25252. protected _samples: number;
  25253. protected _renderTargetOptions: RenderTargetCreationOptions;
  25254. /**
  25255. * Gets render target creation options that were used.
  25256. */
  25257. get renderTargetOptions(): RenderTargetCreationOptions;
  25258. protected _onRatioRescale(): void;
  25259. /**
  25260. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  25261. * It must define where the camera used to render the texture is set
  25262. */
  25263. boundingBoxPosition: Vector3;
  25264. private _boundingBoxSize;
  25265. /**
  25266. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  25267. * When defined, the cubemap will switch to local mode
  25268. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  25269. * @example https://www.babylonjs-playground.com/#RNASML
  25270. */
  25271. set boundingBoxSize(value: Vector3);
  25272. get boundingBoxSize(): Vector3;
  25273. /**
  25274. * In case the RTT has been created with a depth texture, get the associated
  25275. * depth texture.
  25276. * Otherwise, return null.
  25277. */
  25278. get depthStencilTexture(): Nullable<InternalTexture>;
  25279. /**
  25280. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  25281. * or used a shadow, depth texture...
  25282. * @param name The friendly name of the texture
  25283. * @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)
  25284. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  25285. * @param generateMipMaps True if mip maps need to be generated after render.
  25286. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  25287. * @param type The type of the buffer in the RTT (int, half float, float...)
  25288. * @param isCube True if a cube texture needs to be created
  25289. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  25290. * @param generateDepthBuffer True to generate a depth buffer
  25291. * @param generateStencilBuffer True to generate a stencil buffer
  25292. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  25293. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  25294. * @param delayAllocation if the texture allocation should be delayed (default: false)
  25295. */
  25296. constructor(name: string, size: number | {
  25297. width: number;
  25298. height: number;
  25299. layers?: number;
  25300. } | {
  25301. ratio: number;
  25302. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  25303. /**
  25304. * Creates a depth stencil texture.
  25305. * This is only available in WebGL 2 or with the depth texture extension available.
  25306. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  25307. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  25308. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  25309. */
  25310. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  25311. private _processSizeParameter;
  25312. /**
  25313. * Define the number of samples to use in case of MSAA.
  25314. * It defaults to one meaning no MSAA has been enabled.
  25315. */
  25316. get samples(): number;
  25317. set samples(value: number);
  25318. /**
  25319. * Resets the refresh counter of the texture and start bak from scratch.
  25320. * Could be useful to regenerate the texture if it is setup to render only once.
  25321. */
  25322. resetRefreshCounter(): void;
  25323. /**
  25324. * Define the refresh rate of the texture or the rendering frequency.
  25325. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  25326. */
  25327. get refreshRate(): number;
  25328. set refreshRate(value: number);
  25329. /**
  25330. * Adds a post process to the render target rendering passes.
  25331. * @param postProcess define the post process to add
  25332. */
  25333. addPostProcess(postProcess: PostProcess): void;
  25334. /**
  25335. * Clear all the post processes attached to the render target
  25336. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  25337. */
  25338. clearPostProcesses(dispose?: boolean): void;
  25339. /**
  25340. * Remove one of the post process from the list of attached post processes to the texture
  25341. * @param postProcess define the post process to remove from the list
  25342. */
  25343. removePostProcess(postProcess: PostProcess): void;
  25344. /** @hidden */
  25345. _shouldRender(): boolean;
  25346. /**
  25347. * Gets the actual render size of the texture.
  25348. * @returns the width of the render size
  25349. */
  25350. getRenderSize(): number;
  25351. /**
  25352. * Gets the actual render width of the texture.
  25353. * @returns the width of the render size
  25354. */
  25355. getRenderWidth(): number;
  25356. /**
  25357. * Gets the actual render height of the texture.
  25358. * @returns the height of the render size
  25359. */
  25360. getRenderHeight(): number;
  25361. /**
  25362. * Gets the actual number of layers of the texture.
  25363. * @returns the number of layers
  25364. */
  25365. getRenderLayers(): number;
  25366. /**
  25367. * Get if the texture can be rescaled or not.
  25368. */
  25369. get canRescale(): boolean;
  25370. /**
  25371. * Resize the texture using a ratio.
  25372. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  25373. */
  25374. scale(ratio: number): void;
  25375. /**
  25376. * Get the texture reflection matrix used to rotate/transform the reflection.
  25377. * @returns the reflection matrix
  25378. */
  25379. getReflectionTextureMatrix(): Matrix;
  25380. /**
  25381. * Resize the texture to a new desired size.
  25382. * Be carrefull as it will recreate all the data in the new texture.
  25383. * @param size Define the new size. It can be:
  25384. * - a number for squared texture,
  25385. * - an object containing { width: number, height: number }
  25386. * - or an object containing a ratio { ratio: number }
  25387. */
  25388. resize(size: number | {
  25389. width: number;
  25390. height: number;
  25391. } | {
  25392. ratio: number;
  25393. }): void;
  25394. private _defaultRenderListPrepared;
  25395. /**
  25396. * Renders all the objects from the render list into the texture.
  25397. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  25398. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  25399. */
  25400. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  25401. private _bestReflectionRenderTargetDimension;
  25402. private _prepareRenderingManager;
  25403. /**
  25404. * @hidden
  25405. * @param faceIndex face index to bind to if this is a cubetexture
  25406. * @param layer defines the index of the texture to bind in the array
  25407. */
  25408. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  25409. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25410. private renderToTarget;
  25411. /**
  25412. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25413. * This allowed control for front to back rendering or reversly depending of the special needs.
  25414. *
  25415. * @param renderingGroupId The rendering group id corresponding to its index
  25416. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25417. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25418. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25419. */
  25420. 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;
  25421. /**
  25422. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25423. *
  25424. * @param renderingGroupId The rendering group id corresponding to its index
  25425. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25426. */
  25427. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25428. /**
  25429. * Clones the texture.
  25430. * @returns the cloned texture
  25431. */
  25432. clone(): RenderTargetTexture;
  25433. /**
  25434. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  25435. * @returns The JSON representation of the texture
  25436. */
  25437. serialize(): any;
  25438. /**
  25439. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  25440. */
  25441. disposeFramebufferObjects(): void;
  25442. /**
  25443. * Dispose the texture and release its associated resources.
  25444. */
  25445. dispose(): void;
  25446. /** @hidden */
  25447. _rebuild(): void;
  25448. /**
  25449. * Clear the info related to rendering groups preventing retention point in material dispose.
  25450. */
  25451. freeRenderingGroups(): void;
  25452. /**
  25453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  25454. * @returns the view count
  25455. */
  25456. getViewCount(): number;
  25457. }
  25458. }
  25459. declare module "babylonjs/Misc/guid" {
  25460. /**
  25461. * Class used to manipulate GUIDs
  25462. */
  25463. export class GUID {
  25464. /**
  25465. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25466. * Be aware Math.random() could cause collisions, but:
  25467. * "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"
  25468. * @returns a pseudo random id
  25469. */
  25470. static RandomId(): string;
  25471. }
  25472. }
  25473. declare module "babylonjs/Materials/shadowDepthWrapper" {
  25474. import { Nullable } from "babylonjs/types";
  25475. import { Scene } from "babylonjs/scene";
  25476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25477. import { Material } from "babylonjs/Materials/material";
  25478. import { Effect } from "babylonjs/Materials/effect";
  25479. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  25480. /**
  25481. * Options to be used when creating a shadow depth material
  25482. */
  25483. export interface IIOptionShadowDepthMaterial {
  25484. /** Variables in the vertex shader code that need to have their names remapped.
  25485. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  25486. * "var_name" should be either: worldPos or vNormalW
  25487. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  25488. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  25489. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  25490. */
  25491. remappedVariables?: string[];
  25492. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  25493. standalone?: boolean;
  25494. }
  25495. /**
  25496. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  25497. */
  25498. export class ShadowDepthWrapper {
  25499. private _scene;
  25500. private _options?;
  25501. private _baseMaterial;
  25502. private _onEffectCreatedObserver;
  25503. private _subMeshToEffect;
  25504. private _subMeshToDepthEffect;
  25505. private _meshes;
  25506. /** @hidden */
  25507. _matriceNames: any;
  25508. /** Gets the standalone status of the wrapper */
  25509. get standalone(): boolean;
  25510. /** Gets the base material the wrapper is built upon */
  25511. get baseMaterial(): Material;
  25512. /**
  25513. * Instantiate a new shadow depth wrapper.
  25514. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  25515. * generate the shadow depth map. For more information, please refer to the documentation:
  25516. * https://doc.babylonjs.com/babylon101/shadows
  25517. * @param baseMaterial Material to wrap
  25518. * @param scene Define the scene the material belongs to
  25519. * @param options Options used to create the wrapper
  25520. */
  25521. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  25522. /**
  25523. * Gets the effect to use to generate the depth map
  25524. * @param subMesh subMesh to get the effect for
  25525. * @param shadowGenerator shadow generator to get the effect for
  25526. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  25527. */
  25528. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  25529. /**
  25530. * Specifies that the submesh is ready to be used for depth rendering
  25531. * @param subMesh submesh to check
  25532. * @param defines the list of defines to take into account when checking the effect
  25533. * @param shadowGenerator combined with subMesh, it defines the effect to check
  25534. * @param useInstances specifies that instances should be used
  25535. * @returns a boolean indicating that the submesh is ready or not
  25536. */
  25537. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  25538. /**
  25539. * Disposes the resources
  25540. */
  25541. dispose(): void;
  25542. private _makeEffect;
  25543. }
  25544. }
  25545. declare module "babylonjs/Materials/material" {
  25546. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25547. import { SmartArray } from "babylonjs/Misc/smartArray";
  25548. import { Observable } from "babylonjs/Misc/observable";
  25549. import { Nullable } from "babylonjs/types";
  25550. import { Scene } from "babylonjs/scene";
  25551. import { Matrix } from "babylonjs/Maths/math.vector";
  25552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25554. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25555. import { Effect } from "babylonjs/Materials/effect";
  25556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25557. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25558. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25559. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25560. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25561. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25562. import { Mesh } from "babylonjs/Meshes/mesh";
  25563. import { Animation } from "babylonjs/Animations/animation";
  25564. /**
  25565. * Options for compiling materials.
  25566. */
  25567. export interface IMaterialCompilationOptions {
  25568. /**
  25569. * Defines whether clip planes are enabled.
  25570. */
  25571. clipPlane: boolean;
  25572. /**
  25573. * Defines whether instances are enabled.
  25574. */
  25575. useInstances: boolean;
  25576. }
  25577. /**
  25578. * Options passed when calling customShaderNameResolve
  25579. */
  25580. export interface ICustomShaderNameResolveOptions {
  25581. /**
  25582. * 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
  25583. */
  25584. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25585. }
  25586. /**
  25587. * Base class for the main features of a material in Babylon.js
  25588. */
  25589. export class Material implements IAnimatable {
  25590. /**
  25591. * Returns the triangle fill mode
  25592. */
  25593. static readonly TriangleFillMode: number;
  25594. /**
  25595. * Returns the wireframe mode
  25596. */
  25597. static readonly WireFrameFillMode: number;
  25598. /**
  25599. * Returns the point fill mode
  25600. */
  25601. static readonly PointFillMode: number;
  25602. /**
  25603. * Returns the point list draw mode
  25604. */
  25605. static readonly PointListDrawMode: number;
  25606. /**
  25607. * Returns the line list draw mode
  25608. */
  25609. static readonly LineListDrawMode: number;
  25610. /**
  25611. * Returns the line loop draw mode
  25612. */
  25613. static readonly LineLoopDrawMode: number;
  25614. /**
  25615. * Returns the line strip draw mode
  25616. */
  25617. static readonly LineStripDrawMode: number;
  25618. /**
  25619. * Returns the triangle strip draw mode
  25620. */
  25621. static readonly TriangleStripDrawMode: number;
  25622. /**
  25623. * Returns the triangle fan draw mode
  25624. */
  25625. static readonly TriangleFanDrawMode: number;
  25626. /**
  25627. * Stores the clock-wise side orientation
  25628. */
  25629. static readonly ClockWiseSideOrientation: number;
  25630. /**
  25631. * Stores the counter clock-wise side orientation
  25632. */
  25633. static readonly CounterClockWiseSideOrientation: number;
  25634. /**
  25635. * The dirty texture flag value
  25636. */
  25637. static readonly TextureDirtyFlag: number;
  25638. /**
  25639. * The dirty light flag value
  25640. */
  25641. static readonly LightDirtyFlag: number;
  25642. /**
  25643. * The dirty fresnel flag value
  25644. */
  25645. static readonly FresnelDirtyFlag: number;
  25646. /**
  25647. * The dirty attribute flag value
  25648. */
  25649. static readonly AttributesDirtyFlag: number;
  25650. /**
  25651. * The dirty misc flag value
  25652. */
  25653. static readonly MiscDirtyFlag: number;
  25654. /**
  25655. * The dirty prepass flag value
  25656. */
  25657. static readonly PrePassDirtyFlag: number;
  25658. /**
  25659. * The all dirty flag value
  25660. */
  25661. static readonly AllDirtyFlag: number;
  25662. /**
  25663. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25664. */
  25665. static readonly MATERIAL_OPAQUE: number;
  25666. /**
  25667. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25668. */
  25669. static readonly MATERIAL_ALPHATEST: number;
  25670. /**
  25671. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25672. */
  25673. static readonly MATERIAL_ALPHABLEND: number;
  25674. /**
  25675. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25676. * They are also discarded below the alpha cutoff threshold to improve performances.
  25677. */
  25678. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25679. /**
  25680. * The Whiteout method is used to blend normals.
  25681. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25682. */
  25683. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25684. /**
  25685. * The Reoriented Normal Mapping method is used to blend normals.
  25686. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25687. */
  25688. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25689. /**
  25690. * Custom callback helping to override the default shader used in the material.
  25691. */
  25692. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25693. /**
  25694. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25695. */
  25696. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25697. /**
  25698. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25699. * This means that the material can keep using a previous shader while a new one is being compiled.
  25700. * This is mostly used when shader parallel compilation is supported (true by default)
  25701. */
  25702. allowShaderHotSwapping: boolean;
  25703. /**
  25704. * The ID of the material
  25705. */
  25706. id: string;
  25707. /**
  25708. * Gets or sets the unique id of the material
  25709. */
  25710. uniqueId: number;
  25711. /**
  25712. * The name of the material
  25713. */
  25714. name: string;
  25715. /**
  25716. * Gets or sets user defined metadata
  25717. */
  25718. metadata: any;
  25719. /**
  25720. * For internal use only. Please do not use.
  25721. */
  25722. reservedDataStore: any;
  25723. /**
  25724. * Specifies if the ready state should be checked on each call
  25725. */
  25726. checkReadyOnEveryCall: boolean;
  25727. /**
  25728. * Specifies if the ready state should be checked once
  25729. */
  25730. checkReadyOnlyOnce: boolean;
  25731. /**
  25732. * The state of the material
  25733. */
  25734. state: string;
  25735. /**
  25736. * If the material can be rendered to several textures with MRT extension
  25737. */
  25738. get canRenderToMRT(): boolean;
  25739. /**
  25740. * The alpha value of the material
  25741. */
  25742. protected _alpha: number;
  25743. /**
  25744. * List of inspectable custom properties (used by the Inspector)
  25745. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25746. */
  25747. inspectableCustomProperties: IInspectable[];
  25748. /**
  25749. * Sets the alpha value of the material
  25750. */
  25751. set alpha(value: number);
  25752. /**
  25753. * Gets the alpha value of the material
  25754. */
  25755. get alpha(): number;
  25756. /**
  25757. * Specifies if back face culling is enabled
  25758. */
  25759. protected _backFaceCulling: boolean;
  25760. /**
  25761. * Sets the back-face culling state
  25762. */
  25763. set backFaceCulling(value: boolean);
  25764. /**
  25765. * Gets the back-face culling state
  25766. */
  25767. get backFaceCulling(): boolean;
  25768. /**
  25769. * Stores the value for side orientation
  25770. */
  25771. sideOrientation: number;
  25772. /**
  25773. * Callback triggered when the material is compiled
  25774. */
  25775. onCompiled: Nullable<(effect: Effect) => void>;
  25776. /**
  25777. * Callback triggered when an error occurs
  25778. */
  25779. onError: Nullable<(effect: Effect, errors: string) => void>;
  25780. /**
  25781. * Callback triggered to get the render target textures
  25782. */
  25783. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25784. /**
  25785. * Gets a boolean indicating that current material needs to register RTT
  25786. */
  25787. get hasRenderTargetTextures(): boolean;
  25788. /**
  25789. * Specifies if the material should be serialized
  25790. */
  25791. doNotSerialize: boolean;
  25792. /**
  25793. * @hidden
  25794. */
  25795. _storeEffectOnSubMeshes: boolean;
  25796. /**
  25797. * Stores the animations for the material
  25798. */
  25799. animations: Nullable<Array<Animation>>;
  25800. /**
  25801. * An event triggered when the material is disposed
  25802. */
  25803. onDisposeObservable: Observable<Material>;
  25804. /**
  25805. * An observer which watches for dispose events
  25806. */
  25807. private _onDisposeObserver;
  25808. private _onUnBindObservable;
  25809. /**
  25810. * Called during a dispose event
  25811. */
  25812. set onDispose(callback: () => void);
  25813. private _onBindObservable;
  25814. /**
  25815. * An event triggered when the material is bound
  25816. */
  25817. get onBindObservable(): Observable<AbstractMesh>;
  25818. /**
  25819. * An observer which watches for bind events
  25820. */
  25821. private _onBindObserver;
  25822. /**
  25823. * Called during a bind event
  25824. */
  25825. set onBind(callback: (Mesh: AbstractMesh) => void);
  25826. /**
  25827. * An event triggered when the material is unbound
  25828. */
  25829. get onUnBindObservable(): Observable<Material>;
  25830. protected _onEffectCreatedObservable: Nullable<Observable<{
  25831. effect: Effect;
  25832. subMesh: Nullable<SubMesh>;
  25833. }>>;
  25834. /**
  25835. * An event triggered when the effect is (re)created
  25836. */
  25837. get onEffectCreatedObservable(): Observable<{
  25838. effect: Effect;
  25839. subMesh: Nullable<SubMesh>;
  25840. }>;
  25841. /**
  25842. * Stores the value of the alpha mode
  25843. */
  25844. private _alphaMode;
  25845. /**
  25846. * Sets the value of the alpha mode.
  25847. *
  25848. * | Value | Type | Description |
  25849. * | --- | --- | --- |
  25850. * | 0 | ALPHA_DISABLE | |
  25851. * | 1 | ALPHA_ADD | |
  25852. * | 2 | ALPHA_COMBINE | |
  25853. * | 3 | ALPHA_SUBTRACT | |
  25854. * | 4 | ALPHA_MULTIPLY | |
  25855. * | 5 | ALPHA_MAXIMIZED | |
  25856. * | 6 | ALPHA_ONEONE | |
  25857. * | 7 | ALPHA_PREMULTIPLIED | |
  25858. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25859. * | 9 | ALPHA_INTERPOLATE | |
  25860. * | 10 | ALPHA_SCREENMODE | |
  25861. *
  25862. */
  25863. set alphaMode(value: number);
  25864. /**
  25865. * Gets the value of the alpha mode
  25866. */
  25867. get alphaMode(): number;
  25868. /**
  25869. * Stores the state of the need depth pre-pass value
  25870. */
  25871. private _needDepthPrePass;
  25872. /**
  25873. * Sets the need depth pre-pass value
  25874. */
  25875. set needDepthPrePass(value: boolean);
  25876. /**
  25877. * Gets the depth pre-pass value
  25878. */
  25879. get needDepthPrePass(): boolean;
  25880. /**
  25881. * Specifies if depth writing should be disabled
  25882. */
  25883. disableDepthWrite: boolean;
  25884. /**
  25885. * Specifies if color writing should be disabled
  25886. */
  25887. disableColorWrite: boolean;
  25888. /**
  25889. * Specifies if depth writing should be forced
  25890. */
  25891. forceDepthWrite: boolean;
  25892. /**
  25893. * Specifies the depth function that should be used. 0 means the default engine function
  25894. */
  25895. depthFunction: number;
  25896. /**
  25897. * Specifies if there should be a separate pass for culling
  25898. */
  25899. separateCullingPass: boolean;
  25900. /**
  25901. * Stores the state specifing if fog should be enabled
  25902. */
  25903. private _fogEnabled;
  25904. /**
  25905. * Sets the state for enabling fog
  25906. */
  25907. set fogEnabled(value: boolean);
  25908. /**
  25909. * Gets the value of the fog enabled state
  25910. */
  25911. get fogEnabled(): boolean;
  25912. /**
  25913. * Stores the size of points
  25914. */
  25915. pointSize: number;
  25916. /**
  25917. * Stores the z offset value
  25918. */
  25919. zOffset: number;
  25920. get wireframe(): boolean;
  25921. /**
  25922. * Sets the state of wireframe mode
  25923. */
  25924. set wireframe(value: boolean);
  25925. /**
  25926. * Gets the value specifying if point clouds are enabled
  25927. */
  25928. get pointsCloud(): boolean;
  25929. /**
  25930. * Sets the state of point cloud mode
  25931. */
  25932. set pointsCloud(value: boolean);
  25933. /**
  25934. * Gets the material fill mode
  25935. */
  25936. get fillMode(): number;
  25937. /**
  25938. * Sets the material fill mode
  25939. */
  25940. set fillMode(value: number);
  25941. /**
  25942. * @hidden
  25943. * Stores the effects for the material
  25944. */
  25945. _effect: Nullable<Effect>;
  25946. /**
  25947. * Specifies if uniform buffers should be used
  25948. */
  25949. private _useUBO;
  25950. /**
  25951. * Stores a reference to the scene
  25952. */
  25953. private _scene;
  25954. /**
  25955. * Stores the fill mode state
  25956. */
  25957. private _fillMode;
  25958. /**
  25959. * Specifies if the depth write state should be cached
  25960. */
  25961. private _cachedDepthWriteState;
  25962. /**
  25963. * Specifies if the color write state should be cached
  25964. */
  25965. private _cachedColorWriteState;
  25966. /**
  25967. * Specifies if the depth function state should be cached
  25968. */
  25969. private _cachedDepthFunctionState;
  25970. /**
  25971. * Stores the uniform buffer
  25972. */
  25973. protected _uniformBuffer: UniformBuffer;
  25974. /** @hidden */
  25975. _indexInSceneMaterialArray: number;
  25976. /** @hidden */
  25977. meshMap: Nullable<{
  25978. [id: string]: AbstractMesh | undefined;
  25979. }>;
  25980. /**
  25981. * Creates a material instance
  25982. * @param name defines the name of the material
  25983. * @param scene defines the scene to reference
  25984. * @param doNotAdd specifies if the material should be added to the scene
  25985. */
  25986. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25987. /**
  25988. * Returns a string representation of the current material
  25989. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25990. * @returns a string with material information
  25991. */
  25992. toString(fullDetails?: boolean): string;
  25993. /**
  25994. * Gets the class name of the material
  25995. * @returns a string with the class name of the material
  25996. */
  25997. getClassName(): string;
  25998. /**
  25999. * Specifies if updates for the material been locked
  26000. */
  26001. get isFrozen(): boolean;
  26002. /**
  26003. * Locks updates for the material
  26004. */
  26005. freeze(): void;
  26006. /**
  26007. * Unlocks updates for the material
  26008. */
  26009. unfreeze(): void;
  26010. /**
  26011. * Specifies if the material is ready to be used
  26012. * @param mesh defines the mesh to check
  26013. * @param useInstances specifies if instances should be used
  26014. * @returns a boolean indicating if the material is ready to be used
  26015. */
  26016. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26017. /**
  26018. * Specifies that the submesh is ready to be used
  26019. * @param mesh defines the mesh to check
  26020. * @param subMesh defines which submesh to check
  26021. * @param useInstances specifies that instances should be used
  26022. * @returns a boolean indicating that the submesh is ready or not
  26023. */
  26024. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26025. /**
  26026. * Returns the material effect
  26027. * @returns the effect associated with the material
  26028. */
  26029. getEffect(): Nullable<Effect>;
  26030. /**
  26031. * Returns the current scene
  26032. * @returns a Scene
  26033. */
  26034. getScene(): Scene;
  26035. /**
  26036. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26037. */
  26038. protected _forceAlphaTest: boolean;
  26039. /**
  26040. * The transparency mode of the material.
  26041. */
  26042. protected _transparencyMode: Nullable<number>;
  26043. /**
  26044. * Gets the current transparency mode.
  26045. */
  26046. get transparencyMode(): Nullable<number>;
  26047. /**
  26048. * Sets the transparency mode of the material.
  26049. *
  26050. * | Value | Type | Description |
  26051. * | ----- | ----------------------------------- | ----------- |
  26052. * | 0 | OPAQUE | |
  26053. * | 1 | ALPHATEST | |
  26054. * | 2 | ALPHABLEND | |
  26055. * | 3 | ALPHATESTANDBLEND | |
  26056. *
  26057. */
  26058. set transparencyMode(value: Nullable<number>);
  26059. /**
  26060. * Returns true if alpha blending should be disabled.
  26061. */
  26062. protected get _disableAlphaBlending(): boolean;
  26063. /**
  26064. * Specifies whether or not this material should be rendered in alpha blend mode.
  26065. * @returns a boolean specifying if alpha blending is needed
  26066. */
  26067. needAlphaBlending(): boolean;
  26068. /**
  26069. * Specifies if the mesh will require alpha blending
  26070. * @param mesh defines the mesh to check
  26071. * @returns a boolean specifying if alpha blending is needed for the mesh
  26072. */
  26073. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26074. /**
  26075. * Specifies whether or not this material should be rendered in alpha test mode.
  26076. * @returns a boolean specifying if an alpha test is needed.
  26077. */
  26078. needAlphaTesting(): boolean;
  26079. /**
  26080. * Specifies if material alpha testing should be turned on for the mesh
  26081. * @param mesh defines the mesh to check
  26082. */
  26083. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26084. /**
  26085. * Gets the texture used for the alpha test
  26086. * @returns the texture to use for alpha testing
  26087. */
  26088. getAlphaTestTexture(): Nullable<BaseTexture>;
  26089. /**
  26090. * Marks the material to indicate that it needs to be re-calculated
  26091. */
  26092. markDirty(): void;
  26093. /** @hidden */
  26094. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26095. /**
  26096. * Binds the material to the mesh
  26097. * @param world defines the world transformation matrix
  26098. * @param mesh defines the mesh to bind the material to
  26099. */
  26100. bind(world: Matrix, mesh?: Mesh): void;
  26101. /**
  26102. * Binds the submesh to the material
  26103. * @param world defines the world transformation matrix
  26104. * @param mesh defines the mesh containing the submesh
  26105. * @param subMesh defines the submesh to bind the material to
  26106. */
  26107. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26108. /**
  26109. * Binds the world matrix to the material
  26110. * @param world defines the world transformation matrix
  26111. */
  26112. bindOnlyWorldMatrix(world: Matrix): void;
  26113. /**
  26114. * Binds the scene's uniform buffer to the effect.
  26115. * @param effect defines the effect to bind to the scene uniform buffer
  26116. * @param sceneUbo defines the uniform buffer storing scene data
  26117. */
  26118. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26119. /**
  26120. * Binds the view matrix to the effect
  26121. * @param effect defines the effect to bind the view matrix to
  26122. */
  26123. bindView(effect: Effect): void;
  26124. /**
  26125. * Binds the view projection matrix to the effect
  26126. * @param effect defines the effect to bind the view projection matrix to
  26127. */
  26128. bindViewProjection(effect: Effect): void;
  26129. /**
  26130. * Processes to execute after binding the material to a mesh
  26131. * @param mesh defines the rendered mesh
  26132. */
  26133. protected _afterBind(mesh?: Mesh): void;
  26134. /**
  26135. * Unbinds the material from the mesh
  26136. */
  26137. unbind(): void;
  26138. /**
  26139. * Gets the active textures from the material
  26140. * @returns an array of textures
  26141. */
  26142. getActiveTextures(): BaseTexture[];
  26143. /**
  26144. * Specifies if the material uses a texture
  26145. * @param texture defines the texture to check against the material
  26146. * @returns a boolean specifying if the material uses the texture
  26147. */
  26148. hasTexture(texture: BaseTexture): boolean;
  26149. /**
  26150. * Makes a duplicate of the material, and gives it a new name
  26151. * @param name defines the new name for the duplicated material
  26152. * @returns the cloned material
  26153. */
  26154. clone(name: string): Nullable<Material>;
  26155. /**
  26156. * Gets the meshes bound to the material
  26157. * @returns an array of meshes bound to the material
  26158. */
  26159. getBindedMeshes(): AbstractMesh[];
  26160. /**
  26161. * Force shader compilation
  26162. * @param mesh defines the mesh associated with this material
  26163. * @param onCompiled defines a function to execute once the material is compiled
  26164. * @param options defines the options to configure the compilation
  26165. * @param onError defines a function to execute if the material fails compiling
  26166. */
  26167. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26168. /**
  26169. * Force shader compilation
  26170. * @param mesh defines the mesh that will use this material
  26171. * @param options defines additional options for compiling the shaders
  26172. * @returns a promise that resolves when the compilation completes
  26173. */
  26174. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26175. private static readonly _AllDirtyCallBack;
  26176. private static readonly _ImageProcessingDirtyCallBack;
  26177. private static readonly _TextureDirtyCallBack;
  26178. private static readonly _FresnelDirtyCallBack;
  26179. private static readonly _MiscDirtyCallBack;
  26180. private static readonly _PrePassDirtyCallBack;
  26181. private static readonly _LightsDirtyCallBack;
  26182. private static readonly _AttributeDirtyCallBack;
  26183. private static _FresnelAndMiscDirtyCallBack;
  26184. private static _TextureAndMiscDirtyCallBack;
  26185. private static readonly _DirtyCallbackArray;
  26186. private static readonly _RunDirtyCallBacks;
  26187. /**
  26188. * Marks a define in the material to indicate that it needs to be re-computed
  26189. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26190. */
  26191. markAsDirty(flag: number): void;
  26192. /**
  26193. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26194. * @param func defines a function which checks material defines against the submeshes
  26195. */
  26196. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26197. /**
  26198. * Indicates that the scene should check if the rendering now needs a prepass
  26199. */
  26200. protected _markScenePrePassDirty(): void;
  26201. /**
  26202. * Indicates that we need to re-calculated for all submeshes
  26203. */
  26204. protected _markAllSubMeshesAsAllDirty(): void;
  26205. /**
  26206. * Indicates that image processing needs to be re-calculated for all submeshes
  26207. */
  26208. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26209. /**
  26210. * Indicates that textures need to be re-calculated for all submeshes
  26211. */
  26212. protected _markAllSubMeshesAsTexturesDirty(): void;
  26213. /**
  26214. * Indicates that fresnel needs to be re-calculated for all submeshes
  26215. */
  26216. protected _markAllSubMeshesAsFresnelDirty(): void;
  26217. /**
  26218. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26219. */
  26220. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26221. /**
  26222. * Indicates that lights need to be re-calculated for all submeshes
  26223. */
  26224. protected _markAllSubMeshesAsLightsDirty(): void;
  26225. /**
  26226. * Indicates that attributes need to be re-calculated for all submeshes
  26227. */
  26228. protected _markAllSubMeshesAsAttributesDirty(): void;
  26229. /**
  26230. * Indicates that misc needs to be re-calculated for all submeshes
  26231. */
  26232. protected _markAllSubMeshesAsMiscDirty(): void;
  26233. /**
  26234. * Indicates that prepass needs to be re-calculated for all submeshes
  26235. */
  26236. protected _markAllSubMeshesAsPrePassDirty(): void;
  26237. /**
  26238. * Indicates that textures and misc need to be re-calculated for all submeshes
  26239. */
  26240. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26241. /**
  26242. * Sets the required values to the prepass renderer.
  26243. * @param prePassRenderer defines the prepass renderer to setup.
  26244. * @returns true if the pre pass is needed.
  26245. */
  26246. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26247. /**
  26248. * Disposes the material
  26249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26252. */
  26253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26254. /** @hidden */
  26255. private releaseVertexArrayObject;
  26256. /**
  26257. * Serializes this material
  26258. * @returns the serialized material object
  26259. */
  26260. serialize(): any;
  26261. /**
  26262. * Creates a material from parsed material data
  26263. * @param parsedMaterial defines parsed material data
  26264. * @param scene defines the hosting scene
  26265. * @param rootUrl defines the root URL to use to load textures
  26266. * @returns a new material
  26267. */
  26268. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26269. }
  26270. }
  26271. declare module "babylonjs/Materials/multiMaterial" {
  26272. import { Nullable } from "babylonjs/types";
  26273. import { Scene } from "babylonjs/scene";
  26274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26277. import { Material } from "babylonjs/Materials/material";
  26278. /**
  26279. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26280. * separate meshes. This can be use to improve performances.
  26281. * @see https://doc.babylonjs.com/how_to/multi_materials
  26282. */
  26283. export class MultiMaterial extends Material {
  26284. private _subMaterials;
  26285. /**
  26286. * Gets or Sets the list of Materials used within the multi material.
  26287. * They need to be ordered according to the submeshes order in the associated mesh
  26288. */
  26289. get subMaterials(): Nullable<Material>[];
  26290. set subMaterials(value: Nullable<Material>[]);
  26291. /**
  26292. * Function used to align with Node.getChildren()
  26293. * @returns the list of Materials used within the multi material
  26294. */
  26295. getChildren(): Nullable<Material>[];
  26296. /**
  26297. * Instantiates a new Multi Material
  26298. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26299. * separate meshes. This can be use to improve performances.
  26300. * @see https://doc.babylonjs.com/how_to/multi_materials
  26301. * @param name Define the name in the scene
  26302. * @param scene Define the scene the material belongs to
  26303. */
  26304. constructor(name: string, scene: Scene);
  26305. private _hookArray;
  26306. /**
  26307. * Get one of the submaterial by its index in the submaterials array
  26308. * @param index The index to look the sub material at
  26309. * @returns The Material if the index has been defined
  26310. */
  26311. getSubMaterial(index: number): Nullable<Material>;
  26312. /**
  26313. * Get the list of active textures for the whole sub materials list.
  26314. * @returns All the textures that will be used during the rendering
  26315. */
  26316. getActiveTextures(): BaseTexture[];
  26317. /**
  26318. * Gets the current class name of the material e.g. "MultiMaterial"
  26319. * Mainly use in serialization.
  26320. * @returns the class name
  26321. */
  26322. getClassName(): string;
  26323. /**
  26324. * Checks if the material is ready to render the requested sub mesh
  26325. * @param mesh Define the mesh the submesh belongs to
  26326. * @param subMesh Define the sub mesh to look readyness for
  26327. * @param useInstances Define whether or not the material is used with instances
  26328. * @returns true if ready, otherwise false
  26329. */
  26330. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26331. /**
  26332. * Clones the current material and its related sub materials
  26333. * @param name Define the name of the newly cloned material
  26334. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26335. * @returns the cloned material
  26336. */
  26337. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26338. /**
  26339. * Serializes the materials into a JSON representation.
  26340. * @returns the JSON representation
  26341. */
  26342. serialize(): any;
  26343. /**
  26344. * Dispose the material and release its associated resources
  26345. * @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)
  26346. * @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)
  26347. * @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)
  26348. */
  26349. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26350. /**
  26351. * Creates a MultiMaterial from parsed MultiMaterial data.
  26352. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26353. * @param scene defines the hosting scene
  26354. * @returns a new MultiMaterial
  26355. */
  26356. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26357. }
  26358. }
  26359. declare module "babylonjs/Meshes/subMesh" {
  26360. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26361. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26362. import { Engine } from "babylonjs/Engines/engine";
  26363. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26364. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26365. import { Effect } from "babylonjs/Materials/effect";
  26366. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26367. import { Plane } from "babylonjs/Maths/math.plane";
  26368. import { Collider } from "babylonjs/Collisions/collider";
  26369. import { Material } from "babylonjs/Materials/material";
  26370. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26372. import { Mesh } from "babylonjs/Meshes/mesh";
  26373. import { Ray } from "babylonjs/Culling/ray";
  26374. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26375. /**
  26376. * Defines a subdivision inside a mesh
  26377. */
  26378. export class SubMesh implements ICullable {
  26379. /** the material index to use */
  26380. materialIndex: number;
  26381. /** vertex index start */
  26382. verticesStart: number;
  26383. /** vertices count */
  26384. verticesCount: number;
  26385. /** index start */
  26386. indexStart: number;
  26387. /** indices count */
  26388. indexCount: number;
  26389. /** @hidden */
  26390. _materialDefines: Nullable<MaterialDefines>;
  26391. /** @hidden */
  26392. _materialEffect: Nullable<Effect>;
  26393. /** @hidden */
  26394. _effectOverride: Nullable<Effect>;
  26395. /**
  26396. * Gets material defines used by the effect associated to the sub mesh
  26397. */
  26398. get materialDefines(): Nullable<MaterialDefines>;
  26399. /**
  26400. * Sets material defines used by the effect associated to the sub mesh
  26401. */
  26402. set materialDefines(defines: Nullable<MaterialDefines>);
  26403. /**
  26404. * Gets associated effect
  26405. */
  26406. get effect(): Nullable<Effect>;
  26407. /**
  26408. * Sets associated effect (effect used to render this submesh)
  26409. * @param effect defines the effect to associate with
  26410. * @param defines defines the set of defines used to compile this effect
  26411. */
  26412. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26413. /** @hidden */
  26414. _linesIndexCount: number;
  26415. private _mesh;
  26416. private _renderingMesh;
  26417. private _boundingInfo;
  26418. private _linesIndexBuffer;
  26419. /** @hidden */
  26420. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26421. /** @hidden */
  26422. _trianglePlanes: Plane[];
  26423. /** @hidden */
  26424. _lastColliderTransformMatrix: Nullable<Matrix>;
  26425. /** @hidden */
  26426. _renderId: number;
  26427. /** @hidden */
  26428. _alphaIndex: number;
  26429. /** @hidden */
  26430. _distanceToCamera: number;
  26431. /** @hidden */
  26432. _id: number;
  26433. private _currentMaterial;
  26434. /**
  26435. * Add a new submesh to a mesh
  26436. * @param materialIndex defines the material index to use
  26437. * @param verticesStart defines vertex index start
  26438. * @param verticesCount defines vertices count
  26439. * @param indexStart defines index start
  26440. * @param indexCount defines indices count
  26441. * @param mesh defines the parent mesh
  26442. * @param renderingMesh defines an optional rendering mesh
  26443. * @param createBoundingBox defines if bounding box should be created for this submesh
  26444. * @returns the new submesh
  26445. */
  26446. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26447. /**
  26448. * Creates a new submesh
  26449. * @param materialIndex defines the material index to use
  26450. * @param verticesStart defines vertex index start
  26451. * @param verticesCount defines vertices count
  26452. * @param indexStart defines index start
  26453. * @param indexCount defines indices count
  26454. * @param mesh defines the parent mesh
  26455. * @param renderingMesh defines an optional rendering mesh
  26456. * @param createBoundingBox defines if bounding box should be created for this submesh
  26457. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26458. */
  26459. constructor(
  26460. /** the material index to use */
  26461. materialIndex: number,
  26462. /** vertex index start */
  26463. verticesStart: number,
  26464. /** vertices count */
  26465. verticesCount: number,
  26466. /** index start */
  26467. indexStart: number,
  26468. /** indices count */
  26469. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26470. /**
  26471. * Returns true if this submesh covers the entire parent mesh
  26472. * @ignorenaming
  26473. */
  26474. get IsGlobal(): boolean;
  26475. /**
  26476. * Returns the submesh BoudingInfo object
  26477. * @returns current bounding info (or mesh's one if the submesh is global)
  26478. */
  26479. getBoundingInfo(): BoundingInfo;
  26480. /**
  26481. * Sets the submesh BoundingInfo
  26482. * @param boundingInfo defines the new bounding info to use
  26483. * @returns the SubMesh
  26484. */
  26485. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26486. /**
  26487. * Returns the mesh of the current submesh
  26488. * @return the parent mesh
  26489. */
  26490. getMesh(): AbstractMesh;
  26491. /**
  26492. * Returns the rendering mesh of the submesh
  26493. * @returns the rendering mesh (could be different from parent mesh)
  26494. */
  26495. getRenderingMesh(): Mesh;
  26496. /**
  26497. * Returns the replacement mesh of the submesh
  26498. * @returns the replacement mesh (could be different from parent mesh)
  26499. */
  26500. getReplacementMesh(): Nullable<AbstractMesh>;
  26501. /**
  26502. * Returns the effective mesh of the submesh
  26503. * @returns the effective mesh (could be different from parent mesh)
  26504. */
  26505. getEffectiveMesh(): AbstractMesh;
  26506. /**
  26507. * Returns the submesh material
  26508. * @returns null or the current material
  26509. */
  26510. getMaterial(): Nullable<Material>;
  26511. private _IsMultiMaterial;
  26512. /**
  26513. * Sets a new updated BoundingInfo object to the submesh
  26514. * @param data defines an optional position array to use to determine the bounding info
  26515. * @returns the SubMesh
  26516. */
  26517. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26518. /** @hidden */
  26519. _checkCollision(collider: Collider): boolean;
  26520. /**
  26521. * Updates the submesh BoundingInfo
  26522. * @param world defines the world matrix to use to update the bounding info
  26523. * @returns the submesh
  26524. */
  26525. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26526. /**
  26527. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26528. * @param frustumPlanes defines the frustum planes
  26529. * @returns true if the submesh is intersecting with the frustum
  26530. */
  26531. isInFrustum(frustumPlanes: Plane[]): boolean;
  26532. /**
  26533. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26534. * @param frustumPlanes defines the frustum planes
  26535. * @returns true if the submesh is inside the frustum
  26536. */
  26537. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26538. /**
  26539. * Renders the submesh
  26540. * @param enableAlphaMode defines if alpha needs to be used
  26541. * @returns the submesh
  26542. */
  26543. render(enableAlphaMode: boolean): SubMesh;
  26544. /**
  26545. * @hidden
  26546. */
  26547. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26548. /**
  26549. * Checks if the submesh intersects with a ray
  26550. * @param ray defines the ray to test
  26551. * @returns true is the passed ray intersects the submesh bounding box
  26552. */
  26553. canIntersects(ray: Ray): boolean;
  26554. /**
  26555. * Intersects current submesh with a ray
  26556. * @param ray defines the ray to test
  26557. * @param positions defines mesh's positions array
  26558. * @param indices defines mesh's indices array
  26559. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26560. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26561. * @returns intersection info or null if no intersection
  26562. */
  26563. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26564. /** @hidden */
  26565. private _intersectLines;
  26566. /** @hidden */
  26567. private _intersectUnIndexedLines;
  26568. /** @hidden */
  26569. private _intersectTriangles;
  26570. /** @hidden */
  26571. private _intersectUnIndexedTriangles;
  26572. /** @hidden */
  26573. _rebuild(): void;
  26574. /**
  26575. * Creates a new submesh from the passed mesh
  26576. * @param newMesh defines the new hosting mesh
  26577. * @param newRenderingMesh defines an optional rendering mesh
  26578. * @returns the new submesh
  26579. */
  26580. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26581. /**
  26582. * Release associated resources
  26583. */
  26584. dispose(): void;
  26585. /**
  26586. * Gets the class name
  26587. * @returns the string "SubMesh".
  26588. */
  26589. getClassName(): string;
  26590. /**
  26591. * Creates a new submesh from indices data
  26592. * @param materialIndex the index of the main mesh material
  26593. * @param startIndex the index where to start the copy in the mesh indices array
  26594. * @param indexCount the number of indices to copy then from the startIndex
  26595. * @param mesh the main mesh to create the submesh from
  26596. * @param renderingMesh the optional rendering mesh
  26597. * @returns a new submesh
  26598. */
  26599. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26600. }
  26601. }
  26602. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26603. /**
  26604. * Class used to represent data loading progression
  26605. */
  26606. export class SceneLoaderFlags {
  26607. private static _ForceFullSceneLoadingForIncremental;
  26608. private static _ShowLoadingScreen;
  26609. private static _CleanBoneMatrixWeights;
  26610. private static _loggingLevel;
  26611. /**
  26612. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26613. */
  26614. static get ForceFullSceneLoadingForIncremental(): boolean;
  26615. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26616. /**
  26617. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26618. */
  26619. static get ShowLoadingScreen(): boolean;
  26620. static set ShowLoadingScreen(value: boolean);
  26621. /**
  26622. * Defines the current logging level (while loading the scene)
  26623. * @ignorenaming
  26624. */
  26625. static get loggingLevel(): number;
  26626. static set loggingLevel(value: number);
  26627. /**
  26628. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26629. */
  26630. static get CleanBoneMatrixWeights(): boolean;
  26631. static set CleanBoneMatrixWeights(value: boolean);
  26632. }
  26633. }
  26634. declare module "babylonjs/Meshes/geometry" {
  26635. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26636. import { Scene } from "babylonjs/scene";
  26637. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26638. import { Engine } from "babylonjs/Engines/engine";
  26639. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26640. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26641. import { Effect } from "babylonjs/Materials/effect";
  26642. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26643. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26644. import { Mesh } from "babylonjs/Meshes/mesh";
  26645. /**
  26646. * Class used to store geometry data (vertex buffers + index buffer)
  26647. */
  26648. export class Geometry implements IGetSetVerticesData {
  26649. /**
  26650. * Gets or sets the ID of the geometry
  26651. */
  26652. id: string;
  26653. /**
  26654. * Gets or sets the unique ID of the geometry
  26655. */
  26656. uniqueId: number;
  26657. /**
  26658. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26659. */
  26660. delayLoadState: number;
  26661. /**
  26662. * Gets the file containing the data to load when running in delay load state
  26663. */
  26664. delayLoadingFile: Nullable<string>;
  26665. /**
  26666. * Callback called when the geometry is updated
  26667. */
  26668. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26669. private _scene;
  26670. private _engine;
  26671. private _meshes;
  26672. private _totalVertices;
  26673. /** @hidden */
  26674. _indices: IndicesArray;
  26675. /** @hidden */
  26676. _vertexBuffers: {
  26677. [key: string]: VertexBuffer;
  26678. };
  26679. private _isDisposed;
  26680. private _extend;
  26681. private _boundingBias;
  26682. /** @hidden */
  26683. _delayInfo: Array<string>;
  26684. private _indexBuffer;
  26685. private _indexBufferIsUpdatable;
  26686. /** @hidden */
  26687. _boundingInfo: Nullable<BoundingInfo>;
  26688. /** @hidden */
  26689. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26690. /** @hidden */
  26691. _softwareSkinningFrameId: number;
  26692. private _vertexArrayObjects;
  26693. private _updatable;
  26694. /** @hidden */
  26695. _positions: Nullable<Vector3[]>;
  26696. /**
  26697. * 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
  26698. */
  26699. get boundingBias(): Vector2;
  26700. /**
  26701. * 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
  26702. */
  26703. set boundingBias(value: Vector2);
  26704. /**
  26705. * Static function used to attach a new empty geometry to a mesh
  26706. * @param mesh defines the mesh to attach the geometry to
  26707. * @returns the new Geometry
  26708. */
  26709. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26710. /** Get the list of meshes using this geometry */
  26711. get meshes(): Mesh[];
  26712. /**
  26713. * 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
  26714. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26715. */
  26716. useBoundingInfoFromGeometry: boolean;
  26717. /**
  26718. * Creates a new geometry
  26719. * @param id defines the unique ID
  26720. * @param scene defines the hosting scene
  26721. * @param vertexData defines the VertexData used to get geometry data
  26722. * @param updatable defines if geometry must be updatable (false by default)
  26723. * @param mesh defines the mesh that will be associated with the geometry
  26724. */
  26725. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26726. /**
  26727. * Gets the current extend of the geometry
  26728. */
  26729. get extend(): {
  26730. minimum: Vector3;
  26731. maximum: Vector3;
  26732. };
  26733. /**
  26734. * Gets the hosting scene
  26735. * @returns the hosting Scene
  26736. */
  26737. getScene(): Scene;
  26738. /**
  26739. * Gets the hosting engine
  26740. * @returns the hosting Engine
  26741. */
  26742. getEngine(): Engine;
  26743. /**
  26744. * Defines if the geometry is ready to use
  26745. * @returns true if the geometry is ready to be used
  26746. */
  26747. isReady(): boolean;
  26748. /**
  26749. * Gets a value indicating that the geometry should not be serialized
  26750. */
  26751. get doNotSerialize(): boolean;
  26752. /** @hidden */
  26753. _rebuild(): void;
  26754. /**
  26755. * Affects all geometry data in one call
  26756. * @param vertexData defines the geometry data
  26757. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26758. */
  26759. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26760. /**
  26761. * Set specific vertex data
  26762. * @param kind defines the data kind (Position, normal, etc...)
  26763. * @param data defines the vertex data to use
  26764. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26765. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26766. */
  26767. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26768. /**
  26769. * Removes a specific vertex data
  26770. * @param kind defines the data kind (Position, normal, etc...)
  26771. */
  26772. removeVerticesData(kind: string): void;
  26773. /**
  26774. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26775. * @param buffer defines the vertex buffer to use
  26776. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26777. */
  26778. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26779. /**
  26780. * Update a specific vertex buffer
  26781. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26782. * It will do nothing if the buffer is not updatable
  26783. * @param kind defines the data kind (Position, normal, etc...)
  26784. * @param data defines the data to use
  26785. * @param offset defines the offset in the target buffer where to store the data
  26786. * @param useBytes set to true if the offset is in bytes
  26787. */
  26788. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26789. /**
  26790. * Update a specific vertex buffer
  26791. * This function will create a new buffer if the current one is not updatable
  26792. * @param kind defines the data kind (Position, normal, etc...)
  26793. * @param data defines the data to use
  26794. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26795. */
  26796. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26797. private _updateBoundingInfo;
  26798. /** @hidden */
  26799. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26800. /**
  26801. * Gets total number of vertices
  26802. * @returns the total number of vertices
  26803. */
  26804. getTotalVertices(): number;
  26805. /**
  26806. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26807. * @param kind defines the data kind (Position, normal, etc...)
  26808. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26809. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26810. * @returns a float array containing vertex data
  26811. */
  26812. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26813. /**
  26814. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26815. * @param kind defines the data kind (Position, normal, etc...)
  26816. * @returns true if the vertex buffer with the specified kind is updatable
  26817. */
  26818. isVertexBufferUpdatable(kind: string): boolean;
  26819. /**
  26820. * Gets a specific vertex buffer
  26821. * @param kind defines the data kind (Position, normal, etc...)
  26822. * @returns a VertexBuffer
  26823. */
  26824. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26825. /**
  26826. * Returns all vertex buffers
  26827. * @return an object holding all vertex buffers indexed by kind
  26828. */
  26829. getVertexBuffers(): Nullable<{
  26830. [key: string]: VertexBuffer;
  26831. }>;
  26832. /**
  26833. * Gets a boolean indicating if specific vertex buffer is present
  26834. * @param kind defines the data kind (Position, normal, etc...)
  26835. * @returns true if data is present
  26836. */
  26837. isVerticesDataPresent(kind: string): boolean;
  26838. /**
  26839. * Gets a list of all attached data kinds (Position, normal, etc...)
  26840. * @returns a list of string containing all kinds
  26841. */
  26842. getVerticesDataKinds(): string[];
  26843. /**
  26844. * Update index buffer
  26845. * @param indices defines the indices to store in the index buffer
  26846. * @param offset defines the offset in the target buffer where to store the data
  26847. * @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)
  26848. */
  26849. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26850. /**
  26851. * Creates a new index buffer
  26852. * @param indices defines the indices to store in the index buffer
  26853. * @param totalVertices defines the total number of vertices (could be null)
  26854. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26855. */
  26856. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26857. /**
  26858. * Return the total number of indices
  26859. * @returns the total number of indices
  26860. */
  26861. getTotalIndices(): number;
  26862. /**
  26863. * Gets the index buffer array
  26864. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26865. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26866. * @returns the index buffer array
  26867. */
  26868. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26869. /**
  26870. * Gets the index buffer
  26871. * @return the index buffer
  26872. */
  26873. getIndexBuffer(): Nullable<DataBuffer>;
  26874. /** @hidden */
  26875. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26876. /**
  26877. * Release the associated resources for a specific mesh
  26878. * @param mesh defines the source mesh
  26879. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26880. */
  26881. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26882. /**
  26883. * Apply current geometry to a given mesh
  26884. * @param mesh defines the mesh to apply geometry to
  26885. */
  26886. applyToMesh(mesh: Mesh): void;
  26887. private _updateExtend;
  26888. private _applyToMesh;
  26889. private notifyUpdate;
  26890. /**
  26891. * Load the geometry if it was flagged as delay loaded
  26892. * @param scene defines the hosting scene
  26893. * @param onLoaded defines a callback called when the geometry is loaded
  26894. */
  26895. load(scene: Scene, onLoaded?: () => void): void;
  26896. private _queueLoad;
  26897. /**
  26898. * Invert the geometry to move from a right handed system to a left handed one.
  26899. */
  26900. toLeftHanded(): void;
  26901. /** @hidden */
  26902. _resetPointsArrayCache(): void;
  26903. /** @hidden */
  26904. _generatePointsArray(): boolean;
  26905. /**
  26906. * Gets a value indicating if the geometry is disposed
  26907. * @returns true if the geometry was disposed
  26908. */
  26909. isDisposed(): boolean;
  26910. private _disposeVertexArrayObjects;
  26911. /**
  26912. * Free all associated resources
  26913. */
  26914. dispose(): void;
  26915. /**
  26916. * Clone the current geometry into a new geometry
  26917. * @param id defines the unique ID of the new geometry
  26918. * @returns a new geometry object
  26919. */
  26920. copy(id: string): Geometry;
  26921. /**
  26922. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26923. * @return a JSON representation of the current geometry data (without the vertices data)
  26924. */
  26925. serialize(): any;
  26926. private toNumberArray;
  26927. /**
  26928. * Serialize all vertices data into a JSON oject
  26929. * @returns a JSON representation of the current geometry data
  26930. */
  26931. serializeVerticeData(): any;
  26932. /**
  26933. * Extracts a clone of a mesh geometry
  26934. * @param mesh defines the source mesh
  26935. * @param id defines the unique ID of the new geometry object
  26936. * @returns the new geometry object
  26937. */
  26938. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26939. /**
  26940. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26941. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26942. * Be aware Math.random() could cause collisions, but:
  26943. * "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"
  26944. * @returns a string containing a new GUID
  26945. */
  26946. static RandomId(): string;
  26947. /** @hidden */
  26948. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26949. private static _CleanMatricesWeights;
  26950. /**
  26951. * Create a new geometry from persisted data (Using .babylon file format)
  26952. * @param parsedVertexData defines the persisted data
  26953. * @param scene defines the hosting scene
  26954. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26955. * @returns the new geometry object
  26956. */
  26957. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26958. }
  26959. }
  26960. declare module "babylonjs/Meshes/mesh.vertexData" {
  26961. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26962. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26963. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26964. import { Geometry } from "babylonjs/Meshes/geometry";
  26965. import { Mesh } from "babylonjs/Meshes/mesh";
  26966. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26967. /**
  26968. * Define an interface for all classes that will get and set the data on vertices
  26969. */
  26970. export interface IGetSetVerticesData {
  26971. /**
  26972. * Gets a boolean indicating if specific vertex data is present
  26973. * @param kind defines the vertex data kind to use
  26974. * @returns true is data kind is present
  26975. */
  26976. isVerticesDataPresent(kind: string): boolean;
  26977. /**
  26978. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26979. * @param kind defines the data kind (Position, normal, etc...)
  26980. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26981. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26982. * @returns a float array containing vertex data
  26983. */
  26984. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26985. /**
  26986. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26987. * @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.
  26988. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26989. * @returns the indices array or an empty array if the mesh has no geometry
  26990. */
  26991. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26992. /**
  26993. * Set specific vertex data
  26994. * @param kind defines the data kind (Position, normal, etc...)
  26995. * @param data defines the vertex data to use
  26996. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26997. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26998. */
  26999. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27000. /**
  27001. * Update a specific associated vertex buffer
  27002. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27003. * - VertexBuffer.PositionKind
  27004. * - VertexBuffer.UVKind
  27005. * - VertexBuffer.UV2Kind
  27006. * - VertexBuffer.UV3Kind
  27007. * - VertexBuffer.UV4Kind
  27008. * - VertexBuffer.UV5Kind
  27009. * - VertexBuffer.UV6Kind
  27010. * - VertexBuffer.ColorKind
  27011. * - VertexBuffer.MatricesIndicesKind
  27012. * - VertexBuffer.MatricesIndicesExtraKind
  27013. * - VertexBuffer.MatricesWeightsKind
  27014. * - VertexBuffer.MatricesWeightsExtraKind
  27015. * @param data defines the data source
  27016. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27017. * @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)
  27018. */
  27019. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27020. /**
  27021. * Creates a new index buffer
  27022. * @param indices defines the indices to store in the index buffer
  27023. * @param totalVertices defines the total number of vertices (could be null)
  27024. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27025. */
  27026. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27027. }
  27028. /**
  27029. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27030. */
  27031. export class VertexData {
  27032. /**
  27033. * Mesh side orientation : usually the external or front surface
  27034. */
  27035. static readonly FRONTSIDE: number;
  27036. /**
  27037. * Mesh side orientation : usually the internal or back surface
  27038. */
  27039. static readonly BACKSIDE: number;
  27040. /**
  27041. * Mesh side orientation : both internal and external or front and back surfaces
  27042. */
  27043. static readonly DOUBLESIDE: number;
  27044. /**
  27045. * Mesh side orientation : by default, `FRONTSIDE`
  27046. */
  27047. static readonly DEFAULTSIDE: number;
  27048. /**
  27049. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27050. */
  27051. positions: Nullable<FloatArray>;
  27052. /**
  27053. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27054. */
  27055. normals: Nullable<FloatArray>;
  27056. /**
  27057. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27058. */
  27059. tangents: Nullable<FloatArray>;
  27060. /**
  27061. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27062. */
  27063. uvs: Nullable<FloatArray>;
  27064. /**
  27065. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27066. */
  27067. uvs2: Nullable<FloatArray>;
  27068. /**
  27069. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27070. */
  27071. uvs3: Nullable<FloatArray>;
  27072. /**
  27073. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27074. */
  27075. uvs4: Nullable<FloatArray>;
  27076. /**
  27077. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27078. */
  27079. uvs5: Nullable<FloatArray>;
  27080. /**
  27081. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27082. */
  27083. uvs6: Nullable<FloatArray>;
  27084. /**
  27085. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27086. */
  27087. colors: Nullable<FloatArray>;
  27088. /**
  27089. * 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).
  27090. */
  27091. matricesIndices: Nullable<FloatArray>;
  27092. /**
  27093. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27094. */
  27095. matricesWeights: Nullable<FloatArray>;
  27096. /**
  27097. * An array extending the number of possible indices
  27098. */
  27099. matricesIndicesExtra: Nullable<FloatArray>;
  27100. /**
  27101. * An array extending the number of possible weights when the number of indices is extended
  27102. */
  27103. matricesWeightsExtra: Nullable<FloatArray>;
  27104. /**
  27105. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27106. */
  27107. indices: Nullable<IndicesArray>;
  27108. /**
  27109. * Uses the passed data array to set the set the values for the specified kind of data
  27110. * @param data a linear array of floating numbers
  27111. * @param kind the type of data that is being set, eg positions, colors etc
  27112. */
  27113. set(data: FloatArray, kind: string): void;
  27114. /**
  27115. * Associates the vertexData to the passed Mesh.
  27116. * Sets it as updatable or not (default `false`)
  27117. * @param mesh the mesh the vertexData is applied to
  27118. * @param updatable when used and having the value true allows new data to update the vertexData
  27119. * @returns the VertexData
  27120. */
  27121. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27122. /**
  27123. * Associates the vertexData to the passed Geometry.
  27124. * Sets it as updatable or not (default `false`)
  27125. * @param geometry the geometry the vertexData is applied to
  27126. * @param updatable when used and having the value true allows new data to update the vertexData
  27127. * @returns VertexData
  27128. */
  27129. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27130. /**
  27131. * Updates the associated mesh
  27132. * @param mesh the mesh to be updated
  27133. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27134. * @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
  27135. * @returns VertexData
  27136. */
  27137. updateMesh(mesh: Mesh): VertexData;
  27138. /**
  27139. * Updates the associated geometry
  27140. * @param geometry the geometry to be updated
  27141. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27142. * @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
  27143. * @returns VertexData.
  27144. */
  27145. updateGeometry(geometry: Geometry): VertexData;
  27146. private _applyTo;
  27147. private _update;
  27148. /**
  27149. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27150. * @param matrix the transforming matrix
  27151. * @returns the VertexData
  27152. */
  27153. transform(matrix: Matrix): VertexData;
  27154. /**
  27155. * Merges the passed VertexData into the current one
  27156. * @param other the VertexData to be merged into the current one
  27157. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27158. * @returns the modified VertexData
  27159. */
  27160. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27161. private _mergeElement;
  27162. private _validate;
  27163. /**
  27164. * Serializes the VertexData
  27165. * @returns a serialized object
  27166. */
  27167. serialize(): any;
  27168. /**
  27169. * Extracts the vertexData from a mesh
  27170. * @param mesh the mesh from which to extract the VertexData
  27171. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27172. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27173. * @returns the object VertexData associated to the passed mesh
  27174. */
  27175. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27176. /**
  27177. * Extracts the vertexData from the geometry
  27178. * @param geometry the geometry from which to extract the VertexData
  27179. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27180. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27181. * @returns the object VertexData associated to the passed mesh
  27182. */
  27183. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27184. private static _ExtractFrom;
  27185. /**
  27186. * Creates the VertexData for a Ribbon
  27187. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27188. * * pathArray array of paths, each of which an array of successive Vector3
  27189. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27190. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27191. * * 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
  27192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27193. * * 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)
  27194. * * 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)
  27195. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27196. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27197. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27198. * @returns the VertexData of the ribbon
  27199. */
  27200. static CreateRibbon(options: {
  27201. pathArray: Vector3[][];
  27202. closeArray?: boolean;
  27203. closePath?: boolean;
  27204. offset?: number;
  27205. sideOrientation?: number;
  27206. frontUVs?: Vector4;
  27207. backUVs?: Vector4;
  27208. invertUV?: boolean;
  27209. uvs?: Vector2[];
  27210. colors?: Color4[];
  27211. }): VertexData;
  27212. /**
  27213. * Creates the VertexData for a box
  27214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27215. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27216. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27217. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27218. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27219. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27220. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27221. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27222. * * 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)
  27223. * * 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)
  27224. * @returns the VertexData of the box
  27225. */
  27226. static CreateBox(options: {
  27227. size?: number;
  27228. width?: number;
  27229. height?: number;
  27230. depth?: number;
  27231. faceUV?: Vector4[];
  27232. faceColors?: Color4[];
  27233. sideOrientation?: number;
  27234. frontUVs?: Vector4;
  27235. backUVs?: Vector4;
  27236. }): VertexData;
  27237. /**
  27238. * Creates the VertexData for a tiled box
  27239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27240. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27241. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27242. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27244. * @returns the VertexData of the box
  27245. */
  27246. static CreateTiledBox(options: {
  27247. pattern?: number;
  27248. width?: number;
  27249. height?: number;
  27250. depth?: number;
  27251. tileSize?: number;
  27252. tileWidth?: number;
  27253. tileHeight?: number;
  27254. alignHorizontal?: number;
  27255. alignVertical?: number;
  27256. faceUV?: Vector4[];
  27257. faceColors?: Color4[];
  27258. sideOrientation?: number;
  27259. }): VertexData;
  27260. /**
  27261. * Creates the VertexData for a tiled plane
  27262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27263. * * pattern a limited pattern arrangement depending on the number
  27264. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27265. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27266. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27268. * * 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)
  27269. * * 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)
  27270. * @returns the VertexData of the tiled plane
  27271. */
  27272. static CreateTiledPlane(options: {
  27273. pattern?: number;
  27274. tileSize?: number;
  27275. tileWidth?: number;
  27276. tileHeight?: number;
  27277. size?: number;
  27278. width?: number;
  27279. height?: number;
  27280. alignHorizontal?: number;
  27281. alignVertical?: number;
  27282. sideOrientation?: number;
  27283. frontUVs?: Vector4;
  27284. backUVs?: Vector4;
  27285. }): VertexData;
  27286. /**
  27287. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27289. * * segments sets the number of horizontal strips optional, default 32
  27290. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27291. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27292. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27293. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27294. * * 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
  27295. * * 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
  27296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27297. * * 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)
  27298. * * 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)
  27299. * @returns the VertexData of the ellipsoid
  27300. */
  27301. static CreateSphere(options: {
  27302. segments?: number;
  27303. diameter?: number;
  27304. diameterX?: number;
  27305. diameterY?: number;
  27306. diameterZ?: number;
  27307. arc?: number;
  27308. slice?: number;
  27309. sideOrientation?: number;
  27310. frontUVs?: Vector4;
  27311. backUVs?: Vector4;
  27312. }): VertexData;
  27313. /**
  27314. * Creates the VertexData for a cylinder, cone or prism
  27315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27316. * * height sets the height (y direction) of the cylinder, optional, default 2
  27317. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27318. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27319. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27320. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27321. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27322. * * 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
  27323. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27324. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27325. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27326. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27327. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27328. * * 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)
  27329. * * 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)
  27330. * @returns the VertexData of the cylinder, cone or prism
  27331. */
  27332. static CreateCylinder(options: {
  27333. height?: number;
  27334. diameterTop?: number;
  27335. diameterBottom?: number;
  27336. diameter?: number;
  27337. tessellation?: number;
  27338. subdivisions?: number;
  27339. arc?: number;
  27340. faceColors?: Color4[];
  27341. faceUV?: Vector4[];
  27342. hasRings?: boolean;
  27343. enclose?: boolean;
  27344. sideOrientation?: number;
  27345. frontUVs?: Vector4;
  27346. backUVs?: Vector4;
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData for a torus
  27350. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27351. * * diameter the diameter of the torus, optional default 1
  27352. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27353. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27355. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27356. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27357. * @returns the VertexData of the torus
  27358. */
  27359. static CreateTorus(options: {
  27360. diameter?: number;
  27361. thickness?: number;
  27362. tessellation?: number;
  27363. sideOrientation?: number;
  27364. frontUVs?: Vector4;
  27365. backUVs?: Vector4;
  27366. }): VertexData;
  27367. /**
  27368. * Creates the VertexData of the LineSystem
  27369. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27370. * - lines an array of lines, each line being an array of successive Vector3
  27371. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27372. * @returns the VertexData of the LineSystem
  27373. */
  27374. static CreateLineSystem(options: {
  27375. lines: Vector3[][];
  27376. colors?: Nullable<Color4[][]>;
  27377. }): VertexData;
  27378. /**
  27379. * Create the VertexData for a DashedLines
  27380. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27381. * - points an array successive Vector3
  27382. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27383. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27384. * - dashNb the intended total number of dashes, optional, default 200
  27385. * @returns the VertexData for the DashedLines
  27386. */
  27387. static CreateDashedLines(options: {
  27388. points: Vector3[];
  27389. dashSize?: number;
  27390. gapSize?: number;
  27391. dashNb?: number;
  27392. }): VertexData;
  27393. /**
  27394. * Creates the VertexData for a Ground
  27395. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27396. * - width the width (x direction) of the ground, optional, default 1
  27397. * - height the height (z direction) of the ground, optional, default 1
  27398. * - subdivisions the number of subdivisions per side, optional, default 1
  27399. * @returns the VertexData of the Ground
  27400. */
  27401. static CreateGround(options: {
  27402. width?: number;
  27403. height?: number;
  27404. subdivisions?: number;
  27405. subdivisionsX?: number;
  27406. subdivisionsY?: number;
  27407. }): VertexData;
  27408. /**
  27409. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27410. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27411. * * xmin the ground minimum X coordinate, optional, default -1
  27412. * * zmin the ground minimum Z coordinate, optional, default -1
  27413. * * xmax the ground maximum X coordinate, optional, default 1
  27414. * * zmax the ground maximum Z coordinate, optional, default 1
  27415. * * 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}
  27416. * * 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}
  27417. * @returns the VertexData of the TiledGround
  27418. */
  27419. static CreateTiledGround(options: {
  27420. xmin: number;
  27421. zmin: number;
  27422. xmax: number;
  27423. zmax: number;
  27424. subdivisions?: {
  27425. w: number;
  27426. h: number;
  27427. };
  27428. precision?: {
  27429. w: number;
  27430. h: number;
  27431. };
  27432. }): VertexData;
  27433. /**
  27434. * Creates the VertexData of the Ground designed from a heightmap
  27435. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27436. * * width the width (x direction) of the ground
  27437. * * height the height (z direction) of the ground
  27438. * * subdivisions the number of subdivisions per side
  27439. * * minHeight the minimum altitude on the ground, optional, default 0
  27440. * * maxHeight the maximum altitude on the ground, optional default 1
  27441. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27442. * * buffer the array holding the image color data
  27443. * * bufferWidth the width of image
  27444. * * bufferHeight the height of image
  27445. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27446. * @returns the VertexData of the Ground designed from a heightmap
  27447. */
  27448. static CreateGroundFromHeightMap(options: {
  27449. width: number;
  27450. height: number;
  27451. subdivisions: number;
  27452. minHeight: number;
  27453. maxHeight: number;
  27454. colorFilter: Color3;
  27455. buffer: Uint8Array;
  27456. bufferWidth: number;
  27457. bufferHeight: number;
  27458. alphaFilter: number;
  27459. }): VertexData;
  27460. /**
  27461. * Creates the VertexData for a Plane
  27462. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27463. * * size sets the width and height of the plane to the value of size, optional default 1
  27464. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27465. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27467. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27468. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27469. * @returns the VertexData of the box
  27470. */
  27471. static CreatePlane(options: {
  27472. size?: number;
  27473. width?: number;
  27474. height?: number;
  27475. sideOrientation?: number;
  27476. frontUVs?: Vector4;
  27477. backUVs?: Vector4;
  27478. }): VertexData;
  27479. /**
  27480. * Creates the VertexData of the Disc or regular Polygon
  27481. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27482. * * radius the radius of the disc, optional default 0.5
  27483. * * tessellation the number of polygon sides, optional, default 64
  27484. * * 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
  27485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27486. * * 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)
  27487. * * 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)
  27488. * @returns the VertexData of the box
  27489. */
  27490. static CreateDisc(options: {
  27491. radius?: number;
  27492. tessellation?: number;
  27493. arc?: number;
  27494. sideOrientation?: number;
  27495. frontUVs?: Vector4;
  27496. backUVs?: Vector4;
  27497. }): VertexData;
  27498. /**
  27499. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27500. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27501. * @param polygon a mesh built from polygonTriangulation.build()
  27502. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27503. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27504. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27505. * @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)
  27506. * @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)
  27507. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27508. * @returns the VertexData of the Polygon
  27509. */
  27510. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27511. /**
  27512. * Creates the VertexData of the IcoSphere
  27513. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27514. * * radius the radius of the IcoSphere, optional default 1
  27515. * * radiusX allows stretching in the x direction, optional, default radius
  27516. * * radiusY allows stretching in the y direction, optional, default radius
  27517. * * radiusZ allows stretching in the z direction, optional, default radius
  27518. * * flat when true creates a flat shaded mesh, optional, default true
  27519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27521. * * 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)
  27522. * * 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)
  27523. * @returns the VertexData of the IcoSphere
  27524. */
  27525. static CreateIcoSphere(options: {
  27526. radius?: number;
  27527. radiusX?: number;
  27528. radiusY?: number;
  27529. radiusZ?: number;
  27530. flat?: boolean;
  27531. subdivisions?: number;
  27532. sideOrientation?: number;
  27533. frontUVs?: Vector4;
  27534. backUVs?: Vector4;
  27535. }): VertexData;
  27536. /**
  27537. * Creates the VertexData for a Polyhedron
  27538. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27539. * * type provided types are:
  27540. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27541. * * 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)
  27542. * * size the size of the IcoSphere, optional default 1
  27543. * * sizeX allows stretching in the x direction, optional, default size
  27544. * * sizeY allows stretching in the y direction, optional, default size
  27545. * * sizeZ allows stretching in the z direction, optional, default size
  27546. * * 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
  27547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27548. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27549. * * flat when true creates a flat shaded mesh, optional, default true
  27550. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27552. * * 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)
  27553. * * 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)
  27554. * @returns the VertexData of the Polyhedron
  27555. */
  27556. static CreatePolyhedron(options: {
  27557. type?: number;
  27558. size?: number;
  27559. sizeX?: number;
  27560. sizeY?: number;
  27561. sizeZ?: number;
  27562. custom?: any;
  27563. faceUV?: Vector4[];
  27564. faceColors?: Color4[];
  27565. flat?: boolean;
  27566. sideOrientation?: number;
  27567. frontUVs?: Vector4;
  27568. backUVs?: Vector4;
  27569. }): VertexData;
  27570. /**
  27571. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27572. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27573. * @returns the VertexData of the Capsule
  27574. */
  27575. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27576. /**
  27577. * Creates the VertexData for a TorusKnot
  27578. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27579. * * radius the radius of the torus knot, optional, default 2
  27580. * * tube the thickness of the tube, optional, default 0.5
  27581. * * radialSegments the number of sides on each tube segments, optional, default 32
  27582. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27583. * * p the number of windings around the z axis, optional, default 2
  27584. * * q the number of windings around the x axis, optional, default 3
  27585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27586. * * 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)
  27587. * * 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)
  27588. * @returns the VertexData of the Torus Knot
  27589. */
  27590. static CreateTorusKnot(options: {
  27591. radius?: number;
  27592. tube?: number;
  27593. radialSegments?: number;
  27594. tubularSegments?: number;
  27595. p?: number;
  27596. q?: number;
  27597. sideOrientation?: number;
  27598. frontUVs?: Vector4;
  27599. backUVs?: Vector4;
  27600. }): VertexData;
  27601. /**
  27602. * Compute normals for given positions and indices
  27603. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27604. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27605. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27606. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27607. * * facetNormals : optional array of facet normals (vector3)
  27608. * * facetPositions : optional array of facet positions (vector3)
  27609. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27610. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27611. * * bInfo : optional bounding info, required for facetPartitioning computation
  27612. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27613. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27614. * * useRightHandedSystem: optional boolean to for right handed system computation
  27615. * * depthSort : optional boolean to enable the facet depth sort computation
  27616. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27617. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27618. */
  27619. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27620. facetNormals?: any;
  27621. facetPositions?: any;
  27622. facetPartitioning?: any;
  27623. ratio?: number;
  27624. bInfo?: any;
  27625. bbSize?: Vector3;
  27626. subDiv?: any;
  27627. useRightHandedSystem?: boolean;
  27628. depthSort?: boolean;
  27629. distanceTo?: Vector3;
  27630. depthSortedFacets?: any;
  27631. }): void;
  27632. /** @hidden */
  27633. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27634. /**
  27635. * Applies VertexData created from the imported parameters to the geometry
  27636. * @param parsedVertexData the parsed data from an imported file
  27637. * @param geometry the geometry to apply the VertexData to
  27638. */
  27639. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27640. }
  27641. }
  27642. declare module "babylonjs/Morph/morphTarget" {
  27643. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27644. import { Observable } from "babylonjs/Misc/observable";
  27645. import { Nullable, FloatArray } from "babylonjs/types";
  27646. import { Scene } from "babylonjs/scene";
  27647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27648. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27649. /**
  27650. * Defines a target to use with MorphTargetManager
  27651. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27652. */
  27653. export class MorphTarget implements IAnimatable {
  27654. /** defines the name of the target */
  27655. name: string;
  27656. /**
  27657. * Gets or sets the list of animations
  27658. */
  27659. animations: import("babylonjs/Animations/animation").Animation[];
  27660. private _scene;
  27661. private _positions;
  27662. private _normals;
  27663. private _tangents;
  27664. private _uvs;
  27665. private _influence;
  27666. private _uniqueId;
  27667. /**
  27668. * Observable raised when the influence changes
  27669. */
  27670. onInfluenceChanged: Observable<boolean>;
  27671. /** @hidden */
  27672. _onDataLayoutChanged: Observable<void>;
  27673. /**
  27674. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27675. */
  27676. get influence(): number;
  27677. set influence(influence: number);
  27678. /**
  27679. * Gets or sets the id of the morph Target
  27680. */
  27681. id: string;
  27682. private _animationPropertiesOverride;
  27683. /**
  27684. * Gets or sets the animation properties override
  27685. */
  27686. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27687. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27688. /**
  27689. * Creates a new MorphTarget
  27690. * @param name defines the name of the target
  27691. * @param influence defines the influence to use
  27692. * @param scene defines the scene the morphtarget belongs to
  27693. */
  27694. constructor(
  27695. /** defines the name of the target */
  27696. name: string, influence?: number, scene?: Nullable<Scene>);
  27697. /**
  27698. * Gets the unique ID of this manager
  27699. */
  27700. get uniqueId(): number;
  27701. /**
  27702. * Gets a boolean defining if the target contains position data
  27703. */
  27704. get hasPositions(): boolean;
  27705. /**
  27706. * Gets a boolean defining if the target contains normal data
  27707. */
  27708. get hasNormals(): boolean;
  27709. /**
  27710. * Gets a boolean defining if the target contains tangent data
  27711. */
  27712. get hasTangents(): boolean;
  27713. /**
  27714. * Gets a boolean defining if the target contains texture coordinates data
  27715. */
  27716. get hasUVs(): boolean;
  27717. /**
  27718. * Affects position data to this target
  27719. * @param data defines the position data to use
  27720. */
  27721. setPositions(data: Nullable<FloatArray>): void;
  27722. /**
  27723. * Gets the position data stored in this target
  27724. * @returns a FloatArray containing the position data (or null if not present)
  27725. */
  27726. getPositions(): Nullable<FloatArray>;
  27727. /**
  27728. * Affects normal data to this target
  27729. * @param data defines the normal data to use
  27730. */
  27731. setNormals(data: Nullable<FloatArray>): void;
  27732. /**
  27733. * Gets the normal data stored in this target
  27734. * @returns a FloatArray containing the normal data (or null if not present)
  27735. */
  27736. getNormals(): Nullable<FloatArray>;
  27737. /**
  27738. * Affects tangent data to this target
  27739. * @param data defines the tangent data to use
  27740. */
  27741. setTangents(data: Nullable<FloatArray>): void;
  27742. /**
  27743. * Gets the tangent data stored in this target
  27744. * @returns a FloatArray containing the tangent data (or null if not present)
  27745. */
  27746. getTangents(): Nullable<FloatArray>;
  27747. /**
  27748. * Affects texture coordinates data to this target
  27749. * @param data defines the texture coordinates data to use
  27750. */
  27751. setUVs(data: Nullable<FloatArray>): void;
  27752. /**
  27753. * Gets the texture coordinates data stored in this target
  27754. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27755. */
  27756. getUVs(): Nullable<FloatArray>;
  27757. /**
  27758. * Clone the current target
  27759. * @returns a new MorphTarget
  27760. */
  27761. clone(): MorphTarget;
  27762. /**
  27763. * Serializes the current target into a Serialization object
  27764. * @returns the serialized object
  27765. */
  27766. serialize(): any;
  27767. /**
  27768. * Returns the string "MorphTarget"
  27769. * @returns "MorphTarget"
  27770. */
  27771. getClassName(): string;
  27772. /**
  27773. * Creates a new target from serialized data
  27774. * @param serializationObject defines the serialized data to use
  27775. * @returns a new MorphTarget
  27776. */
  27777. static Parse(serializationObject: any): MorphTarget;
  27778. /**
  27779. * Creates a MorphTarget from mesh data
  27780. * @param mesh defines the source mesh
  27781. * @param name defines the name to use for the new target
  27782. * @param influence defines the influence to attach to the target
  27783. * @returns a new MorphTarget
  27784. */
  27785. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27786. }
  27787. }
  27788. declare module "babylonjs/Morph/morphTargetManager" {
  27789. import { Nullable } from "babylonjs/types";
  27790. import { Scene } from "babylonjs/scene";
  27791. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27792. /**
  27793. * This class is used to deform meshes using morphing between different targets
  27794. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27795. */
  27796. export class MorphTargetManager {
  27797. private _targets;
  27798. private _targetInfluenceChangedObservers;
  27799. private _targetDataLayoutChangedObservers;
  27800. private _activeTargets;
  27801. private _scene;
  27802. private _influences;
  27803. private _supportsNormals;
  27804. private _supportsTangents;
  27805. private _supportsUVs;
  27806. private _vertexCount;
  27807. private _uniqueId;
  27808. private _tempInfluences;
  27809. /**
  27810. * Gets or sets a boolean indicating if normals must be morphed
  27811. */
  27812. enableNormalMorphing: boolean;
  27813. /**
  27814. * Gets or sets a boolean indicating if tangents must be morphed
  27815. */
  27816. enableTangentMorphing: boolean;
  27817. /**
  27818. * Gets or sets a boolean indicating if UV must be morphed
  27819. */
  27820. enableUVMorphing: boolean;
  27821. /**
  27822. * Creates a new MorphTargetManager
  27823. * @param scene defines the current scene
  27824. */
  27825. constructor(scene?: Nullable<Scene>);
  27826. /**
  27827. * Gets the unique ID of this manager
  27828. */
  27829. get uniqueId(): number;
  27830. /**
  27831. * Gets the number of vertices handled by this manager
  27832. */
  27833. get vertexCount(): number;
  27834. /**
  27835. * Gets a boolean indicating if this manager supports morphing of normals
  27836. */
  27837. get supportsNormals(): boolean;
  27838. /**
  27839. * Gets a boolean indicating if this manager supports morphing of tangents
  27840. */
  27841. get supportsTangents(): boolean;
  27842. /**
  27843. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27844. */
  27845. get supportsUVs(): boolean;
  27846. /**
  27847. * Gets the number of targets stored in this manager
  27848. */
  27849. get numTargets(): number;
  27850. /**
  27851. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27852. */
  27853. get numInfluencers(): number;
  27854. /**
  27855. * Gets the list of influences (one per target)
  27856. */
  27857. get influences(): Float32Array;
  27858. /**
  27859. * Gets the active target at specified index. An active target is a target with an influence > 0
  27860. * @param index defines the index to check
  27861. * @returns the requested target
  27862. */
  27863. getActiveTarget(index: number): MorphTarget;
  27864. /**
  27865. * Gets the target at specified index
  27866. * @param index defines the index to check
  27867. * @returns the requested target
  27868. */
  27869. getTarget(index: number): MorphTarget;
  27870. /**
  27871. * Add a new target to this manager
  27872. * @param target defines the target to add
  27873. */
  27874. addTarget(target: MorphTarget): void;
  27875. /**
  27876. * Removes a target from the manager
  27877. * @param target defines the target to remove
  27878. */
  27879. removeTarget(target: MorphTarget): void;
  27880. /**
  27881. * Clone the current manager
  27882. * @returns a new MorphTargetManager
  27883. */
  27884. clone(): MorphTargetManager;
  27885. /**
  27886. * Serializes the current manager into a Serialization object
  27887. * @returns the serialized object
  27888. */
  27889. serialize(): any;
  27890. private _syncActiveTargets;
  27891. /**
  27892. * Syncrhonize the targets with all the meshes using this morph target manager
  27893. */
  27894. synchronize(): void;
  27895. /**
  27896. * Creates a new MorphTargetManager from serialized data
  27897. * @param serializationObject defines the serialized data
  27898. * @param scene defines the hosting scene
  27899. * @returns the new MorphTargetManager
  27900. */
  27901. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27902. }
  27903. }
  27904. declare module "babylonjs/Meshes/meshLODLevel" {
  27905. import { Mesh } from "babylonjs/Meshes/mesh";
  27906. import { Nullable } from "babylonjs/types";
  27907. /**
  27908. * Class used to represent a specific level of detail of a mesh
  27909. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27910. */
  27911. export class MeshLODLevel {
  27912. /** Defines the distance where this level should start being displayed */
  27913. distance: number;
  27914. /** Defines the mesh to use to render this level */
  27915. mesh: Nullable<Mesh>;
  27916. /**
  27917. * Creates a new LOD level
  27918. * @param distance defines the distance where this level should star being displayed
  27919. * @param mesh defines the mesh to use to render this level
  27920. */
  27921. constructor(
  27922. /** Defines the distance where this level should start being displayed */
  27923. distance: number,
  27924. /** Defines the mesh to use to render this level */
  27925. mesh: Nullable<Mesh>);
  27926. }
  27927. }
  27928. declare module "babylonjs/Misc/canvasGenerator" {
  27929. /**
  27930. * Helper class used to generate a canvas to manipulate images
  27931. */
  27932. export class CanvasGenerator {
  27933. /**
  27934. * Create a new canvas (or offscreen canvas depending on the context)
  27935. * @param width defines the expected width
  27936. * @param height defines the expected height
  27937. * @return a new canvas or offscreen canvas
  27938. */
  27939. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27940. }
  27941. }
  27942. declare module "babylonjs/Meshes/groundMesh" {
  27943. import { Scene } from "babylonjs/scene";
  27944. import { Vector3 } from "babylonjs/Maths/math.vector";
  27945. import { Mesh } from "babylonjs/Meshes/mesh";
  27946. /**
  27947. * Mesh representing the gorund
  27948. */
  27949. export class GroundMesh extends Mesh {
  27950. /** If octree should be generated */
  27951. generateOctree: boolean;
  27952. private _heightQuads;
  27953. /** @hidden */
  27954. _subdivisionsX: number;
  27955. /** @hidden */
  27956. _subdivisionsY: number;
  27957. /** @hidden */
  27958. _width: number;
  27959. /** @hidden */
  27960. _height: number;
  27961. /** @hidden */
  27962. _minX: number;
  27963. /** @hidden */
  27964. _maxX: number;
  27965. /** @hidden */
  27966. _minZ: number;
  27967. /** @hidden */
  27968. _maxZ: number;
  27969. constructor(name: string, scene: Scene);
  27970. /**
  27971. * "GroundMesh"
  27972. * @returns "GroundMesh"
  27973. */
  27974. getClassName(): string;
  27975. /**
  27976. * The minimum of x and y subdivisions
  27977. */
  27978. get subdivisions(): number;
  27979. /**
  27980. * X subdivisions
  27981. */
  27982. get subdivisionsX(): number;
  27983. /**
  27984. * Y subdivisions
  27985. */
  27986. get subdivisionsY(): number;
  27987. /**
  27988. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27989. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27990. * @param chunksCount the number of subdivisions for x and y
  27991. * @param octreeBlocksSize (Default: 32)
  27992. */
  27993. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27994. /**
  27995. * Returns a height (y) value in the Worl system :
  27996. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27997. * @param x x coordinate
  27998. * @param z z coordinate
  27999. * @returns the ground y position if (x, z) are outside the ground surface.
  28000. */
  28001. getHeightAtCoordinates(x: number, z: number): number;
  28002. /**
  28003. * Returns a normalized vector (Vector3) orthogonal to the ground
  28004. * at the ground coordinates (x, z) expressed in the World system.
  28005. * @param x x coordinate
  28006. * @param z z coordinate
  28007. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  28008. */
  28009. getNormalAtCoordinates(x: number, z: number): Vector3;
  28010. /**
  28011. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  28012. * at the ground coordinates (x, z) expressed in the World system.
  28013. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  28014. * @param x x coordinate
  28015. * @param z z coordinate
  28016. * @param ref vector to store the result
  28017. * @returns the GroundMesh.
  28018. */
  28019. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  28020. /**
  28021. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  28022. * if the ground has been updated.
  28023. * This can be used in the render loop.
  28024. * @returns the GroundMesh.
  28025. */
  28026. updateCoordinateHeights(): GroundMesh;
  28027. private _getFacetAt;
  28028. private _initHeightQuads;
  28029. private _computeHeightQuads;
  28030. /**
  28031. * Serializes this ground mesh
  28032. * @param serializationObject object to write serialization to
  28033. */
  28034. serialize(serializationObject: any): void;
  28035. /**
  28036. * Parses a serialized ground mesh
  28037. * @param parsedMesh the serialized mesh
  28038. * @param scene the scene to create the ground mesh in
  28039. * @returns the created ground mesh
  28040. */
  28041. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  28042. }
  28043. }
  28044. declare module "babylonjs/Physics/physicsJoint" {
  28045. import { Vector3 } from "babylonjs/Maths/math.vector";
  28046. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  28047. /**
  28048. * Interface for Physics-Joint data
  28049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28050. */
  28051. export interface PhysicsJointData {
  28052. /**
  28053. * The main pivot of the joint
  28054. */
  28055. mainPivot?: Vector3;
  28056. /**
  28057. * The connected pivot of the joint
  28058. */
  28059. connectedPivot?: Vector3;
  28060. /**
  28061. * The main axis of the joint
  28062. */
  28063. mainAxis?: Vector3;
  28064. /**
  28065. * The connected axis of the joint
  28066. */
  28067. connectedAxis?: Vector3;
  28068. /**
  28069. * The collision of the joint
  28070. */
  28071. collision?: boolean;
  28072. /**
  28073. * Native Oimo/Cannon/Energy data
  28074. */
  28075. nativeParams?: any;
  28076. }
  28077. /**
  28078. * This is a holder class for the physics joint created by the physics plugin
  28079. * It holds a set of functions to control the underlying joint
  28080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28081. */
  28082. export class PhysicsJoint {
  28083. /**
  28084. * The type of the physics joint
  28085. */
  28086. type: number;
  28087. /**
  28088. * The data for the physics joint
  28089. */
  28090. jointData: PhysicsJointData;
  28091. private _physicsJoint;
  28092. protected _physicsPlugin: IPhysicsEnginePlugin;
  28093. /**
  28094. * Initializes the physics joint
  28095. * @param type The type of the physics joint
  28096. * @param jointData The data for the physics joint
  28097. */
  28098. constructor(
  28099. /**
  28100. * The type of the physics joint
  28101. */
  28102. type: number,
  28103. /**
  28104. * The data for the physics joint
  28105. */
  28106. jointData: PhysicsJointData);
  28107. /**
  28108. * Gets the physics joint
  28109. */
  28110. get physicsJoint(): any;
  28111. /**
  28112. * Sets the physics joint
  28113. */
  28114. set physicsJoint(newJoint: any);
  28115. /**
  28116. * Sets the physics plugin
  28117. */
  28118. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28119. /**
  28120. * Execute a function that is physics-plugin specific.
  28121. * @param {Function} func the function that will be executed.
  28122. * It accepts two parameters: the physics world and the physics joint
  28123. */
  28124. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28125. /**
  28126. * Distance-Joint type
  28127. */
  28128. static DistanceJoint: number;
  28129. /**
  28130. * Hinge-Joint type
  28131. */
  28132. static HingeJoint: number;
  28133. /**
  28134. * Ball-and-Socket joint type
  28135. */
  28136. static BallAndSocketJoint: number;
  28137. /**
  28138. * Wheel-Joint type
  28139. */
  28140. static WheelJoint: number;
  28141. /**
  28142. * Slider-Joint type
  28143. */
  28144. static SliderJoint: number;
  28145. /**
  28146. * Prismatic-Joint type
  28147. */
  28148. static PrismaticJoint: number;
  28149. /**
  28150. * Universal-Joint type
  28151. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28152. */
  28153. static UniversalJoint: number;
  28154. /**
  28155. * Hinge-Joint 2 type
  28156. */
  28157. static Hinge2Joint: number;
  28158. /**
  28159. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28160. */
  28161. static PointToPointJoint: number;
  28162. /**
  28163. * Spring-Joint type
  28164. */
  28165. static SpringJoint: number;
  28166. /**
  28167. * Lock-Joint type
  28168. */
  28169. static LockJoint: number;
  28170. }
  28171. /**
  28172. * A class representing a physics distance joint
  28173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28174. */
  28175. export class DistanceJoint extends PhysicsJoint {
  28176. /**
  28177. *
  28178. * @param jointData The data for the Distance-Joint
  28179. */
  28180. constructor(jointData: DistanceJointData);
  28181. /**
  28182. * Update the predefined distance.
  28183. * @param maxDistance The maximum preferred distance
  28184. * @param minDistance The minimum preferred distance
  28185. */
  28186. updateDistance(maxDistance: number, minDistance?: number): void;
  28187. }
  28188. /**
  28189. * Represents a Motor-Enabled Joint
  28190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28191. */
  28192. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28193. /**
  28194. * Initializes the Motor-Enabled Joint
  28195. * @param type The type of the joint
  28196. * @param jointData The physica joint data for the joint
  28197. */
  28198. constructor(type: number, jointData: PhysicsJointData);
  28199. /**
  28200. * Set the motor values.
  28201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28202. * @param force the force to apply
  28203. * @param maxForce max force for this motor.
  28204. */
  28205. setMotor(force?: number, maxForce?: number): void;
  28206. /**
  28207. * Set the motor's limits.
  28208. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28209. * @param upperLimit The upper limit of the motor
  28210. * @param lowerLimit The lower limit of the motor
  28211. */
  28212. setLimit(upperLimit: number, lowerLimit?: number): void;
  28213. }
  28214. /**
  28215. * This class represents a single physics Hinge-Joint
  28216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28217. */
  28218. export class HingeJoint extends MotorEnabledJoint {
  28219. /**
  28220. * Initializes the Hinge-Joint
  28221. * @param jointData The joint data for the Hinge-Joint
  28222. */
  28223. constructor(jointData: PhysicsJointData);
  28224. /**
  28225. * Set the motor values.
  28226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28227. * @param {number} force the force to apply
  28228. * @param {number} maxForce max force for this motor.
  28229. */
  28230. setMotor(force?: number, maxForce?: number): void;
  28231. /**
  28232. * Set the motor's limits.
  28233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28234. * @param upperLimit The upper limit of the motor
  28235. * @param lowerLimit The lower limit of the motor
  28236. */
  28237. setLimit(upperLimit: number, lowerLimit?: number): void;
  28238. }
  28239. /**
  28240. * This class represents a dual hinge physics joint (same as wheel joint)
  28241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28242. */
  28243. export class Hinge2Joint extends MotorEnabledJoint {
  28244. /**
  28245. * Initializes the Hinge2-Joint
  28246. * @param jointData The joint data for the Hinge2-Joint
  28247. */
  28248. constructor(jointData: PhysicsJointData);
  28249. /**
  28250. * Set the motor values.
  28251. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28252. * @param {number} targetSpeed the speed the motor is to reach
  28253. * @param {number} maxForce max force for this motor.
  28254. * @param {motorIndex} the motor's index, 0 or 1.
  28255. */
  28256. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28257. /**
  28258. * Set the motor limits.
  28259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28260. * @param {number} upperLimit the upper limit
  28261. * @param {number} lowerLimit lower limit
  28262. * @param {motorIndex} the motor's index, 0 or 1.
  28263. */
  28264. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28265. }
  28266. /**
  28267. * Interface for a motor enabled joint
  28268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28269. */
  28270. export interface IMotorEnabledJoint {
  28271. /**
  28272. * Physics joint
  28273. */
  28274. physicsJoint: any;
  28275. /**
  28276. * Sets the motor of the motor-enabled joint
  28277. * @param force The force of the motor
  28278. * @param maxForce The maximum force of the motor
  28279. * @param motorIndex The index of the motor
  28280. */
  28281. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28282. /**
  28283. * Sets the limit of the motor
  28284. * @param upperLimit The upper limit of the motor
  28285. * @param lowerLimit The lower limit of the motor
  28286. * @param motorIndex The index of the motor
  28287. */
  28288. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28289. }
  28290. /**
  28291. * Joint data for a Distance-Joint
  28292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28293. */
  28294. export interface DistanceJointData extends PhysicsJointData {
  28295. /**
  28296. * Max distance the 2 joint objects can be apart
  28297. */
  28298. maxDistance: number;
  28299. }
  28300. /**
  28301. * Joint data from a spring joint
  28302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28303. */
  28304. export interface SpringJointData extends PhysicsJointData {
  28305. /**
  28306. * Length of the spring
  28307. */
  28308. length: number;
  28309. /**
  28310. * Stiffness of the spring
  28311. */
  28312. stiffness: number;
  28313. /**
  28314. * Damping of the spring
  28315. */
  28316. damping: number;
  28317. /** this callback will be called when applying the force to the impostors. */
  28318. forceApplicationCallback: () => void;
  28319. }
  28320. }
  28321. declare module "babylonjs/Physics/physicsRaycastResult" {
  28322. import { Vector3 } from "babylonjs/Maths/math.vector";
  28323. /**
  28324. * Holds the data for the raycast result
  28325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28326. */
  28327. export class PhysicsRaycastResult {
  28328. private _hasHit;
  28329. private _hitDistance;
  28330. private _hitNormalWorld;
  28331. private _hitPointWorld;
  28332. private _rayFromWorld;
  28333. private _rayToWorld;
  28334. /**
  28335. * Gets if there was a hit
  28336. */
  28337. get hasHit(): boolean;
  28338. /**
  28339. * Gets the distance from the hit
  28340. */
  28341. get hitDistance(): number;
  28342. /**
  28343. * Gets the hit normal/direction in the world
  28344. */
  28345. get hitNormalWorld(): Vector3;
  28346. /**
  28347. * Gets the hit point in the world
  28348. */
  28349. get hitPointWorld(): Vector3;
  28350. /**
  28351. * Gets the ray "start point" of the ray in the world
  28352. */
  28353. get rayFromWorld(): Vector3;
  28354. /**
  28355. * Gets the ray "end point" of the ray in the world
  28356. */
  28357. get rayToWorld(): Vector3;
  28358. /**
  28359. * Sets the hit data (normal & point in world space)
  28360. * @param hitNormalWorld defines the normal in world space
  28361. * @param hitPointWorld defines the point in world space
  28362. */
  28363. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28364. /**
  28365. * Sets the distance from the start point to the hit point
  28366. * @param distance
  28367. */
  28368. setHitDistance(distance: number): void;
  28369. /**
  28370. * Calculates the distance manually
  28371. */
  28372. calculateHitDistance(): void;
  28373. /**
  28374. * Resets all the values to default
  28375. * @param from The from point on world space
  28376. * @param to The to point on world space
  28377. */
  28378. reset(from?: Vector3, to?: Vector3): void;
  28379. }
  28380. /**
  28381. * Interface for the size containing width and height
  28382. */
  28383. interface IXYZ {
  28384. /**
  28385. * X
  28386. */
  28387. x: number;
  28388. /**
  28389. * Y
  28390. */
  28391. y: number;
  28392. /**
  28393. * Z
  28394. */
  28395. z: number;
  28396. }
  28397. }
  28398. declare module "babylonjs/Physics/IPhysicsEngine" {
  28399. import { Nullable } from "babylonjs/types";
  28400. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28402. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28403. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28404. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28405. /**
  28406. * Interface used to describe a physics joint
  28407. */
  28408. export interface PhysicsImpostorJoint {
  28409. /** Defines the main impostor to which the joint is linked */
  28410. mainImpostor: PhysicsImpostor;
  28411. /** Defines the impostor that is connected to the main impostor using this joint */
  28412. connectedImpostor: PhysicsImpostor;
  28413. /** Defines the joint itself */
  28414. joint: PhysicsJoint;
  28415. }
  28416. /** @hidden */
  28417. export interface IPhysicsEnginePlugin {
  28418. world: any;
  28419. name: string;
  28420. setGravity(gravity: Vector3): void;
  28421. setTimeStep(timeStep: number): void;
  28422. getTimeStep(): number;
  28423. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28424. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28425. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28427. removePhysicsBody(impostor: PhysicsImpostor): void;
  28428. generateJoint(joint: PhysicsImpostorJoint): void;
  28429. removeJoint(joint: PhysicsImpostorJoint): void;
  28430. isSupported(): boolean;
  28431. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28433. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28434. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28435. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28437. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28438. getBodyMass(impostor: PhysicsImpostor): number;
  28439. getBodyFriction(impostor: PhysicsImpostor): number;
  28440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28441. getBodyRestitution(impostor: PhysicsImpostor): number;
  28442. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28443. getBodyPressure?(impostor: PhysicsImpostor): number;
  28444. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28445. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28446. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28447. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28448. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28449. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28450. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28451. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28452. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28453. sleepBody(impostor: PhysicsImpostor): void;
  28454. wakeUpBody(impostor: PhysicsImpostor): void;
  28455. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28456. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28457. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28459. getRadius(impostor: PhysicsImpostor): number;
  28460. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28462. dispose(): void;
  28463. }
  28464. /**
  28465. * Interface used to define a physics engine
  28466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28467. */
  28468. export interface IPhysicsEngine {
  28469. /**
  28470. * Gets the gravity vector used by the simulation
  28471. */
  28472. gravity: Vector3;
  28473. /**
  28474. * Sets the gravity vector used by the simulation
  28475. * @param gravity defines the gravity vector to use
  28476. */
  28477. setGravity(gravity: Vector3): void;
  28478. /**
  28479. * Set the time step of the physics engine.
  28480. * Default is 1/60.
  28481. * To slow it down, enter 1/600 for example.
  28482. * To speed it up, 1/30
  28483. * @param newTimeStep the new timestep to apply to this world.
  28484. */
  28485. setTimeStep(newTimeStep: number): void;
  28486. /**
  28487. * Get the time step of the physics engine.
  28488. * @returns the current time step
  28489. */
  28490. getTimeStep(): number;
  28491. /**
  28492. * Set the sub time step of the physics engine.
  28493. * Default is 0 meaning there is no sub steps
  28494. * To increase physics resolution precision, set a small value (like 1 ms)
  28495. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28496. */
  28497. setSubTimeStep(subTimeStep: number): void;
  28498. /**
  28499. * Get the sub time step of the physics engine.
  28500. * @returns the current sub time step
  28501. */
  28502. getSubTimeStep(): number;
  28503. /**
  28504. * Release all resources
  28505. */
  28506. dispose(): void;
  28507. /**
  28508. * Gets the name of the current physics plugin
  28509. * @returns the name of the plugin
  28510. */
  28511. getPhysicsPluginName(): string;
  28512. /**
  28513. * Adding a new impostor for the impostor tracking.
  28514. * This will be done by the impostor itself.
  28515. * @param impostor the impostor to add
  28516. */
  28517. addImpostor(impostor: PhysicsImpostor): void;
  28518. /**
  28519. * Remove an impostor from the engine.
  28520. * This impostor and its mesh will not longer be updated by the physics engine.
  28521. * @param impostor the impostor to remove
  28522. */
  28523. removeImpostor(impostor: PhysicsImpostor): void;
  28524. /**
  28525. * Add a joint to the physics engine
  28526. * @param mainImpostor defines the main impostor to which the joint is added.
  28527. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28528. * @param joint defines the joint that will connect both impostors.
  28529. */
  28530. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28531. /**
  28532. * Removes a joint from the simulation
  28533. * @param mainImpostor defines the impostor used with the joint
  28534. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28535. * @param joint defines the joint to remove
  28536. */
  28537. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28538. /**
  28539. * Gets the current plugin used to run the simulation
  28540. * @returns current plugin
  28541. */
  28542. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28543. /**
  28544. * Gets the list of physic impostors
  28545. * @returns an array of PhysicsImpostor
  28546. */
  28547. getImpostors(): Array<PhysicsImpostor>;
  28548. /**
  28549. * Gets the impostor for a physics enabled object
  28550. * @param object defines the object impersonated by the impostor
  28551. * @returns the PhysicsImpostor or null if not found
  28552. */
  28553. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28554. /**
  28555. * Gets the impostor for a physics body object
  28556. * @param body defines physics body used by the impostor
  28557. * @returns the PhysicsImpostor or null if not found
  28558. */
  28559. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28560. /**
  28561. * Does a raycast in the physics world
  28562. * @param from when should the ray start?
  28563. * @param to when should the ray end?
  28564. * @returns PhysicsRaycastResult
  28565. */
  28566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28567. /**
  28568. * Called by the scene. No need to call it.
  28569. * @param delta defines the timespam between frames
  28570. */
  28571. _step(delta: number): void;
  28572. }
  28573. }
  28574. declare module "babylonjs/Physics/physicsImpostor" {
  28575. import { Nullable, IndicesArray } from "babylonjs/types";
  28576. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28579. import { Scene } from "babylonjs/scene";
  28580. import { Bone } from "babylonjs/Bones/bone";
  28581. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28582. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28583. import { Space } from "babylonjs/Maths/math.axis";
  28584. /**
  28585. * The interface for the physics imposter parameters
  28586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28587. */
  28588. export interface PhysicsImpostorParameters {
  28589. /**
  28590. * The mass of the physics imposter
  28591. */
  28592. mass: number;
  28593. /**
  28594. * The friction of the physics imposter
  28595. */
  28596. friction?: number;
  28597. /**
  28598. * The coefficient of restitution of the physics imposter
  28599. */
  28600. restitution?: number;
  28601. /**
  28602. * The native options of the physics imposter
  28603. */
  28604. nativeOptions?: any;
  28605. /**
  28606. * Specifies if the parent should be ignored
  28607. */
  28608. ignoreParent?: boolean;
  28609. /**
  28610. * Specifies if bi-directional transformations should be disabled
  28611. */
  28612. disableBidirectionalTransformation?: boolean;
  28613. /**
  28614. * The pressure inside the physics imposter, soft object only
  28615. */
  28616. pressure?: number;
  28617. /**
  28618. * The stiffness the physics imposter, soft object only
  28619. */
  28620. stiffness?: number;
  28621. /**
  28622. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28623. */
  28624. velocityIterations?: number;
  28625. /**
  28626. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28627. */
  28628. positionIterations?: number;
  28629. /**
  28630. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28631. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28632. * Add to fix multiple points
  28633. */
  28634. fixedPoints?: number;
  28635. /**
  28636. * The collision margin around a soft object
  28637. */
  28638. margin?: number;
  28639. /**
  28640. * The collision margin around a soft object
  28641. */
  28642. damping?: number;
  28643. /**
  28644. * The path for a rope based on an extrusion
  28645. */
  28646. path?: any;
  28647. /**
  28648. * The shape of an extrusion used for a rope based on an extrusion
  28649. */
  28650. shape?: any;
  28651. }
  28652. /**
  28653. * Interface for a physics-enabled object
  28654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28655. */
  28656. export interface IPhysicsEnabledObject {
  28657. /**
  28658. * The position of the physics-enabled object
  28659. */
  28660. position: Vector3;
  28661. /**
  28662. * The rotation of the physics-enabled object
  28663. */
  28664. rotationQuaternion: Nullable<Quaternion>;
  28665. /**
  28666. * The scale of the physics-enabled object
  28667. */
  28668. scaling: Vector3;
  28669. /**
  28670. * The rotation of the physics-enabled object
  28671. */
  28672. rotation?: Vector3;
  28673. /**
  28674. * The parent of the physics-enabled object
  28675. */
  28676. parent?: any;
  28677. /**
  28678. * The bounding info of the physics-enabled object
  28679. * @returns The bounding info of the physics-enabled object
  28680. */
  28681. getBoundingInfo(): BoundingInfo;
  28682. /**
  28683. * Computes the world matrix
  28684. * @param force Specifies if the world matrix should be computed by force
  28685. * @returns A world matrix
  28686. */
  28687. computeWorldMatrix(force: boolean): Matrix;
  28688. /**
  28689. * Gets the world matrix
  28690. * @returns A world matrix
  28691. */
  28692. getWorldMatrix?(): Matrix;
  28693. /**
  28694. * Gets the child meshes
  28695. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28696. * @returns An array of abstract meshes
  28697. */
  28698. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28699. /**
  28700. * Gets the vertex data
  28701. * @param kind The type of vertex data
  28702. * @returns A nullable array of numbers, or a float32 array
  28703. */
  28704. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28705. /**
  28706. * Gets the indices from the mesh
  28707. * @returns A nullable array of index arrays
  28708. */
  28709. getIndices?(): Nullable<IndicesArray>;
  28710. /**
  28711. * Gets the scene from the mesh
  28712. * @returns the indices array or null
  28713. */
  28714. getScene?(): Scene;
  28715. /**
  28716. * Gets the absolute position from the mesh
  28717. * @returns the absolute position
  28718. */
  28719. getAbsolutePosition(): Vector3;
  28720. /**
  28721. * Gets the absolute pivot point from the mesh
  28722. * @returns the absolute pivot point
  28723. */
  28724. getAbsolutePivotPoint(): Vector3;
  28725. /**
  28726. * Rotates the mesh
  28727. * @param axis The axis of rotation
  28728. * @param amount The amount of rotation
  28729. * @param space The space of the rotation
  28730. * @returns The rotation transform node
  28731. */
  28732. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28733. /**
  28734. * Translates the mesh
  28735. * @param axis The axis of translation
  28736. * @param distance The distance of translation
  28737. * @param space The space of the translation
  28738. * @returns The transform node
  28739. */
  28740. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28741. /**
  28742. * Sets the absolute position of the mesh
  28743. * @param absolutePosition The absolute position of the mesh
  28744. * @returns The transform node
  28745. */
  28746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28747. /**
  28748. * Gets the class name of the mesh
  28749. * @returns The class name
  28750. */
  28751. getClassName(): string;
  28752. }
  28753. /**
  28754. * Represents a physics imposter
  28755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28756. */
  28757. export class PhysicsImpostor {
  28758. /**
  28759. * The physics-enabled object used as the physics imposter
  28760. */
  28761. object: IPhysicsEnabledObject;
  28762. /**
  28763. * The type of the physics imposter
  28764. */
  28765. type: number;
  28766. private _options;
  28767. private _scene?;
  28768. /**
  28769. * The default object size of the imposter
  28770. */
  28771. static DEFAULT_OBJECT_SIZE: Vector3;
  28772. /**
  28773. * The identity quaternion of the imposter
  28774. */
  28775. static IDENTITY_QUATERNION: Quaternion;
  28776. /** @hidden */
  28777. _pluginData: any;
  28778. private _physicsEngine;
  28779. private _physicsBody;
  28780. private _bodyUpdateRequired;
  28781. private _onBeforePhysicsStepCallbacks;
  28782. private _onAfterPhysicsStepCallbacks;
  28783. /** @hidden */
  28784. _onPhysicsCollideCallbacks: Array<{
  28785. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28786. otherImpostors: Array<PhysicsImpostor>;
  28787. }>;
  28788. private _deltaPosition;
  28789. private _deltaRotation;
  28790. private _deltaRotationConjugated;
  28791. /** @hidden */
  28792. _isFromLine: boolean;
  28793. private _parent;
  28794. private _isDisposed;
  28795. private static _tmpVecs;
  28796. private static _tmpQuat;
  28797. /**
  28798. * Specifies if the physics imposter is disposed
  28799. */
  28800. get isDisposed(): boolean;
  28801. /**
  28802. * Gets the mass of the physics imposter
  28803. */
  28804. get mass(): number;
  28805. set mass(value: number);
  28806. /**
  28807. * Gets the coefficient of friction
  28808. */
  28809. get friction(): number;
  28810. /**
  28811. * Sets the coefficient of friction
  28812. */
  28813. set friction(value: number);
  28814. /**
  28815. * Gets the coefficient of restitution
  28816. */
  28817. get restitution(): number;
  28818. /**
  28819. * Sets the coefficient of restitution
  28820. */
  28821. set restitution(value: number);
  28822. /**
  28823. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28824. */
  28825. get pressure(): number;
  28826. /**
  28827. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28828. */
  28829. set pressure(value: number);
  28830. /**
  28831. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28832. */
  28833. get stiffness(): number;
  28834. /**
  28835. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28836. */
  28837. set stiffness(value: number);
  28838. /**
  28839. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28840. */
  28841. get velocityIterations(): number;
  28842. /**
  28843. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28844. */
  28845. set velocityIterations(value: number);
  28846. /**
  28847. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28848. */
  28849. get positionIterations(): number;
  28850. /**
  28851. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28852. */
  28853. set positionIterations(value: number);
  28854. /**
  28855. * The unique id of the physics imposter
  28856. * set by the physics engine when adding this impostor to the array
  28857. */
  28858. uniqueId: number;
  28859. /**
  28860. * @hidden
  28861. */
  28862. soft: boolean;
  28863. /**
  28864. * @hidden
  28865. */
  28866. segments: number;
  28867. private _joints;
  28868. /**
  28869. * Initializes the physics imposter
  28870. * @param object The physics-enabled object used as the physics imposter
  28871. * @param type The type of the physics imposter
  28872. * @param _options The options for the physics imposter
  28873. * @param _scene The Babylon scene
  28874. */
  28875. constructor(
  28876. /**
  28877. * The physics-enabled object used as the physics imposter
  28878. */
  28879. object: IPhysicsEnabledObject,
  28880. /**
  28881. * The type of the physics imposter
  28882. */
  28883. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28884. /**
  28885. * This function will completly initialize this impostor.
  28886. * It will create a new body - but only if this mesh has no parent.
  28887. * If it has, this impostor will not be used other than to define the impostor
  28888. * of the child mesh.
  28889. * @hidden
  28890. */
  28891. _init(): void;
  28892. private _getPhysicsParent;
  28893. /**
  28894. * Should a new body be generated.
  28895. * @returns boolean specifying if body initialization is required
  28896. */
  28897. isBodyInitRequired(): boolean;
  28898. /**
  28899. * Sets the updated scaling
  28900. * @param updated Specifies if the scaling is updated
  28901. */
  28902. setScalingUpdated(): void;
  28903. /**
  28904. * Force a regeneration of this or the parent's impostor's body.
  28905. * Use under cautious - This will remove all joints already implemented.
  28906. */
  28907. forceUpdate(): void;
  28908. /**
  28909. * Gets the body that holds this impostor. Either its own, or its parent.
  28910. */
  28911. get physicsBody(): any;
  28912. /**
  28913. * Get the parent of the physics imposter
  28914. * @returns Physics imposter or null
  28915. */
  28916. get parent(): Nullable<PhysicsImpostor>;
  28917. /**
  28918. * Sets the parent of the physics imposter
  28919. */
  28920. set parent(value: Nullable<PhysicsImpostor>);
  28921. /**
  28922. * Set the physics body. Used mainly by the physics engine/plugin
  28923. */
  28924. set physicsBody(physicsBody: any);
  28925. /**
  28926. * Resets the update flags
  28927. */
  28928. resetUpdateFlags(): void;
  28929. /**
  28930. * Gets the object extend size
  28931. * @returns the object extend size
  28932. */
  28933. getObjectExtendSize(): Vector3;
  28934. /**
  28935. * Gets the object center
  28936. * @returns The object center
  28937. */
  28938. getObjectCenter(): Vector3;
  28939. /**
  28940. * Get a specific parameter from the options parameters
  28941. * @param paramName The object parameter name
  28942. * @returns The object parameter
  28943. */
  28944. getParam(paramName: string): any;
  28945. /**
  28946. * Sets a specific parameter in the options given to the physics plugin
  28947. * @param paramName The parameter name
  28948. * @param value The value of the parameter
  28949. */
  28950. setParam(paramName: string, value: number): void;
  28951. /**
  28952. * Specifically change the body's mass option. Won't recreate the physics body object
  28953. * @param mass The mass of the physics imposter
  28954. */
  28955. setMass(mass: number): void;
  28956. /**
  28957. * Gets the linear velocity
  28958. * @returns linear velocity or null
  28959. */
  28960. getLinearVelocity(): Nullable<Vector3>;
  28961. /**
  28962. * Sets the linear velocity
  28963. * @param velocity linear velocity or null
  28964. */
  28965. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28966. /**
  28967. * Gets the angular velocity
  28968. * @returns angular velocity or null
  28969. */
  28970. getAngularVelocity(): Nullable<Vector3>;
  28971. /**
  28972. * Sets the angular velocity
  28973. * @param velocity The velocity or null
  28974. */
  28975. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28976. /**
  28977. * Execute a function with the physics plugin native code
  28978. * Provide a function the will have two variables - the world object and the physics body object
  28979. * @param func The function to execute with the physics plugin native code
  28980. */
  28981. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28982. /**
  28983. * Register a function that will be executed before the physics world is stepping forward
  28984. * @param func The function to execute before the physics world is stepped forward
  28985. */
  28986. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28987. /**
  28988. * Unregister a function that will be executed before the physics world is stepping forward
  28989. * @param func The function to execute before the physics world is stepped forward
  28990. */
  28991. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28992. /**
  28993. * Register a function that will be executed after the physics step
  28994. * @param func The function to execute after physics step
  28995. */
  28996. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28997. /**
  28998. * Unregisters a function that will be executed after the physics step
  28999. * @param func The function to execute after physics step
  29000. */
  29001. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  29002. /**
  29003. * register a function that will be executed when this impostor collides against a different body
  29004. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  29005. * @param func Callback that is executed on collision
  29006. */
  29007. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  29008. /**
  29009. * Unregisters the physics imposter on contact
  29010. * @param collideAgainst The physics object to collide against
  29011. * @param func Callback to execute on collision
  29012. */
  29013. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  29014. private _tmpQuat;
  29015. private _tmpQuat2;
  29016. /**
  29017. * Get the parent rotation
  29018. * @returns The parent rotation
  29019. */
  29020. getParentsRotation(): Quaternion;
  29021. /**
  29022. * this function is executed by the physics engine.
  29023. */
  29024. beforeStep: () => void;
  29025. /**
  29026. * this function is executed by the physics engine
  29027. */
  29028. afterStep: () => void;
  29029. /**
  29030. * Legacy collision detection event support
  29031. */
  29032. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  29033. /**
  29034. * event and body object due to cannon's event-based architecture.
  29035. */
  29036. onCollide: (e: {
  29037. body: any;
  29038. }) => void;
  29039. /**
  29040. * Apply a force
  29041. * @param force The force to apply
  29042. * @param contactPoint The contact point for the force
  29043. * @returns The physics imposter
  29044. */
  29045. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29046. /**
  29047. * Apply an impulse
  29048. * @param force The impulse force
  29049. * @param contactPoint The contact point for the impulse force
  29050. * @returns The physics imposter
  29051. */
  29052. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29053. /**
  29054. * A help function to create a joint
  29055. * @param otherImpostor A physics imposter used to create a joint
  29056. * @param jointType The type of joint
  29057. * @param jointData The data for the joint
  29058. * @returns The physics imposter
  29059. */
  29060. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  29061. /**
  29062. * Add a joint to this impostor with a different impostor
  29063. * @param otherImpostor A physics imposter used to add a joint
  29064. * @param joint The joint to add
  29065. * @returns The physics imposter
  29066. */
  29067. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  29068. /**
  29069. * Add an anchor to a cloth impostor
  29070. * @param otherImpostor rigid impostor to anchor to
  29071. * @param width ratio across width from 0 to 1
  29072. * @param height ratio up height from 0 to 1
  29073. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  29074. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  29075. * @returns impostor the soft imposter
  29076. */
  29077. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29078. /**
  29079. * Add a hook to a rope impostor
  29080. * @param otherImpostor rigid impostor to anchor to
  29081. * @param length ratio across rope from 0 to 1
  29082. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29083. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29084. * @returns impostor the rope imposter
  29085. */
  29086. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29087. /**
  29088. * Will keep this body still, in a sleep mode.
  29089. * @returns the physics imposter
  29090. */
  29091. sleep(): PhysicsImpostor;
  29092. /**
  29093. * Wake the body up.
  29094. * @returns The physics imposter
  29095. */
  29096. wakeUp(): PhysicsImpostor;
  29097. /**
  29098. * Clones the physics imposter
  29099. * @param newObject The physics imposter clones to this physics-enabled object
  29100. * @returns A nullable physics imposter
  29101. */
  29102. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29103. /**
  29104. * Disposes the physics imposter
  29105. */
  29106. dispose(): void;
  29107. /**
  29108. * Sets the delta position
  29109. * @param position The delta position amount
  29110. */
  29111. setDeltaPosition(position: Vector3): void;
  29112. /**
  29113. * Sets the delta rotation
  29114. * @param rotation The delta rotation amount
  29115. */
  29116. setDeltaRotation(rotation: Quaternion): void;
  29117. /**
  29118. * Gets the box size of the physics imposter and stores the result in the input parameter
  29119. * @param result Stores the box size
  29120. * @returns The physics imposter
  29121. */
  29122. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29123. /**
  29124. * Gets the radius of the physics imposter
  29125. * @returns Radius of the physics imposter
  29126. */
  29127. getRadius(): number;
  29128. /**
  29129. * Sync a bone with this impostor
  29130. * @param bone The bone to sync to the impostor.
  29131. * @param boneMesh The mesh that the bone is influencing.
  29132. * @param jointPivot The pivot of the joint / bone in local space.
  29133. * @param distToJoint Optional distance from the impostor to the joint.
  29134. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29135. */
  29136. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29137. /**
  29138. * Sync impostor to a bone
  29139. * @param bone The bone that the impostor will be synced to.
  29140. * @param boneMesh The mesh that the bone is influencing.
  29141. * @param jointPivot The pivot of the joint / bone in local space.
  29142. * @param distToJoint Optional distance from the impostor to the joint.
  29143. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29144. * @param boneAxis Optional vector3 axis the bone is aligned with
  29145. */
  29146. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29147. /**
  29148. * No-Imposter type
  29149. */
  29150. static NoImpostor: number;
  29151. /**
  29152. * Sphere-Imposter type
  29153. */
  29154. static SphereImpostor: number;
  29155. /**
  29156. * Box-Imposter type
  29157. */
  29158. static BoxImpostor: number;
  29159. /**
  29160. * Plane-Imposter type
  29161. */
  29162. static PlaneImpostor: number;
  29163. /**
  29164. * Mesh-imposter type
  29165. */
  29166. static MeshImpostor: number;
  29167. /**
  29168. * Capsule-Impostor type (Ammo.js plugin only)
  29169. */
  29170. static CapsuleImpostor: number;
  29171. /**
  29172. * Cylinder-Imposter type
  29173. */
  29174. static CylinderImpostor: number;
  29175. /**
  29176. * Particle-Imposter type
  29177. */
  29178. static ParticleImpostor: number;
  29179. /**
  29180. * Heightmap-Imposter type
  29181. */
  29182. static HeightmapImpostor: number;
  29183. /**
  29184. * ConvexHull-Impostor type (Ammo.js plugin only)
  29185. */
  29186. static ConvexHullImpostor: number;
  29187. /**
  29188. * Custom-Imposter type (Ammo.js plugin only)
  29189. */
  29190. static CustomImpostor: number;
  29191. /**
  29192. * Rope-Imposter type
  29193. */
  29194. static RopeImpostor: number;
  29195. /**
  29196. * Cloth-Imposter type
  29197. */
  29198. static ClothImpostor: number;
  29199. /**
  29200. * Softbody-Imposter type
  29201. */
  29202. static SoftbodyImpostor: number;
  29203. }
  29204. }
  29205. declare module "babylonjs/Meshes/mesh" {
  29206. import { Observable } from "babylonjs/Misc/observable";
  29207. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29208. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29209. import { Camera } from "babylonjs/Cameras/camera";
  29210. import { Scene } from "babylonjs/scene";
  29211. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29212. import { Color4 } from "babylonjs/Maths/math.color";
  29213. import { Engine } from "babylonjs/Engines/engine";
  29214. import { Node } from "babylonjs/node";
  29215. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29216. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29217. import { Buffer } from "babylonjs/Meshes/buffer";
  29218. import { Geometry } from "babylonjs/Meshes/geometry";
  29219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29221. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29222. import { Effect } from "babylonjs/Materials/effect";
  29223. import { Material } from "babylonjs/Materials/material";
  29224. import { Skeleton } from "babylonjs/Bones/skeleton";
  29225. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29226. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29227. import { Path3D } from "babylonjs/Maths/math.path";
  29228. import { Plane } from "babylonjs/Maths/math.plane";
  29229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29230. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29231. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29232. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29233. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29234. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29235. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29236. /**
  29237. * @hidden
  29238. **/
  29239. export class _CreationDataStorage {
  29240. closePath?: boolean;
  29241. closeArray?: boolean;
  29242. idx: number[];
  29243. dashSize: number;
  29244. gapSize: number;
  29245. path3D: Path3D;
  29246. pathArray: Vector3[][];
  29247. arc: number;
  29248. radius: number;
  29249. cap: number;
  29250. tessellation: number;
  29251. }
  29252. /**
  29253. * @hidden
  29254. **/
  29255. class _InstanceDataStorage {
  29256. visibleInstances: any;
  29257. batchCache: _InstancesBatch;
  29258. instancesBufferSize: number;
  29259. instancesBuffer: Nullable<Buffer>;
  29260. instancesData: Float32Array;
  29261. overridenInstanceCount: number;
  29262. isFrozen: boolean;
  29263. previousBatch: Nullable<_InstancesBatch>;
  29264. hardwareInstancedRendering: boolean;
  29265. sideOrientation: number;
  29266. manualUpdate: boolean;
  29267. previousRenderId: number;
  29268. }
  29269. /**
  29270. * @hidden
  29271. **/
  29272. export class _InstancesBatch {
  29273. mustReturn: boolean;
  29274. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29275. renderSelf: boolean[];
  29276. hardwareInstancedRendering: boolean[];
  29277. }
  29278. /**
  29279. * @hidden
  29280. **/
  29281. class _ThinInstanceDataStorage {
  29282. instancesCount: number;
  29283. matrixBuffer: Nullable<Buffer>;
  29284. matrixBufferSize: number;
  29285. matrixData: Nullable<Float32Array>;
  29286. boundingVectors: Array<Vector3>;
  29287. worldMatrices: Nullable<Matrix[]>;
  29288. }
  29289. /**
  29290. * Class used to represent renderable models
  29291. */
  29292. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29293. /**
  29294. * Mesh side orientation : usually the external or front surface
  29295. */
  29296. static readonly FRONTSIDE: number;
  29297. /**
  29298. * Mesh side orientation : usually the internal or back surface
  29299. */
  29300. static readonly BACKSIDE: number;
  29301. /**
  29302. * Mesh side orientation : both internal and external or front and back surfaces
  29303. */
  29304. static readonly DOUBLESIDE: number;
  29305. /**
  29306. * Mesh side orientation : by default, `FRONTSIDE`
  29307. */
  29308. static readonly DEFAULTSIDE: number;
  29309. /**
  29310. * Mesh cap setting : no cap
  29311. */
  29312. static readonly NO_CAP: number;
  29313. /**
  29314. * Mesh cap setting : one cap at the beginning of the mesh
  29315. */
  29316. static readonly CAP_START: number;
  29317. /**
  29318. * Mesh cap setting : one cap at the end of the mesh
  29319. */
  29320. static readonly CAP_END: number;
  29321. /**
  29322. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29323. */
  29324. static readonly CAP_ALL: number;
  29325. /**
  29326. * Mesh pattern setting : no flip or rotate
  29327. */
  29328. static readonly NO_FLIP: number;
  29329. /**
  29330. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29331. */
  29332. static readonly FLIP_TILE: number;
  29333. /**
  29334. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29335. */
  29336. static readonly ROTATE_TILE: number;
  29337. /**
  29338. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29339. */
  29340. static readonly FLIP_ROW: number;
  29341. /**
  29342. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29343. */
  29344. static readonly ROTATE_ROW: number;
  29345. /**
  29346. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29347. */
  29348. static readonly FLIP_N_ROTATE_TILE: number;
  29349. /**
  29350. * Mesh pattern setting : rotate pattern and rotate
  29351. */
  29352. static readonly FLIP_N_ROTATE_ROW: number;
  29353. /**
  29354. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29355. */
  29356. static readonly CENTER: number;
  29357. /**
  29358. * Mesh tile positioning : part tiles on left
  29359. */
  29360. static readonly LEFT: number;
  29361. /**
  29362. * Mesh tile positioning : part tiles on right
  29363. */
  29364. static readonly RIGHT: number;
  29365. /**
  29366. * Mesh tile positioning : part tiles on top
  29367. */
  29368. static readonly TOP: number;
  29369. /**
  29370. * Mesh tile positioning : part tiles on bottom
  29371. */
  29372. static readonly BOTTOM: number;
  29373. /**
  29374. * Gets the default side orientation.
  29375. * @param orientation the orientation to value to attempt to get
  29376. * @returns the default orientation
  29377. * @hidden
  29378. */
  29379. static _GetDefaultSideOrientation(orientation?: number): number;
  29380. private _internalMeshDataInfo;
  29381. get computeBonesUsingShaders(): boolean;
  29382. set computeBonesUsingShaders(value: boolean);
  29383. /**
  29384. * An event triggered before rendering the mesh
  29385. */
  29386. get onBeforeRenderObservable(): Observable<Mesh>;
  29387. /**
  29388. * An event triggered before binding the mesh
  29389. */
  29390. get onBeforeBindObservable(): Observable<Mesh>;
  29391. /**
  29392. * An event triggered after rendering the mesh
  29393. */
  29394. get onAfterRenderObservable(): Observable<Mesh>;
  29395. /**
  29396. * An event triggered before drawing the mesh
  29397. */
  29398. get onBeforeDrawObservable(): Observable<Mesh>;
  29399. private _onBeforeDrawObserver;
  29400. /**
  29401. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29402. */
  29403. set onBeforeDraw(callback: () => void);
  29404. get hasInstances(): boolean;
  29405. get hasThinInstances(): boolean;
  29406. /**
  29407. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29408. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29409. */
  29410. delayLoadState: number;
  29411. /**
  29412. * Gets the list of instances created from this mesh
  29413. * it is not supposed to be modified manually.
  29414. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29415. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29416. */
  29417. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29418. /**
  29419. * Gets the file containing delay loading data for this mesh
  29420. */
  29421. delayLoadingFile: string;
  29422. /** @hidden */
  29423. _binaryInfo: any;
  29424. /**
  29425. * User defined function used to change how LOD level selection is done
  29426. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29427. */
  29428. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29429. /**
  29430. * Gets or sets the morph target manager
  29431. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29432. */
  29433. get morphTargetManager(): Nullable<MorphTargetManager>;
  29434. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29435. /** @hidden */
  29436. _creationDataStorage: Nullable<_CreationDataStorage>;
  29437. /** @hidden */
  29438. _geometry: Nullable<Geometry>;
  29439. /** @hidden */
  29440. _delayInfo: Array<string>;
  29441. /** @hidden */
  29442. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29443. /** @hidden */
  29444. _instanceDataStorage: _InstanceDataStorage;
  29445. /** @hidden */
  29446. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29447. private _effectiveMaterial;
  29448. /** @hidden */
  29449. _shouldGenerateFlatShading: boolean;
  29450. /** @hidden */
  29451. _originalBuilderSideOrientation: number;
  29452. /**
  29453. * Use this property to change the original side orientation defined at construction time
  29454. */
  29455. overrideMaterialSideOrientation: Nullable<number>;
  29456. /**
  29457. * Gets the source mesh (the one used to clone this one from)
  29458. */
  29459. get source(): Nullable<Mesh>;
  29460. /**
  29461. * Gets the list of clones of this mesh
  29462. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29463. * Note that useClonedMeshMap=true is the default setting
  29464. */
  29465. get cloneMeshMap(): Nullable<{
  29466. [id: string]: Mesh | undefined;
  29467. }>;
  29468. /**
  29469. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29470. */
  29471. get isUnIndexed(): boolean;
  29472. set isUnIndexed(value: boolean);
  29473. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29474. get worldMatrixInstancedBuffer(): Float32Array;
  29475. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29476. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29477. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29478. /**
  29479. * @constructor
  29480. * @param name The value used by scene.getMeshByName() to do a lookup.
  29481. * @param scene The scene to add this mesh to.
  29482. * @param parent The parent of this mesh, if it has one
  29483. * @param source An optional Mesh from which geometry is shared, cloned.
  29484. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29485. * When false, achieved by calling a clone(), also passing False.
  29486. * This will make creation of children, recursive.
  29487. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29488. */
  29489. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29490. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29491. doNotInstantiate: boolean;
  29492. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29493. /**
  29494. * Gets the class name
  29495. * @returns the string "Mesh".
  29496. */
  29497. getClassName(): string;
  29498. /** @hidden */
  29499. get _isMesh(): boolean;
  29500. /**
  29501. * Returns a description of this mesh
  29502. * @param fullDetails define if full details about this mesh must be used
  29503. * @returns a descriptive string representing this mesh
  29504. */
  29505. toString(fullDetails?: boolean): string;
  29506. /** @hidden */
  29507. _unBindEffect(): void;
  29508. /**
  29509. * Gets a boolean indicating if this mesh has LOD
  29510. */
  29511. get hasLODLevels(): boolean;
  29512. /**
  29513. * Gets the list of MeshLODLevel associated with the current mesh
  29514. * @returns an array of MeshLODLevel
  29515. */
  29516. getLODLevels(): MeshLODLevel[];
  29517. private _sortLODLevels;
  29518. /**
  29519. * Add a mesh as LOD level triggered at the given distance.
  29520. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29521. * @param distance The distance from the center of the object to show this level
  29522. * @param mesh The mesh to be added as LOD level (can be null)
  29523. * @return This mesh (for chaining)
  29524. */
  29525. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29526. /**
  29527. * Returns the LOD level mesh at the passed distance or null if not found.
  29528. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29529. * @param distance The distance from the center of the object to show this level
  29530. * @returns a Mesh or `null`
  29531. */
  29532. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29533. /**
  29534. * Remove a mesh from the LOD array
  29535. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29536. * @param mesh defines the mesh to be removed
  29537. * @return This mesh (for chaining)
  29538. */
  29539. removeLODLevel(mesh: Mesh): Mesh;
  29540. /**
  29541. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29542. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29543. * @param camera defines the camera to use to compute distance
  29544. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29545. * @return This mesh (for chaining)
  29546. */
  29547. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29548. /**
  29549. * Gets the mesh internal Geometry object
  29550. */
  29551. get geometry(): Nullable<Geometry>;
  29552. /**
  29553. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29554. * @returns the total number of vertices
  29555. */
  29556. getTotalVertices(): number;
  29557. /**
  29558. * Returns the content of an associated vertex buffer
  29559. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29560. * - VertexBuffer.PositionKind
  29561. * - VertexBuffer.UVKind
  29562. * - VertexBuffer.UV2Kind
  29563. * - VertexBuffer.UV3Kind
  29564. * - VertexBuffer.UV4Kind
  29565. * - VertexBuffer.UV5Kind
  29566. * - VertexBuffer.UV6Kind
  29567. * - VertexBuffer.ColorKind
  29568. * - VertexBuffer.MatricesIndicesKind
  29569. * - VertexBuffer.MatricesIndicesExtraKind
  29570. * - VertexBuffer.MatricesWeightsKind
  29571. * - VertexBuffer.MatricesWeightsExtraKind
  29572. * @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
  29573. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29574. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29575. */
  29576. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29577. /**
  29578. * Returns the mesh VertexBuffer object from the requested `kind`
  29579. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29580. * - VertexBuffer.PositionKind
  29581. * - VertexBuffer.NormalKind
  29582. * - VertexBuffer.UVKind
  29583. * - VertexBuffer.UV2Kind
  29584. * - VertexBuffer.UV3Kind
  29585. * - VertexBuffer.UV4Kind
  29586. * - VertexBuffer.UV5Kind
  29587. * - VertexBuffer.UV6Kind
  29588. * - VertexBuffer.ColorKind
  29589. * - VertexBuffer.MatricesIndicesKind
  29590. * - VertexBuffer.MatricesIndicesExtraKind
  29591. * - VertexBuffer.MatricesWeightsKind
  29592. * - VertexBuffer.MatricesWeightsExtraKind
  29593. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29594. */
  29595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29596. /**
  29597. * Tests if a specific vertex buffer is associated with this mesh
  29598. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29599. * - VertexBuffer.PositionKind
  29600. * - VertexBuffer.NormalKind
  29601. * - VertexBuffer.UVKind
  29602. * - VertexBuffer.UV2Kind
  29603. * - VertexBuffer.UV3Kind
  29604. * - VertexBuffer.UV4Kind
  29605. * - VertexBuffer.UV5Kind
  29606. * - VertexBuffer.UV6Kind
  29607. * - VertexBuffer.ColorKind
  29608. * - VertexBuffer.MatricesIndicesKind
  29609. * - VertexBuffer.MatricesIndicesExtraKind
  29610. * - VertexBuffer.MatricesWeightsKind
  29611. * - VertexBuffer.MatricesWeightsExtraKind
  29612. * @returns a boolean
  29613. */
  29614. isVerticesDataPresent(kind: string): boolean;
  29615. /**
  29616. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29617. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29618. * - VertexBuffer.PositionKind
  29619. * - VertexBuffer.UVKind
  29620. * - VertexBuffer.UV2Kind
  29621. * - VertexBuffer.UV3Kind
  29622. * - VertexBuffer.UV4Kind
  29623. * - VertexBuffer.UV5Kind
  29624. * - VertexBuffer.UV6Kind
  29625. * - VertexBuffer.ColorKind
  29626. * - VertexBuffer.MatricesIndicesKind
  29627. * - VertexBuffer.MatricesIndicesExtraKind
  29628. * - VertexBuffer.MatricesWeightsKind
  29629. * - VertexBuffer.MatricesWeightsExtraKind
  29630. * @returns a boolean
  29631. */
  29632. isVertexBufferUpdatable(kind: string): boolean;
  29633. /**
  29634. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29635. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29636. * - VertexBuffer.PositionKind
  29637. * - VertexBuffer.NormalKind
  29638. * - VertexBuffer.UVKind
  29639. * - VertexBuffer.UV2Kind
  29640. * - VertexBuffer.UV3Kind
  29641. * - VertexBuffer.UV4Kind
  29642. * - VertexBuffer.UV5Kind
  29643. * - VertexBuffer.UV6Kind
  29644. * - VertexBuffer.ColorKind
  29645. * - VertexBuffer.MatricesIndicesKind
  29646. * - VertexBuffer.MatricesIndicesExtraKind
  29647. * - VertexBuffer.MatricesWeightsKind
  29648. * - VertexBuffer.MatricesWeightsExtraKind
  29649. * @returns an array of strings
  29650. */
  29651. getVerticesDataKinds(): string[];
  29652. /**
  29653. * Returns a positive integer : the total number of indices in this mesh geometry.
  29654. * @returns the numner of indices or zero if the mesh has no geometry.
  29655. */
  29656. getTotalIndices(): number;
  29657. /**
  29658. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29659. * @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.
  29660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29661. * @returns the indices array or an empty array if the mesh has no geometry
  29662. */
  29663. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29664. get isBlocked(): boolean;
  29665. /**
  29666. * Determine if the current mesh is ready to be rendered
  29667. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29668. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29669. * @returns true if all associated assets are ready (material, textures, shaders)
  29670. */
  29671. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29672. /**
  29673. * 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.
  29674. */
  29675. get areNormalsFrozen(): boolean;
  29676. /**
  29677. * 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.
  29678. * @returns the current mesh
  29679. */
  29680. freezeNormals(): Mesh;
  29681. /**
  29682. * 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
  29683. * @returns the current mesh
  29684. */
  29685. unfreezeNormals(): Mesh;
  29686. /**
  29687. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29688. */
  29689. set overridenInstanceCount(count: number);
  29690. /** @hidden */
  29691. _preActivate(): Mesh;
  29692. /** @hidden */
  29693. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29694. /** @hidden */
  29695. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29696. protected _afterComputeWorldMatrix(): void;
  29697. /** @hidden */
  29698. _postActivate(): void;
  29699. /**
  29700. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29701. * This means the mesh underlying bounding box and sphere are recomputed.
  29702. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29703. * @returns the current mesh
  29704. */
  29705. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29706. /** @hidden */
  29707. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29708. /**
  29709. * This function will subdivide the mesh into multiple submeshes
  29710. * @param count defines the expected number of submeshes
  29711. */
  29712. subdivide(count: number): void;
  29713. /**
  29714. * Copy a FloatArray into a specific associated vertex buffer
  29715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29716. * - VertexBuffer.PositionKind
  29717. * - VertexBuffer.UVKind
  29718. * - VertexBuffer.UV2Kind
  29719. * - VertexBuffer.UV3Kind
  29720. * - VertexBuffer.UV4Kind
  29721. * - VertexBuffer.UV5Kind
  29722. * - VertexBuffer.UV6Kind
  29723. * - VertexBuffer.ColorKind
  29724. * - VertexBuffer.MatricesIndicesKind
  29725. * - VertexBuffer.MatricesIndicesExtraKind
  29726. * - VertexBuffer.MatricesWeightsKind
  29727. * - VertexBuffer.MatricesWeightsExtraKind
  29728. * @param data defines the data source
  29729. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29730. * @param stride defines the data stride size (can be null)
  29731. * @returns the current mesh
  29732. */
  29733. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29734. /**
  29735. * Delete a vertex buffer associated with this mesh
  29736. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29737. * - VertexBuffer.PositionKind
  29738. * - VertexBuffer.UVKind
  29739. * - VertexBuffer.UV2Kind
  29740. * - VertexBuffer.UV3Kind
  29741. * - VertexBuffer.UV4Kind
  29742. * - VertexBuffer.UV5Kind
  29743. * - VertexBuffer.UV6Kind
  29744. * - VertexBuffer.ColorKind
  29745. * - VertexBuffer.MatricesIndicesKind
  29746. * - VertexBuffer.MatricesIndicesExtraKind
  29747. * - VertexBuffer.MatricesWeightsKind
  29748. * - VertexBuffer.MatricesWeightsExtraKind
  29749. */
  29750. removeVerticesData(kind: string): void;
  29751. /**
  29752. * Flags an associated vertex buffer as updatable
  29753. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29754. * - VertexBuffer.PositionKind
  29755. * - VertexBuffer.UVKind
  29756. * - VertexBuffer.UV2Kind
  29757. * - VertexBuffer.UV3Kind
  29758. * - VertexBuffer.UV4Kind
  29759. * - VertexBuffer.UV5Kind
  29760. * - VertexBuffer.UV6Kind
  29761. * - VertexBuffer.ColorKind
  29762. * - VertexBuffer.MatricesIndicesKind
  29763. * - VertexBuffer.MatricesIndicesExtraKind
  29764. * - VertexBuffer.MatricesWeightsKind
  29765. * - VertexBuffer.MatricesWeightsExtraKind
  29766. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29767. */
  29768. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29769. /**
  29770. * Sets the mesh global Vertex Buffer
  29771. * @param buffer defines the buffer to use
  29772. * @returns the current mesh
  29773. */
  29774. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29775. /**
  29776. * Update a specific associated vertex buffer
  29777. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29778. * - VertexBuffer.PositionKind
  29779. * - VertexBuffer.UVKind
  29780. * - VertexBuffer.UV2Kind
  29781. * - VertexBuffer.UV3Kind
  29782. * - VertexBuffer.UV4Kind
  29783. * - VertexBuffer.UV5Kind
  29784. * - VertexBuffer.UV6Kind
  29785. * - VertexBuffer.ColorKind
  29786. * - VertexBuffer.MatricesIndicesKind
  29787. * - VertexBuffer.MatricesIndicesExtraKind
  29788. * - VertexBuffer.MatricesWeightsKind
  29789. * - VertexBuffer.MatricesWeightsExtraKind
  29790. * @param data defines the data source
  29791. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29792. * @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)
  29793. * @returns the current mesh
  29794. */
  29795. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29796. /**
  29797. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29798. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29799. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29800. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29801. * @returns the current mesh
  29802. */
  29803. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29804. /**
  29805. * Creates a un-shared specific occurence of the geometry for the mesh.
  29806. * @returns the current mesh
  29807. */
  29808. makeGeometryUnique(): Mesh;
  29809. /**
  29810. * Set the index buffer of this mesh
  29811. * @param indices defines the source data
  29812. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29813. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29814. * @returns the current mesh
  29815. */
  29816. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29817. /**
  29818. * Update the current index buffer
  29819. * @param indices defines the source data
  29820. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29821. * @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)
  29822. * @returns the current mesh
  29823. */
  29824. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29825. /**
  29826. * Invert the geometry to move from a right handed system to a left handed one.
  29827. * @returns the current mesh
  29828. */
  29829. toLeftHanded(): Mesh;
  29830. /** @hidden */
  29831. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29832. /** @hidden */
  29833. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29834. /**
  29835. * Registers for this mesh a javascript function called just before the rendering process
  29836. * @param func defines the function to call before rendering this mesh
  29837. * @returns the current mesh
  29838. */
  29839. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29840. /**
  29841. * Disposes a previously registered javascript function called before the rendering
  29842. * @param func defines the function to remove
  29843. * @returns the current mesh
  29844. */
  29845. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29846. /**
  29847. * Registers for this mesh a javascript function called just after the rendering is complete
  29848. * @param func defines the function to call after rendering this mesh
  29849. * @returns the current mesh
  29850. */
  29851. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29852. /**
  29853. * Disposes a previously registered javascript function called after the rendering.
  29854. * @param func defines the function to remove
  29855. * @returns the current mesh
  29856. */
  29857. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29858. /** @hidden */
  29859. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29860. /** @hidden */
  29861. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29862. /** @hidden */
  29863. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29864. /** @hidden */
  29865. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29866. /** @hidden */
  29867. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29868. /** @hidden */
  29869. _rebuild(): void;
  29870. /** @hidden */
  29871. _freeze(): void;
  29872. /** @hidden */
  29873. _unFreeze(): void;
  29874. /**
  29875. * 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
  29876. * @param subMesh defines the subMesh to render
  29877. * @param enableAlphaMode defines if alpha mode can be changed
  29878. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29879. * @returns the current mesh
  29880. */
  29881. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29882. private _onBeforeDraw;
  29883. /**
  29884. * Renormalize the mesh and patch it up if there are no weights
  29885. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29886. * However in the case of zero weights then we set just a single influence to 1.
  29887. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29888. */
  29889. cleanMatrixWeights(): void;
  29890. private normalizeSkinFourWeights;
  29891. private normalizeSkinWeightsAndExtra;
  29892. /**
  29893. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29894. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29895. * the user know there was an issue with importing the mesh
  29896. * @returns a validation object with skinned, valid and report string
  29897. */
  29898. validateSkinning(): {
  29899. skinned: boolean;
  29900. valid: boolean;
  29901. report: string;
  29902. };
  29903. /** @hidden */
  29904. _checkDelayState(): Mesh;
  29905. private _queueLoad;
  29906. /**
  29907. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29908. * A mesh is in the frustum if its bounding box intersects the frustum
  29909. * @param frustumPlanes defines the frustum to test
  29910. * @returns true if the mesh is in the frustum planes
  29911. */
  29912. isInFrustum(frustumPlanes: Plane[]): boolean;
  29913. /**
  29914. * Sets the mesh material by the material or multiMaterial `id` property
  29915. * @param id is a string identifying the material or the multiMaterial
  29916. * @returns the current mesh
  29917. */
  29918. setMaterialByID(id: string): Mesh;
  29919. /**
  29920. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29921. * @returns an array of IAnimatable
  29922. */
  29923. getAnimatables(): IAnimatable[];
  29924. /**
  29925. * Modifies the mesh geometry according to the passed transformation matrix.
  29926. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29927. * The mesh normals are modified using the same transformation.
  29928. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29929. * @param transform defines the transform matrix to use
  29930. * @see https://doc.babylonjs.com/resources/baking_transformations
  29931. * @returns the current mesh
  29932. */
  29933. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29934. /**
  29935. * Modifies the mesh geometry according to its own current World Matrix.
  29936. * The mesh World Matrix is then reset.
  29937. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29938. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29939. * @see https://doc.babylonjs.com/resources/baking_transformations
  29940. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29941. * @returns the current mesh
  29942. */
  29943. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29944. /** @hidden */
  29945. get _positions(): Nullable<Vector3[]>;
  29946. /** @hidden */
  29947. _resetPointsArrayCache(): Mesh;
  29948. /** @hidden */
  29949. _generatePointsArray(): boolean;
  29950. /**
  29951. * Returns a new Mesh object generated from the current mesh properties.
  29952. * This method must not get confused with createInstance()
  29953. * @param name is a string, the name given to the new mesh
  29954. * @param newParent can be any Node object (default `null`)
  29955. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29956. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29957. * @returns a new mesh
  29958. */
  29959. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29960. /**
  29961. * Releases resources associated with this mesh.
  29962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29964. */
  29965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29966. /** @hidden */
  29967. _disposeInstanceSpecificData(): void;
  29968. /** @hidden */
  29969. _disposeThinInstanceSpecificData(): void;
  29970. /**
  29971. * Modifies the mesh geometry according to a displacement map.
  29972. * 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.
  29973. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29974. * @param url is a string, the URL from the image file is to be downloaded.
  29975. * @param minHeight is the lower limit of the displacement.
  29976. * @param maxHeight is the upper limit of the displacement.
  29977. * @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.
  29978. * @param uvOffset is an optional vector2 used to offset UV.
  29979. * @param uvScale is an optional vector2 used to scale UV.
  29980. * @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.
  29981. * @returns the Mesh.
  29982. */
  29983. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29984. /**
  29985. * Modifies the mesh geometry according to a displacementMap buffer.
  29986. * 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.
  29987. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29988. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29989. * @param heightMapWidth is the width of the buffer image.
  29990. * @param heightMapHeight is the height of the buffer image.
  29991. * @param minHeight is the lower limit of the displacement.
  29992. * @param maxHeight is the upper limit of the displacement.
  29993. * @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.
  29994. * @param uvOffset is an optional vector2 used to offset UV.
  29995. * @param uvScale is an optional vector2 used to scale UV.
  29996. * @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.
  29997. * @returns the Mesh.
  29998. */
  29999. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  30000. /**
  30001. * Modify the mesh to get a flat shading rendering.
  30002. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  30003. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  30004. * @returns current mesh
  30005. */
  30006. convertToFlatShadedMesh(): Mesh;
  30007. /**
  30008. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  30009. * In other words, more vertices, no more indices and a single bigger VBO.
  30010. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  30011. * @returns current mesh
  30012. */
  30013. convertToUnIndexedMesh(): Mesh;
  30014. /**
  30015. * Inverses facet orientations.
  30016. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30017. * @param flipNormals will also inverts the normals
  30018. * @returns current mesh
  30019. */
  30020. flipFaces(flipNormals?: boolean): Mesh;
  30021. /**
  30022. * Increase the number of facets and hence vertices in a mesh
  30023. * Vertex normals are interpolated from existing vertex normals
  30024. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30025. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  30026. */
  30027. increaseVertices(numberPerEdge: number): void;
  30028. /**
  30029. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  30030. * This will undo any application of covertToFlatShadedMesh
  30031. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30032. */
  30033. forceSharedVertices(): void;
  30034. /** @hidden */
  30035. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  30036. /** @hidden */
  30037. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  30038. /**
  30039. * Creates a new InstancedMesh object from the mesh model.
  30040. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30041. * @param name defines the name of the new instance
  30042. * @returns a new InstancedMesh
  30043. */
  30044. createInstance(name: string): InstancedMesh;
  30045. /**
  30046. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  30047. * After this call, all the mesh instances have the same submeshes than the current mesh.
  30048. * @returns the current mesh
  30049. */
  30050. synchronizeInstances(): Mesh;
  30051. /**
  30052. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  30053. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  30054. * This should be used together with the simplification to avoid disappearing triangles.
  30055. * @param successCallback an optional success callback to be called after the optimization finished.
  30056. * @returns the current mesh
  30057. */
  30058. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  30059. /**
  30060. * Serialize current mesh
  30061. * @param serializationObject defines the object which will receive the serialization data
  30062. */
  30063. serialize(serializationObject: any): void;
  30064. /** @hidden */
  30065. _syncGeometryWithMorphTargetManager(): void;
  30066. /** @hidden */
  30067. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  30068. /**
  30069. * Returns a new Mesh object parsed from the source provided.
  30070. * @param parsedMesh is the source
  30071. * @param scene defines the hosting scene
  30072. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  30073. * @returns a new Mesh
  30074. */
  30075. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  30076. /**
  30077. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  30078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30079. * @param name defines the name of the mesh to create
  30080. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30081. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30082. * @param closePath creates a seam between the first and the last points of each path of the path array
  30083. * @param offset is taken in account only if the `pathArray` is containing a single path
  30084. * @param scene defines the hosting scene
  30085. * @param updatable defines if the mesh must be flagged as updatable
  30086. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30087. * @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)
  30088. * @returns a new Mesh
  30089. */
  30090. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30091. /**
  30092. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30093. * @param name defines the name of the mesh to create
  30094. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30095. * @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
  30096. * @param scene defines the hosting scene
  30097. * @param updatable defines if the mesh must be flagged as updatable
  30098. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30099. * @returns a new Mesh
  30100. */
  30101. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30102. /**
  30103. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30104. * @param name defines the name of the mesh to create
  30105. * @param size sets the size (float) of each box side (default 1)
  30106. * @param scene defines the hosting scene
  30107. * @param updatable defines if the mesh must be flagged as updatable
  30108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30109. * @returns a new Mesh
  30110. */
  30111. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30112. /**
  30113. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30114. * @param name defines the name of the mesh to create
  30115. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30116. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30117. * @param scene defines the hosting scene
  30118. * @param updatable defines if the mesh must be flagged as updatable
  30119. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30120. * @returns a new Mesh
  30121. */
  30122. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30123. /**
  30124. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30125. * @param name defines the name of the mesh to create
  30126. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30127. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30128. * @param scene defines the hosting scene
  30129. * @returns a new Mesh
  30130. */
  30131. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30132. /**
  30133. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30134. * @param name defines the name of the mesh to create
  30135. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30136. * @param diameterTop set the top cap diameter (floats, default 1)
  30137. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30138. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30139. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30140. * @param scene defines the hosting scene
  30141. * @param updatable defines if the mesh must be flagged as updatable
  30142. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30143. * @returns a new Mesh
  30144. */
  30145. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30146. /**
  30147. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30148. * @param name defines the name of the mesh to create
  30149. * @param diameter sets the diameter size (float) of the torus (default 1)
  30150. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30151. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30152. * @param scene defines the hosting scene
  30153. * @param updatable defines if the mesh must be flagged as updatable
  30154. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30155. * @returns a new Mesh
  30156. */
  30157. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30158. /**
  30159. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30160. * @param name defines the name of the mesh to create
  30161. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30162. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30163. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30164. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30165. * @param p the number of windings on X axis (positive integers, default 2)
  30166. * @param q the number of windings on Y axis (positive integers, default 3)
  30167. * @param scene defines the hosting scene
  30168. * @param updatable defines if the mesh must be flagged as updatable
  30169. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30170. * @returns a new Mesh
  30171. */
  30172. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30173. /**
  30174. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30175. * @param name defines the name of the mesh to create
  30176. * @param points is an array successive Vector3
  30177. * @param scene defines the hosting scene
  30178. * @param updatable defines if the mesh must be flagged as updatable
  30179. * @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).
  30180. * @returns a new Mesh
  30181. */
  30182. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30183. /**
  30184. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30185. * @param name defines the name of the mesh to create
  30186. * @param points is an array successive Vector3
  30187. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30188. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30189. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30190. * @param scene defines the hosting scene
  30191. * @param updatable defines if the mesh must be flagged as updatable
  30192. * @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)
  30193. * @returns a new Mesh
  30194. */
  30195. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30196. /**
  30197. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30198. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30199. * 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.
  30200. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30201. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30202. * Remember you can only change the shape positions, not their number when updating a polygon.
  30203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30204. * @param name defines the name of the mesh to create
  30205. * @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
  30206. * @param scene defines the hosting scene
  30207. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30208. * @param updatable defines if the mesh must be flagged as updatable
  30209. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30210. * @param earcutInjection can be used to inject your own earcut reference
  30211. * @returns a new Mesh
  30212. */
  30213. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30214. /**
  30215. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30217. * @param name defines the name of the mesh to create
  30218. * @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
  30219. * @param depth defines the height of extrusion
  30220. * @param scene defines the hosting scene
  30221. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30222. * @param updatable defines if the mesh must be flagged as updatable
  30223. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30224. * @param earcutInjection can be used to inject your own earcut reference
  30225. * @returns a new Mesh
  30226. */
  30227. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30228. /**
  30229. * Creates an extruded shape mesh.
  30230. * 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
  30231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30233. * @param name defines the name of the mesh to create
  30234. * @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
  30235. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30236. * @param scale is the value to scale the shape
  30237. * @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
  30238. * @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
  30239. * @param scene defines the hosting scene
  30240. * @param updatable defines if the mesh must be flagged as updatable
  30241. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30242. * @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)
  30243. * @returns a new Mesh
  30244. */
  30245. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30246. /**
  30247. * Creates an custom extruded shape mesh.
  30248. * The custom extrusion is a parametric shape.
  30249. * It has no predefined shape. Its final shape will depend on the input parameters.
  30250. * Please consider using the same method from the MeshBuilder class instead
  30251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30252. * @param name defines the name of the mesh to create
  30253. * @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
  30254. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30255. * @param scaleFunction is a custom Javascript function called on each path point
  30256. * @param rotationFunction is a custom Javascript function called on each path point
  30257. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30258. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30259. * @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
  30260. * @param scene defines the hosting scene
  30261. * @param updatable defines if the mesh must be flagged as updatable
  30262. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30263. * @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)
  30264. * @returns a new Mesh
  30265. */
  30266. 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;
  30267. /**
  30268. * Creates lathe mesh.
  30269. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30270. * Please consider using the same method from the MeshBuilder class instead
  30271. * @param name defines the name of the mesh to create
  30272. * @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
  30273. * @param radius is the radius value of the lathe
  30274. * @param tessellation is the side number of the lathe.
  30275. * @param scene defines the hosting scene
  30276. * @param updatable defines if the mesh must be flagged as updatable
  30277. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30278. * @returns a new Mesh
  30279. */
  30280. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30281. /**
  30282. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30283. * @param name defines the name of the mesh to create
  30284. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30285. * @param scene defines the hosting scene
  30286. * @param updatable defines if the mesh must be flagged as updatable
  30287. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30288. * @returns a new Mesh
  30289. */
  30290. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30291. /**
  30292. * Creates a ground mesh.
  30293. * Please consider using the same method from the MeshBuilder class instead
  30294. * @param name defines the name of the mesh to create
  30295. * @param width set the width of the ground
  30296. * @param height set the height of the ground
  30297. * @param subdivisions sets the number of subdivisions per side
  30298. * @param scene defines the hosting scene
  30299. * @param updatable defines if the mesh must be flagged as updatable
  30300. * @returns a new Mesh
  30301. */
  30302. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30303. /**
  30304. * Creates a tiled ground mesh.
  30305. * Please consider using the same method from the MeshBuilder class instead
  30306. * @param name defines the name of the mesh to create
  30307. * @param xmin set the ground minimum X coordinate
  30308. * @param zmin set the ground minimum Y coordinate
  30309. * @param xmax set the ground maximum X coordinate
  30310. * @param zmax set the ground maximum Z coordinate
  30311. * @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
  30312. * @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
  30313. * @param scene defines the hosting scene
  30314. * @param updatable defines if the mesh must be flagged as updatable
  30315. * @returns a new Mesh
  30316. */
  30317. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30318. w: number;
  30319. h: number;
  30320. }, precision: {
  30321. w: number;
  30322. h: number;
  30323. }, scene: Scene, updatable?: boolean): Mesh;
  30324. /**
  30325. * Creates a ground mesh from a height map.
  30326. * Please consider using the same method from the MeshBuilder class instead
  30327. * @see https://doc.babylonjs.com/babylon101/height_map
  30328. * @param name defines the name of the mesh to create
  30329. * @param url sets the URL of the height map image resource
  30330. * @param width set the ground width size
  30331. * @param height set the ground height size
  30332. * @param subdivisions sets the number of subdivision per side
  30333. * @param minHeight is the minimum altitude on the ground
  30334. * @param maxHeight is the maximum altitude on the ground
  30335. * @param scene defines the hosting scene
  30336. * @param updatable defines if the mesh must be flagged as updatable
  30337. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30338. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30339. * @returns a new Mesh
  30340. */
  30341. 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;
  30342. /**
  30343. * Creates a tube mesh.
  30344. * The tube is a parametric shape.
  30345. * It has no predefined shape. Its final shape will depend on the input parameters.
  30346. * Please consider using the same method from the MeshBuilder class instead
  30347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30348. * @param name defines the name of the mesh to create
  30349. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30350. * @param radius sets the tube radius size
  30351. * @param tessellation is the number of sides on the tubular surface
  30352. * @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
  30353. * @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
  30354. * @param scene defines the hosting scene
  30355. * @param updatable defines if the mesh must be flagged as updatable
  30356. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30357. * @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)
  30358. * @returns a new Mesh
  30359. */
  30360. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30361. (i: number, distance: number): number;
  30362. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30363. /**
  30364. * Creates a polyhedron mesh.
  30365. * Please consider using the same method from the MeshBuilder class instead.
  30366. * * 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
  30367. * * The parameter `size` (positive float, default 1) sets the polygon size
  30368. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30369. * * 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`
  30370. * * 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
  30371. * * 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)`)
  30372. * * 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
  30373. * * 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
  30374. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30377. * @param name defines the name of the mesh to create
  30378. * @param options defines the options used to create the mesh
  30379. * @param scene defines the hosting scene
  30380. * @returns a new Mesh
  30381. */
  30382. static CreatePolyhedron(name: string, options: {
  30383. type?: number;
  30384. size?: number;
  30385. sizeX?: number;
  30386. sizeY?: number;
  30387. sizeZ?: number;
  30388. custom?: any;
  30389. faceUV?: Vector4[];
  30390. faceColors?: Color4[];
  30391. updatable?: boolean;
  30392. sideOrientation?: number;
  30393. }, scene: Scene): Mesh;
  30394. /**
  30395. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30396. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30397. * * 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`)
  30398. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30399. * * 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
  30400. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30403. * @param name defines the name of the mesh
  30404. * @param options defines the options used to create the mesh
  30405. * @param scene defines the hosting scene
  30406. * @returns a new Mesh
  30407. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30408. */
  30409. static CreateIcoSphere(name: string, options: {
  30410. radius?: number;
  30411. flat?: boolean;
  30412. subdivisions?: number;
  30413. sideOrientation?: number;
  30414. updatable?: boolean;
  30415. }, scene: Scene): Mesh;
  30416. /**
  30417. * Creates a decal mesh.
  30418. * Please consider using the same method from the MeshBuilder class instead.
  30419. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30420. * @param name defines the name of the mesh
  30421. * @param sourceMesh defines the mesh receiving the decal
  30422. * @param position sets the position of the decal in world coordinates
  30423. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30424. * @param size sets the decal scaling
  30425. * @param angle sets the angle to rotate the decal
  30426. * @returns a new Mesh
  30427. */
  30428. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30429. /** Creates a Capsule Mesh
  30430. * @param name defines the name of the mesh.
  30431. * @param options the constructors options used to shape the mesh.
  30432. * @param scene defines the scene the mesh is scoped to.
  30433. * @returns the capsule mesh
  30434. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30435. */
  30436. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30437. /**
  30438. * Prepare internal position array for software CPU skinning
  30439. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30440. */
  30441. setPositionsForCPUSkinning(): Float32Array;
  30442. /**
  30443. * Prepare internal normal array for software CPU skinning
  30444. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30445. */
  30446. setNormalsForCPUSkinning(): Float32Array;
  30447. /**
  30448. * Updates the vertex buffer by applying transformation from the bones
  30449. * @param skeleton defines the skeleton to apply to current mesh
  30450. * @returns the current mesh
  30451. */
  30452. applySkeleton(skeleton: Skeleton): Mesh;
  30453. /**
  30454. * 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
  30455. * @param meshes defines the list of meshes to scan
  30456. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30457. */
  30458. static MinMax(meshes: AbstractMesh[]): {
  30459. min: Vector3;
  30460. max: Vector3;
  30461. };
  30462. /**
  30463. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30464. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30465. * @returns a vector3
  30466. */
  30467. static Center(meshesOrMinMaxVector: {
  30468. min: Vector3;
  30469. max: Vector3;
  30470. } | AbstractMesh[]): Vector3;
  30471. /**
  30472. * Merge the array of meshes into a single mesh for performance reasons.
  30473. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30474. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30475. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30476. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30477. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30478. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30479. * @returns a new mesh
  30480. */
  30481. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30482. /** @hidden */
  30483. addInstance(instance: InstancedMesh): void;
  30484. /** @hidden */
  30485. removeInstance(instance: InstancedMesh): void;
  30486. }
  30487. }
  30488. declare module "babylonjs/Cameras/camera" {
  30489. import { SmartArray } from "babylonjs/Misc/smartArray";
  30490. import { Observable } from "babylonjs/Misc/observable";
  30491. import { Nullable } from "babylonjs/types";
  30492. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30493. import { Scene } from "babylonjs/scene";
  30494. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30495. import { Node } from "babylonjs/node";
  30496. import { Mesh } from "babylonjs/Meshes/mesh";
  30497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30498. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30499. import { Viewport } from "babylonjs/Maths/math.viewport";
  30500. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30501. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30502. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30503. import { Ray } from "babylonjs/Culling/ray";
  30504. /**
  30505. * This is the base class of all the camera used in the application.
  30506. * @see https://doc.babylonjs.com/features/cameras
  30507. */
  30508. export class Camera extends Node {
  30509. /** @hidden */
  30510. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30511. /**
  30512. * This is the default projection mode used by the cameras.
  30513. * It helps recreating a feeling of perspective and better appreciate depth.
  30514. * This is the best way to simulate real life cameras.
  30515. */
  30516. static readonly PERSPECTIVE_CAMERA: number;
  30517. /**
  30518. * This helps creating camera with an orthographic mode.
  30519. * 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.
  30520. */
  30521. static readonly ORTHOGRAPHIC_CAMERA: number;
  30522. /**
  30523. * This is the default FOV mode for perspective cameras.
  30524. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30525. */
  30526. static readonly FOVMODE_VERTICAL_FIXED: number;
  30527. /**
  30528. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30529. */
  30530. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30531. /**
  30532. * This specifies ther is no need for a camera rig.
  30533. * Basically only one eye is rendered corresponding to the camera.
  30534. */
  30535. static readonly RIG_MODE_NONE: number;
  30536. /**
  30537. * Simulates a camera Rig with one blue eye and one red eye.
  30538. * This can be use with 3d blue and red glasses.
  30539. */
  30540. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30541. /**
  30542. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30543. */
  30544. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30545. /**
  30546. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30547. */
  30548. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30549. /**
  30550. * Defines that both eyes of the camera will be rendered over under each other.
  30551. */
  30552. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30553. /**
  30554. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30555. */
  30556. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30557. /**
  30558. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30559. */
  30560. static readonly RIG_MODE_VR: number;
  30561. /**
  30562. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30563. */
  30564. static readonly RIG_MODE_WEBVR: number;
  30565. /**
  30566. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30567. */
  30568. static readonly RIG_MODE_CUSTOM: number;
  30569. /**
  30570. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30571. */
  30572. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30573. /**
  30574. * Define the input manager associated with the camera.
  30575. */
  30576. inputs: CameraInputsManager<Camera>;
  30577. /** @hidden */
  30578. _position: Vector3;
  30579. /**
  30580. * Define the current local position of the camera in the scene
  30581. */
  30582. get position(): Vector3;
  30583. set position(newPosition: Vector3);
  30584. protected _upVector: Vector3;
  30585. /**
  30586. * The vector the camera should consider as up.
  30587. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30588. */
  30589. set upVector(vec: Vector3);
  30590. get upVector(): Vector3;
  30591. /**
  30592. * Define the current limit on the left side for an orthographic camera
  30593. * In scene unit
  30594. */
  30595. orthoLeft: Nullable<number>;
  30596. /**
  30597. * Define the current limit on the right side for an orthographic camera
  30598. * In scene unit
  30599. */
  30600. orthoRight: Nullable<number>;
  30601. /**
  30602. * Define the current limit on the bottom side for an orthographic camera
  30603. * In scene unit
  30604. */
  30605. orthoBottom: Nullable<number>;
  30606. /**
  30607. * Define the current limit on the top side for an orthographic camera
  30608. * In scene unit
  30609. */
  30610. orthoTop: Nullable<number>;
  30611. /**
  30612. * Field Of View is set in Radians. (default is 0.8)
  30613. */
  30614. fov: number;
  30615. /**
  30616. * Define the minimum distance the camera can see from.
  30617. * This is important to note that the depth buffer are not infinite and the closer it starts
  30618. * the more your scene might encounter depth fighting issue.
  30619. */
  30620. minZ: number;
  30621. /**
  30622. * Define the maximum distance the camera can see to.
  30623. * This is important to note that the depth buffer are not infinite and the further it end
  30624. * the more your scene might encounter depth fighting issue.
  30625. */
  30626. maxZ: number;
  30627. /**
  30628. * Define the default inertia of the camera.
  30629. * This helps giving a smooth feeling to the camera movement.
  30630. */
  30631. inertia: number;
  30632. /**
  30633. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30634. */
  30635. mode: number;
  30636. /**
  30637. * Define whether the camera is intermediate.
  30638. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30639. */
  30640. isIntermediate: boolean;
  30641. /**
  30642. * Define the viewport of the camera.
  30643. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30644. */
  30645. viewport: Viewport;
  30646. /**
  30647. * Restricts the camera to viewing objects with the same layerMask.
  30648. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30649. */
  30650. layerMask: number;
  30651. /**
  30652. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30653. */
  30654. fovMode: number;
  30655. /**
  30656. * Rig mode of the camera.
  30657. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30658. * This is normally controlled byt the camera themselves as internal use.
  30659. */
  30660. cameraRigMode: number;
  30661. /**
  30662. * Defines the distance between both "eyes" in case of a RIG
  30663. */
  30664. interaxialDistance: number;
  30665. /**
  30666. * Defines if stereoscopic rendering is done side by side or over under.
  30667. */
  30668. isStereoscopicSideBySide: boolean;
  30669. /**
  30670. * 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
  30671. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30672. * else in the scene. (Eg. security camera)
  30673. *
  30674. * 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)
  30675. */
  30676. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30677. /**
  30678. * When set, the camera will render to this render target instead of the default canvas
  30679. *
  30680. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30681. */
  30682. outputRenderTarget: Nullable<RenderTargetTexture>;
  30683. /**
  30684. * Observable triggered when the camera view matrix has changed.
  30685. */
  30686. onViewMatrixChangedObservable: Observable<Camera>;
  30687. /**
  30688. * Observable triggered when the camera Projection matrix has changed.
  30689. */
  30690. onProjectionMatrixChangedObservable: Observable<Camera>;
  30691. /**
  30692. * Observable triggered when the inputs have been processed.
  30693. */
  30694. onAfterCheckInputsObservable: Observable<Camera>;
  30695. /**
  30696. * Observable triggered when reset has been called and applied to the camera.
  30697. */
  30698. onRestoreStateObservable: Observable<Camera>;
  30699. /**
  30700. * Is this camera a part of a rig system?
  30701. */
  30702. isRigCamera: boolean;
  30703. /**
  30704. * If isRigCamera set to true this will be set with the parent camera.
  30705. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30706. */
  30707. rigParent?: Camera;
  30708. /** @hidden */
  30709. _cameraRigParams: any;
  30710. /** @hidden */
  30711. _rigCameras: Camera[];
  30712. /** @hidden */
  30713. _rigPostProcess: Nullable<PostProcess>;
  30714. protected _webvrViewMatrix: Matrix;
  30715. /** @hidden */
  30716. _skipRendering: boolean;
  30717. /** @hidden */
  30718. _projectionMatrix: Matrix;
  30719. /** @hidden */
  30720. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30721. /** @hidden */
  30722. _activeMeshes: SmartArray<AbstractMesh>;
  30723. protected _globalPosition: Vector3;
  30724. /** @hidden */
  30725. _computedViewMatrix: Matrix;
  30726. private _doNotComputeProjectionMatrix;
  30727. private _transformMatrix;
  30728. private _frustumPlanes;
  30729. private _refreshFrustumPlanes;
  30730. private _storedFov;
  30731. private _stateStored;
  30732. /**
  30733. * Instantiates a new camera object.
  30734. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30735. * @see https://doc.babylonjs.com/features/cameras
  30736. * @param name Defines the name of the camera in the scene
  30737. * @param position Defines the position of the camera
  30738. * @param scene Defines the scene the camera belongs too
  30739. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30740. */
  30741. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30742. /**
  30743. * Store current camera state (fov, position, etc..)
  30744. * @returns the camera
  30745. */
  30746. storeState(): Camera;
  30747. /**
  30748. * Restores the camera state values if it has been stored. You must call storeState() first
  30749. */
  30750. protected _restoreStateValues(): boolean;
  30751. /**
  30752. * Restored camera state. You must call storeState() first.
  30753. * @returns true if restored and false otherwise
  30754. */
  30755. restoreState(): boolean;
  30756. /**
  30757. * Gets the class name of the camera.
  30758. * @returns the class name
  30759. */
  30760. getClassName(): string;
  30761. /** @hidden */
  30762. readonly _isCamera: boolean;
  30763. /**
  30764. * Gets a string representation of the camera useful for debug purpose.
  30765. * @param fullDetails Defines that a more verboe level of logging is required
  30766. * @returns the string representation
  30767. */
  30768. toString(fullDetails?: boolean): string;
  30769. /**
  30770. * Gets the current world space position of the camera.
  30771. */
  30772. get globalPosition(): Vector3;
  30773. /**
  30774. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30775. * @returns the active meshe list
  30776. */
  30777. getActiveMeshes(): SmartArray<AbstractMesh>;
  30778. /**
  30779. * Check whether a mesh is part of the current active mesh list of the camera
  30780. * @param mesh Defines the mesh to check
  30781. * @returns true if active, false otherwise
  30782. */
  30783. isActiveMesh(mesh: Mesh): boolean;
  30784. /**
  30785. * Is this camera ready to be used/rendered
  30786. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30787. * @return true if the camera is ready
  30788. */
  30789. isReady(completeCheck?: boolean): boolean;
  30790. /** @hidden */
  30791. _initCache(): void;
  30792. /** @hidden */
  30793. _updateCache(ignoreParentClass?: boolean): void;
  30794. /** @hidden */
  30795. _isSynchronized(): boolean;
  30796. /** @hidden */
  30797. _isSynchronizedViewMatrix(): boolean;
  30798. /** @hidden */
  30799. _isSynchronizedProjectionMatrix(): boolean;
  30800. /**
  30801. * Attach the input controls to a specific dom element to get the input from.
  30802. * @param element Defines the element the controls should be listened from
  30803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30804. */
  30805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30806. /**
  30807. * Detach the current controls from the specified dom element.
  30808. * @param element Defines the element to stop listening the inputs from
  30809. */
  30810. detachControl(element: HTMLElement): void;
  30811. /**
  30812. * Update the camera state according to the different inputs gathered during the frame.
  30813. */
  30814. update(): void;
  30815. /** @hidden */
  30816. _checkInputs(): void;
  30817. /** @hidden */
  30818. get rigCameras(): Camera[];
  30819. /**
  30820. * Gets the post process used by the rig cameras
  30821. */
  30822. get rigPostProcess(): Nullable<PostProcess>;
  30823. /**
  30824. * Internal, gets the first post proces.
  30825. * @returns the first post process to be run on this camera.
  30826. */
  30827. _getFirstPostProcess(): Nullable<PostProcess>;
  30828. private _cascadePostProcessesToRigCams;
  30829. /**
  30830. * Attach a post process to the camera.
  30831. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30832. * @param postProcess The post process to attach to the camera
  30833. * @param insertAt The position of the post process in case several of them are in use in the scene
  30834. * @returns the position the post process has been inserted at
  30835. */
  30836. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30837. /**
  30838. * Detach a post process to the camera.
  30839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30840. * @param postProcess The post process to detach from the camera
  30841. */
  30842. detachPostProcess(postProcess: PostProcess): void;
  30843. /**
  30844. * Gets the current world matrix of the camera
  30845. */
  30846. getWorldMatrix(): Matrix;
  30847. /** @hidden */
  30848. _getViewMatrix(): Matrix;
  30849. /**
  30850. * Gets the current view matrix of the camera.
  30851. * @param force forces the camera to recompute the matrix without looking at the cached state
  30852. * @returns the view matrix
  30853. */
  30854. getViewMatrix(force?: boolean): Matrix;
  30855. /**
  30856. * Freeze the projection matrix.
  30857. * It will prevent the cache check of the camera projection compute and can speed up perf
  30858. * if no parameter of the camera are meant to change
  30859. * @param projection Defines manually a projection if necessary
  30860. */
  30861. freezeProjectionMatrix(projection?: Matrix): void;
  30862. /**
  30863. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30864. */
  30865. unfreezeProjectionMatrix(): void;
  30866. /**
  30867. * Gets the current projection matrix of the camera.
  30868. * @param force forces the camera to recompute the matrix without looking at the cached state
  30869. * @returns the projection matrix
  30870. */
  30871. getProjectionMatrix(force?: boolean): Matrix;
  30872. /**
  30873. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30874. * @returns a Matrix
  30875. */
  30876. getTransformationMatrix(): Matrix;
  30877. private _updateFrustumPlanes;
  30878. /**
  30879. * Checks if a cullable object (mesh...) is in the camera frustum
  30880. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30881. * @param target The object to check
  30882. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30883. * @returns true if the object is in frustum otherwise false
  30884. */
  30885. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30886. /**
  30887. * Checks if a cullable object (mesh...) is in the camera frustum
  30888. * Unlike isInFrustum this cheks the full bounding box
  30889. * @param target The object to check
  30890. * @returns true if the object is in frustum otherwise false
  30891. */
  30892. isCompletelyInFrustum(target: ICullable): boolean;
  30893. /**
  30894. * Gets a ray in the forward direction from the camera.
  30895. * @param length Defines the length of the ray to create
  30896. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30897. * @param origin Defines the start point of the ray which defaults to the camera position
  30898. * @returns the forward ray
  30899. */
  30900. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30901. /**
  30902. * Gets a ray in the forward direction from the camera.
  30903. * @param refRay the ray to (re)use when setting the values
  30904. * @param length Defines the length of the ray to create
  30905. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30906. * @param origin Defines the start point of the ray which defaults to the camera position
  30907. * @returns the forward ray
  30908. */
  30909. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30910. /**
  30911. * Releases resources associated with this node.
  30912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30914. */
  30915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30916. /** @hidden */
  30917. _isLeftCamera: boolean;
  30918. /**
  30919. * Gets the left camera of a rig setup in case of Rigged Camera
  30920. */
  30921. get isLeftCamera(): boolean;
  30922. /** @hidden */
  30923. _isRightCamera: boolean;
  30924. /**
  30925. * Gets the right camera of a rig setup in case of Rigged Camera
  30926. */
  30927. get isRightCamera(): boolean;
  30928. /**
  30929. * Gets the left camera of a rig setup in case of Rigged Camera
  30930. */
  30931. get leftCamera(): Nullable<FreeCamera>;
  30932. /**
  30933. * Gets the right camera of a rig setup in case of Rigged Camera
  30934. */
  30935. get rightCamera(): Nullable<FreeCamera>;
  30936. /**
  30937. * Gets the left camera target of a rig setup in case of Rigged Camera
  30938. * @returns the target position
  30939. */
  30940. getLeftTarget(): Nullable<Vector3>;
  30941. /**
  30942. * Gets the right camera target of a rig setup in case of Rigged Camera
  30943. * @returns the target position
  30944. */
  30945. getRightTarget(): Nullable<Vector3>;
  30946. /**
  30947. * @hidden
  30948. */
  30949. setCameraRigMode(mode: number, rigParams: any): void;
  30950. /** @hidden */
  30951. static _setStereoscopicRigMode(camera: Camera): void;
  30952. /** @hidden */
  30953. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30954. /** @hidden */
  30955. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30956. /** @hidden */
  30957. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30958. /** @hidden */
  30959. _getVRProjectionMatrix(): Matrix;
  30960. protected _updateCameraRotationMatrix(): void;
  30961. protected _updateWebVRCameraRotationMatrix(): void;
  30962. /**
  30963. * This function MUST be overwritten by the different WebVR cameras available.
  30964. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30965. * @hidden
  30966. */
  30967. _getWebVRProjectionMatrix(): Matrix;
  30968. /**
  30969. * This function MUST be overwritten by the different WebVR cameras available.
  30970. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30971. * @hidden
  30972. */
  30973. _getWebVRViewMatrix(): Matrix;
  30974. /** @hidden */
  30975. setCameraRigParameter(name: string, value: any): void;
  30976. /**
  30977. * needs to be overridden by children so sub has required properties to be copied
  30978. * @hidden
  30979. */
  30980. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30981. /**
  30982. * May need to be overridden by children
  30983. * @hidden
  30984. */
  30985. _updateRigCameras(): void;
  30986. /** @hidden */
  30987. _setupInputs(): void;
  30988. /**
  30989. * Serialiaze the camera setup to a json represention
  30990. * @returns the JSON representation
  30991. */
  30992. serialize(): any;
  30993. /**
  30994. * Clones the current camera.
  30995. * @param name The cloned camera name
  30996. * @returns the cloned camera
  30997. */
  30998. clone(name: string): Camera;
  30999. /**
  31000. * Gets the direction of the camera relative to a given local axis.
  31001. * @param localAxis Defines the reference axis to provide a relative direction.
  31002. * @return the direction
  31003. */
  31004. getDirection(localAxis: Vector3): Vector3;
  31005. /**
  31006. * Returns the current camera absolute rotation
  31007. */
  31008. get absoluteRotation(): Quaternion;
  31009. /**
  31010. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31011. * @param localAxis Defines the reference axis to provide a relative direction.
  31012. * @param result Defines the vector to store the result in
  31013. */
  31014. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31015. /**
  31016. * Gets a camera constructor for a given camera type
  31017. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31018. * @param name The name of the camera the result will be able to instantiate
  31019. * @param scene The scene the result will construct the camera in
  31020. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31021. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31022. * @returns a factory method to construc the camera
  31023. */
  31024. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31025. /**
  31026. * Compute the world matrix of the camera.
  31027. * @returns the camera world matrix
  31028. */
  31029. computeWorldMatrix(): Matrix;
  31030. /**
  31031. * Parse a JSON and creates the camera from the parsed information
  31032. * @param parsedCamera The JSON to parse
  31033. * @param scene The scene to instantiate the camera in
  31034. * @returns the newly constructed camera
  31035. */
  31036. static Parse(parsedCamera: any, scene: Scene): Camera;
  31037. }
  31038. }
  31039. declare module "babylonjs/Meshes/Builders/discBuilder" {
  31040. import { Nullable } from "babylonjs/types";
  31041. import { Scene } from "babylonjs/scene";
  31042. import { Vector4 } from "babylonjs/Maths/math.vector";
  31043. import { Mesh } from "babylonjs/Meshes/mesh";
  31044. /**
  31045. * Class containing static functions to help procedurally build meshes
  31046. */
  31047. export class DiscBuilder {
  31048. /**
  31049. * Creates a plane polygonal mesh. By default, this is a disc
  31050. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  31051. * * 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
  31052. * * 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
  31053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  31054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  31055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  31056. * @param name defines the name of the mesh
  31057. * @param options defines the options used to create the mesh
  31058. * @param scene defines the hosting scene
  31059. * @returns the plane polygonal mesh
  31060. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  31061. */
  31062. static CreateDisc(name: string, options: {
  31063. radius?: number;
  31064. tessellation?: number;
  31065. arc?: number;
  31066. updatable?: boolean;
  31067. sideOrientation?: number;
  31068. frontUVs?: Vector4;
  31069. backUVs?: Vector4;
  31070. }, scene?: Nullable<Scene>): Mesh;
  31071. }
  31072. }
  31073. declare module "babylonjs/Materials/fresnelParameters" {
  31074. import { DeepImmutable } from "babylonjs/types";
  31075. import { Color3 } from "babylonjs/Maths/math.color";
  31076. /**
  31077. * Options to be used when creating a FresnelParameters.
  31078. */
  31079. export type IFresnelParametersCreationOptions = {
  31080. /**
  31081. * Define the color used on edges (grazing angle)
  31082. */
  31083. leftColor?: Color3;
  31084. /**
  31085. * Define the color used on center
  31086. */
  31087. rightColor?: Color3;
  31088. /**
  31089. * Define bias applied to computed fresnel term
  31090. */
  31091. bias?: number;
  31092. /**
  31093. * Defined the power exponent applied to fresnel term
  31094. */
  31095. power?: number;
  31096. /**
  31097. * Define if the fresnel effect is enable or not.
  31098. */
  31099. isEnabled?: boolean;
  31100. };
  31101. /**
  31102. * Serialized format for FresnelParameters.
  31103. */
  31104. export type IFresnelParametersSerialized = {
  31105. /**
  31106. * Define the color used on edges (grazing angle) [as an array]
  31107. */
  31108. leftColor: number[];
  31109. /**
  31110. * Define the color used on center [as an array]
  31111. */
  31112. rightColor: number[];
  31113. /**
  31114. * Define bias applied to computed fresnel term
  31115. */
  31116. bias: number;
  31117. /**
  31118. * Defined the power exponent applied to fresnel term
  31119. */
  31120. power?: number;
  31121. /**
  31122. * Define if the fresnel effect is enable or not.
  31123. */
  31124. isEnabled: boolean;
  31125. };
  31126. /**
  31127. * This represents all the required information to add a fresnel effect on a material:
  31128. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31129. */
  31130. export class FresnelParameters {
  31131. private _isEnabled;
  31132. /**
  31133. * Define if the fresnel effect is enable or not.
  31134. */
  31135. get isEnabled(): boolean;
  31136. set isEnabled(value: boolean);
  31137. /**
  31138. * Define the color used on edges (grazing angle)
  31139. */
  31140. leftColor: Color3;
  31141. /**
  31142. * Define the color used on center
  31143. */
  31144. rightColor: Color3;
  31145. /**
  31146. * Define bias applied to computed fresnel term
  31147. */
  31148. bias: number;
  31149. /**
  31150. * Defined the power exponent applied to fresnel term
  31151. */
  31152. power: number;
  31153. /**
  31154. * Creates a new FresnelParameters object.
  31155. *
  31156. * @param options provide your own settings to optionally to override defaults
  31157. */
  31158. constructor(options?: IFresnelParametersCreationOptions);
  31159. /**
  31160. * Clones the current fresnel and its valuues
  31161. * @returns a clone fresnel configuration
  31162. */
  31163. clone(): FresnelParameters;
  31164. /**
  31165. * Determines equality between FresnelParameters objects
  31166. * @param otherFresnelParameters defines the second operand
  31167. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31168. */
  31169. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31170. /**
  31171. * Serializes the current fresnel parameters to a JSON representation.
  31172. * @return the JSON serialization
  31173. */
  31174. serialize(): IFresnelParametersSerialized;
  31175. /**
  31176. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31177. * @param parsedFresnelParameters Define the JSON representation
  31178. * @returns the parsed parameters
  31179. */
  31180. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31181. }
  31182. }
  31183. declare module "babylonjs/Materials/materialFlags" {
  31184. /**
  31185. * This groups all the flags used to control the materials channel.
  31186. */
  31187. export class MaterialFlags {
  31188. private static _DiffuseTextureEnabled;
  31189. /**
  31190. * Are diffuse textures enabled in the application.
  31191. */
  31192. static get DiffuseTextureEnabled(): boolean;
  31193. static set DiffuseTextureEnabled(value: boolean);
  31194. private static _DetailTextureEnabled;
  31195. /**
  31196. * Are detail textures enabled in the application.
  31197. */
  31198. static get DetailTextureEnabled(): boolean;
  31199. static set DetailTextureEnabled(value: boolean);
  31200. private static _AmbientTextureEnabled;
  31201. /**
  31202. * Are ambient textures enabled in the application.
  31203. */
  31204. static get AmbientTextureEnabled(): boolean;
  31205. static set AmbientTextureEnabled(value: boolean);
  31206. private static _OpacityTextureEnabled;
  31207. /**
  31208. * Are opacity textures enabled in the application.
  31209. */
  31210. static get OpacityTextureEnabled(): boolean;
  31211. static set OpacityTextureEnabled(value: boolean);
  31212. private static _ReflectionTextureEnabled;
  31213. /**
  31214. * Are reflection textures enabled in the application.
  31215. */
  31216. static get ReflectionTextureEnabled(): boolean;
  31217. static set ReflectionTextureEnabled(value: boolean);
  31218. private static _EmissiveTextureEnabled;
  31219. /**
  31220. * Are emissive textures enabled in the application.
  31221. */
  31222. static get EmissiveTextureEnabled(): boolean;
  31223. static set EmissiveTextureEnabled(value: boolean);
  31224. private static _SpecularTextureEnabled;
  31225. /**
  31226. * Are specular textures enabled in the application.
  31227. */
  31228. static get SpecularTextureEnabled(): boolean;
  31229. static set SpecularTextureEnabled(value: boolean);
  31230. private static _BumpTextureEnabled;
  31231. /**
  31232. * Are bump textures enabled in the application.
  31233. */
  31234. static get BumpTextureEnabled(): boolean;
  31235. static set BumpTextureEnabled(value: boolean);
  31236. private static _LightmapTextureEnabled;
  31237. /**
  31238. * Are lightmap textures enabled in the application.
  31239. */
  31240. static get LightmapTextureEnabled(): boolean;
  31241. static set LightmapTextureEnabled(value: boolean);
  31242. private static _RefractionTextureEnabled;
  31243. /**
  31244. * Are refraction textures enabled in the application.
  31245. */
  31246. static get RefractionTextureEnabled(): boolean;
  31247. static set RefractionTextureEnabled(value: boolean);
  31248. private static _ColorGradingTextureEnabled;
  31249. /**
  31250. * Are color grading textures enabled in the application.
  31251. */
  31252. static get ColorGradingTextureEnabled(): boolean;
  31253. static set ColorGradingTextureEnabled(value: boolean);
  31254. private static _FresnelEnabled;
  31255. /**
  31256. * Are fresnels enabled in the application.
  31257. */
  31258. static get FresnelEnabled(): boolean;
  31259. static set FresnelEnabled(value: boolean);
  31260. private static _ClearCoatTextureEnabled;
  31261. /**
  31262. * Are clear coat textures enabled in the application.
  31263. */
  31264. static get ClearCoatTextureEnabled(): boolean;
  31265. static set ClearCoatTextureEnabled(value: boolean);
  31266. private static _ClearCoatBumpTextureEnabled;
  31267. /**
  31268. * Are clear coat bump textures enabled in the application.
  31269. */
  31270. static get ClearCoatBumpTextureEnabled(): boolean;
  31271. static set ClearCoatBumpTextureEnabled(value: boolean);
  31272. private static _ClearCoatTintTextureEnabled;
  31273. /**
  31274. * Are clear coat tint textures enabled in the application.
  31275. */
  31276. static get ClearCoatTintTextureEnabled(): boolean;
  31277. static set ClearCoatTintTextureEnabled(value: boolean);
  31278. private static _SheenTextureEnabled;
  31279. /**
  31280. * Are sheen textures enabled in the application.
  31281. */
  31282. static get SheenTextureEnabled(): boolean;
  31283. static set SheenTextureEnabled(value: boolean);
  31284. private static _AnisotropicTextureEnabled;
  31285. /**
  31286. * Are anisotropic textures enabled in the application.
  31287. */
  31288. static get AnisotropicTextureEnabled(): boolean;
  31289. static set AnisotropicTextureEnabled(value: boolean);
  31290. private static _ThicknessTextureEnabled;
  31291. /**
  31292. * Are thickness textures enabled in the application.
  31293. */
  31294. static get ThicknessTextureEnabled(): boolean;
  31295. static set ThicknessTextureEnabled(value: boolean);
  31296. }
  31297. }
  31298. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31299. /** @hidden */
  31300. export var defaultFragmentDeclaration: {
  31301. name: string;
  31302. shader: string;
  31303. };
  31304. }
  31305. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31306. /** @hidden */
  31307. export var defaultUboDeclaration: {
  31308. name: string;
  31309. shader: string;
  31310. };
  31311. }
  31312. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31313. /** @hidden */
  31314. export var prePassDeclaration: {
  31315. name: string;
  31316. shader: string;
  31317. };
  31318. }
  31319. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31320. /** @hidden */
  31321. export var lightFragmentDeclaration: {
  31322. name: string;
  31323. shader: string;
  31324. };
  31325. }
  31326. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31327. /** @hidden */
  31328. export var lightUboDeclaration: {
  31329. name: string;
  31330. shader: string;
  31331. };
  31332. }
  31333. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31334. /** @hidden */
  31335. export var lightsFragmentFunctions: {
  31336. name: string;
  31337. shader: string;
  31338. };
  31339. }
  31340. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31341. /** @hidden */
  31342. export var shadowsFragmentFunctions: {
  31343. name: string;
  31344. shader: string;
  31345. };
  31346. }
  31347. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31348. /** @hidden */
  31349. export var fresnelFunction: {
  31350. name: string;
  31351. shader: string;
  31352. };
  31353. }
  31354. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31355. /** @hidden */
  31356. export var bumpFragmentMainFunctions: {
  31357. name: string;
  31358. shader: string;
  31359. };
  31360. }
  31361. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31362. /** @hidden */
  31363. export var bumpFragmentFunctions: {
  31364. name: string;
  31365. shader: string;
  31366. };
  31367. }
  31368. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31369. /** @hidden */
  31370. export var logDepthDeclaration: {
  31371. name: string;
  31372. shader: string;
  31373. };
  31374. }
  31375. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31376. /** @hidden */
  31377. export var bumpFragment: {
  31378. name: string;
  31379. shader: string;
  31380. };
  31381. }
  31382. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31383. /** @hidden */
  31384. export var depthPrePass: {
  31385. name: string;
  31386. shader: string;
  31387. };
  31388. }
  31389. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31390. /** @hidden */
  31391. export var lightFragment: {
  31392. name: string;
  31393. shader: string;
  31394. };
  31395. }
  31396. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31397. /** @hidden */
  31398. export var logDepthFragment: {
  31399. name: string;
  31400. shader: string;
  31401. };
  31402. }
  31403. declare module "babylonjs/Shaders/default.fragment" {
  31404. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31408. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31411. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31412. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31413. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31414. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31415. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31416. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31417. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31418. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31419. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31420. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31421. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31422. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31423. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31424. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31425. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31426. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31427. /** @hidden */
  31428. export var defaultPixelShader: {
  31429. name: string;
  31430. shader: string;
  31431. };
  31432. }
  31433. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31434. /** @hidden */
  31435. export var defaultVertexDeclaration: {
  31436. name: string;
  31437. shader: string;
  31438. };
  31439. }
  31440. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  31441. /** @hidden */
  31442. export var prePassVertexDeclaration: {
  31443. name: string;
  31444. shader: string;
  31445. };
  31446. }
  31447. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31448. /** @hidden */
  31449. export var bumpVertexDeclaration: {
  31450. name: string;
  31451. shader: string;
  31452. };
  31453. }
  31454. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  31455. /** @hidden */
  31456. export var prePassVertex: {
  31457. name: string;
  31458. shader: string;
  31459. };
  31460. }
  31461. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31462. /** @hidden */
  31463. export var bumpVertex: {
  31464. name: string;
  31465. shader: string;
  31466. };
  31467. }
  31468. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31469. /** @hidden */
  31470. export var fogVertex: {
  31471. name: string;
  31472. shader: string;
  31473. };
  31474. }
  31475. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31476. /** @hidden */
  31477. export var shadowsVertex: {
  31478. name: string;
  31479. shader: string;
  31480. };
  31481. }
  31482. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31483. /** @hidden */
  31484. export var pointCloudVertex: {
  31485. name: string;
  31486. shader: string;
  31487. };
  31488. }
  31489. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31490. /** @hidden */
  31491. export var logDepthVertex: {
  31492. name: string;
  31493. shader: string;
  31494. };
  31495. }
  31496. declare module "babylonjs/Shaders/default.vertex" {
  31497. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31498. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31499. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31500. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31501. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31502. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  31503. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31505. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31506. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31507. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31510. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31514. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  31515. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31516. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31517. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31518. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31519. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31520. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31521. /** @hidden */
  31522. export var defaultVertexShader: {
  31523. name: string;
  31524. shader: string;
  31525. };
  31526. }
  31527. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31528. import { Nullable } from "babylonjs/types";
  31529. import { Scene } from "babylonjs/scene";
  31530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31531. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31533. /**
  31534. * @hidden
  31535. */
  31536. export interface IMaterialDetailMapDefines {
  31537. DETAIL: boolean;
  31538. DETAILDIRECTUV: number;
  31539. DETAIL_NORMALBLENDMETHOD: number;
  31540. /** @hidden */
  31541. _areTexturesDirty: boolean;
  31542. }
  31543. /**
  31544. * Define the code related to the detail map parameters of a material
  31545. *
  31546. * Inspired from:
  31547. * 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
  31548. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31549. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31550. */
  31551. export class DetailMapConfiguration {
  31552. private _texture;
  31553. /**
  31554. * The detail texture of the material.
  31555. */
  31556. texture: Nullable<BaseTexture>;
  31557. /**
  31558. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31559. * Bigger values mean stronger blending
  31560. */
  31561. diffuseBlendLevel: number;
  31562. /**
  31563. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31564. * Bigger values mean stronger blending. Only used with PBR materials
  31565. */
  31566. roughnessBlendLevel: number;
  31567. /**
  31568. * Defines how strong the bump effect from the detail map is
  31569. * Bigger values mean stronger effect
  31570. */
  31571. bumpLevel: number;
  31572. private _normalBlendMethod;
  31573. /**
  31574. * The method used to blend the bump and detail normals together
  31575. */
  31576. normalBlendMethod: number;
  31577. private _isEnabled;
  31578. /**
  31579. * Enable or disable the detail map on this material
  31580. */
  31581. isEnabled: boolean;
  31582. /** @hidden */
  31583. private _internalMarkAllSubMeshesAsTexturesDirty;
  31584. /** @hidden */
  31585. _markAllSubMeshesAsTexturesDirty(): void;
  31586. /**
  31587. * Instantiate a new detail map
  31588. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31589. */
  31590. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31591. /**
  31592. * Gets whether the submesh is ready to be used or not.
  31593. * @param defines the list of "defines" to update.
  31594. * @param scene defines the scene the material belongs to.
  31595. * @returns - boolean indicating that the submesh is ready or not.
  31596. */
  31597. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31598. /**
  31599. * Update the defines for detail map usage
  31600. * @param defines the list of "defines" to update.
  31601. * @param scene defines the scene the material belongs to.
  31602. */
  31603. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31604. /**
  31605. * Binds the material data.
  31606. * @param uniformBuffer defines the Uniform buffer to fill in.
  31607. * @param scene defines the scene the material belongs to.
  31608. * @param isFrozen defines whether the material is frozen or not.
  31609. */
  31610. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31611. /**
  31612. * Checks to see if a texture is used in the material.
  31613. * @param texture - Base texture to use.
  31614. * @returns - Boolean specifying if a texture is used in the material.
  31615. */
  31616. hasTexture(texture: BaseTexture): boolean;
  31617. /**
  31618. * Returns an array of the actively used textures.
  31619. * @param activeTextures Array of BaseTextures
  31620. */
  31621. getActiveTextures(activeTextures: BaseTexture[]): void;
  31622. /**
  31623. * Returns the animatable textures.
  31624. * @param animatables Array of animatable textures.
  31625. */
  31626. getAnimatables(animatables: IAnimatable[]): void;
  31627. /**
  31628. * Disposes the resources of the material.
  31629. * @param forceDisposeTextures - Forces the disposal of all textures.
  31630. */
  31631. dispose(forceDisposeTextures?: boolean): void;
  31632. /**
  31633. * Get the current class name useful for serialization or dynamic coding.
  31634. * @returns "DetailMap"
  31635. */
  31636. getClassName(): string;
  31637. /**
  31638. * Add the required uniforms to the current list.
  31639. * @param uniforms defines the current uniform list.
  31640. */
  31641. static AddUniforms(uniforms: string[]): void;
  31642. /**
  31643. * Add the required samplers to the current list.
  31644. * @param samplers defines the current sampler list.
  31645. */
  31646. static AddSamplers(samplers: string[]): void;
  31647. /**
  31648. * Add the required uniforms to the current buffer.
  31649. * @param uniformBuffer defines the current uniform buffer.
  31650. */
  31651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31652. /**
  31653. * Makes a duplicate of the current instance into another one.
  31654. * @param detailMap define the instance where to copy the info
  31655. */
  31656. copyTo(detailMap: DetailMapConfiguration): void;
  31657. /**
  31658. * Serializes this detail map instance
  31659. * @returns - An object with the serialized instance.
  31660. */
  31661. serialize(): any;
  31662. /**
  31663. * Parses a detail map setting from a serialized object.
  31664. * @param source - Serialized object.
  31665. * @param scene Defines the scene we are parsing for
  31666. * @param rootUrl Defines the rootUrl to load from
  31667. */
  31668. parse(source: any, scene: Scene, rootUrl: string): void;
  31669. }
  31670. }
  31671. declare module "babylonjs/Materials/standardMaterial" {
  31672. import { SmartArray } from "babylonjs/Misc/smartArray";
  31673. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31674. import { Nullable } from "babylonjs/types";
  31675. import { Scene } from "babylonjs/scene";
  31676. import { Matrix } from "babylonjs/Maths/math.vector";
  31677. import { Color3 } from "babylonjs/Maths/math.color";
  31678. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31680. import { Mesh } from "babylonjs/Meshes/mesh";
  31681. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  31682. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31683. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31684. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31685. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31686. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31688. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31689. import "babylonjs/Shaders/default.fragment";
  31690. import "babylonjs/Shaders/default.vertex";
  31691. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31692. /** @hidden */
  31693. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31694. MAINUV1: boolean;
  31695. MAINUV2: boolean;
  31696. DIFFUSE: boolean;
  31697. DIFFUSEDIRECTUV: number;
  31698. DETAIL: boolean;
  31699. DETAILDIRECTUV: number;
  31700. DETAIL_NORMALBLENDMETHOD: number;
  31701. AMBIENT: boolean;
  31702. AMBIENTDIRECTUV: number;
  31703. OPACITY: boolean;
  31704. OPACITYDIRECTUV: number;
  31705. OPACITYRGB: boolean;
  31706. REFLECTION: boolean;
  31707. EMISSIVE: boolean;
  31708. EMISSIVEDIRECTUV: number;
  31709. SPECULAR: boolean;
  31710. SPECULARDIRECTUV: number;
  31711. BUMP: boolean;
  31712. BUMPDIRECTUV: number;
  31713. PARALLAX: boolean;
  31714. PARALLAXOCCLUSION: boolean;
  31715. SPECULAROVERALPHA: boolean;
  31716. CLIPPLANE: boolean;
  31717. CLIPPLANE2: boolean;
  31718. CLIPPLANE3: boolean;
  31719. CLIPPLANE4: boolean;
  31720. CLIPPLANE5: boolean;
  31721. CLIPPLANE6: boolean;
  31722. ALPHATEST: boolean;
  31723. DEPTHPREPASS: boolean;
  31724. ALPHAFROMDIFFUSE: boolean;
  31725. POINTSIZE: boolean;
  31726. FOG: boolean;
  31727. SPECULARTERM: boolean;
  31728. DIFFUSEFRESNEL: boolean;
  31729. OPACITYFRESNEL: boolean;
  31730. REFLECTIONFRESNEL: boolean;
  31731. REFRACTIONFRESNEL: boolean;
  31732. EMISSIVEFRESNEL: boolean;
  31733. FRESNEL: boolean;
  31734. NORMAL: boolean;
  31735. UV1: boolean;
  31736. UV2: boolean;
  31737. VERTEXCOLOR: boolean;
  31738. VERTEXALPHA: boolean;
  31739. NUM_BONE_INFLUENCERS: number;
  31740. BonesPerMesh: number;
  31741. BONETEXTURE: boolean;
  31742. BONES_VELOCITY_ENABLED: boolean;
  31743. INSTANCES: boolean;
  31744. THIN_INSTANCES: boolean;
  31745. GLOSSINESS: boolean;
  31746. ROUGHNESS: boolean;
  31747. EMISSIVEASILLUMINATION: boolean;
  31748. LINKEMISSIVEWITHDIFFUSE: boolean;
  31749. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31750. LIGHTMAP: boolean;
  31751. LIGHTMAPDIRECTUV: number;
  31752. OBJECTSPACE_NORMALMAP: boolean;
  31753. USELIGHTMAPASSHADOWMAP: boolean;
  31754. REFLECTIONMAP_3D: boolean;
  31755. REFLECTIONMAP_SPHERICAL: boolean;
  31756. REFLECTIONMAP_PLANAR: boolean;
  31757. REFLECTIONMAP_CUBIC: boolean;
  31758. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31759. REFLECTIONMAP_PROJECTION: boolean;
  31760. REFLECTIONMAP_SKYBOX: boolean;
  31761. REFLECTIONMAP_EXPLICIT: boolean;
  31762. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31763. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31764. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31765. INVERTCUBICMAP: boolean;
  31766. LOGARITHMICDEPTH: boolean;
  31767. REFRACTION: boolean;
  31768. REFRACTIONMAP_3D: boolean;
  31769. REFLECTIONOVERALPHA: boolean;
  31770. TWOSIDEDLIGHTING: boolean;
  31771. SHADOWFLOAT: boolean;
  31772. MORPHTARGETS: boolean;
  31773. MORPHTARGETS_NORMAL: boolean;
  31774. MORPHTARGETS_TANGENT: boolean;
  31775. MORPHTARGETS_UV: boolean;
  31776. NUM_MORPH_INFLUENCERS: number;
  31777. NONUNIFORMSCALING: boolean;
  31778. PREMULTIPLYALPHA: boolean;
  31779. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31780. ALPHABLEND: boolean;
  31781. PREPASS: boolean;
  31782. PREPASS_IRRADIANCE: boolean;
  31783. PREPASS_IRRADIANCE_INDEX: number;
  31784. PREPASS_ALBEDO: boolean;
  31785. PREPASS_ALBEDO_INDEX: number;
  31786. PREPASS_DEPTHNORMAL: boolean;
  31787. PREPASS_DEPTHNORMAL_INDEX: number;
  31788. PREPASS_POSITION: boolean;
  31789. PREPASS_POSITION_INDEX: number;
  31790. PREPASS_VELOCITY: boolean;
  31791. PREPASS_VELOCITY_INDEX: number;
  31792. PREPASS_REFLECTIVITY: boolean;
  31793. PREPASS_REFLECTIVITY_INDEX: number;
  31794. SCENE_MRT_COUNT: number;
  31795. RGBDLIGHTMAP: boolean;
  31796. RGBDREFLECTION: boolean;
  31797. RGBDREFRACTION: boolean;
  31798. IMAGEPROCESSING: boolean;
  31799. VIGNETTE: boolean;
  31800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31801. VIGNETTEBLENDMODEOPAQUE: boolean;
  31802. TONEMAPPING: boolean;
  31803. TONEMAPPING_ACES: boolean;
  31804. CONTRAST: boolean;
  31805. COLORCURVES: boolean;
  31806. COLORGRADING: boolean;
  31807. COLORGRADING3D: boolean;
  31808. SAMPLER3DGREENDEPTH: boolean;
  31809. SAMPLER3DBGRMAP: boolean;
  31810. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31811. MULTIVIEW: boolean;
  31812. /**
  31813. * If the reflection texture on this material is in linear color space
  31814. * @hidden
  31815. */
  31816. IS_REFLECTION_LINEAR: boolean;
  31817. /**
  31818. * If the refraction texture on this material is in linear color space
  31819. * @hidden
  31820. */
  31821. IS_REFRACTION_LINEAR: boolean;
  31822. EXPOSURE: boolean;
  31823. constructor();
  31824. setReflectionMode(modeToEnable: string): void;
  31825. }
  31826. /**
  31827. * This is the default material used in Babylon. It is the best trade off between quality
  31828. * and performances.
  31829. * @see https://doc.babylonjs.com/babylon101/materials
  31830. */
  31831. export class StandardMaterial extends PushMaterial {
  31832. private _diffuseTexture;
  31833. /**
  31834. * The basic texture of the material as viewed under a light.
  31835. */
  31836. diffuseTexture: Nullable<BaseTexture>;
  31837. private _ambientTexture;
  31838. /**
  31839. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31840. */
  31841. ambientTexture: Nullable<BaseTexture>;
  31842. private _opacityTexture;
  31843. /**
  31844. * Define the transparency of the material from a texture.
  31845. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31846. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31847. */
  31848. opacityTexture: Nullable<BaseTexture>;
  31849. private _reflectionTexture;
  31850. /**
  31851. * Define the texture used to display the reflection.
  31852. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31853. */
  31854. reflectionTexture: Nullable<BaseTexture>;
  31855. private _emissiveTexture;
  31856. /**
  31857. * Define texture of the material as if self lit.
  31858. * This will be mixed in the final result even in the absence of light.
  31859. */
  31860. emissiveTexture: Nullable<BaseTexture>;
  31861. private _specularTexture;
  31862. /**
  31863. * Define how the color and intensity of the highlight given by the light in the material.
  31864. */
  31865. specularTexture: Nullable<BaseTexture>;
  31866. private _bumpTexture;
  31867. /**
  31868. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31869. * 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.
  31870. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31871. */
  31872. bumpTexture: Nullable<BaseTexture>;
  31873. private _lightmapTexture;
  31874. /**
  31875. * Complex lighting can be computationally expensive to compute at runtime.
  31876. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31877. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31878. */
  31879. lightmapTexture: Nullable<BaseTexture>;
  31880. private _refractionTexture;
  31881. /**
  31882. * Define the texture used to display the refraction.
  31883. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31884. */
  31885. refractionTexture: Nullable<BaseTexture>;
  31886. /**
  31887. * The color of the material lit by the environmental background lighting.
  31888. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31889. */
  31890. ambientColor: Color3;
  31891. /**
  31892. * The basic color of the material as viewed under a light.
  31893. */
  31894. diffuseColor: Color3;
  31895. /**
  31896. * Define how the color and intensity of the highlight given by the light in the material.
  31897. */
  31898. specularColor: Color3;
  31899. /**
  31900. * Define the color of the material as if self lit.
  31901. * This will be mixed in the final result even in the absence of light.
  31902. */
  31903. emissiveColor: Color3;
  31904. /**
  31905. * Defines how sharp are the highlights in the material.
  31906. * The bigger the value the sharper giving a more glossy feeling to the result.
  31907. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31908. */
  31909. specularPower: number;
  31910. private _useAlphaFromDiffuseTexture;
  31911. /**
  31912. * Does the transparency come from the diffuse texture alpha channel.
  31913. */
  31914. useAlphaFromDiffuseTexture: boolean;
  31915. private _useEmissiveAsIllumination;
  31916. /**
  31917. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31918. */
  31919. useEmissiveAsIllumination: boolean;
  31920. private _linkEmissiveWithDiffuse;
  31921. /**
  31922. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31923. * the emissive level when the final color is close to one.
  31924. */
  31925. linkEmissiveWithDiffuse: boolean;
  31926. private _useSpecularOverAlpha;
  31927. /**
  31928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31930. */
  31931. useSpecularOverAlpha: boolean;
  31932. private _useReflectionOverAlpha;
  31933. /**
  31934. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31935. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31936. */
  31937. useReflectionOverAlpha: boolean;
  31938. private _disableLighting;
  31939. /**
  31940. * Does lights from the scene impacts this material.
  31941. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31942. */
  31943. disableLighting: boolean;
  31944. private _useObjectSpaceNormalMap;
  31945. /**
  31946. * Allows using an object space normal map (instead of tangent space).
  31947. */
  31948. useObjectSpaceNormalMap: boolean;
  31949. private _useParallax;
  31950. /**
  31951. * Is parallax enabled or not.
  31952. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31953. */
  31954. useParallax: boolean;
  31955. private _useParallaxOcclusion;
  31956. /**
  31957. * Is parallax occlusion enabled or not.
  31958. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31959. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31960. */
  31961. useParallaxOcclusion: boolean;
  31962. /**
  31963. * 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.
  31964. */
  31965. parallaxScaleBias: number;
  31966. private _roughness;
  31967. /**
  31968. * Helps to define how blurry the reflections should appears in the material.
  31969. */
  31970. roughness: number;
  31971. /**
  31972. * In case of refraction, define the value of the index of refraction.
  31973. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31974. */
  31975. indexOfRefraction: number;
  31976. /**
  31977. * Invert the refraction texture alongside the y axis.
  31978. * It can be useful with procedural textures or probe for instance.
  31979. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31980. */
  31981. invertRefractionY: boolean;
  31982. /**
  31983. * Defines the alpha limits in alpha test mode.
  31984. */
  31985. alphaCutOff: number;
  31986. private _useLightmapAsShadowmap;
  31987. /**
  31988. * In case of light mapping, define whether the map contains light or shadow informations.
  31989. */
  31990. useLightmapAsShadowmap: boolean;
  31991. private _diffuseFresnelParameters;
  31992. /**
  31993. * Define the diffuse fresnel parameters of the material.
  31994. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31995. */
  31996. diffuseFresnelParameters: FresnelParameters;
  31997. private _opacityFresnelParameters;
  31998. /**
  31999. * Define the opacity fresnel parameters of the material.
  32000. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32001. */
  32002. opacityFresnelParameters: FresnelParameters;
  32003. private _reflectionFresnelParameters;
  32004. /**
  32005. * Define the reflection fresnel parameters of the material.
  32006. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32007. */
  32008. reflectionFresnelParameters: FresnelParameters;
  32009. private _refractionFresnelParameters;
  32010. /**
  32011. * Define the refraction fresnel parameters of the material.
  32012. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32013. */
  32014. refractionFresnelParameters: FresnelParameters;
  32015. private _emissiveFresnelParameters;
  32016. /**
  32017. * Define the emissive fresnel parameters of the material.
  32018. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32019. */
  32020. emissiveFresnelParameters: FresnelParameters;
  32021. private _useReflectionFresnelFromSpecular;
  32022. /**
  32023. * If true automatically deducts the fresnels values from the material specularity.
  32024. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32025. */
  32026. useReflectionFresnelFromSpecular: boolean;
  32027. private _useGlossinessFromSpecularMapAlpha;
  32028. /**
  32029. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  32030. */
  32031. useGlossinessFromSpecularMapAlpha: boolean;
  32032. private _maxSimultaneousLights;
  32033. /**
  32034. * Defines the maximum number of lights that can be used in the material
  32035. */
  32036. maxSimultaneousLights: number;
  32037. private _invertNormalMapX;
  32038. /**
  32039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32040. */
  32041. invertNormalMapX: boolean;
  32042. private _invertNormalMapY;
  32043. /**
  32044. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32045. */
  32046. invertNormalMapY: boolean;
  32047. private _twoSidedLighting;
  32048. /**
  32049. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32050. */
  32051. twoSidedLighting: boolean;
  32052. /**
  32053. * Default configuration related to image processing available in the standard Material.
  32054. */
  32055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32056. /**
  32057. * Gets the image processing configuration used either in this material.
  32058. */
  32059. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  32060. /**
  32061. * Sets the Default image processing configuration used either in the this material.
  32062. *
  32063. * If sets to null, the scene one is in use.
  32064. */
  32065. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  32066. /**
  32067. * Keep track of the image processing observer to allow dispose and replace.
  32068. */
  32069. private _imageProcessingObserver;
  32070. /**
  32071. * Attaches a new image processing configuration to the Standard Material.
  32072. * @param configuration
  32073. */
  32074. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32075. /**
  32076. * Defines additionnal PrePass parameters for the material.
  32077. */
  32078. readonly prePassConfiguration: PrePassConfiguration;
  32079. /**
  32080. * Gets wether the color curves effect is enabled.
  32081. */
  32082. get cameraColorCurvesEnabled(): boolean;
  32083. /**
  32084. * Sets wether the color curves effect is enabled.
  32085. */
  32086. set cameraColorCurvesEnabled(value: boolean);
  32087. /**
  32088. * Gets wether the color grading effect is enabled.
  32089. */
  32090. get cameraColorGradingEnabled(): boolean;
  32091. /**
  32092. * Gets wether the color grading effect is enabled.
  32093. */
  32094. set cameraColorGradingEnabled(value: boolean);
  32095. /**
  32096. * Gets wether tonemapping is enabled or not.
  32097. */
  32098. get cameraToneMappingEnabled(): boolean;
  32099. /**
  32100. * Sets wether tonemapping is enabled or not
  32101. */
  32102. set cameraToneMappingEnabled(value: boolean);
  32103. /**
  32104. * The camera exposure used on this material.
  32105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32106. * This corresponds to a photographic exposure.
  32107. */
  32108. get cameraExposure(): number;
  32109. /**
  32110. * The camera exposure used on this material.
  32111. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32112. * This corresponds to a photographic exposure.
  32113. */
  32114. set cameraExposure(value: number);
  32115. /**
  32116. * Gets The camera contrast used on this material.
  32117. */
  32118. get cameraContrast(): number;
  32119. /**
  32120. * Sets The camera contrast used on this material.
  32121. */
  32122. set cameraContrast(value: number);
  32123. /**
  32124. * Gets the Color Grading 2D Lookup Texture.
  32125. */
  32126. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32127. /**
  32128. * Sets the Color Grading 2D Lookup Texture.
  32129. */
  32130. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32131. /**
  32132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32134. * 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;
  32135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32136. */
  32137. get cameraColorCurves(): Nullable<ColorCurves>;
  32138. /**
  32139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32141. * 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;
  32142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32143. */
  32144. set cameraColorCurves(value: Nullable<ColorCurves>);
  32145. /**
  32146. * Can this material render to several textures at once
  32147. */
  32148. get canRenderToMRT(): boolean;
  32149. /**
  32150. * Defines the detail map parameters for the material.
  32151. */
  32152. readonly detailMap: DetailMapConfiguration;
  32153. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32154. protected _worldViewProjectionMatrix: Matrix;
  32155. protected _globalAmbientColor: Color3;
  32156. protected _useLogarithmicDepth: boolean;
  32157. protected _rebuildInParallel: boolean;
  32158. /**
  32159. * Instantiates a new standard material.
  32160. * This is the default material used in Babylon. It is the best trade off between quality
  32161. * and performances.
  32162. * @see https://doc.babylonjs.com/babylon101/materials
  32163. * @param name Define the name of the material in the scene
  32164. * @param scene Define the scene the material belong to
  32165. */
  32166. constructor(name: string, scene: Scene);
  32167. /**
  32168. * Gets a boolean indicating that current material needs to register RTT
  32169. */
  32170. get hasRenderTargetTextures(): boolean;
  32171. /**
  32172. * Gets the current class name of the material e.g. "StandardMaterial"
  32173. * Mainly use in serialization.
  32174. * @returns the class name
  32175. */
  32176. getClassName(): string;
  32177. /**
  32178. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32179. * You can try switching to logarithmic depth.
  32180. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32181. */
  32182. get useLogarithmicDepth(): boolean;
  32183. set useLogarithmicDepth(value: boolean);
  32184. /**
  32185. * Specifies if the material will require alpha blending
  32186. * @returns a boolean specifying if alpha blending is needed
  32187. */
  32188. needAlphaBlending(): boolean;
  32189. /**
  32190. * Specifies if this material should be rendered in alpha test mode
  32191. * @returns a boolean specifying if an alpha test is needed.
  32192. */
  32193. needAlphaTesting(): boolean;
  32194. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32195. /**
  32196. * Get the texture used for alpha test purpose.
  32197. * @returns the diffuse texture in case of the standard material.
  32198. */
  32199. getAlphaTestTexture(): Nullable<BaseTexture>;
  32200. /**
  32201. * Get if the submesh is ready to be used and all its information available.
  32202. * Child classes can use it to update shaders
  32203. * @param mesh defines the mesh to check
  32204. * @param subMesh defines which submesh to check
  32205. * @param useInstances specifies that instances should be used
  32206. * @returns a boolean indicating that the submesh is ready or not
  32207. */
  32208. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32209. /**
  32210. * Builds the material UBO layouts.
  32211. * Used internally during the effect preparation.
  32212. */
  32213. buildUniformLayout(): void;
  32214. /**
  32215. * Unbinds the material from the mesh
  32216. */
  32217. unbind(): void;
  32218. /**
  32219. * Binds the submesh to this material by preparing the effect and shader to draw
  32220. * @param world defines the world transformation matrix
  32221. * @param mesh defines the mesh containing the submesh
  32222. * @param subMesh defines the submesh to bind the material to
  32223. */
  32224. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32225. /**
  32226. * Get the list of animatables in the material.
  32227. * @returns the list of animatables object used in the material
  32228. */
  32229. getAnimatables(): IAnimatable[];
  32230. /**
  32231. * Gets the active textures from the material
  32232. * @returns an array of textures
  32233. */
  32234. getActiveTextures(): BaseTexture[];
  32235. /**
  32236. * Specifies if the material uses a texture
  32237. * @param texture defines the texture to check against the material
  32238. * @returns a boolean specifying if the material uses the texture
  32239. */
  32240. hasTexture(texture: BaseTexture): boolean;
  32241. /**
  32242. * Disposes the material
  32243. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32244. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32245. */
  32246. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32247. /**
  32248. * Makes a duplicate of the material, and gives it a new name
  32249. * @param name defines the new name for the duplicated material
  32250. * @returns the cloned material
  32251. */
  32252. clone(name: string): StandardMaterial;
  32253. /**
  32254. * Serializes this material in a JSON representation
  32255. * @returns the serialized material object
  32256. */
  32257. serialize(): any;
  32258. /**
  32259. * Creates a standard material from parsed material data
  32260. * @param source defines the JSON representation of the material
  32261. * @param scene defines the hosting scene
  32262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32263. * @returns a new standard material
  32264. */
  32265. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32266. /**
  32267. * Are diffuse textures enabled in the application.
  32268. */
  32269. static get DiffuseTextureEnabled(): boolean;
  32270. static set DiffuseTextureEnabled(value: boolean);
  32271. /**
  32272. * Are detail textures enabled in the application.
  32273. */
  32274. static get DetailTextureEnabled(): boolean;
  32275. static set DetailTextureEnabled(value: boolean);
  32276. /**
  32277. * Are ambient textures enabled in the application.
  32278. */
  32279. static get AmbientTextureEnabled(): boolean;
  32280. static set AmbientTextureEnabled(value: boolean);
  32281. /**
  32282. * Are opacity textures enabled in the application.
  32283. */
  32284. static get OpacityTextureEnabled(): boolean;
  32285. static set OpacityTextureEnabled(value: boolean);
  32286. /**
  32287. * Are reflection textures enabled in the application.
  32288. */
  32289. static get ReflectionTextureEnabled(): boolean;
  32290. static set ReflectionTextureEnabled(value: boolean);
  32291. /**
  32292. * Are emissive textures enabled in the application.
  32293. */
  32294. static get EmissiveTextureEnabled(): boolean;
  32295. static set EmissiveTextureEnabled(value: boolean);
  32296. /**
  32297. * Are specular textures enabled in the application.
  32298. */
  32299. static get SpecularTextureEnabled(): boolean;
  32300. static set SpecularTextureEnabled(value: boolean);
  32301. /**
  32302. * Are bump textures enabled in the application.
  32303. */
  32304. static get BumpTextureEnabled(): boolean;
  32305. static set BumpTextureEnabled(value: boolean);
  32306. /**
  32307. * Are lightmap textures enabled in the application.
  32308. */
  32309. static get LightmapTextureEnabled(): boolean;
  32310. static set LightmapTextureEnabled(value: boolean);
  32311. /**
  32312. * Are refraction textures enabled in the application.
  32313. */
  32314. static get RefractionTextureEnabled(): boolean;
  32315. static set RefractionTextureEnabled(value: boolean);
  32316. /**
  32317. * Are color grading textures enabled in the application.
  32318. */
  32319. static get ColorGradingTextureEnabled(): boolean;
  32320. static set ColorGradingTextureEnabled(value: boolean);
  32321. /**
  32322. * Are fresnels enabled in the application.
  32323. */
  32324. static get FresnelEnabled(): boolean;
  32325. static set FresnelEnabled(value: boolean);
  32326. }
  32327. }
  32328. declare module "babylonjs/Particles/solidParticleSystem" {
  32329. import { Nullable } from "babylonjs/types";
  32330. import { Mesh } from "babylonjs/Meshes/mesh";
  32331. import { Scene, IDisposable } from "babylonjs/scene";
  32332. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32333. import { Material } from "babylonjs/Materials/material";
  32334. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32335. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32336. /**
  32337. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32338. *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.
  32339. * The SPS is also a particle system. It provides some methods to manage the particles.
  32340. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32341. *
  32342. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32343. */
  32344. export class SolidParticleSystem implements IDisposable {
  32345. /**
  32346. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32347. * Example : var p = SPS.particles[i];
  32348. */
  32349. particles: SolidParticle[];
  32350. /**
  32351. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32352. */
  32353. nbParticles: number;
  32354. /**
  32355. * If the particles must ever face the camera (default false). Useful for planar particles.
  32356. */
  32357. billboard: boolean;
  32358. /**
  32359. * Recompute normals when adding a shape
  32360. */
  32361. recomputeNormals: boolean;
  32362. /**
  32363. * This a counter ofr your own usage. It's not set by any SPS functions.
  32364. */
  32365. counter: number;
  32366. /**
  32367. * The SPS name. This name is also given to the underlying mesh.
  32368. */
  32369. name: string;
  32370. /**
  32371. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32372. */
  32373. mesh: Mesh;
  32374. /**
  32375. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32376. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32377. */
  32378. vars: any;
  32379. /**
  32380. * This array is populated when the SPS is set as 'pickable'.
  32381. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32382. * Each element of this array is an object `{idx: int, faceId: int}`.
  32383. * `idx` is the picked particle index in the `SPS.particles` array
  32384. * `faceId` is the picked face index counted within this particle.
  32385. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32386. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32387. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32388. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32389. */
  32390. pickedParticles: {
  32391. idx: number;
  32392. faceId: number;
  32393. }[];
  32394. /**
  32395. * This array is populated when the SPS is set as 'pickable'
  32396. * Each key of this array is a submesh index.
  32397. * Each element of this array is a second array defined like this :
  32398. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32399. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32400. * `idx` is the picked particle index in the `SPS.particles` array
  32401. * `faceId` is the picked face index counted within this particle.
  32402. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32403. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32404. */
  32405. pickedBySubMesh: {
  32406. idx: number;
  32407. faceId: number;
  32408. }[][];
  32409. /**
  32410. * This array is populated when `enableDepthSort` is set to true.
  32411. * Each element of this array is an instance of the class DepthSortedParticle.
  32412. */
  32413. depthSortedParticles: DepthSortedParticle[];
  32414. /**
  32415. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32416. * @hidden
  32417. */
  32418. _bSphereOnly: boolean;
  32419. /**
  32420. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32421. * @hidden
  32422. */
  32423. _bSphereRadiusFactor: number;
  32424. private _scene;
  32425. private _positions;
  32426. private _indices;
  32427. private _normals;
  32428. private _colors;
  32429. private _uvs;
  32430. private _indices32;
  32431. private _positions32;
  32432. private _normals32;
  32433. private _fixedNormal32;
  32434. private _colors32;
  32435. private _uvs32;
  32436. private _index;
  32437. private _updatable;
  32438. private _pickable;
  32439. private _isVisibilityBoxLocked;
  32440. private _alwaysVisible;
  32441. private _depthSort;
  32442. private _expandable;
  32443. private _shapeCounter;
  32444. private _copy;
  32445. private _color;
  32446. private _computeParticleColor;
  32447. private _computeParticleTexture;
  32448. private _computeParticleRotation;
  32449. private _computeParticleVertex;
  32450. private _computeBoundingBox;
  32451. private _depthSortParticles;
  32452. private _camera;
  32453. private _mustUnrotateFixedNormals;
  32454. private _particlesIntersect;
  32455. private _needs32Bits;
  32456. private _isNotBuilt;
  32457. private _lastParticleId;
  32458. private _idxOfId;
  32459. private _multimaterialEnabled;
  32460. private _useModelMaterial;
  32461. private _indicesByMaterial;
  32462. private _materialIndexes;
  32463. private _depthSortFunction;
  32464. private _materialSortFunction;
  32465. private _materials;
  32466. private _multimaterial;
  32467. private _materialIndexesById;
  32468. private _defaultMaterial;
  32469. private _autoUpdateSubMeshes;
  32470. private _tmpVertex;
  32471. /**
  32472. * Creates a SPS (Solid Particle System) object.
  32473. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32474. * @param scene (Scene) is the scene in which the SPS is added.
  32475. * @param options defines the options of the sps e.g.
  32476. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32477. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32478. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32479. * * 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.
  32480. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32481. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32482. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32483. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32484. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32485. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32486. */
  32487. constructor(name: string, scene: Scene, options?: {
  32488. updatable?: boolean;
  32489. isPickable?: boolean;
  32490. enableDepthSort?: boolean;
  32491. particleIntersection?: boolean;
  32492. boundingSphereOnly?: boolean;
  32493. bSphereRadiusFactor?: number;
  32494. expandable?: boolean;
  32495. useModelMaterial?: boolean;
  32496. enableMultiMaterial?: boolean;
  32497. });
  32498. /**
  32499. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32500. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32501. * @returns the created mesh
  32502. */
  32503. buildMesh(): Mesh;
  32504. /**
  32505. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32506. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32507. * Thus the particles generated from `digest()` have their property `position` set yet.
  32508. * @param mesh ( Mesh ) is the mesh to be digested
  32509. * @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
  32510. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32511. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32512. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32513. * @returns the current SPS
  32514. */
  32515. digest(mesh: Mesh, options?: {
  32516. facetNb?: number;
  32517. number?: number;
  32518. delta?: number;
  32519. storage?: [];
  32520. }): SolidParticleSystem;
  32521. /**
  32522. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32523. * @hidden
  32524. */
  32525. private _unrotateFixedNormals;
  32526. /**
  32527. * Resets the temporary working copy particle
  32528. * @hidden
  32529. */
  32530. private _resetCopy;
  32531. /**
  32532. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32533. * @param p the current index in the positions array to be updated
  32534. * @param ind the current index in the indices array
  32535. * @param shape a Vector3 array, the shape geometry
  32536. * @param positions the positions array to be updated
  32537. * @param meshInd the shape indices array
  32538. * @param indices the indices array to be updated
  32539. * @param meshUV the shape uv array
  32540. * @param uvs the uv array to be updated
  32541. * @param meshCol the shape color array
  32542. * @param colors the color array to be updated
  32543. * @param meshNor the shape normals array
  32544. * @param normals the normals array to be updated
  32545. * @param idx the particle index
  32546. * @param idxInShape the particle index in its shape
  32547. * @param options the addShape() method passed options
  32548. * @model the particle model
  32549. * @hidden
  32550. */
  32551. private _meshBuilder;
  32552. /**
  32553. * Returns a shape Vector3 array from positions float array
  32554. * @param positions float array
  32555. * @returns a vector3 array
  32556. * @hidden
  32557. */
  32558. private _posToShape;
  32559. /**
  32560. * Returns a shapeUV array from a float uvs (array deep copy)
  32561. * @param uvs as a float array
  32562. * @returns a shapeUV array
  32563. * @hidden
  32564. */
  32565. private _uvsToShapeUV;
  32566. /**
  32567. * Adds a new particle object in the particles array
  32568. * @param idx particle index in particles array
  32569. * @param id particle id
  32570. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32571. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32572. * @param model particle ModelShape object
  32573. * @param shapeId model shape identifier
  32574. * @param idxInShape index of the particle in the current model
  32575. * @param bInfo model bounding info object
  32576. * @param storage target storage array, if any
  32577. * @hidden
  32578. */
  32579. private _addParticle;
  32580. /**
  32581. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32582. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32583. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32584. * @param nb (positive integer) the number of particles to be created from this model
  32585. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32586. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32587. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32588. * @returns the number of shapes in the system
  32589. */
  32590. addShape(mesh: Mesh, nb: number, options?: {
  32591. positionFunction?: any;
  32592. vertexFunction?: any;
  32593. storage?: [];
  32594. }): number;
  32595. /**
  32596. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32597. * @hidden
  32598. */
  32599. private _rebuildParticle;
  32600. /**
  32601. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32602. * @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.
  32603. * @returns the SPS.
  32604. */
  32605. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32606. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32607. * Returns an array with the removed particles.
  32608. * 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.
  32609. * The SPS can't be empty so at least one particle needs to remain in place.
  32610. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32611. * @param start index of the first particle to remove
  32612. * @param end index of the last particle to remove (included)
  32613. * @returns an array populated with the removed particles
  32614. */
  32615. removeParticles(start: number, end: number): SolidParticle[];
  32616. /**
  32617. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32618. * @param solidParticleArray an array populated with Solid Particles objects
  32619. * @returns the SPS
  32620. */
  32621. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32622. /**
  32623. * Creates a new particle and modifies the SPS mesh geometry :
  32624. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32625. * - calls _addParticle() to populate the particle array
  32626. * factorized code from addShape() and insertParticlesFromArray()
  32627. * @param idx particle index in the particles array
  32628. * @param i particle index in its shape
  32629. * @param modelShape particle ModelShape object
  32630. * @param shape shape vertex array
  32631. * @param meshInd shape indices array
  32632. * @param meshUV shape uv array
  32633. * @param meshCol shape color array
  32634. * @param meshNor shape normals array
  32635. * @param bbInfo shape bounding info
  32636. * @param storage target particle storage
  32637. * @options addShape() passed options
  32638. * @hidden
  32639. */
  32640. private _insertNewParticle;
  32641. /**
  32642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32643. * This method calls `updateParticle()` for each particle of the SPS.
  32644. * For an animated SPS, it is usually called within the render loop.
  32645. * 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.
  32646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32649. * @returns the SPS.
  32650. */
  32651. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32652. /**
  32653. * Disposes the SPS.
  32654. */
  32655. dispose(): void;
  32656. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32657. * idx is the particle index in the SPS
  32658. * faceId is the picked face index counted within this particle.
  32659. * Returns null if the pickInfo can't identify a picked particle.
  32660. * @param pickingInfo (PickingInfo object)
  32661. * @returns {idx: number, faceId: number} or null
  32662. */
  32663. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32664. idx: number;
  32665. faceId: number;
  32666. }>;
  32667. /**
  32668. * Returns a SolidParticle object from its identifier : particle.id
  32669. * @param id (integer) the particle Id
  32670. * @returns the searched particle or null if not found in the SPS.
  32671. */
  32672. getParticleById(id: number): Nullable<SolidParticle>;
  32673. /**
  32674. * Returns a new array populated with the particles having the passed shapeId.
  32675. * @param shapeId (integer) the shape identifier
  32676. * @returns a new solid particle array
  32677. */
  32678. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32679. /**
  32680. * Populates the passed array "ref" with the particles having the passed shapeId.
  32681. * @param shapeId the shape identifier
  32682. * @returns the SPS
  32683. * @param ref
  32684. */
  32685. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32686. /**
  32687. * Computes the required SubMeshes according the materials assigned to the particles.
  32688. * @returns the solid particle system.
  32689. * Does nothing if called before the SPS mesh is built.
  32690. */
  32691. computeSubMeshes(): SolidParticleSystem;
  32692. /**
  32693. * Sorts the solid particles by material when MultiMaterial is enabled.
  32694. * Updates the indices32 array.
  32695. * Updates the indicesByMaterial array.
  32696. * Updates the mesh indices array.
  32697. * @returns the SPS
  32698. * @hidden
  32699. */
  32700. private _sortParticlesByMaterial;
  32701. /**
  32702. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32703. * @hidden
  32704. */
  32705. private _setMaterialIndexesById;
  32706. /**
  32707. * Returns an array with unique values of Materials from the passed array
  32708. * @param array the material array to be checked and filtered
  32709. * @hidden
  32710. */
  32711. private _filterUniqueMaterialId;
  32712. /**
  32713. * Sets a new Standard Material as _defaultMaterial if not already set.
  32714. * @hidden
  32715. */
  32716. private _setDefaultMaterial;
  32717. /**
  32718. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32719. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32720. * @returns the SPS.
  32721. */
  32722. refreshVisibleSize(): SolidParticleSystem;
  32723. /**
  32724. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32725. * @param size the size (float) of the visibility box
  32726. * note : this doesn't lock the SPS mesh bounding box.
  32727. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32728. */
  32729. setVisibilityBox(size: number): void;
  32730. /**
  32731. * Gets whether the SPS as always visible or not
  32732. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32733. */
  32734. get isAlwaysVisible(): boolean;
  32735. /**
  32736. * Sets the SPS as always visible or not
  32737. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32738. */
  32739. set isAlwaysVisible(val: boolean);
  32740. /**
  32741. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32743. */
  32744. set isVisibilityBoxLocked(val: boolean);
  32745. /**
  32746. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32747. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32748. */
  32749. get isVisibilityBoxLocked(): boolean;
  32750. /**
  32751. * Tells to `setParticles()` to compute the particle rotations or not.
  32752. * Default value : true. The SPS is faster when it's set to false.
  32753. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32754. */
  32755. set computeParticleRotation(val: boolean);
  32756. /**
  32757. * Tells to `setParticles()` to compute the particle colors or not.
  32758. * Default value : true. The SPS is faster when it's set to false.
  32759. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32760. */
  32761. set computeParticleColor(val: boolean);
  32762. set computeParticleTexture(val: boolean);
  32763. /**
  32764. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32765. * Default value : false. The SPS is faster when it's set to false.
  32766. * Note : the particle custom vertex positions aren't stored values.
  32767. */
  32768. set computeParticleVertex(val: boolean);
  32769. /**
  32770. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32771. */
  32772. set computeBoundingBox(val: boolean);
  32773. /**
  32774. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32775. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32776. * Default : `true`
  32777. */
  32778. set depthSortParticles(val: boolean);
  32779. /**
  32780. * Gets if `setParticles()` computes the particle rotations or not.
  32781. * Default value : true. The SPS is faster when it's set to false.
  32782. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32783. */
  32784. get computeParticleRotation(): boolean;
  32785. /**
  32786. * Gets if `setParticles()` computes the particle colors or not.
  32787. * Default value : true. The SPS is faster when it's set to false.
  32788. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32789. */
  32790. get computeParticleColor(): boolean;
  32791. /**
  32792. * Gets if `setParticles()` computes the particle textures or not.
  32793. * Default value : true. The SPS is faster when it's set to false.
  32794. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32795. */
  32796. get computeParticleTexture(): boolean;
  32797. /**
  32798. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32799. * Default value : false. The SPS is faster when it's set to false.
  32800. * Note : the particle custom vertex positions aren't stored values.
  32801. */
  32802. get computeParticleVertex(): boolean;
  32803. /**
  32804. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32805. */
  32806. get computeBoundingBox(): boolean;
  32807. /**
  32808. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32809. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32810. * Default : `true`
  32811. */
  32812. get depthSortParticles(): boolean;
  32813. /**
  32814. * Gets if the SPS is created as expandable at construction time.
  32815. * Default : `false`
  32816. */
  32817. get expandable(): boolean;
  32818. /**
  32819. * Gets if the SPS supports the Multi Materials
  32820. */
  32821. get multimaterialEnabled(): boolean;
  32822. /**
  32823. * Gets if the SPS uses the model materials for its own multimaterial.
  32824. */
  32825. get useModelMaterial(): boolean;
  32826. /**
  32827. * The SPS used material array.
  32828. */
  32829. get materials(): Material[];
  32830. /**
  32831. * Sets the SPS MultiMaterial from the passed materials.
  32832. * Note : the passed array is internally copied and not used then by reference.
  32833. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32834. */
  32835. setMultiMaterial(materials: Material[]): void;
  32836. /**
  32837. * The SPS computed multimaterial object
  32838. */
  32839. get multimaterial(): MultiMaterial;
  32840. set multimaterial(mm: MultiMaterial);
  32841. /**
  32842. * If the subMeshes must be updated on the next call to setParticles()
  32843. */
  32844. get autoUpdateSubMeshes(): boolean;
  32845. set autoUpdateSubMeshes(val: boolean);
  32846. /**
  32847. * This function does nothing. It may be overwritten to set all the particle first values.
  32848. * The SPS doesn't call this function, you may have to call it by your own.
  32849. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32850. */
  32851. initParticles(): void;
  32852. /**
  32853. * This function does nothing. It may be overwritten to recycle a particle.
  32854. * The SPS doesn't call this function, you may have to call it by your own.
  32855. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32856. * @param particle The particle to recycle
  32857. * @returns the recycled particle
  32858. */
  32859. recycleParticle(particle: SolidParticle): SolidParticle;
  32860. /**
  32861. * Updates a particle : this function should be overwritten by the user.
  32862. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32863. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32864. * @example : just set a particle position or velocity and recycle conditions
  32865. * @param particle The particle to update
  32866. * @returns the updated particle
  32867. */
  32868. updateParticle(particle: SolidParticle): SolidParticle;
  32869. /**
  32870. * Updates a vertex of a particle : it can be overwritten by the user.
  32871. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32872. * @param particle the current particle
  32873. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32874. * @param pt the index of the current vertex in the particle shape
  32875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32876. * @example : just set a vertex particle position or color
  32877. * @returns the sps
  32878. */
  32879. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32880. /**
  32881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32882. * This does nothing and may be overwritten by the user.
  32883. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32885. * @param update the boolean update value actually passed to setParticles()
  32886. */
  32887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32888. /**
  32889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32890. * This will be passed three parameters.
  32891. * This does nothing and may be overwritten by the user.
  32892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32894. * @param update the boolean update value actually passed to setParticles()
  32895. */
  32896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32897. }
  32898. }
  32899. declare module "babylonjs/Particles/solidParticle" {
  32900. import { Nullable } from "babylonjs/types";
  32901. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32902. import { Color4 } from "babylonjs/Maths/math.color";
  32903. import { Mesh } from "babylonjs/Meshes/mesh";
  32904. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32905. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32906. import { Plane } from "babylonjs/Maths/math.plane";
  32907. import { Material } from "babylonjs/Materials/material";
  32908. /**
  32909. * Represents one particle of a solid particle system.
  32910. */
  32911. export class SolidParticle {
  32912. /**
  32913. * particle global index
  32914. */
  32915. idx: number;
  32916. /**
  32917. * particle identifier
  32918. */
  32919. id: number;
  32920. /**
  32921. * The color of the particle
  32922. */
  32923. color: Nullable<Color4>;
  32924. /**
  32925. * The world space position of the particle.
  32926. */
  32927. position: Vector3;
  32928. /**
  32929. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32930. */
  32931. rotation: Vector3;
  32932. /**
  32933. * The world space rotation quaternion of the particle.
  32934. */
  32935. rotationQuaternion: Nullable<Quaternion>;
  32936. /**
  32937. * The scaling of the particle.
  32938. */
  32939. scaling: Vector3;
  32940. /**
  32941. * The uvs of the particle.
  32942. */
  32943. uvs: Vector4;
  32944. /**
  32945. * The current speed of the particle.
  32946. */
  32947. velocity: Vector3;
  32948. /**
  32949. * The pivot point in the particle local space.
  32950. */
  32951. pivot: Vector3;
  32952. /**
  32953. * Must the particle be translated from its pivot point in its local space ?
  32954. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32955. * Default : false
  32956. */
  32957. translateFromPivot: boolean;
  32958. /**
  32959. * Is the particle active or not ?
  32960. */
  32961. alive: boolean;
  32962. /**
  32963. * Is the particle visible or not ?
  32964. */
  32965. isVisible: boolean;
  32966. /**
  32967. * Index of this particle in the global "positions" array (Internal use)
  32968. * @hidden
  32969. */
  32970. _pos: number;
  32971. /**
  32972. * @hidden Index of this particle in the global "indices" array (Internal use)
  32973. */
  32974. _ind: number;
  32975. /**
  32976. * @hidden ModelShape of this particle (Internal use)
  32977. */
  32978. _model: ModelShape;
  32979. /**
  32980. * ModelShape id of this particle
  32981. */
  32982. shapeId: number;
  32983. /**
  32984. * Index of the particle in its shape id
  32985. */
  32986. idxInShape: number;
  32987. /**
  32988. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32989. */
  32990. _modelBoundingInfo: BoundingInfo;
  32991. /**
  32992. * @hidden Particle BoundingInfo object (Internal use)
  32993. */
  32994. _boundingInfo: BoundingInfo;
  32995. /**
  32996. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32997. */
  32998. _sps: SolidParticleSystem;
  32999. /**
  33000. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33001. */
  33002. _stillInvisible: boolean;
  33003. /**
  33004. * @hidden Last computed particle rotation matrix
  33005. */
  33006. _rotationMatrix: number[];
  33007. /**
  33008. * Parent particle Id, if any.
  33009. * Default null.
  33010. */
  33011. parentId: Nullable<number>;
  33012. /**
  33013. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  33014. */
  33015. materialIndex: Nullable<number>;
  33016. /**
  33017. * Custom object or properties.
  33018. */
  33019. props: Nullable<any>;
  33020. /**
  33021. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  33022. * The possible values are :
  33023. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33024. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33027. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33028. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  33029. * */
  33030. cullingStrategy: number;
  33031. /**
  33032. * @hidden Internal global position in the SPS.
  33033. */
  33034. _globalPosition: Vector3;
  33035. /**
  33036. * Creates a Solid Particle object.
  33037. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33038. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  33039. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  33040. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33041. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33042. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33043. * @param shapeId (integer) is the model shape identifier in the SPS.
  33044. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33045. * @param sps defines the sps it is associated to
  33046. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33047. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  33048. */
  33049. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  33050. /**
  33051. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  33052. * @param target the particle target
  33053. * @returns the current particle
  33054. */
  33055. copyToRef(target: SolidParticle): SolidParticle;
  33056. /**
  33057. * Legacy support, changed scale to scaling
  33058. */
  33059. get scale(): Vector3;
  33060. /**
  33061. * Legacy support, changed scale to scaling
  33062. */
  33063. set scale(scale: Vector3);
  33064. /**
  33065. * Legacy support, changed quaternion to rotationQuaternion
  33066. */
  33067. get quaternion(): Nullable<Quaternion>;
  33068. /**
  33069. * Legacy support, changed quaternion to rotationQuaternion
  33070. */
  33071. set quaternion(q: Nullable<Quaternion>);
  33072. /**
  33073. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33074. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33075. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33076. * @returns true if it intersects
  33077. */
  33078. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33079. /**
  33080. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  33081. * A particle is in the frustum if its bounding box intersects the frustum
  33082. * @param frustumPlanes defines the frustum to test
  33083. * @returns true if the particle is in the frustum planes
  33084. */
  33085. isInFrustum(frustumPlanes: Plane[]): boolean;
  33086. /**
  33087. * get the rotation matrix of the particle
  33088. * @hidden
  33089. */
  33090. getRotationMatrix(m: Matrix): void;
  33091. }
  33092. /**
  33093. * Represents the shape of the model used by one particle of a solid particle system.
  33094. * SPS internal tool, don't use it manually.
  33095. */
  33096. export class ModelShape {
  33097. /**
  33098. * The shape id
  33099. * @hidden
  33100. */
  33101. shapeID: number;
  33102. /**
  33103. * flat array of model positions (internal use)
  33104. * @hidden
  33105. */
  33106. _shape: Vector3[];
  33107. /**
  33108. * flat array of model UVs (internal use)
  33109. * @hidden
  33110. */
  33111. _shapeUV: number[];
  33112. /**
  33113. * color array of the model
  33114. * @hidden
  33115. */
  33116. _shapeColors: number[];
  33117. /**
  33118. * indices array of the model
  33119. * @hidden
  33120. */
  33121. _indices: number[];
  33122. /**
  33123. * normals array of the model
  33124. * @hidden
  33125. */
  33126. _normals: number[];
  33127. /**
  33128. * length of the shape in the model indices array (internal use)
  33129. * @hidden
  33130. */
  33131. _indicesLength: number;
  33132. /**
  33133. * Custom position function (internal use)
  33134. * @hidden
  33135. */
  33136. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33137. /**
  33138. * Custom vertex function (internal use)
  33139. * @hidden
  33140. */
  33141. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33142. /**
  33143. * Model material (internal use)
  33144. * @hidden
  33145. */
  33146. _material: Nullable<Material>;
  33147. /**
  33148. * 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.
  33149. * SPS internal tool, don't use it manually.
  33150. * @hidden
  33151. */
  33152. 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>);
  33153. }
  33154. /**
  33155. * Represents a Depth Sorted Particle in the solid particle system.
  33156. * @hidden
  33157. */
  33158. export class DepthSortedParticle {
  33159. /**
  33160. * Particle index
  33161. */
  33162. idx: number;
  33163. /**
  33164. * Index of the particle in the "indices" array
  33165. */
  33166. ind: number;
  33167. /**
  33168. * Length of the particle shape in the "indices" array
  33169. */
  33170. indicesLength: number;
  33171. /**
  33172. * Squared distance from the particle to the camera
  33173. */
  33174. sqDistance: number;
  33175. /**
  33176. * Material index when used with MultiMaterials
  33177. */
  33178. materialIndex: number;
  33179. /**
  33180. * Creates a new sorted particle
  33181. * @param materialIndex
  33182. */
  33183. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33184. }
  33185. /**
  33186. * Represents a solid particle vertex
  33187. */
  33188. export class SolidParticleVertex {
  33189. /**
  33190. * Vertex position
  33191. */
  33192. position: Vector3;
  33193. /**
  33194. * Vertex color
  33195. */
  33196. color: Color4;
  33197. /**
  33198. * Vertex UV
  33199. */
  33200. uv: Vector2;
  33201. /**
  33202. * Creates a new solid particle vertex
  33203. */
  33204. constructor();
  33205. /** Vertex x coordinate */
  33206. get x(): number;
  33207. set x(val: number);
  33208. /** Vertex y coordinate */
  33209. get y(): number;
  33210. set y(val: number);
  33211. /** Vertex z coordinate */
  33212. get z(): number;
  33213. set z(val: number);
  33214. }
  33215. }
  33216. declare module "babylonjs/Collisions/meshCollisionData" {
  33217. import { Collider } from "babylonjs/Collisions/collider";
  33218. import { Vector3 } from "babylonjs/Maths/math.vector";
  33219. import { Nullable } from "babylonjs/types";
  33220. import { Observer } from "babylonjs/Misc/observable";
  33221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33222. /**
  33223. * @hidden
  33224. */
  33225. export class _MeshCollisionData {
  33226. _checkCollisions: boolean;
  33227. _collisionMask: number;
  33228. _collisionGroup: number;
  33229. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33230. _collider: Nullable<Collider>;
  33231. _oldPositionForCollisions: Vector3;
  33232. _diffPositionForCollisions: Vector3;
  33233. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33234. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33235. _collisionResponse: boolean;
  33236. }
  33237. }
  33238. declare module "babylonjs/Meshes/abstractMesh" {
  33239. import { Observable } from "babylonjs/Misc/observable";
  33240. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33241. import { Camera } from "babylonjs/Cameras/camera";
  33242. import { Scene, IDisposable } from "babylonjs/scene";
  33243. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33244. import { Node } from "babylonjs/node";
  33245. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33248. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33249. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33250. import { Material } from "babylonjs/Materials/material";
  33251. import { Light } from "babylonjs/Lights/light";
  33252. import { Skeleton } from "babylonjs/Bones/skeleton";
  33253. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33254. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33255. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33256. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33257. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33258. import { Plane } from "babylonjs/Maths/math.plane";
  33259. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33260. import { Ray } from "babylonjs/Culling/ray";
  33261. import { Collider } from "babylonjs/Collisions/collider";
  33262. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33263. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33264. /** @hidden */
  33265. class _FacetDataStorage {
  33266. facetPositions: Vector3[];
  33267. facetNormals: Vector3[];
  33268. facetPartitioning: number[][];
  33269. facetNb: number;
  33270. partitioningSubdivisions: number;
  33271. partitioningBBoxRatio: number;
  33272. facetDataEnabled: boolean;
  33273. facetParameters: any;
  33274. bbSize: Vector3;
  33275. subDiv: {
  33276. max: number;
  33277. X: number;
  33278. Y: number;
  33279. Z: number;
  33280. };
  33281. facetDepthSort: boolean;
  33282. facetDepthSortEnabled: boolean;
  33283. depthSortedIndices: IndicesArray;
  33284. depthSortedFacets: {
  33285. ind: number;
  33286. sqDistance: number;
  33287. }[];
  33288. facetDepthSortFunction: (f1: {
  33289. ind: number;
  33290. sqDistance: number;
  33291. }, f2: {
  33292. ind: number;
  33293. sqDistance: number;
  33294. }) => number;
  33295. facetDepthSortFrom: Vector3;
  33296. facetDepthSortOrigin: Vector3;
  33297. invertedMatrix: Matrix;
  33298. }
  33299. /**
  33300. * @hidden
  33301. **/
  33302. class _InternalAbstractMeshDataInfo {
  33303. _hasVertexAlpha: boolean;
  33304. _useVertexColors: boolean;
  33305. _numBoneInfluencers: number;
  33306. _applyFog: boolean;
  33307. _receiveShadows: boolean;
  33308. _facetData: _FacetDataStorage;
  33309. _visibility: number;
  33310. _skeleton: Nullable<Skeleton>;
  33311. _layerMask: number;
  33312. _computeBonesUsingShaders: boolean;
  33313. _isActive: boolean;
  33314. _onlyForInstances: boolean;
  33315. _isActiveIntermediate: boolean;
  33316. _onlyForInstancesIntermediate: boolean;
  33317. _actAsRegularMesh: boolean;
  33318. }
  33319. /**
  33320. * Class used to store all common mesh properties
  33321. */
  33322. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33323. /** No occlusion */
  33324. static OCCLUSION_TYPE_NONE: number;
  33325. /** Occlusion set to optimisitic */
  33326. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33327. /** Occlusion set to strict */
  33328. static OCCLUSION_TYPE_STRICT: number;
  33329. /** Use an accurante occlusion algorithm */
  33330. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33331. /** Use a conservative occlusion algorithm */
  33332. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33333. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33334. * Test order :
  33335. * Is the bounding sphere outside the frustum ?
  33336. * If not, are the bounding box vertices outside the frustum ?
  33337. * It not, then the cullable object is in the frustum.
  33338. */
  33339. static readonly CULLINGSTRATEGY_STANDARD: number;
  33340. /** Culling strategy : Bounding Sphere Only.
  33341. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33342. * It's also less accurate than the standard because some not visible objects can still be selected.
  33343. * Test : is the bounding sphere outside the frustum ?
  33344. * If not, then the cullable object is in the frustum.
  33345. */
  33346. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33347. /** Culling strategy : Optimistic Inclusion.
  33348. * This in an inclusion test first, then the standard exclusion test.
  33349. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33350. * 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.
  33351. * Anyway, it's as accurate as the standard strategy.
  33352. * Test :
  33353. * Is the cullable object bounding sphere center in the frustum ?
  33354. * If not, apply the default culling strategy.
  33355. */
  33356. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33357. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33358. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33359. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33360. * 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.
  33361. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33362. * Test :
  33363. * Is the cullable object bounding sphere center in the frustum ?
  33364. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33365. */
  33366. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33367. /**
  33368. * No billboard
  33369. */
  33370. static get BILLBOARDMODE_NONE(): number;
  33371. /** Billboard on X axis */
  33372. static get BILLBOARDMODE_X(): number;
  33373. /** Billboard on Y axis */
  33374. static get BILLBOARDMODE_Y(): number;
  33375. /** Billboard on Z axis */
  33376. static get BILLBOARDMODE_Z(): number;
  33377. /** Billboard on all axes */
  33378. static get BILLBOARDMODE_ALL(): number;
  33379. /** Billboard on using position instead of orientation */
  33380. static get BILLBOARDMODE_USE_POSITION(): number;
  33381. /** @hidden */
  33382. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33383. /**
  33384. * The culling strategy to use to check whether the mesh must be rendered or not.
  33385. * This value can be changed at any time and will be used on the next render mesh selection.
  33386. * The possible values are :
  33387. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33388. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33389. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33390. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33391. * Please read each static variable documentation to get details about the culling process.
  33392. * */
  33393. cullingStrategy: number;
  33394. /**
  33395. * Gets the number of facets in the mesh
  33396. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33397. */
  33398. get facetNb(): number;
  33399. /**
  33400. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33401. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33402. */
  33403. get partitioningSubdivisions(): number;
  33404. set partitioningSubdivisions(nb: number);
  33405. /**
  33406. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33407. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33408. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33409. */
  33410. get partitioningBBoxRatio(): number;
  33411. set partitioningBBoxRatio(ratio: number);
  33412. /**
  33413. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33414. * Works only for updatable meshes.
  33415. * Doesn't work with multi-materials
  33416. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33417. */
  33418. get mustDepthSortFacets(): boolean;
  33419. set mustDepthSortFacets(sort: boolean);
  33420. /**
  33421. * The location (Vector3) where the facet depth sort must be computed from.
  33422. * By default, the active camera position.
  33423. * Used only when facet depth sort is enabled
  33424. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33425. */
  33426. get facetDepthSortFrom(): Vector3;
  33427. set facetDepthSortFrom(location: Vector3);
  33428. /**
  33429. * gets a boolean indicating if facetData is enabled
  33430. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33431. */
  33432. get isFacetDataEnabled(): boolean;
  33433. /** @hidden */
  33434. _updateNonUniformScalingState(value: boolean): boolean;
  33435. /**
  33436. * An event triggered when this mesh collides with another one
  33437. */
  33438. onCollideObservable: Observable<AbstractMesh>;
  33439. /** Set a function to call when this mesh collides with another one */
  33440. set onCollide(callback: () => void);
  33441. /**
  33442. * An event triggered when the collision's position changes
  33443. */
  33444. onCollisionPositionChangeObservable: Observable<Vector3>;
  33445. /** Set a function to call when the collision's position changes */
  33446. set onCollisionPositionChange(callback: () => void);
  33447. /**
  33448. * An event triggered when material is changed
  33449. */
  33450. onMaterialChangedObservable: Observable<AbstractMesh>;
  33451. /**
  33452. * Gets or sets the orientation for POV movement & rotation
  33453. */
  33454. definedFacingForward: boolean;
  33455. /** @hidden */
  33456. _occlusionQuery: Nullable<WebGLQuery>;
  33457. /** @hidden */
  33458. _renderingGroup: Nullable<RenderingGroup>;
  33459. /**
  33460. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33461. */
  33462. get visibility(): number;
  33463. /**
  33464. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33465. */
  33466. set visibility(value: number);
  33467. /** Gets or sets the alpha index used to sort transparent meshes
  33468. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33469. */
  33470. alphaIndex: number;
  33471. /**
  33472. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33473. */
  33474. isVisible: boolean;
  33475. /**
  33476. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33477. */
  33478. isPickable: boolean;
  33479. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33480. showSubMeshesBoundingBox: boolean;
  33481. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33482. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33483. */
  33484. isBlocker: boolean;
  33485. /**
  33486. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33487. */
  33488. enablePointerMoveEvents: boolean;
  33489. private _renderingGroupId;
  33490. /**
  33491. * Specifies the rendering group id for this mesh (0 by default)
  33492. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33493. */
  33494. get renderingGroupId(): number;
  33495. set renderingGroupId(value: number);
  33496. private _material;
  33497. /** Gets or sets current material */
  33498. get material(): Nullable<Material>;
  33499. set material(value: Nullable<Material>);
  33500. /**
  33501. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33502. * @see https://doc.babylonjs.com/babylon101/shadows
  33503. */
  33504. get receiveShadows(): boolean;
  33505. set receiveShadows(value: boolean);
  33506. /** Defines color to use when rendering outline */
  33507. outlineColor: Color3;
  33508. /** Define width to use when rendering outline */
  33509. outlineWidth: number;
  33510. /** Defines color to use when rendering overlay */
  33511. overlayColor: Color3;
  33512. /** Defines alpha to use when rendering overlay */
  33513. overlayAlpha: number;
  33514. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33515. get hasVertexAlpha(): boolean;
  33516. set hasVertexAlpha(value: boolean);
  33517. /** 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) */
  33518. get useVertexColors(): boolean;
  33519. set useVertexColors(value: boolean);
  33520. /**
  33521. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33522. */
  33523. get computeBonesUsingShaders(): boolean;
  33524. set computeBonesUsingShaders(value: boolean);
  33525. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33526. get numBoneInfluencers(): number;
  33527. set numBoneInfluencers(value: number);
  33528. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33529. get applyFog(): boolean;
  33530. set applyFog(value: boolean);
  33531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33532. useOctreeForRenderingSelection: boolean;
  33533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33534. useOctreeForPicking: boolean;
  33535. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33536. useOctreeForCollisions: boolean;
  33537. /**
  33538. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33539. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33540. */
  33541. get layerMask(): number;
  33542. set layerMask(value: number);
  33543. /**
  33544. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33545. */
  33546. alwaysSelectAsActiveMesh: boolean;
  33547. /**
  33548. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33549. */
  33550. doNotSyncBoundingInfo: boolean;
  33551. /**
  33552. * Gets or sets the current action manager
  33553. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33554. */
  33555. actionManager: Nullable<AbstractActionManager>;
  33556. private _meshCollisionData;
  33557. /**
  33558. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33559. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33560. */
  33561. ellipsoid: Vector3;
  33562. /**
  33563. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33564. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33565. */
  33566. ellipsoidOffset: Vector3;
  33567. /**
  33568. * Gets or sets a collision mask used to mask collisions (default is -1).
  33569. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33570. */
  33571. get collisionMask(): number;
  33572. set collisionMask(mask: number);
  33573. /**
  33574. * Gets or sets a collision response flag (default is true).
  33575. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33576. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33577. * to respond to the collision.
  33578. */
  33579. get collisionResponse(): boolean;
  33580. set collisionResponse(response: boolean);
  33581. /**
  33582. * Gets or sets the current collision group mask (-1 by default).
  33583. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33584. */
  33585. get collisionGroup(): number;
  33586. set collisionGroup(mask: number);
  33587. /**
  33588. * Gets or sets current surrounding meshes (null by default).
  33589. *
  33590. * By default collision detection is tested against every mesh in the scene.
  33591. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33592. * meshes will be tested for the collision.
  33593. *
  33594. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33595. */
  33596. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33597. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33598. /**
  33599. * Defines edge width used when edgesRenderer is enabled
  33600. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33601. */
  33602. edgesWidth: number;
  33603. /**
  33604. * Defines edge color used when edgesRenderer is enabled
  33605. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33606. */
  33607. edgesColor: Color4;
  33608. /** @hidden */
  33609. _edgesRenderer: Nullable<IEdgesRenderer>;
  33610. /** @hidden */
  33611. _masterMesh: Nullable<AbstractMesh>;
  33612. /** @hidden */
  33613. _boundingInfo: Nullable<BoundingInfo>;
  33614. /** @hidden */
  33615. _renderId: number;
  33616. /**
  33617. * Gets or sets the list of subMeshes
  33618. * @see https://doc.babylonjs.com/how_to/multi_materials
  33619. */
  33620. subMeshes: SubMesh[];
  33621. /** @hidden */
  33622. _intersectionsInProgress: AbstractMesh[];
  33623. /** @hidden */
  33624. _unIndexed: boolean;
  33625. /** @hidden */
  33626. _lightSources: Light[];
  33627. /** Gets the list of lights affecting that mesh */
  33628. get lightSources(): Light[];
  33629. /** @hidden */
  33630. get _positions(): Nullable<Vector3[]>;
  33631. /** @hidden */
  33632. _waitingData: {
  33633. lods: Nullable<any>;
  33634. actions: Nullable<any>;
  33635. freezeWorldMatrix: Nullable<boolean>;
  33636. };
  33637. /** @hidden */
  33638. _bonesTransformMatrices: Nullable<Float32Array>;
  33639. /** @hidden */
  33640. _transformMatrixTexture: Nullable<RawTexture>;
  33641. /**
  33642. * Gets or sets a skeleton to apply skining transformations
  33643. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33644. */
  33645. set skeleton(value: Nullable<Skeleton>);
  33646. get skeleton(): Nullable<Skeleton>;
  33647. /**
  33648. * An event triggered when the mesh is rebuilt.
  33649. */
  33650. onRebuildObservable: Observable<AbstractMesh>;
  33651. /**
  33652. * Creates a new AbstractMesh
  33653. * @param name defines the name of the mesh
  33654. * @param scene defines the hosting scene
  33655. */
  33656. constructor(name: string, scene?: Nullable<Scene>);
  33657. /**
  33658. * Returns the string "AbstractMesh"
  33659. * @returns "AbstractMesh"
  33660. */
  33661. getClassName(): string;
  33662. /**
  33663. * Gets a string representation of the current mesh
  33664. * @param fullDetails defines a boolean indicating if full details must be included
  33665. * @returns a string representation of the current mesh
  33666. */
  33667. toString(fullDetails?: boolean): string;
  33668. /**
  33669. * @hidden
  33670. */
  33671. protected _getEffectiveParent(): Nullable<Node>;
  33672. /** @hidden */
  33673. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33674. /** @hidden */
  33675. _rebuild(): void;
  33676. /** @hidden */
  33677. _resyncLightSources(): void;
  33678. /** @hidden */
  33679. _resyncLightSource(light: Light): void;
  33680. /** @hidden */
  33681. _unBindEffect(): void;
  33682. /** @hidden */
  33683. _removeLightSource(light: Light, dispose: boolean): void;
  33684. private _markSubMeshesAsDirty;
  33685. /** @hidden */
  33686. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33687. /** @hidden */
  33688. _markSubMeshesAsAttributesDirty(): void;
  33689. /** @hidden */
  33690. _markSubMeshesAsMiscDirty(): void;
  33691. /**
  33692. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33693. */
  33694. get scaling(): Vector3;
  33695. set scaling(newScaling: Vector3);
  33696. /**
  33697. * Returns true if the mesh is blocked. Implemented by child classes
  33698. */
  33699. get isBlocked(): boolean;
  33700. /**
  33701. * Returns the mesh itself by default. Implemented by child classes
  33702. * @param camera defines the camera to use to pick the right LOD level
  33703. * @returns the currentAbstractMesh
  33704. */
  33705. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33706. /**
  33707. * Returns 0 by default. Implemented by child classes
  33708. * @returns an integer
  33709. */
  33710. getTotalVertices(): number;
  33711. /**
  33712. * Returns a positive integer : the total number of indices in this mesh geometry.
  33713. * @returns the numner of indices or zero if the mesh has no geometry.
  33714. */
  33715. getTotalIndices(): number;
  33716. /**
  33717. * Returns null by default. Implemented by child classes
  33718. * @returns null
  33719. */
  33720. getIndices(): Nullable<IndicesArray>;
  33721. /**
  33722. * Returns the array of the requested vertex data kind. Implemented by child classes
  33723. * @param kind defines the vertex data kind to use
  33724. * @returns null
  33725. */
  33726. getVerticesData(kind: string): Nullable<FloatArray>;
  33727. /**
  33728. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33729. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33730. * Note that a new underlying VertexBuffer object is created each call.
  33731. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33732. * @param kind defines vertex data kind:
  33733. * * VertexBuffer.PositionKind
  33734. * * VertexBuffer.UVKind
  33735. * * VertexBuffer.UV2Kind
  33736. * * VertexBuffer.UV3Kind
  33737. * * VertexBuffer.UV4Kind
  33738. * * VertexBuffer.UV5Kind
  33739. * * VertexBuffer.UV6Kind
  33740. * * VertexBuffer.ColorKind
  33741. * * VertexBuffer.MatricesIndicesKind
  33742. * * VertexBuffer.MatricesIndicesExtraKind
  33743. * * VertexBuffer.MatricesWeightsKind
  33744. * * VertexBuffer.MatricesWeightsExtraKind
  33745. * @param data defines the data source
  33746. * @param updatable defines if the data must be flagged as updatable (or static)
  33747. * @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
  33748. * @returns the current mesh
  33749. */
  33750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33751. /**
  33752. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33753. * If the mesh has no geometry, it is simply returned as it is.
  33754. * @param kind defines vertex data kind:
  33755. * * VertexBuffer.PositionKind
  33756. * * VertexBuffer.UVKind
  33757. * * VertexBuffer.UV2Kind
  33758. * * VertexBuffer.UV3Kind
  33759. * * VertexBuffer.UV4Kind
  33760. * * VertexBuffer.UV5Kind
  33761. * * VertexBuffer.UV6Kind
  33762. * * VertexBuffer.ColorKind
  33763. * * VertexBuffer.MatricesIndicesKind
  33764. * * VertexBuffer.MatricesIndicesExtraKind
  33765. * * VertexBuffer.MatricesWeightsKind
  33766. * * VertexBuffer.MatricesWeightsExtraKind
  33767. * @param data defines the data source
  33768. * @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
  33769. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33770. * @returns the current mesh
  33771. */
  33772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33773. /**
  33774. * Sets the mesh indices,
  33775. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33776. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33777. * @param totalVertices Defines the total number of vertices
  33778. * @returns the current mesh
  33779. */
  33780. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33781. /**
  33782. * Gets a boolean indicating if specific vertex data is present
  33783. * @param kind defines the vertex data kind to use
  33784. * @returns true is data kind is present
  33785. */
  33786. isVerticesDataPresent(kind: string): boolean;
  33787. /**
  33788. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33789. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33790. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33791. * @returns a BoundingInfo
  33792. */
  33793. getBoundingInfo(): BoundingInfo;
  33794. /**
  33795. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33796. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33797. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33798. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33799. * @returns the current mesh
  33800. */
  33801. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33802. /**
  33803. * Overwrite the current bounding info
  33804. * @param boundingInfo defines the new bounding info
  33805. * @returns the current mesh
  33806. */
  33807. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33808. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33809. get useBones(): boolean;
  33810. /** @hidden */
  33811. _preActivate(): void;
  33812. /** @hidden */
  33813. _preActivateForIntermediateRendering(renderId: number): void;
  33814. /** @hidden */
  33815. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33816. /** @hidden */
  33817. _postActivate(): void;
  33818. /** @hidden */
  33819. _freeze(): void;
  33820. /** @hidden */
  33821. _unFreeze(): void;
  33822. /**
  33823. * Gets the current world matrix
  33824. * @returns a Matrix
  33825. */
  33826. getWorldMatrix(): Matrix;
  33827. /** @hidden */
  33828. _getWorldMatrixDeterminant(): number;
  33829. /**
  33830. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33831. */
  33832. get isAnInstance(): boolean;
  33833. /**
  33834. * Gets a boolean indicating if this mesh has instances
  33835. */
  33836. get hasInstances(): boolean;
  33837. /**
  33838. * Gets a boolean indicating if this mesh has thin instances
  33839. */
  33840. get hasThinInstances(): boolean;
  33841. /**
  33842. * Perform relative position change from the point of view of behind the front of the mesh.
  33843. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33844. * Supports definition of mesh facing forward or backward
  33845. * @param amountRight defines the distance on the right axis
  33846. * @param amountUp defines the distance on the up axis
  33847. * @param amountForward defines the distance on the forward axis
  33848. * @returns the current mesh
  33849. */
  33850. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33851. /**
  33852. * Calculate relative position change from the point of view of behind the front of the mesh.
  33853. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33854. * Supports definition of mesh facing forward or backward
  33855. * @param amountRight defines the distance on the right axis
  33856. * @param amountUp defines the distance on the up axis
  33857. * @param amountForward defines the distance on the forward axis
  33858. * @returns the new displacement vector
  33859. */
  33860. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33861. /**
  33862. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33863. * Supports definition of mesh facing forward or backward
  33864. * @param flipBack defines the flip
  33865. * @param twirlClockwise defines the twirl
  33866. * @param tiltRight defines the tilt
  33867. * @returns the current mesh
  33868. */
  33869. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33870. /**
  33871. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33872. * Supports definition of mesh facing forward or backward.
  33873. * @param flipBack defines the flip
  33874. * @param twirlClockwise defines the twirl
  33875. * @param tiltRight defines the tilt
  33876. * @returns the new rotation vector
  33877. */
  33878. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33879. /**
  33880. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33881. * This means the mesh underlying bounding box and sphere are recomputed.
  33882. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33883. * @returns the current mesh
  33884. */
  33885. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33886. /** @hidden */
  33887. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33888. /** @hidden */
  33889. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33890. /** @hidden */
  33891. _updateBoundingInfo(): AbstractMesh;
  33892. /** @hidden */
  33893. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33894. /** @hidden */
  33895. protected _afterComputeWorldMatrix(): void;
  33896. /** @hidden */
  33897. get _effectiveMesh(): AbstractMesh;
  33898. /**
  33899. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33900. * A mesh is in the frustum if its bounding box intersects the frustum
  33901. * @param frustumPlanes defines the frustum to test
  33902. * @returns true if the mesh is in the frustum planes
  33903. */
  33904. isInFrustum(frustumPlanes: Plane[]): boolean;
  33905. /**
  33906. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33907. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33908. * @param frustumPlanes defines the frustum to test
  33909. * @returns true if the mesh is completely in the frustum planes
  33910. */
  33911. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33912. /**
  33913. * True if the mesh intersects another mesh or a SolidParticle object
  33914. * @param mesh defines a target mesh or SolidParticle to test
  33915. * @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)
  33916. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33917. * @returns true if there is an intersection
  33918. */
  33919. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33920. /**
  33921. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33922. * @param point defines the point to test
  33923. * @returns true if there is an intersection
  33924. */
  33925. intersectsPoint(point: Vector3): boolean;
  33926. /**
  33927. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33928. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33929. */
  33930. get checkCollisions(): boolean;
  33931. set checkCollisions(collisionEnabled: boolean);
  33932. /**
  33933. * Gets Collider object used to compute collisions (not physics)
  33934. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33935. */
  33936. get collider(): Nullable<Collider>;
  33937. /**
  33938. * Move the mesh using collision engine
  33939. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33940. * @param displacement defines the requested displacement vector
  33941. * @returns the current mesh
  33942. */
  33943. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33944. private _onCollisionPositionChange;
  33945. /** @hidden */
  33946. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33947. /** @hidden */
  33948. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33949. /** @hidden */
  33950. _checkCollision(collider: Collider): AbstractMesh;
  33951. /** @hidden */
  33952. _generatePointsArray(): boolean;
  33953. /**
  33954. * Checks if the passed Ray intersects with the mesh
  33955. * @param ray defines the ray to use
  33956. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33957. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33958. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33959. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33960. * @returns the picking info
  33961. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33962. */
  33963. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33964. /**
  33965. * Clones the current mesh
  33966. * @param name defines the mesh name
  33967. * @param newParent defines the new mesh parent
  33968. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33969. * @returns the new mesh
  33970. */
  33971. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33972. /**
  33973. * Disposes all the submeshes of the current meshnp
  33974. * @returns the current mesh
  33975. */
  33976. releaseSubMeshes(): AbstractMesh;
  33977. /**
  33978. * Releases resources associated with this abstract mesh.
  33979. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33980. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33981. */
  33982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33983. /**
  33984. * Adds the passed mesh as a child to the current mesh
  33985. * @param mesh defines the child mesh
  33986. * @returns the current mesh
  33987. */
  33988. addChild(mesh: AbstractMesh): AbstractMesh;
  33989. /**
  33990. * Removes the passed mesh from the current mesh children list
  33991. * @param mesh defines the child mesh
  33992. * @returns the current mesh
  33993. */
  33994. removeChild(mesh: AbstractMesh): AbstractMesh;
  33995. /** @hidden */
  33996. private _initFacetData;
  33997. /**
  33998. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33999. * This method can be called within the render loop.
  34000. * 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
  34001. * @returns the current mesh
  34002. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34003. */
  34004. updateFacetData(): AbstractMesh;
  34005. /**
  34006. * Returns the facetLocalNormals array.
  34007. * The normals are expressed in the mesh local spac
  34008. * @returns an array of Vector3
  34009. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34010. */
  34011. getFacetLocalNormals(): Vector3[];
  34012. /**
  34013. * Returns the facetLocalPositions array.
  34014. * The facet positions are expressed in the mesh local space
  34015. * @returns an array of Vector3
  34016. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34017. */
  34018. getFacetLocalPositions(): Vector3[];
  34019. /**
  34020. * Returns the facetLocalPartioning array
  34021. * @returns an array of array of numbers
  34022. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34023. */
  34024. getFacetLocalPartitioning(): number[][];
  34025. /**
  34026. * Returns the i-th facet position in the world system.
  34027. * This method allocates a new Vector3 per call
  34028. * @param i defines the facet index
  34029. * @returns a new Vector3
  34030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34031. */
  34032. getFacetPosition(i: number): Vector3;
  34033. /**
  34034. * Sets the reference Vector3 with the i-th facet position in the world system
  34035. * @param i defines the facet index
  34036. * @param ref defines the target vector
  34037. * @returns the current mesh
  34038. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34039. */
  34040. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  34041. /**
  34042. * Returns the i-th facet normal in the world system.
  34043. * This method allocates a new Vector3 per call
  34044. * @param i defines the facet index
  34045. * @returns a new Vector3
  34046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34047. */
  34048. getFacetNormal(i: number): Vector3;
  34049. /**
  34050. * Sets the reference Vector3 with the i-th facet normal in the world system
  34051. * @param i defines the facet index
  34052. * @param ref defines the target vector
  34053. * @returns the current mesh
  34054. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34055. */
  34056. getFacetNormalToRef(i: number, ref: Vector3): this;
  34057. /**
  34058. * 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)
  34059. * @param x defines x coordinate
  34060. * @param y defines y coordinate
  34061. * @param z defines z coordinate
  34062. * @returns the array of facet indexes
  34063. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34064. */
  34065. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  34066. /**
  34067. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  34068. * @param projected sets as the (x,y,z) world projection on the facet
  34069. * @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
  34070. * @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
  34071. * @param x defines x coordinate
  34072. * @param y defines y coordinate
  34073. * @param z defines z coordinate
  34074. * @returns the face index if found (or null instead)
  34075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34076. */
  34077. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34078. /**
  34079. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  34080. * @param projected sets as the (x,y,z) local projection on the facet
  34081. * @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
  34082. * @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
  34083. * @param x defines x coordinate
  34084. * @param y defines y coordinate
  34085. * @param z defines z coordinate
  34086. * @returns the face index if found (or null instead)
  34087. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34088. */
  34089. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34090. /**
  34091. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  34092. * @returns the parameters
  34093. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34094. */
  34095. getFacetDataParameters(): any;
  34096. /**
  34097. * Disables the feature FacetData and frees the related memory
  34098. * @returns the current mesh
  34099. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34100. */
  34101. disableFacetData(): AbstractMesh;
  34102. /**
  34103. * Updates the AbstractMesh indices array
  34104. * @param indices defines the data source
  34105. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34106. * @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)
  34107. * @returns the current mesh
  34108. */
  34109. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34110. /**
  34111. * Creates new normals data for the mesh
  34112. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34113. * @returns the current mesh
  34114. */
  34115. createNormals(updatable: boolean): AbstractMesh;
  34116. /**
  34117. * Align the mesh with a normal
  34118. * @param normal defines the normal to use
  34119. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34120. * @returns the current mesh
  34121. */
  34122. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34123. /** @hidden */
  34124. _checkOcclusionQuery(): boolean;
  34125. /**
  34126. * Disables the mesh edge rendering mode
  34127. * @returns the currentAbstractMesh
  34128. */
  34129. disableEdgesRendering(): AbstractMesh;
  34130. /**
  34131. * Enables the edge rendering mode on the mesh.
  34132. * This mode makes the mesh edges visible
  34133. * @param epsilon defines the maximal distance between two angles to detect a face
  34134. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34135. * @returns the currentAbstractMesh
  34136. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34137. */
  34138. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34139. /**
  34140. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34141. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34142. */
  34143. getConnectedParticleSystems(): IParticleSystem[];
  34144. }
  34145. }
  34146. declare module "babylonjs/Actions/actionEvent" {
  34147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34148. import { Nullable } from "babylonjs/types";
  34149. import { Sprite } from "babylonjs/Sprites/sprite";
  34150. import { Scene } from "babylonjs/scene";
  34151. import { Vector2 } from "babylonjs/Maths/math.vector";
  34152. /**
  34153. * Interface used to define ActionEvent
  34154. */
  34155. export interface IActionEvent {
  34156. /** The mesh or sprite that triggered the action */
  34157. source: any;
  34158. /** The X mouse cursor position at the time of the event */
  34159. pointerX: number;
  34160. /** The Y mouse cursor position at the time of the event */
  34161. pointerY: number;
  34162. /** The mesh that is currently pointed at (can be null) */
  34163. meshUnderPointer: Nullable<AbstractMesh>;
  34164. /** the original (browser) event that triggered the ActionEvent */
  34165. sourceEvent?: any;
  34166. /** additional data for the event */
  34167. additionalData?: any;
  34168. }
  34169. /**
  34170. * ActionEvent is the event being sent when an action is triggered.
  34171. */
  34172. export class ActionEvent implements IActionEvent {
  34173. /** The mesh or sprite that triggered the action */
  34174. source: any;
  34175. /** The X mouse cursor position at the time of the event */
  34176. pointerX: number;
  34177. /** The Y mouse cursor position at the time of the event */
  34178. pointerY: number;
  34179. /** The mesh that is currently pointed at (can be null) */
  34180. meshUnderPointer: Nullable<AbstractMesh>;
  34181. /** the original (browser) event that triggered the ActionEvent */
  34182. sourceEvent?: any;
  34183. /** additional data for the event */
  34184. additionalData?: any;
  34185. /**
  34186. * Creates a new ActionEvent
  34187. * @param source The mesh or sprite that triggered the action
  34188. * @param pointerX The X mouse cursor position at the time of the event
  34189. * @param pointerY The Y mouse cursor position at the time of the event
  34190. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34191. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34192. * @param additionalData additional data for the event
  34193. */
  34194. constructor(
  34195. /** The mesh or sprite that triggered the action */
  34196. source: any,
  34197. /** The X mouse cursor position at the time of the event */
  34198. pointerX: number,
  34199. /** The Y mouse cursor position at the time of the event */
  34200. pointerY: number,
  34201. /** The mesh that is currently pointed at (can be null) */
  34202. meshUnderPointer: Nullable<AbstractMesh>,
  34203. /** the original (browser) event that triggered the ActionEvent */
  34204. sourceEvent?: any,
  34205. /** additional data for the event */
  34206. additionalData?: any);
  34207. /**
  34208. * Helper function to auto-create an ActionEvent from a source mesh.
  34209. * @param source The source mesh that triggered the event
  34210. * @param evt The original (browser) event
  34211. * @param additionalData additional data for the event
  34212. * @returns the new ActionEvent
  34213. */
  34214. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34215. /**
  34216. * Helper function to auto-create an ActionEvent from a source sprite
  34217. * @param source The source sprite that triggered the event
  34218. * @param scene Scene associated with the sprite
  34219. * @param evt The original (browser) event
  34220. * @param additionalData additional data for the event
  34221. * @returns the new ActionEvent
  34222. */
  34223. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34224. /**
  34225. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34226. * @param scene the scene where the event occurred
  34227. * @param evt The original (browser) event
  34228. * @returns the new ActionEvent
  34229. */
  34230. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34231. /**
  34232. * Helper function to auto-create an ActionEvent from a primitive
  34233. * @param prim defines the target primitive
  34234. * @param pointerPos defines the pointer position
  34235. * @param evt The original (browser) event
  34236. * @param additionalData additional data for the event
  34237. * @returns the new ActionEvent
  34238. */
  34239. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34240. }
  34241. }
  34242. declare module "babylonjs/Actions/abstractActionManager" {
  34243. import { IDisposable } from "babylonjs/scene";
  34244. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34245. import { IAction } from "babylonjs/Actions/action";
  34246. import { Nullable } from "babylonjs/types";
  34247. /**
  34248. * Abstract class used to decouple action Manager from scene and meshes.
  34249. * Do not instantiate.
  34250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34251. */
  34252. export abstract class AbstractActionManager implements IDisposable {
  34253. /** Gets the list of active triggers */
  34254. static Triggers: {
  34255. [key: string]: number;
  34256. };
  34257. /** Gets the cursor to use when hovering items */
  34258. hoverCursor: string;
  34259. /** Gets the list of actions */
  34260. actions: IAction[];
  34261. /**
  34262. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34263. */
  34264. isRecursive: boolean;
  34265. /**
  34266. * Releases all associated resources
  34267. */
  34268. abstract dispose(): void;
  34269. /**
  34270. * Does this action manager has pointer triggers
  34271. */
  34272. abstract get hasPointerTriggers(): boolean;
  34273. /**
  34274. * Does this action manager has pick triggers
  34275. */
  34276. abstract get hasPickTriggers(): boolean;
  34277. /**
  34278. * Process a specific trigger
  34279. * @param trigger defines the trigger to process
  34280. * @param evt defines the event details to be processed
  34281. */
  34282. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34283. /**
  34284. * Does this action manager handles actions of any of the given triggers
  34285. * @param triggers defines the triggers to be tested
  34286. * @return a boolean indicating whether one (or more) of the triggers is handled
  34287. */
  34288. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34289. /**
  34290. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34291. * speed.
  34292. * @param triggerA defines the trigger to be tested
  34293. * @param triggerB defines the trigger to be tested
  34294. * @return a boolean indicating whether one (or more) of the triggers is handled
  34295. */
  34296. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34297. /**
  34298. * Does this action manager handles actions of a given trigger
  34299. * @param trigger defines the trigger to be tested
  34300. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34301. * @return whether the trigger is handled
  34302. */
  34303. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34304. /**
  34305. * Serialize this manager to a JSON object
  34306. * @param name defines the property name to store this manager
  34307. * @returns a JSON representation of this manager
  34308. */
  34309. abstract serialize(name: string): any;
  34310. /**
  34311. * Registers an action to this action manager
  34312. * @param action defines the action to be registered
  34313. * @return the action amended (prepared) after registration
  34314. */
  34315. abstract registerAction(action: IAction): Nullable<IAction>;
  34316. /**
  34317. * Unregisters an action to this action manager
  34318. * @param action defines the action to be unregistered
  34319. * @return a boolean indicating whether the action has been unregistered
  34320. */
  34321. abstract unregisterAction(action: IAction): Boolean;
  34322. /**
  34323. * Does exist one action manager with at least one trigger
  34324. **/
  34325. static get HasTriggers(): boolean;
  34326. /**
  34327. * Does exist one action manager with at least one pick trigger
  34328. **/
  34329. static get HasPickTriggers(): boolean;
  34330. /**
  34331. * Does exist one action manager that handles actions of a given trigger
  34332. * @param trigger defines the trigger to be tested
  34333. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34334. **/
  34335. static HasSpecificTrigger(trigger: number): boolean;
  34336. }
  34337. }
  34338. declare module "babylonjs/node" {
  34339. import { Scene } from "babylonjs/scene";
  34340. import { Nullable } from "babylonjs/types";
  34341. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34342. import { Engine } from "babylonjs/Engines/engine";
  34343. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34344. import { Observable } from "babylonjs/Misc/observable";
  34345. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34346. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34347. import { Animatable } from "babylonjs/Animations/animatable";
  34348. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34349. import { Animation } from "babylonjs/Animations/animation";
  34350. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34352. /**
  34353. * Defines how a node can be built from a string name.
  34354. */
  34355. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34356. /**
  34357. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34358. */
  34359. export class Node implements IBehaviorAware<Node> {
  34360. /** @hidden */
  34361. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34362. private static _NodeConstructors;
  34363. /**
  34364. * Add a new node constructor
  34365. * @param type defines the type name of the node to construct
  34366. * @param constructorFunc defines the constructor function
  34367. */
  34368. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34369. /**
  34370. * Returns a node constructor based on type name
  34371. * @param type defines the type name
  34372. * @param name defines the new node name
  34373. * @param scene defines the hosting scene
  34374. * @param options defines optional options to transmit to constructors
  34375. * @returns the new constructor or null
  34376. */
  34377. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34378. /**
  34379. * Gets or sets the name of the node
  34380. */
  34381. name: string;
  34382. /**
  34383. * Gets or sets the id of the node
  34384. */
  34385. id: string;
  34386. /**
  34387. * Gets or sets the unique id of the node
  34388. */
  34389. uniqueId: number;
  34390. /**
  34391. * Gets or sets a string used to store user defined state for the node
  34392. */
  34393. state: string;
  34394. /**
  34395. * Gets or sets an object used to store user defined information for the node
  34396. */
  34397. metadata: any;
  34398. /**
  34399. * For internal use only. Please do not use.
  34400. */
  34401. reservedDataStore: any;
  34402. /**
  34403. * List of inspectable custom properties (used by the Inspector)
  34404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34405. */
  34406. inspectableCustomProperties: IInspectable[];
  34407. private _doNotSerialize;
  34408. /**
  34409. * Gets or sets a boolean used to define if the node must be serialized
  34410. */
  34411. get doNotSerialize(): boolean;
  34412. set doNotSerialize(value: boolean);
  34413. /** @hidden */
  34414. _isDisposed: boolean;
  34415. /**
  34416. * Gets a list of Animations associated with the node
  34417. */
  34418. animations: import("babylonjs/Animations/animation").Animation[];
  34419. protected _ranges: {
  34420. [name: string]: Nullable<AnimationRange>;
  34421. };
  34422. /**
  34423. * Callback raised when the node is ready to be used
  34424. */
  34425. onReady: Nullable<(node: Node) => void>;
  34426. private _isEnabled;
  34427. private _isParentEnabled;
  34428. private _isReady;
  34429. /** @hidden */
  34430. _currentRenderId: number;
  34431. private _parentUpdateId;
  34432. /** @hidden */
  34433. _childUpdateId: number;
  34434. /** @hidden */
  34435. _waitingParentId: Nullable<string>;
  34436. /** @hidden */
  34437. _scene: Scene;
  34438. /** @hidden */
  34439. _cache: any;
  34440. private _parentNode;
  34441. private _children;
  34442. /** @hidden */
  34443. _worldMatrix: Matrix;
  34444. /** @hidden */
  34445. _worldMatrixDeterminant: number;
  34446. /** @hidden */
  34447. _worldMatrixDeterminantIsDirty: boolean;
  34448. /** @hidden */
  34449. private _sceneRootNodesIndex;
  34450. /**
  34451. * Gets a boolean indicating if the node has been disposed
  34452. * @returns true if the node was disposed
  34453. */
  34454. isDisposed(): boolean;
  34455. /**
  34456. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34457. * @see https://doc.babylonjs.com/how_to/parenting
  34458. */
  34459. set parent(parent: Nullable<Node>);
  34460. get parent(): Nullable<Node>;
  34461. /** @hidden */
  34462. _addToSceneRootNodes(): void;
  34463. /** @hidden */
  34464. _removeFromSceneRootNodes(): void;
  34465. private _animationPropertiesOverride;
  34466. /**
  34467. * Gets or sets the animation properties override
  34468. */
  34469. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34470. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34471. /**
  34472. * Gets a string identifying the name of the class
  34473. * @returns "Node" string
  34474. */
  34475. getClassName(): string;
  34476. /** @hidden */
  34477. readonly _isNode: boolean;
  34478. /**
  34479. * An event triggered when the mesh is disposed
  34480. */
  34481. onDisposeObservable: Observable<Node>;
  34482. private _onDisposeObserver;
  34483. /**
  34484. * Sets a callback that will be raised when the node will be disposed
  34485. */
  34486. set onDispose(callback: () => void);
  34487. /**
  34488. * Creates a new Node
  34489. * @param name the name and id to be given to this node
  34490. * @param scene the scene this node will be added to
  34491. */
  34492. constructor(name: string, scene?: Nullable<Scene>);
  34493. /**
  34494. * Gets the scene of the node
  34495. * @returns a scene
  34496. */
  34497. getScene(): Scene;
  34498. /**
  34499. * Gets the engine of the node
  34500. * @returns a Engine
  34501. */
  34502. getEngine(): Engine;
  34503. private _behaviors;
  34504. /**
  34505. * Attach a behavior to the node
  34506. * @see https://doc.babylonjs.com/features/behaviour
  34507. * @param behavior defines the behavior to attach
  34508. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34509. * @returns the current Node
  34510. */
  34511. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34512. /**
  34513. * Remove an attached behavior
  34514. * @see https://doc.babylonjs.com/features/behaviour
  34515. * @param behavior defines the behavior to attach
  34516. * @returns the current Node
  34517. */
  34518. removeBehavior(behavior: Behavior<Node>): Node;
  34519. /**
  34520. * Gets the list of attached behaviors
  34521. * @see https://doc.babylonjs.com/features/behaviour
  34522. */
  34523. get behaviors(): Behavior<Node>[];
  34524. /**
  34525. * Gets an attached behavior by name
  34526. * @param name defines the name of the behavior to look for
  34527. * @see https://doc.babylonjs.com/features/behaviour
  34528. * @returns null if behavior was not found else the requested behavior
  34529. */
  34530. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34531. /**
  34532. * Returns the latest update of the World matrix
  34533. * @returns a Matrix
  34534. */
  34535. getWorldMatrix(): Matrix;
  34536. /** @hidden */
  34537. _getWorldMatrixDeterminant(): number;
  34538. /**
  34539. * Returns directly the latest state of the mesh World matrix.
  34540. * A Matrix is returned.
  34541. */
  34542. get worldMatrixFromCache(): Matrix;
  34543. /** @hidden */
  34544. _initCache(): void;
  34545. /** @hidden */
  34546. updateCache(force?: boolean): void;
  34547. /** @hidden */
  34548. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34549. /** @hidden */
  34550. _updateCache(ignoreParentClass?: boolean): void;
  34551. /** @hidden */
  34552. _isSynchronized(): boolean;
  34553. /** @hidden */
  34554. _markSyncedWithParent(): void;
  34555. /** @hidden */
  34556. isSynchronizedWithParent(): boolean;
  34557. /** @hidden */
  34558. isSynchronized(): boolean;
  34559. /**
  34560. * Is this node ready to be used/rendered
  34561. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34562. * @return true if the node is ready
  34563. */
  34564. isReady(completeCheck?: boolean): boolean;
  34565. /**
  34566. * Is this node enabled?
  34567. * 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
  34568. * @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
  34569. * @return whether this node (and its parent) is enabled
  34570. */
  34571. isEnabled(checkAncestors?: boolean): boolean;
  34572. /** @hidden */
  34573. protected _syncParentEnabledState(): void;
  34574. /**
  34575. * Set the enabled state of this node
  34576. * @param value defines the new enabled state
  34577. */
  34578. setEnabled(value: boolean): void;
  34579. /**
  34580. * Is this node a descendant of the given node?
  34581. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34582. * @param ancestor defines the parent node to inspect
  34583. * @returns a boolean indicating if this node is a descendant of the given node
  34584. */
  34585. isDescendantOf(ancestor: Node): boolean;
  34586. /** @hidden */
  34587. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34588. /**
  34589. * Will return all nodes that have this node as ascendant
  34590. * @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
  34591. * @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
  34592. * @return all children nodes of all types
  34593. */
  34594. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34595. /**
  34596. * Get all child-meshes of this node
  34597. * @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)
  34598. * @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
  34599. * @returns an array of AbstractMesh
  34600. */
  34601. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34602. /**
  34603. * Get all direct children of this node
  34604. * @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
  34605. * @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)
  34606. * @returns an array of Node
  34607. */
  34608. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34609. /** @hidden */
  34610. _setReady(state: boolean): void;
  34611. /**
  34612. * Get an animation by name
  34613. * @param name defines the name of the animation to look for
  34614. * @returns null if not found else the requested animation
  34615. */
  34616. getAnimationByName(name: string): Nullable<Animation>;
  34617. /**
  34618. * Creates an animation range for this node
  34619. * @param name defines the name of the range
  34620. * @param from defines the starting key
  34621. * @param to defines the end key
  34622. */
  34623. createAnimationRange(name: string, from: number, to: number): void;
  34624. /**
  34625. * Delete a specific animation range
  34626. * @param name defines the name of the range to delete
  34627. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34628. */
  34629. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34630. /**
  34631. * Get an animation range by name
  34632. * @param name defines the name of the animation range to look for
  34633. * @returns null if not found else the requested animation range
  34634. */
  34635. getAnimationRange(name: string): Nullable<AnimationRange>;
  34636. /**
  34637. * Gets the list of all animation ranges defined on this node
  34638. * @returns an array
  34639. */
  34640. getAnimationRanges(): Nullable<AnimationRange>[];
  34641. /**
  34642. * Will start the animation sequence
  34643. * @param name defines the range frames for animation sequence
  34644. * @param loop defines if the animation should loop (false by default)
  34645. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34646. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34647. * @returns the object created for this animation. If range does not exist, it will return null
  34648. */
  34649. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34650. /**
  34651. * Serialize animation ranges into a JSON compatible object
  34652. * @returns serialization object
  34653. */
  34654. serializeAnimationRanges(): any;
  34655. /**
  34656. * Computes the world matrix of the node
  34657. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34658. * @returns the world matrix
  34659. */
  34660. computeWorldMatrix(force?: boolean): Matrix;
  34661. /**
  34662. * Releases resources associated with this node.
  34663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34665. */
  34666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34667. /**
  34668. * Parse animation range data from a serialization object and store them into a given node
  34669. * @param node defines where to store the animation ranges
  34670. * @param parsedNode defines the serialization object to read data from
  34671. * @param scene defines the hosting scene
  34672. */
  34673. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34674. /**
  34675. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34676. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34677. * @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
  34678. * @returns the new bounding vectors
  34679. */
  34680. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34681. min: Vector3;
  34682. max: Vector3;
  34683. };
  34684. }
  34685. }
  34686. declare module "babylonjs/Animations/animation" {
  34687. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34688. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34689. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34690. import { Nullable } from "babylonjs/types";
  34691. import { Scene } from "babylonjs/scene";
  34692. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34693. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34694. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34695. import { Node } from "babylonjs/node";
  34696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34697. import { Size } from "babylonjs/Maths/math.size";
  34698. import { Animatable } from "babylonjs/Animations/animatable";
  34699. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34700. /**
  34701. * @hidden
  34702. */
  34703. export class _IAnimationState {
  34704. key: number;
  34705. repeatCount: number;
  34706. workValue?: any;
  34707. loopMode?: number;
  34708. offsetValue?: any;
  34709. highLimitValue?: any;
  34710. }
  34711. /**
  34712. * Class used to store any kind of animation
  34713. */
  34714. export class Animation {
  34715. /**Name of the animation */
  34716. name: string;
  34717. /**Property to animate */
  34718. targetProperty: string;
  34719. /**The frames per second of the animation */
  34720. framePerSecond: number;
  34721. /**The data type of the animation */
  34722. dataType: number;
  34723. /**The loop mode of the animation */
  34724. loopMode?: number | undefined;
  34725. /**Specifies if blending should be enabled */
  34726. enableBlending?: boolean | undefined;
  34727. /**
  34728. * Use matrix interpolation instead of using direct key value when animating matrices
  34729. */
  34730. static AllowMatricesInterpolation: boolean;
  34731. /**
  34732. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34733. */
  34734. static AllowMatrixDecomposeForInterpolation: boolean;
  34735. /** Define the Url to load snippets */
  34736. static SnippetUrl: string;
  34737. /** Snippet ID if the animation was created from the snippet server */
  34738. snippetId: string;
  34739. /**
  34740. * Stores the key frames of the animation
  34741. */
  34742. private _keys;
  34743. /**
  34744. * Stores the easing function of the animation
  34745. */
  34746. private _easingFunction;
  34747. /**
  34748. * @hidden Internal use only
  34749. */
  34750. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34751. /**
  34752. * The set of event that will be linked to this animation
  34753. */
  34754. private _events;
  34755. /**
  34756. * Stores an array of target property paths
  34757. */
  34758. targetPropertyPath: string[];
  34759. /**
  34760. * Stores the blending speed of the animation
  34761. */
  34762. blendingSpeed: number;
  34763. /**
  34764. * Stores the animation ranges for the animation
  34765. */
  34766. private _ranges;
  34767. /**
  34768. * @hidden Internal use
  34769. */
  34770. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34771. /**
  34772. * Sets up an animation
  34773. * @param property The property to animate
  34774. * @param animationType The animation type to apply
  34775. * @param framePerSecond The frames per second of the animation
  34776. * @param easingFunction The easing function used in the animation
  34777. * @returns The created animation
  34778. */
  34779. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34780. /**
  34781. * Create and start an animation on a node
  34782. * @param name defines the name of the global animation that will be run on all nodes
  34783. * @param node defines the root node where the animation will take place
  34784. * @param targetProperty defines property to animate
  34785. * @param framePerSecond defines the number of frame per second yo use
  34786. * @param totalFrame defines the number of frames in total
  34787. * @param from defines the initial value
  34788. * @param to defines the final value
  34789. * @param loopMode defines which loop mode you want to use (off by default)
  34790. * @param easingFunction defines the easing function to use (linear by default)
  34791. * @param onAnimationEnd defines the callback to call when animation end
  34792. * @returns the animatable created for this animation
  34793. */
  34794. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34795. /**
  34796. * Create and start an animation on a node and its descendants
  34797. * @param name defines the name of the global animation that will be run on all nodes
  34798. * @param node defines the root node where the animation will take place
  34799. * @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
  34800. * @param targetProperty defines property to animate
  34801. * @param framePerSecond defines the number of frame per second to use
  34802. * @param totalFrame defines the number of frames in total
  34803. * @param from defines the initial value
  34804. * @param to defines the final value
  34805. * @param loopMode defines which loop mode you want to use (off by default)
  34806. * @param easingFunction defines the easing function to use (linear by default)
  34807. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34808. * @returns the list of animatables created for all nodes
  34809. * @example https://www.babylonjs-playground.com/#MH0VLI
  34810. */
  34811. 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[]>;
  34812. /**
  34813. * Creates a new animation, merges it with the existing animations and starts it
  34814. * @param name Name of the animation
  34815. * @param node Node which contains the scene that begins the animations
  34816. * @param targetProperty Specifies which property to animate
  34817. * @param framePerSecond The frames per second of the animation
  34818. * @param totalFrame The total number of frames
  34819. * @param from The frame at the beginning of the animation
  34820. * @param to The frame at the end of the animation
  34821. * @param loopMode Specifies the loop mode of the animation
  34822. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34823. * @param onAnimationEnd Callback to run once the animation is complete
  34824. * @returns Nullable animation
  34825. */
  34826. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34827. /**
  34828. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34829. * @param sourceAnimation defines the Animation containing keyframes to convert
  34830. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34831. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34832. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34833. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34834. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34835. */
  34836. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34837. /**
  34838. * Transition property of an host to the target Value
  34839. * @param property The property to transition
  34840. * @param targetValue The target Value of the property
  34841. * @param host The object where the property to animate belongs
  34842. * @param scene Scene used to run the animation
  34843. * @param frameRate Framerate (in frame/s) to use
  34844. * @param transition The transition type we want to use
  34845. * @param duration The duration of the animation, in milliseconds
  34846. * @param onAnimationEnd Callback trigger at the end of the animation
  34847. * @returns Nullable animation
  34848. */
  34849. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34850. /**
  34851. * Return the array of runtime animations currently using this animation
  34852. */
  34853. get runtimeAnimations(): RuntimeAnimation[];
  34854. /**
  34855. * Specifies if any of the runtime animations are currently running
  34856. */
  34857. get hasRunningRuntimeAnimations(): boolean;
  34858. /**
  34859. * Initializes the animation
  34860. * @param name Name of the animation
  34861. * @param targetProperty Property to animate
  34862. * @param framePerSecond The frames per second of the animation
  34863. * @param dataType The data type of the animation
  34864. * @param loopMode The loop mode of the animation
  34865. * @param enableBlending Specifies if blending should be enabled
  34866. */
  34867. constructor(
  34868. /**Name of the animation */
  34869. name: string,
  34870. /**Property to animate */
  34871. targetProperty: string,
  34872. /**The frames per second of the animation */
  34873. framePerSecond: number,
  34874. /**The data type of the animation */
  34875. dataType: number,
  34876. /**The loop mode of the animation */
  34877. loopMode?: number | undefined,
  34878. /**Specifies if blending should be enabled */
  34879. enableBlending?: boolean | undefined);
  34880. /**
  34881. * Converts the animation to a string
  34882. * @param fullDetails support for multiple levels of logging within scene loading
  34883. * @returns String form of the animation
  34884. */
  34885. toString(fullDetails?: boolean): string;
  34886. /**
  34887. * Add an event to this animation
  34888. * @param event Event to add
  34889. */
  34890. addEvent(event: AnimationEvent): void;
  34891. /**
  34892. * Remove all events found at the given frame
  34893. * @param frame The frame to remove events from
  34894. */
  34895. removeEvents(frame: number): void;
  34896. /**
  34897. * Retrieves all the events from the animation
  34898. * @returns Events from the animation
  34899. */
  34900. getEvents(): AnimationEvent[];
  34901. /**
  34902. * Creates an animation range
  34903. * @param name Name of the animation range
  34904. * @param from Starting frame of the animation range
  34905. * @param to Ending frame of the animation
  34906. */
  34907. createRange(name: string, from: number, to: number): void;
  34908. /**
  34909. * Deletes an animation range by name
  34910. * @param name Name of the animation range to delete
  34911. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34912. */
  34913. deleteRange(name: string, deleteFrames?: boolean): void;
  34914. /**
  34915. * Gets the animation range by name, or null if not defined
  34916. * @param name Name of the animation range
  34917. * @returns Nullable animation range
  34918. */
  34919. getRange(name: string): Nullable<AnimationRange>;
  34920. /**
  34921. * Gets the key frames from the animation
  34922. * @returns The key frames of the animation
  34923. */
  34924. getKeys(): Array<IAnimationKey>;
  34925. /**
  34926. * Gets the highest frame rate of the animation
  34927. * @returns Highest frame rate of the animation
  34928. */
  34929. getHighestFrame(): number;
  34930. /**
  34931. * Gets the easing function of the animation
  34932. * @returns Easing function of the animation
  34933. */
  34934. getEasingFunction(): IEasingFunction;
  34935. /**
  34936. * Sets the easing function of the animation
  34937. * @param easingFunction A custom mathematical formula for animation
  34938. */
  34939. setEasingFunction(easingFunction: EasingFunction): void;
  34940. /**
  34941. * Interpolates a scalar linearly
  34942. * @param startValue Start value of the animation curve
  34943. * @param endValue End value of the animation curve
  34944. * @param gradient Scalar amount to interpolate
  34945. * @returns Interpolated scalar value
  34946. */
  34947. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34948. /**
  34949. * Interpolates a scalar cubically
  34950. * @param startValue Start value of the animation curve
  34951. * @param outTangent End tangent of the animation
  34952. * @param endValue End value of the animation curve
  34953. * @param inTangent Start tangent of the animation curve
  34954. * @param gradient Scalar amount to interpolate
  34955. * @returns Interpolated scalar value
  34956. */
  34957. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34958. /**
  34959. * Interpolates a quaternion using a spherical linear interpolation
  34960. * @param startValue Start value of the animation curve
  34961. * @param endValue End value of the animation curve
  34962. * @param gradient Scalar amount to interpolate
  34963. * @returns Interpolated quaternion value
  34964. */
  34965. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34966. /**
  34967. * Interpolates a quaternion cubically
  34968. * @param startValue Start value of the animation curve
  34969. * @param outTangent End tangent of the animation curve
  34970. * @param endValue End value of the animation curve
  34971. * @param inTangent Start tangent of the animation curve
  34972. * @param gradient Scalar amount to interpolate
  34973. * @returns Interpolated quaternion value
  34974. */
  34975. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34976. /**
  34977. * Interpolates a Vector3 linearl
  34978. * @param startValue Start value of the animation curve
  34979. * @param endValue End value of the animation curve
  34980. * @param gradient Scalar amount to interpolate
  34981. * @returns Interpolated scalar value
  34982. */
  34983. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34984. /**
  34985. * Interpolates a Vector3 cubically
  34986. * @param startValue Start value of the animation curve
  34987. * @param outTangent End tangent of the animation
  34988. * @param endValue End value of the animation curve
  34989. * @param inTangent Start tangent of the animation curve
  34990. * @param gradient Scalar amount to interpolate
  34991. * @returns InterpolatedVector3 value
  34992. */
  34993. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34994. /**
  34995. * Interpolates a Vector2 linearly
  34996. * @param startValue Start value of the animation curve
  34997. * @param endValue End value of the animation curve
  34998. * @param gradient Scalar amount to interpolate
  34999. * @returns Interpolated Vector2 value
  35000. */
  35001. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  35002. /**
  35003. * Interpolates a Vector2 cubically
  35004. * @param startValue Start value of the animation curve
  35005. * @param outTangent End tangent of the animation
  35006. * @param endValue End value of the animation curve
  35007. * @param inTangent Start tangent of the animation curve
  35008. * @param gradient Scalar amount to interpolate
  35009. * @returns Interpolated Vector2 value
  35010. */
  35011. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  35012. /**
  35013. * Interpolates a size linearly
  35014. * @param startValue Start value of the animation curve
  35015. * @param endValue End value of the animation curve
  35016. * @param gradient Scalar amount to interpolate
  35017. * @returns Interpolated Size value
  35018. */
  35019. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  35020. /**
  35021. * Interpolates a Color3 linearly
  35022. * @param startValue Start value of the animation curve
  35023. * @param endValue End value of the animation curve
  35024. * @param gradient Scalar amount to interpolate
  35025. * @returns Interpolated Color3 value
  35026. */
  35027. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  35028. /**
  35029. * Interpolates a Color4 linearly
  35030. * @param startValue Start value of the animation curve
  35031. * @param endValue End value of the animation curve
  35032. * @param gradient Scalar amount to interpolate
  35033. * @returns Interpolated Color3 value
  35034. */
  35035. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  35036. /**
  35037. * @hidden Internal use only
  35038. */
  35039. _getKeyValue(value: any): any;
  35040. /**
  35041. * @hidden Internal use only
  35042. */
  35043. _interpolate(currentFrame: number, state: _IAnimationState): any;
  35044. /**
  35045. * Defines the function to use to interpolate matrices
  35046. * @param startValue defines the start matrix
  35047. * @param endValue defines the end matrix
  35048. * @param gradient defines the gradient between both matrices
  35049. * @param result defines an optional target matrix where to store the interpolation
  35050. * @returns the interpolated matrix
  35051. */
  35052. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  35053. /**
  35054. * Makes a copy of the animation
  35055. * @returns Cloned animation
  35056. */
  35057. clone(): Animation;
  35058. /**
  35059. * Sets the key frames of the animation
  35060. * @param values The animation key frames to set
  35061. */
  35062. setKeys(values: Array<IAnimationKey>): void;
  35063. /**
  35064. * Serializes the animation to an object
  35065. * @returns Serialized object
  35066. */
  35067. serialize(): any;
  35068. /**
  35069. * Float animation type
  35070. */
  35071. static readonly ANIMATIONTYPE_FLOAT: number;
  35072. /**
  35073. * Vector3 animation type
  35074. */
  35075. static readonly ANIMATIONTYPE_VECTOR3: number;
  35076. /**
  35077. * Quaternion animation type
  35078. */
  35079. static readonly ANIMATIONTYPE_QUATERNION: number;
  35080. /**
  35081. * Matrix animation type
  35082. */
  35083. static readonly ANIMATIONTYPE_MATRIX: number;
  35084. /**
  35085. * Color3 animation type
  35086. */
  35087. static readonly ANIMATIONTYPE_COLOR3: number;
  35088. /**
  35089. * Color3 animation type
  35090. */
  35091. static readonly ANIMATIONTYPE_COLOR4: number;
  35092. /**
  35093. * Vector2 animation type
  35094. */
  35095. static readonly ANIMATIONTYPE_VECTOR2: number;
  35096. /**
  35097. * Size animation type
  35098. */
  35099. static readonly ANIMATIONTYPE_SIZE: number;
  35100. /**
  35101. * Relative Loop Mode
  35102. */
  35103. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  35104. /**
  35105. * Cycle Loop Mode
  35106. */
  35107. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  35108. /**
  35109. * Constant Loop Mode
  35110. */
  35111. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35112. /** @hidden */
  35113. static _UniversalLerp(left: any, right: any, amount: number): any;
  35114. /**
  35115. * Parses an animation object and creates an animation
  35116. * @param parsedAnimation Parsed animation object
  35117. * @returns Animation object
  35118. */
  35119. static Parse(parsedAnimation: any): Animation;
  35120. /**
  35121. * Appends the serialized animations from the source animations
  35122. * @param source Source containing the animations
  35123. * @param destination Target to store the animations
  35124. */
  35125. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35126. /**
  35127. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35128. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35129. * @param url defines the url to load from
  35130. * @returns a promise that will resolve to the new animation or an array of animations
  35131. */
  35132. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35133. /**
  35134. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35135. * @param snippetId defines the snippet to load
  35136. * @returns a promise that will resolve to the new animation or a new array of animations
  35137. */
  35138. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35139. }
  35140. }
  35141. declare module "babylonjs/Animations/animatable.interface" {
  35142. import { Nullable } from "babylonjs/types";
  35143. import { Animation } from "babylonjs/Animations/animation";
  35144. /**
  35145. * Interface containing an array of animations
  35146. */
  35147. export interface IAnimatable {
  35148. /**
  35149. * Array of animations
  35150. */
  35151. animations: Nullable<Array<Animation>>;
  35152. }
  35153. }
  35154. declare module "babylonjs/Misc/decorators" {
  35155. import { Nullable } from "babylonjs/types";
  35156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35157. import { Scene } from "babylonjs/scene";
  35158. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35159. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35160. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35162. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35163. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35164. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35165. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35166. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35167. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35168. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35169. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35170. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35171. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35172. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35173. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35174. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35175. /**
  35176. * Decorator used to define property that can be serialized as reference to a camera
  35177. * @param sourceName defines the name of the property to decorate
  35178. */
  35179. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35180. /**
  35181. * Class used to help serialization objects
  35182. */
  35183. export class SerializationHelper {
  35184. /** @hidden */
  35185. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35186. /** @hidden */
  35187. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35188. /** @hidden */
  35189. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35190. /** @hidden */
  35191. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35192. /**
  35193. * Appends the serialized animations from the source animations
  35194. * @param source Source containing the animations
  35195. * @param destination Target to store the animations
  35196. */
  35197. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35198. /**
  35199. * Static function used to serialized a specific entity
  35200. * @param entity defines the entity to serialize
  35201. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35202. * @returns a JSON compatible object representing the serialization of the entity
  35203. */
  35204. static Serialize<T>(entity: T, serializationObject?: any): any;
  35205. /**
  35206. * Creates a new entity from a serialization data object
  35207. * @param creationFunction defines a function used to instanciated the new entity
  35208. * @param source defines the source serialization data
  35209. * @param scene defines the hosting scene
  35210. * @param rootUrl defines the root url for resources
  35211. * @returns a new entity
  35212. */
  35213. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35214. /**
  35215. * Clones an object
  35216. * @param creationFunction defines the function used to instanciate the new object
  35217. * @param source defines the source object
  35218. * @returns the cloned object
  35219. */
  35220. static Clone<T>(creationFunction: () => T, source: T): T;
  35221. /**
  35222. * Instanciates a new object based on a source one (some data will be shared between both object)
  35223. * @param creationFunction defines the function used to instanciate the new object
  35224. * @param source defines the source object
  35225. * @returns the new object
  35226. */
  35227. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35228. }
  35229. }
  35230. declare module "babylonjs/Materials/Textures/baseTexture" {
  35231. import { Observable } from "babylonjs/Misc/observable";
  35232. import { Nullable } from "babylonjs/types";
  35233. import { Scene } from "babylonjs/scene";
  35234. import { Matrix } from "babylonjs/Maths/math.vector";
  35235. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35237. import { ISize } from "babylonjs/Maths/math.size";
  35238. import "babylonjs/Misc/fileTools";
  35239. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35240. /**
  35241. * Base class of all the textures in babylon.
  35242. * It groups all the common properties the materials, post process, lights... might need
  35243. * in order to make a correct use of the texture.
  35244. */
  35245. export class BaseTexture implements IAnimatable {
  35246. /**
  35247. * Default anisotropic filtering level for the application.
  35248. * It is set to 4 as a good tradeoff between perf and quality.
  35249. */
  35250. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35251. /**
  35252. * Gets or sets the unique id of the texture
  35253. */
  35254. uniqueId: number;
  35255. /**
  35256. * Define the name of the texture.
  35257. */
  35258. name: string;
  35259. /**
  35260. * Gets or sets an object used to store user defined information.
  35261. */
  35262. metadata: any;
  35263. /**
  35264. * For internal use only. Please do not use.
  35265. */
  35266. reservedDataStore: any;
  35267. private _hasAlpha;
  35268. /**
  35269. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35270. */
  35271. set hasAlpha(value: boolean);
  35272. get hasAlpha(): boolean;
  35273. /**
  35274. * Defines if the alpha value should be determined via the rgb values.
  35275. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35276. */
  35277. getAlphaFromRGB: boolean;
  35278. /**
  35279. * Intensity or strength of the texture.
  35280. * It is commonly used by materials to fine tune the intensity of the texture
  35281. */
  35282. level: number;
  35283. /**
  35284. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35285. * This is part of the texture as textures usually maps to one uv set.
  35286. */
  35287. coordinatesIndex: number;
  35288. protected _coordinatesMode: number;
  35289. /**
  35290. * How a texture is mapped.
  35291. *
  35292. * | Value | Type | Description |
  35293. * | ----- | ----------------------------------- | ----------- |
  35294. * | 0 | EXPLICIT_MODE | |
  35295. * | 1 | SPHERICAL_MODE | |
  35296. * | 2 | PLANAR_MODE | |
  35297. * | 3 | CUBIC_MODE | |
  35298. * | 4 | PROJECTION_MODE | |
  35299. * | 5 | SKYBOX_MODE | |
  35300. * | 6 | INVCUBIC_MODE | |
  35301. * | 7 | EQUIRECTANGULAR_MODE | |
  35302. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35303. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35304. */
  35305. set coordinatesMode(value: number);
  35306. get coordinatesMode(): number;
  35307. private _wrapU;
  35308. /**
  35309. * | Value | Type | Description |
  35310. * | ----- | ------------------ | ----------- |
  35311. * | 0 | CLAMP_ADDRESSMODE | |
  35312. * | 1 | WRAP_ADDRESSMODE | |
  35313. * | 2 | MIRROR_ADDRESSMODE | |
  35314. */
  35315. get wrapU(): number;
  35316. set wrapU(value: number);
  35317. private _wrapV;
  35318. /**
  35319. * | Value | Type | Description |
  35320. * | ----- | ------------------ | ----------- |
  35321. * | 0 | CLAMP_ADDRESSMODE | |
  35322. * | 1 | WRAP_ADDRESSMODE | |
  35323. * | 2 | MIRROR_ADDRESSMODE | |
  35324. */
  35325. get wrapV(): number;
  35326. set wrapV(value: number);
  35327. /**
  35328. * | Value | Type | Description |
  35329. * | ----- | ------------------ | ----------- |
  35330. * | 0 | CLAMP_ADDRESSMODE | |
  35331. * | 1 | WRAP_ADDRESSMODE | |
  35332. * | 2 | MIRROR_ADDRESSMODE | |
  35333. */
  35334. wrapR: number;
  35335. /**
  35336. * With compliant hardware and browser (supporting anisotropic filtering)
  35337. * this defines the level of anisotropic filtering in the texture.
  35338. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35339. */
  35340. anisotropicFilteringLevel: number;
  35341. /**
  35342. * Define if the texture is a cube texture or if false a 2d texture.
  35343. */
  35344. get isCube(): boolean;
  35345. set isCube(value: boolean);
  35346. /**
  35347. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35348. */
  35349. get is3D(): boolean;
  35350. set is3D(value: boolean);
  35351. /**
  35352. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35353. */
  35354. get is2DArray(): boolean;
  35355. set is2DArray(value: boolean);
  35356. private _gammaSpace;
  35357. /**
  35358. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35359. * HDR texture are usually stored in linear space.
  35360. * This only impacts the PBR and Background materials
  35361. */
  35362. get gammaSpace(): boolean;
  35363. set gammaSpace(gamma: boolean);
  35364. /**
  35365. * Gets or sets whether or not the texture contains RGBD data.
  35366. */
  35367. get isRGBD(): boolean;
  35368. set isRGBD(value: boolean);
  35369. /**
  35370. * Is Z inverted in the texture (useful in a cube texture).
  35371. */
  35372. invertZ: boolean;
  35373. /**
  35374. * Are mip maps generated for this texture or not.
  35375. */
  35376. get noMipmap(): boolean;
  35377. /**
  35378. * @hidden
  35379. */
  35380. lodLevelInAlpha: boolean;
  35381. /**
  35382. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35383. */
  35384. get lodGenerationOffset(): number;
  35385. set lodGenerationOffset(value: number);
  35386. /**
  35387. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35388. */
  35389. get lodGenerationScale(): number;
  35390. set lodGenerationScale(value: number);
  35391. /**
  35392. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35393. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35394. * average roughness values.
  35395. */
  35396. get linearSpecularLOD(): boolean;
  35397. set linearSpecularLOD(value: boolean);
  35398. /**
  35399. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35400. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35401. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35402. */
  35403. get irradianceTexture(): Nullable<BaseTexture>;
  35404. set irradianceTexture(value: Nullable<BaseTexture>);
  35405. /**
  35406. * Define if the texture is a render target.
  35407. */
  35408. isRenderTarget: boolean;
  35409. /**
  35410. * Define the unique id of the texture in the scene.
  35411. */
  35412. get uid(): string;
  35413. /** @hidden */
  35414. _prefiltered: boolean;
  35415. /**
  35416. * Return a string representation of the texture.
  35417. * @returns the texture as a string
  35418. */
  35419. toString(): string;
  35420. /**
  35421. * Get the class name of the texture.
  35422. * @returns "BaseTexture"
  35423. */
  35424. getClassName(): string;
  35425. /**
  35426. * Define the list of animation attached to the texture.
  35427. */
  35428. animations: import("babylonjs/Animations/animation").Animation[];
  35429. /**
  35430. * An event triggered when the texture is disposed.
  35431. */
  35432. onDisposeObservable: Observable<BaseTexture>;
  35433. private _onDisposeObserver;
  35434. /**
  35435. * Callback triggered when the texture has been disposed.
  35436. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35437. */
  35438. set onDispose(callback: () => void);
  35439. /**
  35440. * Define the current state of the loading sequence when in delayed load mode.
  35441. */
  35442. delayLoadState: number;
  35443. protected _scene: Nullable<Scene>;
  35444. protected _engine: Nullable<ThinEngine>;
  35445. /** @hidden */
  35446. _texture: Nullable<InternalTexture>;
  35447. private _uid;
  35448. /**
  35449. * Define if the texture is preventinga material to render or not.
  35450. * If not and the texture is not ready, the engine will use a default black texture instead.
  35451. */
  35452. get isBlocking(): boolean;
  35453. /**
  35454. * Instantiates a new BaseTexture.
  35455. * Base class of all the textures in babylon.
  35456. * It groups all the common properties the materials, post process, lights... might need
  35457. * in order to make a correct use of the texture.
  35458. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35459. */
  35460. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35461. /**
  35462. * Get the scene the texture belongs to.
  35463. * @returns the scene or null if undefined
  35464. */
  35465. getScene(): Nullable<Scene>;
  35466. /** @hidden */
  35467. protected _getEngine(): Nullable<ThinEngine>;
  35468. /**
  35469. * Get the texture transform matrix used to offset tile the texture for istance.
  35470. * @returns the transformation matrix
  35471. */
  35472. getTextureMatrix(): Matrix;
  35473. /**
  35474. * Get the texture reflection matrix used to rotate/transform the reflection.
  35475. * @returns the reflection matrix
  35476. */
  35477. getReflectionTextureMatrix(): Matrix;
  35478. /**
  35479. * Get the underlying lower level texture from Babylon.
  35480. * @returns the insternal texture
  35481. */
  35482. getInternalTexture(): Nullable<InternalTexture>;
  35483. /**
  35484. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35485. * @returns true if ready or not blocking
  35486. */
  35487. isReadyOrNotBlocking(): boolean;
  35488. /**
  35489. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35490. * @returns true if fully ready
  35491. */
  35492. isReady(): boolean;
  35493. private _cachedSize;
  35494. /**
  35495. * Get the size of the texture.
  35496. * @returns the texture size.
  35497. */
  35498. getSize(): ISize;
  35499. /**
  35500. * Get the base size of the texture.
  35501. * It can be different from the size if the texture has been resized for POT for instance
  35502. * @returns the base size
  35503. */
  35504. getBaseSize(): ISize;
  35505. /**
  35506. * Update the sampling mode of the texture.
  35507. * Default is Trilinear mode.
  35508. *
  35509. * | Value | Type | Description |
  35510. * | ----- | ------------------ | ----------- |
  35511. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35512. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35513. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35514. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35515. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35516. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35517. * | 7 | NEAREST_LINEAR | |
  35518. * | 8 | NEAREST_NEAREST | |
  35519. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35520. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35521. * | 11 | LINEAR_LINEAR | |
  35522. * | 12 | LINEAR_NEAREST | |
  35523. *
  35524. * > _mag_: magnification filter (close to the viewer)
  35525. * > _min_: minification filter (far from the viewer)
  35526. * > _mip_: filter used between mip map levels
  35527. *@param samplingMode Define the new sampling mode of the texture
  35528. */
  35529. updateSamplingMode(samplingMode: number): void;
  35530. /**
  35531. * Scales the texture if is `canRescale()`
  35532. * @param ratio the resize factor we want to use to rescale
  35533. */
  35534. scale(ratio: number): void;
  35535. /**
  35536. * Get if the texture can rescale.
  35537. */
  35538. get canRescale(): boolean;
  35539. /** @hidden */
  35540. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35541. /** @hidden */
  35542. _rebuild(): void;
  35543. /**
  35544. * Triggers the load sequence in delayed load mode.
  35545. */
  35546. delayLoad(): void;
  35547. /**
  35548. * Clones the texture.
  35549. * @returns the cloned texture
  35550. */
  35551. clone(): Nullable<BaseTexture>;
  35552. /**
  35553. * Get the texture underlying type (INT, FLOAT...)
  35554. */
  35555. get textureType(): number;
  35556. /**
  35557. * Get the texture underlying format (RGB, RGBA...)
  35558. */
  35559. get textureFormat(): number;
  35560. /**
  35561. * Indicates that textures need to be re-calculated for all materials
  35562. */
  35563. protected _markAllSubMeshesAsTexturesDirty(): void;
  35564. /**
  35565. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35566. * This will returns an RGBA array buffer containing either in values (0-255) or
  35567. * float values (0-1) depending of the underlying buffer type.
  35568. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35569. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35570. * @param buffer defines a user defined buffer to fill with data (can be null)
  35571. * @returns The Array buffer containing the pixels data.
  35572. */
  35573. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35574. /**
  35575. * Release and destroy the underlying lower level texture aka internalTexture.
  35576. */
  35577. releaseInternalTexture(): void;
  35578. /** @hidden */
  35579. get _lodTextureHigh(): Nullable<BaseTexture>;
  35580. /** @hidden */
  35581. get _lodTextureMid(): Nullable<BaseTexture>;
  35582. /** @hidden */
  35583. get _lodTextureLow(): Nullable<BaseTexture>;
  35584. /**
  35585. * Dispose the texture and release its associated resources.
  35586. */
  35587. dispose(): void;
  35588. /**
  35589. * Serialize the texture into a JSON representation that can be parsed later on.
  35590. * @returns the JSON representation of the texture
  35591. */
  35592. serialize(): any;
  35593. /**
  35594. * Helper function to be called back once a list of texture contains only ready textures.
  35595. * @param textures Define the list of textures to wait for
  35596. * @param callback Define the callback triggered once the entire list will be ready
  35597. */
  35598. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35599. private static _isScene;
  35600. }
  35601. }
  35602. declare module "babylonjs/Materials/effect" {
  35603. import { Observable } from "babylonjs/Misc/observable";
  35604. import { Nullable } from "babylonjs/types";
  35605. import { IDisposable } from "babylonjs/scene";
  35606. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35607. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35608. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35609. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35610. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35611. import { Engine } from "babylonjs/Engines/engine";
  35612. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35615. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35616. /**
  35617. * Options to be used when creating an effect.
  35618. */
  35619. export interface IEffectCreationOptions {
  35620. /**
  35621. * Atrributes that will be used in the shader.
  35622. */
  35623. attributes: string[];
  35624. /**
  35625. * Uniform varible names that will be set in the shader.
  35626. */
  35627. uniformsNames: string[];
  35628. /**
  35629. * Uniform buffer variable names that will be set in the shader.
  35630. */
  35631. uniformBuffersNames: string[];
  35632. /**
  35633. * Sampler texture variable names that will be set in the shader.
  35634. */
  35635. samplers: string[];
  35636. /**
  35637. * Define statements that will be set in the shader.
  35638. */
  35639. defines: any;
  35640. /**
  35641. * Possible fallbacks for this effect to improve performance when needed.
  35642. */
  35643. fallbacks: Nullable<IEffectFallbacks>;
  35644. /**
  35645. * Callback that will be called when the shader is compiled.
  35646. */
  35647. onCompiled: Nullable<(effect: Effect) => void>;
  35648. /**
  35649. * Callback that will be called if an error occurs during shader compilation.
  35650. */
  35651. onError: Nullable<(effect: Effect, errors: string) => void>;
  35652. /**
  35653. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35654. */
  35655. indexParameters?: any;
  35656. /**
  35657. * Max number of lights that can be used in the shader.
  35658. */
  35659. maxSimultaneousLights?: number;
  35660. /**
  35661. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35662. */
  35663. transformFeedbackVaryings?: Nullable<string[]>;
  35664. /**
  35665. * 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
  35666. */
  35667. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35668. /**
  35669. * Is this effect rendering to several color attachments ?
  35670. */
  35671. multiTarget?: boolean;
  35672. }
  35673. /**
  35674. * Effect containing vertex and fragment shader that can be executed on an object.
  35675. */
  35676. export class Effect implements IDisposable {
  35677. /**
  35678. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35679. */
  35680. static ShadersRepository: string;
  35681. /**
  35682. * Enable logging of the shader code when a compilation error occurs
  35683. */
  35684. static LogShaderCodeOnCompilationError: boolean;
  35685. /**
  35686. * Name of the effect.
  35687. */
  35688. name: any;
  35689. /**
  35690. * String container all the define statements that should be set on the shader.
  35691. */
  35692. defines: string;
  35693. /**
  35694. * Callback that will be called when the shader is compiled.
  35695. */
  35696. onCompiled: Nullable<(effect: Effect) => void>;
  35697. /**
  35698. * Callback that will be called if an error occurs during shader compilation.
  35699. */
  35700. onError: Nullable<(effect: Effect, errors: string) => void>;
  35701. /**
  35702. * Callback that will be called when effect is bound.
  35703. */
  35704. onBind: Nullable<(effect: Effect) => void>;
  35705. /**
  35706. * Unique ID of the effect.
  35707. */
  35708. uniqueId: number;
  35709. /**
  35710. * Observable that will be called when the shader is compiled.
  35711. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35712. */
  35713. onCompileObservable: Observable<Effect>;
  35714. /**
  35715. * Observable that will be called if an error occurs during shader compilation.
  35716. */
  35717. onErrorObservable: Observable<Effect>;
  35718. /** @hidden */
  35719. _onBindObservable: Nullable<Observable<Effect>>;
  35720. /**
  35721. * @hidden
  35722. * Specifies if the effect was previously ready
  35723. */
  35724. _wasPreviouslyReady: boolean;
  35725. /**
  35726. * Observable that will be called when effect is bound.
  35727. */
  35728. get onBindObservable(): Observable<Effect>;
  35729. /** @hidden */
  35730. _bonesComputationForcedToCPU: boolean;
  35731. /** @hidden */
  35732. _multiTarget: boolean;
  35733. private static _uniqueIdSeed;
  35734. private _engine;
  35735. private _uniformBuffersNames;
  35736. private _uniformBuffersNamesList;
  35737. private _uniformsNames;
  35738. private _samplerList;
  35739. private _samplers;
  35740. private _isReady;
  35741. private _compilationError;
  35742. private _allFallbacksProcessed;
  35743. private _attributesNames;
  35744. private _attributes;
  35745. private _attributeLocationByName;
  35746. private _uniforms;
  35747. /**
  35748. * Key for the effect.
  35749. * @hidden
  35750. */
  35751. _key: string;
  35752. private _indexParameters;
  35753. private _fallbacks;
  35754. private _vertexSourceCode;
  35755. private _fragmentSourceCode;
  35756. private _vertexSourceCodeOverride;
  35757. private _fragmentSourceCodeOverride;
  35758. private _transformFeedbackVaryings;
  35759. /**
  35760. * Compiled shader to webGL program.
  35761. * @hidden
  35762. */
  35763. _pipelineContext: Nullable<IPipelineContext>;
  35764. private _valueCache;
  35765. private static _baseCache;
  35766. /**
  35767. * Instantiates an effect.
  35768. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35769. * @param baseName Name of the effect.
  35770. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35771. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35772. * @param samplers List of sampler variables that will be passed to the shader.
  35773. * @param engine Engine to be used to render the effect
  35774. * @param defines Define statements to be added to the shader.
  35775. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35776. * @param onCompiled Callback that will be called when the shader is compiled.
  35777. * @param onError Callback that will be called if an error occurs during shader compilation.
  35778. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35779. */
  35780. 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);
  35781. private _useFinalCode;
  35782. /**
  35783. * Unique key for this effect
  35784. */
  35785. get key(): string;
  35786. /**
  35787. * If the effect has been compiled and prepared.
  35788. * @returns if the effect is compiled and prepared.
  35789. */
  35790. isReady(): boolean;
  35791. private _isReadyInternal;
  35792. /**
  35793. * The engine the effect was initialized with.
  35794. * @returns the engine.
  35795. */
  35796. getEngine(): Engine;
  35797. /**
  35798. * The pipeline context for this effect
  35799. * @returns the associated pipeline context
  35800. */
  35801. getPipelineContext(): Nullable<IPipelineContext>;
  35802. /**
  35803. * The set of names of attribute variables for the shader.
  35804. * @returns An array of attribute names.
  35805. */
  35806. getAttributesNames(): string[];
  35807. /**
  35808. * Returns the attribute at the given index.
  35809. * @param index The index of the attribute.
  35810. * @returns The location of the attribute.
  35811. */
  35812. getAttributeLocation(index: number): number;
  35813. /**
  35814. * Returns the attribute based on the name of the variable.
  35815. * @param name of the attribute to look up.
  35816. * @returns the attribute location.
  35817. */
  35818. getAttributeLocationByName(name: string): number;
  35819. /**
  35820. * The number of attributes.
  35821. * @returns the numnber of attributes.
  35822. */
  35823. getAttributesCount(): number;
  35824. /**
  35825. * Gets the index of a uniform variable.
  35826. * @param uniformName of the uniform to look up.
  35827. * @returns the index.
  35828. */
  35829. getUniformIndex(uniformName: string): number;
  35830. /**
  35831. * Returns the attribute based on the name of the variable.
  35832. * @param uniformName of the uniform to look up.
  35833. * @returns the location of the uniform.
  35834. */
  35835. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35836. /**
  35837. * Returns an array of sampler variable names
  35838. * @returns The array of sampler variable names.
  35839. */
  35840. getSamplers(): string[];
  35841. /**
  35842. * Returns an array of uniform variable names
  35843. * @returns The array of uniform variable names.
  35844. */
  35845. getUniformNames(): string[];
  35846. /**
  35847. * Returns an array of uniform buffer variable names
  35848. * @returns The array of uniform buffer variable names.
  35849. */
  35850. getUniformBuffersNames(): string[];
  35851. /**
  35852. * Returns the index parameters used to create the effect
  35853. * @returns The index parameters object
  35854. */
  35855. getIndexParameters(): any;
  35856. /**
  35857. * The error from the last compilation.
  35858. * @returns the error string.
  35859. */
  35860. getCompilationError(): string;
  35861. /**
  35862. * Gets a boolean indicating that all fallbacks were used during compilation
  35863. * @returns true if all fallbacks were used
  35864. */
  35865. allFallbacksProcessed(): boolean;
  35866. /**
  35867. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35868. * @param func The callback to be used.
  35869. */
  35870. executeWhenCompiled(func: (effect: Effect) => void): void;
  35871. private _checkIsReady;
  35872. private _loadShader;
  35873. /**
  35874. * Gets the vertex shader source code of this effect
  35875. */
  35876. get vertexSourceCode(): string;
  35877. /**
  35878. * Gets the fragment shader source code of this effect
  35879. */
  35880. get fragmentSourceCode(): string;
  35881. /**
  35882. * Recompiles the webGL program
  35883. * @param vertexSourceCode The source code for the vertex shader.
  35884. * @param fragmentSourceCode The source code for the fragment shader.
  35885. * @param onCompiled Callback called when completed.
  35886. * @param onError Callback called on error.
  35887. * @hidden
  35888. */
  35889. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35890. /**
  35891. * Prepares the effect
  35892. * @hidden
  35893. */
  35894. _prepareEffect(): void;
  35895. private _getShaderCodeAndErrorLine;
  35896. private _processCompilationErrors;
  35897. /**
  35898. * Checks if the effect is supported. (Must be called after compilation)
  35899. */
  35900. get isSupported(): boolean;
  35901. /**
  35902. * Binds a texture to the engine to be used as output of the shader.
  35903. * @param channel Name of the output variable.
  35904. * @param texture Texture to bind.
  35905. * @hidden
  35906. */
  35907. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35908. /**
  35909. * Sets a texture on the engine to be used in the shader.
  35910. * @param channel Name of the sampler variable.
  35911. * @param texture Texture to set.
  35912. */
  35913. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35914. /**
  35915. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35916. * @param channel Name of the sampler variable.
  35917. * @param texture Texture to set.
  35918. */
  35919. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35920. /**
  35921. * Sets an array of textures on the engine to be used in the shader.
  35922. * @param channel Name of the variable.
  35923. * @param textures Textures to set.
  35924. */
  35925. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35926. /**
  35927. * 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)
  35928. * @param channel Name of the sampler variable.
  35929. * @param postProcess Post process to get the input texture from.
  35930. */
  35931. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35932. /**
  35933. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35934. * 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)
  35935. * @param channel Name of the sampler variable.
  35936. * @param postProcess Post process to get the output texture from.
  35937. */
  35938. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35939. /** @hidden */
  35940. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35941. /** @hidden */
  35942. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35943. /** @hidden */
  35944. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35945. /** @hidden */
  35946. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35947. /**
  35948. * Binds a buffer to a uniform.
  35949. * @param buffer Buffer to bind.
  35950. * @param name Name of the uniform variable to bind to.
  35951. */
  35952. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35953. /**
  35954. * Binds block to a uniform.
  35955. * @param blockName Name of the block to bind.
  35956. * @param index Index to bind.
  35957. */
  35958. bindUniformBlock(blockName: string, index: number): void;
  35959. /**
  35960. * Sets an interger value on a uniform variable.
  35961. * @param uniformName Name of the variable.
  35962. * @param value Value to be set.
  35963. * @returns this effect.
  35964. */
  35965. setInt(uniformName: string, value: number): Effect;
  35966. /**
  35967. * Sets an int array on a uniform variable.
  35968. * @param uniformName Name of the variable.
  35969. * @param array array to be set.
  35970. * @returns this effect.
  35971. */
  35972. setIntArray(uniformName: string, array: Int32Array): Effect;
  35973. /**
  35974. * 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)
  35975. * @param uniformName Name of the variable.
  35976. * @param array array to be set.
  35977. * @returns this effect.
  35978. */
  35979. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35980. /**
  35981. * 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)
  35982. * @param uniformName Name of the variable.
  35983. * @param array array to be set.
  35984. * @returns this effect.
  35985. */
  35986. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35987. /**
  35988. * 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)
  35989. * @param uniformName Name of the variable.
  35990. * @param array array to be set.
  35991. * @returns this effect.
  35992. */
  35993. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35994. /**
  35995. * Sets an float array on a uniform variable.
  35996. * @param uniformName Name of the variable.
  35997. * @param array array to be set.
  35998. * @returns this effect.
  35999. */
  36000. setFloatArray(uniformName: string, array: Float32Array): Effect;
  36001. /**
  36002. * 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)
  36003. * @param uniformName Name of the variable.
  36004. * @param array array to be set.
  36005. * @returns this effect.
  36006. */
  36007. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  36008. /**
  36009. * 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)
  36010. * @param uniformName Name of the variable.
  36011. * @param array array to be set.
  36012. * @returns this effect.
  36013. */
  36014. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  36015. /**
  36016. * 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)
  36017. * @param uniformName Name of the variable.
  36018. * @param array array to be set.
  36019. * @returns this effect.
  36020. */
  36021. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  36022. /**
  36023. * Sets an array on a uniform variable.
  36024. * @param uniformName Name of the variable.
  36025. * @param array array to be set.
  36026. * @returns this effect.
  36027. */
  36028. setArray(uniformName: string, array: number[]): Effect;
  36029. /**
  36030. * 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)
  36031. * @param uniformName Name of the variable.
  36032. * @param array array to be set.
  36033. * @returns this effect.
  36034. */
  36035. setArray2(uniformName: string, array: number[]): Effect;
  36036. /**
  36037. * 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)
  36038. * @param uniformName Name of the variable.
  36039. * @param array array to be set.
  36040. * @returns this effect.
  36041. */
  36042. setArray3(uniformName: string, array: number[]): Effect;
  36043. /**
  36044. * 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)
  36045. * @param uniformName Name of the variable.
  36046. * @param array array to be set.
  36047. * @returns this effect.
  36048. */
  36049. setArray4(uniformName: string, array: number[]): Effect;
  36050. /**
  36051. * Sets matrices on a uniform variable.
  36052. * @param uniformName Name of the variable.
  36053. * @param matrices matrices to be set.
  36054. * @returns this effect.
  36055. */
  36056. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  36057. /**
  36058. * Sets matrix on a uniform variable.
  36059. * @param uniformName Name of the variable.
  36060. * @param matrix matrix to be set.
  36061. * @returns this effect.
  36062. */
  36063. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  36064. /**
  36065. * 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)
  36066. * @param uniformName Name of the variable.
  36067. * @param matrix matrix to be set.
  36068. * @returns this effect.
  36069. */
  36070. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36071. /**
  36072. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  36073. * @param uniformName Name of the variable.
  36074. * @param matrix matrix to be set.
  36075. * @returns this effect.
  36076. */
  36077. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36078. /**
  36079. * Sets a float on a uniform variable.
  36080. * @param uniformName Name of the variable.
  36081. * @param value value to be set.
  36082. * @returns this effect.
  36083. */
  36084. setFloat(uniformName: string, value: number): Effect;
  36085. /**
  36086. * Sets a boolean on a uniform variable.
  36087. * @param uniformName Name of the variable.
  36088. * @param bool value to be set.
  36089. * @returns this effect.
  36090. */
  36091. setBool(uniformName: string, bool: boolean): Effect;
  36092. /**
  36093. * Sets a Vector2 on a uniform variable.
  36094. * @param uniformName Name of the variable.
  36095. * @param vector2 vector2 to be set.
  36096. * @returns this effect.
  36097. */
  36098. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  36099. /**
  36100. * Sets a float2 on a uniform variable.
  36101. * @param uniformName Name of the variable.
  36102. * @param x First float in float2.
  36103. * @param y Second float in float2.
  36104. * @returns this effect.
  36105. */
  36106. setFloat2(uniformName: string, x: number, y: number): Effect;
  36107. /**
  36108. * Sets a Vector3 on a uniform variable.
  36109. * @param uniformName Name of the variable.
  36110. * @param vector3 Value to be set.
  36111. * @returns this effect.
  36112. */
  36113. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36114. /**
  36115. * Sets a float3 on a uniform variable.
  36116. * @param uniformName Name of the variable.
  36117. * @param x First float in float3.
  36118. * @param y Second float in float3.
  36119. * @param z Third float in float3.
  36120. * @returns this effect.
  36121. */
  36122. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36123. /**
  36124. * Sets a Vector4 on a uniform variable.
  36125. * @param uniformName Name of the variable.
  36126. * @param vector4 Value to be set.
  36127. * @returns this effect.
  36128. */
  36129. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36130. /**
  36131. * Sets a float4 on a uniform variable.
  36132. * @param uniformName Name of the variable.
  36133. * @param x First float in float4.
  36134. * @param y Second float in float4.
  36135. * @param z Third float in float4.
  36136. * @param w Fourth float in float4.
  36137. * @returns this effect.
  36138. */
  36139. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36140. /**
  36141. * Sets a Color3 on a uniform variable.
  36142. * @param uniformName Name of the variable.
  36143. * @param color3 Value to be set.
  36144. * @returns this effect.
  36145. */
  36146. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36147. /**
  36148. * Sets a Color4 on a uniform variable.
  36149. * @param uniformName Name of the variable.
  36150. * @param color3 Value to be set.
  36151. * @param alpha Alpha value to be set.
  36152. * @returns this effect.
  36153. */
  36154. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36155. /**
  36156. * Sets a Color4 on a uniform variable
  36157. * @param uniformName defines the name of the variable
  36158. * @param color4 defines the value to be set
  36159. * @returns this effect.
  36160. */
  36161. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36162. /** Release all associated resources */
  36163. dispose(): void;
  36164. /**
  36165. * This function will add a new shader to the shader store
  36166. * @param name the name of the shader
  36167. * @param pixelShader optional pixel shader content
  36168. * @param vertexShader optional vertex shader content
  36169. */
  36170. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36171. /**
  36172. * Store of each shader (The can be looked up using effect.key)
  36173. */
  36174. static ShadersStore: {
  36175. [key: string]: string;
  36176. };
  36177. /**
  36178. * Store of each included file for a shader (The can be looked up using effect.key)
  36179. */
  36180. static IncludesShadersStore: {
  36181. [key: string]: string;
  36182. };
  36183. /**
  36184. * Resets the cache of effects.
  36185. */
  36186. static ResetCache(): void;
  36187. }
  36188. }
  36189. declare module "babylonjs/Engines/engineCapabilities" {
  36190. /**
  36191. * Interface used to describe the capabilities of the engine relatively to the current browser
  36192. */
  36193. export interface EngineCapabilities {
  36194. /** Maximum textures units per fragment shader */
  36195. maxTexturesImageUnits: number;
  36196. /** Maximum texture units per vertex shader */
  36197. maxVertexTextureImageUnits: number;
  36198. /** Maximum textures units in the entire pipeline */
  36199. maxCombinedTexturesImageUnits: number;
  36200. /** Maximum texture size */
  36201. maxTextureSize: number;
  36202. /** Maximum texture samples */
  36203. maxSamples?: number;
  36204. /** Maximum cube texture size */
  36205. maxCubemapTextureSize: number;
  36206. /** Maximum render texture size */
  36207. maxRenderTextureSize: number;
  36208. /** Maximum number of vertex attributes */
  36209. maxVertexAttribs: number;
  36210. /** Maximum number of varyings */
  36211. maxVaryingVectors: number;
  36212. /** Maximum number of uniforms per vertex shader */
  36213. maxVertexUniformVectors: number;
  36214. /** Maximum number of uniforms per fragment shader */
  36215. maxFragmentUniformVectors: number;
  36216. /** Defines if standard derivates (dx/dy) are supported */
  36217. standardDerivatives: boolean;
  36218. /** Defines if s3tc texture compression is supported */
  36219. s3tc?: WEBGL_compressed_texture_s3tc;
  36220. /** Defines if pvrtc texture compression is supported */
  36221. pvrtc: any;
  36222. /** Defines if etc1 texture compression is supported */
  36223. etc1: any;
  36224. /** Defines if etc2 texture compression is supported */
  36225. etc2: any;
  36226. /** Defines if astc texture compression is supported */
  36227. astc: any;
  36228. /** Defines if bptc texture compression is supported */
  36229. bptc: any;
  36230. /** Defines if float textures are supported */
  36231. textureFloat: boolean;
  36232. /** Defines if vertex array objects are supported */
  36233. vertexArrayObject: boolean;
  36234. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36235. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36236. /** Gets the maximum level of anisotropy supported */
  36237. maxAnisotropy: number;
  36238. /** Defines if instancing is supported */
  36239. instancedArrays: boolean;
  36240. /** Defines if 32 bits indices are supported */
  36241. uintIndices: boolean;
  36242. /** Defines if high precision shaders are supported */
  36243. highPrecisionShaderSupported: boolean;
  36244. /** Defines if depth reading in the fragment shader is supported */
  36245. fragmentDepthSupported: boolean;
  36246. /** Defines if float texture linear filtering is supported*/
  36247. textureFloatLinearFiltering: boolean;
  36248. /** Defines if rendering to float textures is supported */
  36249. textureFloatRender: boolean;
  36250. /** Defines if half float textures are supported*/
  36251. textureHalfFloat: boolean;
  36252. /** Defines if half float texture linear filtering is supported*/
  36253. textureHalfFloatLinearFiltering: boolean;
  36254. /** Defines if rendering to half float textures is supported */
  36255. textureHalfFloatRender: boolean;
  36256. /** Defines if textureLOD shader command is supported */
  36257. textureLOD: boolean;
  36258. /** Defines if draw buffers extension is supported */
  36259. drawBuffersExtension: boolean;
  36260. /** Defines if depth textures are supported */
  36261. depthTextureExtension: boolean;
  36262. /** Defines if float color buffer are supported */
  36263. colorBufferFloat: boolean;
  36264. /** Gets disjoint timer query extension (null if not supported) */
  36265. timerQuery?: EXT_disjoint_timer_query;
  36266. /** Defines if timestamp can be used with timer query */
  36267. canUseTimestampForTimerQuery: boolean;
  36268. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36269. multiview?: any;
  36270. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36271. oculusMultiview?: any;
  36272. /** Function used to let the system compiles shaders in background */
  36273. parallelShaderCompile?: {
  36274. COMPLETION_STATUS_KHR: number;
  36275. };
  36276. /** Max number of texture samples for MSAA */
  36277. maxMSAASamples: number;
  36278. /** Defines if the blend min max extension is supported */
  36279. blendMinMax: boolean;
  36280. }
  36281. }
  36282. declare module "babylonjs/States/depthCullingState" {
  36283. import { Nullable } from "babylonjs/types";
  36284. /**
  36285. * @hidden
  36286. **/
  36287. export class DepthCullingState {
  36288. private _isDepthTestDirty;
  36289. private _isDepthMaskDirty;
  36290. private _isDepthFuncDirty;
  36291. private _isCullFaceDirty;
  36292. private _isCullDirty;
  36293. private _isZOffsetDirty;
  36294. private _isFrontFaceDirty;
  36295. private _depthTest;
  36296. private _depthMask;
  36297. private _depthFunc;
  36298. private _cull;
  36299. private _cullFace;
  36300. private _zOffset;
  36301. private _frontFace;
  36302. /**
  36303. * Initializes the state.
  36304. */
  36305. constructor();
  36306. get isDirty(): boolean;
  36307. get zOffset(): number;
  36308. set zOffset(value: number);
  36309. get cullFace(): Nullable<number>;
  36310. set cullFace(value: Nullable<number>);
  36311. get cull(): Nullable<boolean>;
  36312. set cull(value: Nullable<boolean>);
  36313. get depthFunc(): Nullable<number>;
  36314. set depthFunc(value: Nullable<number>);
  36315. get depthMask(): boolean;
  36316. set depthMask(value: boolean);
  36317. get depthTest(): boolean;
  36318. set depthTest(value: boolean);
  36319. get frontFace(): Nullable<number>;
  36320. set frontFace(value: Nullable<number>);
  36321. reset(): void;
  36322. apply(gl: WebGLRenderingContext): void;
  36323. }
  36324. }
  36325. declare module "babylonjs/States/stencilState" {
  36326. /**
  36327. * @hidden
  36328. **/
  36329. export class StencilState {
  36330. /** 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 */
  36331. static readonly ALWAYS: number;
  36332. /** Passed to stencilOperation to specify that stencil value must be kept */
  36333. static readonly KEEP: number;
  36334. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36335. static readonly REPLACE: number;
  36336. private _isStencilTestDirty;
  36337. private _isStencilMaskDirty;
  36338. private _isStencilFuncDirty;
  36339. private _isStencilOpDirty;
  36340. private _stencilTest;
  36341. private _stencilMask;
  36342. private _stencilFunc;
  36343. private _stencilFuncRef;
  36344. private _stencilFuncMask;
  36345. private _stencilOpStencilFail;
  36346. private _stencilOpDepthFail;
  36347. private _stencilOpStencilDepthPass;
  36348. get isDirty(): boolean;
  36349. get stencilFunc(): number;
  36350. set stencilFunc(value: number);
  36351. get stencilFuncRef(): number;
  36352. set stencilFuncRef(value: number);
  36353. get stencilFuncMask(): number;
  36354. set stencilFuncMask(value: number);
  36355. get stencilOpStencilFail(): number;
  36356. set stencilOpStencilFail(value: number);
  36357. get stencilOpDepthFail(): number;
  36358. set stencilOpDepthFail(value: number);
  36359. get stencilOpStencilDepthPass(): number;
  36360. set stencilOpStencilDepthPass(value: number);
  36361. get stencilMask(): number;
  36362. set stencilMask(value: number);
  36363. get stencilTest(): boolean;
  36364. set stencilTest(value: boolean);
  36365. constructor();
  36366. reset(): void;
  36367. apply(gl: WebGLRenderingContext): void;
  36368. }
  36369. }
  36370. declare module "babylonjs/States/alphaCullingState" {
  36371. /**
  36372. * @hidden
  36373. **/
  36374. export class AlphaState {
  36375. private _isAlphaBlendDirty;
  36376. private _isBlendFunctionParametersDirty;
  36377. private _isBlendEquationParametersDirty;
  36378. private _isBlendConstantsDirty;
  36379. private _alphaBlend;
  36380. private _blendFunctionParameters;
  36381. private _blendEquationParameters;
  36382. private _blendConstants;
  36383. /**
  36384. * Initializes the state.
  36385. */
  36386. constructor();
  36387. get isDirty(): boolean;
  36388. get alphaBlend(): boolean;
  36389. set alphaBlend(value: boolean);
  36390. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36391. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36392. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36393. reset(): void;
  36394. apply(gl: WebGLRenderingContext): void;
  36395. }
  36396. }
  36397. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36398. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36399. /** @hidden */
  36400. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36401. attributeProcessor(attribute: string): string;
  36402. varyingProcessor(varying: string, isFragment: boolean): string;
  36403. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36404. }
  36405. }
  36406. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36407. /**
  36408. * Interface for attribute information associated with buffer instanciation
  36409. */
  36410. export interface InstancingAttributeInfo {
  36411. /**
  36412. * Name of the GLSL attribute
  36413. * if attribute index is not specified, this is used to retrieve the index from the effect
  36414. */
  36415. attributeName: string;
  36416. /**
  36417. * Index/offset of the attribute in the vertex shader
  36418. * if not specified, this will be computes from the name.
  36419. */
  36420. index?: number;
  36421. /**
  36422. * size of the attribute, 1, 2, 3 or 4
  36423. */
  36424. attributeSize: number;
  36425. /**
  36426. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36427. */
  36428. offset: number;
  36429. /**
  36430. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36431. * default to 1
  36432. */
  36433. divisor?: number;
  36434. /**
  36435. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36436. * default is FLOAT
  36437. */
  36438. attributeType?: number;
  36439. /**
  36440. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36441. */
  36442. normalized?: boolean;
  36443. }
  36444. }
  36445. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36447. import { Nullable } from "babylonjs/types";
  36448. module "babylonjs/Engines/thinEngine" {
  36449. interface ThinEngine {
  36450. /**
  36451. * Update a video texture
  36452. * @param texture defines the texture to update
  36453. * @param video defines the video element to use
  36454. * @param invertY defines if data must be stored with Y axis inverted
  36455. */
  36456. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36457. }
  36458. }
  36459. }
  36460. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36462. import { Nullable } from "babylonjs/types";
  36463. module "babylonjs/Engines/thinEngine" {
  36464. interface ThinEngine {
  36465. /**
  36466. * Creates a dynamic texture
  36467. * @param width defines the width of the texture
  36468. * @param height defines the height of the texture
  36469. * @param generateMipMaps defines if the engine should generate the mip levels
  36470. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36471. * @returns the dynamic texture inside an InternalTexture
  36472. */
  36473. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36474. /**
  36475. * Update the content of a dynamic texture
  36476. * @param texture defines the texture to update
  36477. * @param canvas defines the canvas containing the source
  36478. * @param invertY defines if data must be stored with Y axis inverted
  36479. * @param premulAlpha defines if alpha is stored as premultiplied
  36480. * @param format defines the format of the data
  36481. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36482. */
  36483. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36484. }
  36485. }
  36486. }
  36487. declare module "babylonjs/Materials/Textures/videoTexture" {
  36488. import { Observable } from "babylonjs/Misc/observable";
  36489. import { Nullable } from "babylonjs/types";
  36490. import { Scene } from "babylonjs/scene";
  36491. import { Texture } from "babylonjs/Materials/Textures/texture";
  36492. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36494. /**
  36495. * Settings for finer control over video usage
  36496. */
  36497. export interface VideoTextureSettings {
  36498. /**
  36499. * Applies `autoplay` to video, if specified
  36500. */
  36501. autoPlay?: boolean;
  36502. /**
  36503. * Applies `loop` to video, if specified
  36504. */
  36505. loop?: boolean;
  36506. /**
  36507. * Automatically updates internal texture from video at every frame in the render loop
  36508. */
  36509. autoUpdateTexture: boolean;
  36510. /**
  36511. * Image src displayed during the video loading or until the user interacts with the video.
  36512. */
  36513. poster?: string;
  36514. }
  36515. /**
  36516. * If you want to display a video in your scene, this is the special texture for that.
  36517. * This special texture works similar to other textures, with the exception of a few parameters.
  36518. * @see https://doc.babylonjs.com/how_to/video_texture
  36519. */
  36520. export class VideoTexture extends Texture {
  36521. /**
  36522. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36523. */
  36524. readonly autoUpdateTexture: boolean;
  36525. /**
  36526. * The video instance used by the texture internally
  36527. */
  36528. readonly video: HTMLVideoElement;
  36529. private _onUserActionRequestedObservable;
  36530. /**
  36531. * Event triggerd when a dom action is required by the user to play the video.
  36532. * This happens due to recent changes in browser policies preventing video to auto start.
  36533. */
  36534. get onUserActionRequestedObservable(): Observable<Texture>;
  36535. private _generateMipMaps;
  36536. private _stillImageCaptured;
  36537. private _displayingPosterTexture;
  36538. private _settings;
  36539. private _createInternalTextureOnEvent;
  36540. private _frameId;
  36541. private _currentSrc;
  36542. /**
  36543. * Creates a video texture.
  36544. * If you want to display a video in your scene, this is the special texture for that.
  36545. * This special texture works similar to other textures, with the exception of a few parameters.
  36546. * @see https://doc.babylonjs.com/how_to/video_texture
  36547. * @param name optional name, will detect from video source, if not defined
  36548. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36549. * @param scene is obviously the current scene.
  36550. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36551. * @param invertY is false by default but can be used to invert video on Y axis
  36552. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36553. * @param settings allows finer control over video usage
  36554. */
  36555. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36556. private _getName;
  36557. private _getVideo;
  36558. private _createInternalTexture;
  36559. private reset;
  36560. /**
  36561. * @hidden Internal method to initiate `update`.
  36562. */
  36563. _rebuild(): void;
  36564. /**
  36565. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36566. */
  36567. update(): void;
  36568. /**
  36569. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36570. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36571. */
  36572. updateTexture(isVisible: boolean): void;
  36573. protected _updateInternalTexture: () => void;
  36574. /**
  36575. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36576. * @param url New url.
  36577. */
  36578. updateURL(url: string): void;
  36579. /**
  36580. * Clones the texture.
  36581. * @returns the cloned texture
  36582. */
  36583. clone(): VideoTexture;
  36584. /**
  36585. * Dispose the texture and release its associated resources.
  36586. */
  36587. dispose(): void;
  36588. /**
  36589. * Creates a video texture straight from a stream.
  36590. * @param scene Define the scene the texture should be created in
  36591. * @param stream Define the stream the texture should be created from
  36592. * @returns The created video texture as a promise
  36593. */
  36594. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36595. /**
  36596. * Creates a video texture straight from your WebCam video feed.
  36597. * @param scene Define the scene the texture should be created in
  36598. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36599. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36600. * @returns The created video texture as a promise
  36601. */
  36602. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36603. minWidth: number;
  36604. maxWidth: number;
  36605. minHeight: number;
  36606. maxHeight: number;
  36607. deviceId: string;
  36608. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36609. /**
  36610. * Creates a video texture straight from your WebCam video feed.
  36611. * @param scene Define the scene the texture should be created in
  36612. * @param onReady Define a callback to triggered once the texture will be ready
  36613. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36614. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36615. */
  36616. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36617. minWidth: number;
  36618. maxWidth: number;
  36619. minHeight: number;
  36620. maxHeight: number;
  36621. deviceId: string;
  36622. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36623. }
  36624. }
  36625. declare module "babylonjs/Engines/thinEngine" {
  36626. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36627. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36628. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36629. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36630. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36631. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36632. import { Observable } from "babylonjs/Misc/observable";
  36633. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36634. import { StencilState } from "babylonjs/States/stencilState";
  36635. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36637. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36638. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36639. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36640. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36641. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36642. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36643. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36645. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36646. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36647. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36648. import { WebRequest } from "babylonjs/Misc/webRequest";
  36649. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36650. /**
  36651. * Defines the interface used by objects working like Scene
  36652. * @hidden
  36653. */
  36654. export interface ISceneLike {
  36655. _addPendingData(data: any): void;
  36656. _removePendingData(data: any): void;
  36657. offlineProvider: IOfflineProvider;
  36658. }
  36659. /**
  36660. * Information about the current host
  36661. */
  36662. export interface HostInformation {
  36663. /**
  36664. * Defines if the current host is a mobile
  36665. */
  36666. isMobile: boolean;
  36667. }
  36668. /** Interface defining initialization parameters for Engine class */
  36669. export interface EngineOptions extends WebGLContextAttributes {
  36670. /**
  36671. * Defines if the engine should no exceed a specified device ratio
  36672. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36673. */
  36674. limitDeviceRatio?: number;
  36675. /**
  36676. * Defines if webvr should be enabled automatically
  36677. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36678. */
  36679. autoEnableWebVR?: boolean;
  36680. /**
  36681. * Defines if webgl2 should be turned off even if supported
  36682. * @see https://doc.babylonjs.com/features/webgl2
  36683. */
  36684. disableWebGL2Support?: boolean;
  36685. /**
  36686. * Defines if webaudio should be initialized as well
  36687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36688. */
  36689. audioEngine?: boolean;
  36690. /**
  36691. * Defines if animations should run using a deterministic lock step
  36692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36693. */
  36694. deterministicLockstep?: boolean;
  36695. /** Defines the maximum steps to use with deterministic lock step mode */
  36696. lockstepMaxSteps?: number;
  36697. /** Defines the seconds between each deterministic lock step */
  36698. timeStep?: number;
  36699. /**
  36700. * Defines that engine should ignore context lost events
  36701. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36702. */
  36703. doNotHandleContextLost?: boolean;
  36704. /**
  36705. * Defines that engine should ignore modifying touch action attribute and style
  36706. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36707. */
  36708. doNotHandleTouchAction?: boolean;
  36709. /**
  36710. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36711. */
  36712. useHighPrecisionFloats?: boolean;
  36713. /**
  36714. * Make the canvas XR Compatible for XR sessions
  36715. */
  36716. xrCompatible?: boolean;
  36717. /**
  36718. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36719. */
  36720. useHighPrecisionMatrix?: boolean;
  36721. /**
  36722. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  36723. */
  36724. failIfMajorPerformanceCaveat?: boolean;
  36725. }
  36726. /**
  36727. * The base engine class (root of all engines)
  36728. */
  36729. export class ThinEngine {
  36730. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36731. static ExceptionList: ({
  36732. key: string;
  36733. capture: string;
  36734. captureConstraint: number;
  36735. targets: string[];
  36736. } | {
  36737. key: string;
  36738. capture: null;
  36739. captureConstraint: null;
  36740. targets: string[];
  36741. })[];
  36742. /** @hidden */
  36743. static _TextureLoaders: IInternalTextureLoader[];
  36744. /**
  36745. * Returns the current npm package of the sdk
  36746. */
  36747. static get NpmPackage(): string;
  36748. /**
  36749. * Returns the current version of the framework
  36750. */
  36751. static get Version(): string;
  36752. /**
  36753. * Returns a string describing the current engine
  36754. */
  36755. get description(): string;
  36756. /**
  36757. * Gets or sets the epsilon value used by collision engine
  36758. */
  36759. static CollisionsEpsilon: number;
  36760. /**
  36761. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36762. */
  36763. static get ShadersRepository(): string;
  36764. static set ShadersRepository(value: string);
  36765. /** @hidden */
  36766. _shaderProcessor: IShaderProcessor;
  36767. /**
  36768. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36769. */
  36770. forcePOTTextures: boolean;
  36771. /**
  36772. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36773. */
  36774. isFullscreen: boolean;
  36775. /**
  36776. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36777. */
  36778. cullBackFaces: boolean;
  36779. /**
  36780. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36781. */
  36782. renderEvenInBackground: boolean;
  36783. /**
  36784. * Gets or sets a boolean indicating that cache can be kept between frames
  36785. */
  36786. preventCacheWipeBetweenFrames: boolean;
  36787. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36788. validateShaderPrograms: boolean;
  36789. /**
  36790. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36791. * This can provide greater z depth for distant objects.
  36792. */
  36793. useReverseDepthBuffer: boolean;
  36794. /**
  36795. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36796. */
  36797. disableUniformBuffers: boolean;
  36798. /** @hidden */
  36799. _uniformBuffers: UniformBuffer[];
  36800. /**
  36801. * Gets a boolean indicating that the engine supports uniform buffers
  36802. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36803. */
  36804. get supportsUniformBuffers(): boolean;
  36805. /** @hidden */
  36806. _gl: WebGLRenderingContext;
  36807. /** @hidden */
  36808. _webGLVersion: number;
  36809. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36810. protected _windowIsBackground: boolean;
  36811. protected _creationOptions: EngineOptions;
  36812. protected _highPrecisionShadersAllowed: boolean;
  36813. /** @hidden */
  36814. get _shouldUseHighPrecisionShader(): boolean;
  36815. /**
  36816. * Gets a boolean indicating that only power of 2 textures are supported
  36817. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36818. */
  36819. get needPOTTextures(): boolean;
  36820. /** @hidden */
  36821. _badOS: boolean;
  36822. /** @hidden */
  36823. _badDesktopOS: boolean;
  36824. private _hardwareScalingLevel;
  36825. /** @hidden */
  36826. _caps: EngineCapabilities;
  36827. private _isStencilEnable;
  36828. private _glVersion;
  36829. private _glRenderer;
  36830. private _glVendor;
  36831. /** @hidden */
  36832. _videoTextureSupported: boolean;
  36833. protected _renderingQueueLaunched: boolean;
  36834. protected _activeRenderLoops: (() => void)[];
  36835. /**
  36836. * Observable signaled when a context lost event is raised
  36837. */
  36838. onContextLostObservable: Observable<ThinEngine>;
  36839. /**
  36840. * Observable signaled when a context restored event is raised
  36841. */
  36842. onContextRestoredObservable: Observable<ThinEngine>;
  36843. private _onContextLost;
  36844. private _onContextRestored;
  36845. protected _contextWasLost: boolean;
  36846. /** @hidden */
  36847. _doNotHandleContextLost: boolean;
  36848. /**
  36849. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36851. */
  36852. get doNotHandleContextLost(): boolean;
  36853. set doNotHandleContextLost(value: boolean);
  36854. /**
  36855. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36856. */
  36857. disableVertexArrayObjects: boolean;
  36858. /** @hidden */
  36859. protected _colorWrite: boolean;
  36860. /** @hidden */
  36861. protected _colorWriteChanged: boolean;
  36862. /** @hidden */
  36863. protected _depthCullingState: DepthCullingState;
  36864. /** @hidden */
  36865. protected _stencilState: StencilState;
  36866. /** @hidden */
  36867. _alphaState: AlphaState;
  36868. /** @hidden */
  36869. _alphaMode: number;
  36870. /** @hidden */
  36871. _alphaEquation: number;
  36872. /** @hidden */
  36873. _internalTexturesCache: InternalTexture[];
  36874. /** @hidden */
  36875. protected _activeChannel: number;
  36876. private _currentTextureChannel;
  36877. /** @hidden */
  36878. protected _boundTexturesCache: {
  36879. [key: string]: Nullable<InternalTexture>;
  36880. };
  36881. /** @hidden */
  36882. protected _currentEffect: Nullable<Effect>;
  36883. /** @hidden */
  36884. protected _currentProgram: Nullable<WebGLProgram>;
  36885. private _compiledEffects;
  36886. private _vertexAttribArraysEnabled;
  36887. /** @hidden */
  36888. protected _cachedViewport: Nullable<IViewportLike>;
  36889. private _cachedVertexArrayObject;
  36890. /** @hidden */
  36891. protected _cachedVertexBuffers: any;
  36892. /** @hidden */
  36893. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36894. /** @hidden */
  36895. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36896. /** @hidden */
  36897. _currentRenderTarget: Nullable<InternalTexture>;
  36898. private _uintIndicesCurrentlySet;
  36899. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36900. /** @hidden */
  36901. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36902. /** @hidden */
  36903. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36904. private _currentBufferPointers;
  36905. private _currentInstanceLocations;
  36906. private _currentInstanceBuffers;
  36907. private _textureUnits;
  36908. /** @hidden */
  36909. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36910. /** @hidden */
  36911. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36912. /** @hidden */
  36913. _boundRenderFunction: any;
  36914. private _vaoRecordInProgress;
  36915. private _mustWipeVertexAttributes;
  36916. private _emptyTexture;
  36917. private _emptyCubeTexture;
  36918. private _emptyTexture3D;
  36919. private _emptyTexture2DArray;
  36920. /** @hidden */
  36921. _frameHandler: number;
  36922. private _nextFreeTextureSlots;
  36923. private _maxSimultaneousTextures;
  36924. private _activeRequests;
  36925. /** @hidden */
  36926. _transformTextureUrl: Nullable<(url: string) => string>;
  36927. /**
  36928. * Gets information about the current host
  36929. */
  36930. hostInformation: HostInformation;
  36931. protected get _supportsHardwareTextureRescaling(): boolean;
  36932. private _framebufferDimensionsObject;
  36933. /**
  36934. * sets the object from which width and height will be taken from when getting render width and height
  36935. * Will fallback to the gl object
  36936. * @param dimensions the framebuffer width and height that will be used.
  36937. */
  36938. set framebufferDimensionsObject(dimensions: Nullable<{
  36939. framebufferWidth: number;
  36940. framebufferHeight: number;
  36941. }>);
  36942. /**
  36943. * Gets the current viewport
  36944. */
  36945. get currentViewport(): Nullable<IViewportLike>;
  36946. /**
  36947. * Gets the default empty texture
  36948. */
  36949. get emptyTexture(): InternalTexture;
  36950. /**
  36951. * Gets the default empty 3D texture
  36952. */
  36953. get emptyTexture3D(): InternalTexture;
  36954. /**
  36955. * Gets the default empty 2D array texture
  36956. */
  36957. get emptyTexture2DArray(): InternalTexture;
  36958. /**
  36959. * Gets the default empty cube texture
  36960. */
  36961. get emptyCubeTexture(): InternalTexture;
  36962. /**
  36963. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36964. */
  36965. readonly premultipliedAlpha: boolean;
  36966. /**
  36967. * Observable event triggered before each texture is initialized
  36968. */
  36969. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36970. /**
  36971. * Creates a new engine
  36972. * @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
  36973. * @param antialias defines enable antialiasing (default: false)
  36974. * @param options defines further options to be sent to the getContext() function
  36975. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36976. */
  36977. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36978. private _rebuildInternalTextures;
  36979. private _rebuildEffects;
  36980. /**
  36981. * Gets a boolean indicating if all created effects are ready
  36982. * @returns true if all effects are ready
  36983. */
  36984. areAllEffectsReady(): boolean;
  36985. protected _rebuildBuffers(): void;
  36986. protected _initGLContext(): void;
  36987. /**
  36988. * Gets version of the current webGL context
  36989. */
  36990. get webGLVersion(): number;
  36991. /**
  36992. * Gets a string identifying the name of the class
  36993. * @returns "Engine" string
  36994. */
  36995. getClassName(): string;
  36996. /**
  36997. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36998. */
  36999. get isStencilEnable(): boolean;
  37000. /** @hidden */
  37001. _prepareWorkingCanvas(): void;
  37002. /**
  37003. * Reset the texture cache to empty state
  37004. */
  37005. resetTextureCache(): void;
  37006. /**
  37007. * Gets an object containing information about the current webGL context
  37008. * @returns an object containing the vender, the renderer and the version of the current webGL context
  37009. */
  37010. getGlInfo(): {
  37011. vendor: string;
  37012. renderer: string;
  37013. version: string;
  37014. };
  37015. /**
  37016. * Defines the hardware scaling level.
  37017. * By default the hardware scaling level is computed from the window device ratio.
  37018. * 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.
  37019. * @param level defines the level to use
  37020. */
  37021. setHardwareScalingLevel(level: number): void;
  37022. /**
  37023. * Gets the current hardware scaling level.
  37024. * By default the hardware scaling level is computed from the window device ratio.
  37025. * 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.
  37026. * @returns a number indicating the current hardware scaling level
  37027. */
  37028. getHardwareScalingLevel(): number;
  37029. /**
  37030. * Gets the list of loaded textures
  37031. * @returns an array containing all loaded textures
  37032. */
  37033. getLoadedTexturesCache(): InternalTexture[];
  37034. /**
  37035. * Gets the object containing all engine capabilities
  37036. * @returns the EngineCapabilities object
  37037. */
  37038. getCaps(): EngineCapabilities;
  37039. /**
  37040. * stop executing a render loop function and remove it from the execution array
  37041. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  37042. */
  37043. stopRenderLoop(renderFunction?: () => void): void;
  37044. /** @hidden */
  37045. _renderLoop(): void;
  37046. /**
  37047. * Gets the HTML canvas attached with the current webGL context
  37048. * @returns a HTML canvas
  37049. */
  37050. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  37051. /**
  37052. * Gets host window
  37053. * @returns the host window object
  37054. */
  37055. getHostWindow(): Nullable<Window>;
  37056. /**
  37057. * Gets the current render width
  37058. * @param useScreen defines if screen size must be used (or the current render target if any)
  37059. * @returns a number defining the current render width
  37060. */
  37061. getRenderWidth(useScreen?: boolean): number;
  37062. /**
  37063. * Gets the current render height
  37064. * @param useScreen defines if screen size must be used (or the current render target if any)
  37065. * @returns a number defining the current render height
  37066. */
  37067. getRenderHeight(useScreen?: boolean): number;
  37068. /**
  37069. * Can be used to override the current requestAnimationFrame requester.
  37070. * @hidden
  37071. */
  37072. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  37073. /**
  37074. * Register and execute a render loop. The engine can have more than one render function
  37075. * @param renderFunction defines the function to continuously execute
  37076. */
  37077. runRenderLoop(renderFunction: () => void): void;
  37078. /**
  37079. * Clear the current render buffer or the current render target (if any is set up)
  37080. * @param color defines the color to use
  37081. * @param backBuffer defines if the back buffer must be cleared
  37082. * @param depth defines if the depth buffer must be cleared
  37083. * @param stencil defines if the stencil buffer must be cleared
  37084. */
  37085. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  37086. private _viewportCached;
  37087. /** @hidden */
  37088. _viewport(x: number, y: number, width: number, height: number): void;
  37089. /**
  37090. * Set the WebGL's viewport
  37091. * @param viewport defines the viewport element to be used
  37092. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  37093. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  37094. */
  37095. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  37096. /**
  37097. * Begin a new frame
  37098. */
  37099. beginFrame(): void;
  37100. /**
  37101. * Enf the current frame
  37102. */
  37103. endFrame(): void;
  37104. /**
  37105. * Resize the view according to the canvas' size
  37106. */
  37107. resize(): void;
  37108. /**
  37109. * Force a specific size of the canvas
  37110. * @param width defines the new canvas' width
  37111. * @param height defines the new canvas' height
  37112. * @returns true if the size was changed
  37113. */
  37114. setSize(width: number, height: number): boolean;
  37115. /**
  37116. * Binds the frame buffer to the specified texture.
  37117. * @param texture The texture to render to or null for the default canvas
  37118. * @param faceIndex The face of the texture to render to in case of cube texture
  37119. * @param requiredWidth The width of the target to render to
  37120. * @param requiredHeight The height of the target to render to
  37121. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37122. * @param lodLevel defines the lod level to bind to the frame buffer
  37123. * @param layer defines the 2d array index to bind to frame buffer to
  37124. */
  37125. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37126. /** @hidden */
  37127. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37128. /**
  37129. * Unbind the current render target texture from the webGL context
  37130. * @param texture defines the render target texture to unbind
  37131. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37132. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37133. */
  37134. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37135. /**
  37136. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37137. */
  37138. flushFramebuffer(): void;
  37139. /**
  37140. * Unbind the current render target and bind the default framebuffer
  37141. */
  37142. restoreDefaultFramebuffer(): void;
  37143. /** @hidden */
  37144. protected _resetVertexBufferBinding(): void;
  37145. /**
  37146. * Creates a vertex buffer
  37147. * @param data the data for the vertex buffer
  37148. * @returns the new WebGL static buffer
  37149. */
  37150. createVertexBuffer(data: DataArray): DataBuffer;
  37151. private _createVertexBuffer;
  37152. /**
  37153. * Creates a dynamic vertex buffer
  37154. * @param data the data for the dynamic vertex buffer
  37155. * @returns the new WebGL dynamic buffer
  37156. */
  37157. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37158. protected _resetIndexBufferBinding(): void;
  37159. /**
  37160. * Creates a new index buffer
  37161. * @param indices defines the content of the index buffer
  37162. * @param updatable defines if the index buffer must be updatable
  37163. * @returns a new webGL buffer
  37164. */
  37165. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37166. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37167. /**
  37168. * Bind a webGL buffer to the webGL context
  37169. * @param buffer defines the buffer to bind
  37170. */
  37171. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37172. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37173. private bindBuffer;
  37174. /**
  37175. * update the bound buffer with the given data
  37176. * @param data defines the data to update
  37177. */
  37178. updateArrayBuffer(data: Float32Array): void;
  37179. private _vertexAttribPointer;
  37180. /** @hidden */
  37181. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37182. private _bindVertexBuffersAttributes;
  37183. /**
  37184. * Records a vertex array object
  37185. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37186. * @param vertexBuffers defines the list of vertex buffers to store
  37187. * @param indexBuffer defines the index buffer to store
  37188. * @param effect defines the effect to store
  37189. * @returns the new vertex array object
  37190. */
  37191. recordVertexArrayObject(vertexBuffers: {
  37192. [key: string]: VertexBuffer;
  37193. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37194. /**
  37195. * Bind a specific vertex array object
  37196. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37197. * @param vertexArrayObject defines the vertex array object to bind
  37198. * @param indexBuffer defines the index buffer to bind
  37199. */
  37200. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37201. /**
  37202. * Bind webGl buffers directly to the webGL context
  37203. * @param vertexBuffer defines the vertex buffer to bind
  37204. * @param indexBuffer defines the index buffer to bind
  37205. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37206. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37207. * @param effect defines the effect associated with the vertex buffer
  37208. */
  37209. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37210. private _unbindVertexArrayObject;
  37211. /**
  37212. * Bind a list of vertex buffers to the webGL context
  37213. * @param vertexBuffers defines the list of vertex buffers to bind
  37214. * @param indexBuffer defines the index buffer to bind
  37215. * @param effect defines the effect associated with the vertex buffers
  37216. */
  37217. bindBuffers(vertexBuffers: {
  37218. [key: string]: Nullable<VertexBuffer>;
  37219. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37220. /**
  37221. * Unbind all instance attributes
  37222. */
  37223. unbindInstanceAttributes(): void;
  37224. /**
  37225. * Release and free the memory of a vertex array object
  37226. * @param vao defines the vertex array object to delete
  37227. */
  37228. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37229. /** @hidden */
  37230. _releaseBuffer(buffer: DataBuffer): boolean;
  37231. protected _deleteBuffer(buffer: DataBuffer): void;
  37232. /**
  37233. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37234. * @param instancesBuffer defines the webGL buffer to update and bind
  37235. * @param data defines the data to store in the buffer
  37236. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37237. */
  37238. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37239. /**
  37240. * Bind the content of a webGL buffer used with instantiation
  37241. * @param instancesBuffer defines the webGL buffer to bind
  37242. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37243. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37244. */
  37245. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37246. /**
  37247. * Disable the instance attribute corresponding to the name in parameter
  37248. * @param name defines the name of the attribute to disable
  37249. */
  37250. disableInstanceAttributeByName(name: string): void;
  37251. /**
  37252. * Disable the instance attribute corresponding to the location in parameter
  37253. * @param attributeLocation defines the attribute location of the attribute to disable
  37254. */
  37255. disableInstanceAttribute(attributeLocation: number): void;
  37256. /**
  37257. * Disable the attribute corresponding to the location in parameter
  37258. * @param attributeLocation defines the attribute location of the attribute to disable
  37259. */
  37260. disableAttributeByIndex(attributeLocation: number): void;
  37261. /**
  37262. * Send a draw order
  37263. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37264. * @param indexStart defines the starting index
  37265. * @param indexCount defines the number of index to draw
  37266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37267. */
  37268. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37269. /**
  37270. * Draw a list of points
  37271. * @param verticesStart defines the index of first vertex to draw
  37272. * @param verticesCount defines the count of vertices to draw
  37273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37274. */
  37275. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37276. /**
  37277. * Draw a list of unindexed primitives
  37278. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37279. * @param verticesStart defines the index of first vertex to draw
  37280. * @param verticesCount defines the count of vertices to draw
  37281. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37282. */
  37283. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37284. /**
  37285. * Draw a list of indexed primitives
  37286. * @param fillMode defines the primitive to use
  37287. * @param indexStart defines the starting index
  37288. * @param indexCount defines the number of index to draw
  37289. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37290. */
  37291. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37292. /**
  37293. * Draw a list of unindexed primitives
  37294. * @param fillMode defines the primitive to use
  37295. * @param verticesStart defines the index of first vertex to draw
  37296. * @param verticesCount defines the count of vertices to draw
  37297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37298. */
  37299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37300. private _drawMode;
  37301. /** @hidden */
  37302. protected _reportDrawCall(): void;
  37303. /** @hidden */
  37304. _releaseEffect(effect: Effect): void;
  37305. /** @hidden */
  37306. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37307. /**
  37308. * Create a new effect (used to store vertex/fragment shaders)
  37309. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37310. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37311. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37312. * @param samplers defines an array of string used to represent textures
  37313. * @param defines defines the string containing the defines to use to compile the shaders
  37314. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37315. * @param onCompiled defines a function to call when the effect creation is successful
  37316. * @param onError defines a function to call when the effect creation has failed
  37317. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37318. * @returns the new Effect
  37319. */
  37320. 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;
  37321. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37322. private _compileShader;
  37323. private _compileRawShader;
  37324. /** @hidden */
  37325. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37326. /**
  37327. * Directly creates a webGL program
  37328. * @param pipelineContext defines the pipeline context to attach to
  37329. * @param vertexCode defines the vertex shader code to use
  37330. * @param fragmentCode defines the fragment shader code to use
  37331. * @param context defines the webGL context to use (if not set, the current one will be used)
  37332. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37333. * @returns the new webGL program
  37334. */
  37335. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37336. /**
  37337. * Creates a webGL program
  37338. * @param pipelineContext defines the pipeline context to attach to
  37339. * @param vertexCode defines the vertex shader code to use
  37340. * @param fragmentCode defines the fragment shader code to use
  37341. * @param defines defines the string containing the defines to use to compile the shaders
  37342. * @param context defines the webGL context to use (if not set, the current one will be used)
  37343. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37344. * @returns the new webGL program
  37345. */
  37346. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37347. /**
  37348. * Creates a new pipeline context
  37349. * @returns the new pipeline
  37350. */
  37351. createPipelineContext(): IPipelineContext;
  37352. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37353. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37354. /** @hidden */
  37355. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37356. /** @hidden */
  37357. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37358. /** @hidden */
  37359. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37360. /**
  37361. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37362. * @param pipelineContext defines the pipeline context to use
  37363. * @param uniformsNames defines the list of uniform names
  37364. * @returns an array of webGL uniform locations
  37365. */
  37366. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37367. /**
  37368. * Gets the lsit of active attributes for a given webGL program
  37369. * @param pipelineContext defines the pipeline context to use
  37370. * @param attributesNames defines the list of attribute names to get
  37371. * @returns an array of indices indicating the offset of each attribute
  37372. */
  37373. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37374. /**
  37375. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37376. * @param effect defines the effect to activate
  37377. */
  37378. enableEffect(effect: Nullable<Effect>): void;
  37379. /**
  37380. * Set the value of an uniform to a number (int)
  37381. * @param uniform defines the webGL uniform location where to store the value
  37382. * @param value defines the int number to store
  37383. * @returns true if the value was set
  37384. */
  37385. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37386. /**
  37387. * Set the value of an uniform to an array of int32
  37388. * @param uniform defines the webGL uniform location where to store the value
  37389. * @param array defines the array of int32 to store
  37390. * @returns true if the value was set
  37391. */
  37392. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37393. /**
  37394. * Set the value of an uniform to an array of int32 (stored as vec2)
  37395. * @param uniform defines the webGL uniform location where to store the value
  37396. * @param array defines the array of int32 to store
  37397. * @returns true if the value was set
  37398. */
  37399. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37400. /**
  37401. * Set the value of an uniform to an array of int32 (stored as vec3)
  37402. * @param uniform defines the webGL uniform location where to store the value
  37403. * @param array defines the array of int32 to store
  37404. * @returns true if the value was set
  37405. */
  37406. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37407. /**
  37408. * Set the value of an uniform to an array of int32 (stored as vec4)
  37409. * @param uniform defines the webGL uniform location where to store the value
  37410. * @param array defines the array of int32 to store
  37411. * @returns true if the value was set
  37412. */
  37413. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37414. /**
  37415. * Set the value of an uniform to an array of number
  37416. * @param uniform defines the webGL uniform location where to store the value
  37417. * @param array defines the array of number to store
  37418. * @returns true if the value was set
  37419. */
  37420. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37421. /**
  37422. * Set the value of an uniform to an array of number (stored as vec2)
  37423. * @param uniform defines the webGL uniform location where to store the value
  37424. * @param array defines the array of number to store
  37425. * @returns true if the value was set
  37426. */
  37427. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37428. /**
  37429. * Set the value of an uniform to an array of number (stored as vec3)
  37430. * @param uniform defines the webGL uniform location where to store the value
  37431. * @param array defines the array of number to store
  37432. * @returns true if the value was set
  37433. */
  37434. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37435. /**
  37436. * Set the value of an uniform to an array of number (stored as vec4)
  37437. * @param uniform defines the webGL uniform location where to store the value
  37438. * @param array defines the array of number to store
  37439. * @returns true if the value was set
  37440. */
  37441. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37442. /**
  37443. * Set the value of an uniform to an array of float32 (stored as matrices)
  37444. * @param uniform defines the webGL uniform location where to store the value
  37445. * @param matrices defines the array of float32 to store
  37446. * @returns true if the value was set
  37447. */
  37448. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37449. /**
  37450. * Set the value of an uniform to a matrix (3x3)
  37451. * @param uniform defines the webGL uniform location where to store the value
  37452. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37453. * @returns true if the value was set
  37454. */
  37455. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37456. /**
  37457. * Set the value of an uniform to a matrix (2x2)
  37458. * @param uniform defines the webGL uniform location where to store the value
  37459. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37460. * @returns true if the value was set
  37461. */
  37462. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37463. /**
  37464. * Set the value of an uniform to a number (float)
  37465. * @param uniform defines the webGL uniform location where to store the value
  37466. * @param value defines the float number to store
  37467. * @returns true if the value was transfered
  37468. */
  37469. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37470. /**
  37471. * Set the value of an uniform to a vec2
  37472. * @param uniform defines the webGL uniform location where to store the value
  37473. * @param x defines the 1st component of the value
  37474. * @param y defines the 2nd component of the value
  37475. * @returns true if the value was set
  37476. */
  37477. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37478. /**
  37479. * Set the value of an uniform to a vec3
  37480. * @param uniform defines the webGL uniform location where to store the value
  37481. * @param x defines the 1st component of the value
  37482. * @param y defines the 2nd component of the value
  37483. * @param z defines the 3rd component of the value
  37484. * @returns true if the value was set
  37485. */
  37486. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37487. /**
  37488. * Set the value of an uniform to a vec4
  37489. * @param uniform defines the webGL uniform location where to store the value
  37490. * @param x defines the 1st component of the value
  37491. * @param y defines the 2nd component of the value
  37492. * @param z defines the 3rd component of the value
  37493. * @param w defines the 4th component of the value
  37494. * @returns true if the value was set
  37495. */
  37496. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37497. /**
  37498. * Apply all cached states (depth, culling, stencil and alpha)
  37499. */
  37500. applyStates(): void;
  37501. /**
  37502. * Enable or disable color writing
  37503. * @param enable defines the state to set
  37504. */
  37505. setColorWrite(enable: boolean): void;
  37506. /**
  37507. * Gets a boolean indicating if color writing is enabled
  37508. * @returns the current color writing state
  37509. */
  37510. getColorWrite(): boolean;
  37511. /**
  37512. * Gets the depth culling state manager
  37513. */
  37514. get depthCullingState(): DepthCullingState;
  37515. /**
  37516. * Gets the alpha state manager
  37517. */
  37518. get alphaState(): AlphaState;
  37519. /**
  37520. * Gets the stencil state manager
  37521. */
  37522. get stencilState(): StencilState;
  37523. /**
  37524. * Clears the list of texture accessible through engine.
  37525. * This can help preventing texture load conflict due to name collision.
  37526. */
  37527. clearInternalTexturesCache(): void;
  37528. /**
  37529. * Force the entire cache to be cleared
  37530. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37531. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37532. */
  37533. wipeCaches(bruteForce?: boolean): void;
  37534. /** @hidden */
  37535. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37536. min: number;
  37537. mag: number;
  37538. };
  37539. /** @hidden */
  37540. _createTexture(): WebGLTexture;
  37541. /**
  37542. * Usually called from Texture.ts.
  37543. * Passed information to create a WebGLTexture
  37544. * @param url defines a value which contains one of the following:
  37545. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37546. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37547. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37549. * @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)
  37550. * @param scene needed for loading to the correct scene
  37551. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37552. * @param onLoad optional callback to be called upon successful completion
  37553. * @param onError optional callback to be called upon failure
  37554. * @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
  37555. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37556. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37557. * @param forcedExtension defines the extension to use to pick the right loader
  37558. * @param mimeType defines an optional mime type
  37559. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37560. */
  37561. 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;
  37562. /**
  37563. * Loads an image as an HTMLImageElement.
  37564. * @param input url string, ArrayBuffer, or Blob to load
  37565. * @param onLoad callback called when the image successfully loads
  37566. * @param onError callback called when the image fails to load
  37567. * @param offlineProvider offline provider for caching
  37568. * @param mimeType optional mime type
  37569. * @returns the HTMLImageElement of the loaded image
  37570. * @hidden
  37571. */
  37572. 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>;
  37573. /**
  37574. * @hidden
  37575. */
  37576. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37577. private _unpackFlipYCached;
  37578. /**
  37579. * In case you are sharing the context with other applications, it might
  37580. * be interested to not cache the unpack flip y state to ensure a consistent
  37581. * value would be set.
  37582. */
  37583. enableUnpackFlipYCached: boolean;
  37584. /** @hidden */
  37585. _unpackFlipY(value: boolean): void;
  37586. /** @hidden */
  37587. _getUnpackAlignement(): number;
  37588. private _getTextureTarget;
  37589. /**
  37590. * Update the sampling mode of a given texture
  37591. * @param samplingMode defines the required sampling mode
  37592. * @param texture defines the texture to update
  37593. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37594. */
  37595. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37596. /**
  37597. * Update the sampling mode of a given texture
  37598. * @param texture defines the texture to update
  37599. * @param wrapU defines the texture wrap mode of the u coordinates
  37600. * @param wrapV defines the texture wrap mode of the v coordinates
  37601. * @param wrapR defines the texture wrap mode of the r coordinates
  37602. */
  37603. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37604. /** @hidden */
  37605. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37606. width: number;
  37607. height: number;
  37608. layers?: number;
  37609. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37610. /** @hidden */
  37611. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37612. /** @hidden */
  37613. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37614. /**
  37615. * Update a portion of an internal texture
  37616. * @param texture defines the texture to update
  37617. * @param imageData defines the data to store into the texture
  37618. * @param xOffset defines the x coordinates of the update rectangle
  37619. * @param yOffset defines the y coordinates of the update rectangle
  37620. * @param width defines the width of the update rectangle
  37621. * @param height defines the height of the update rectangle
  37622. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37623. * @param lod defines the lod level to update (0 by default)
  37624. */
  37625. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37626. /** @hidden */
  37627. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37628. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37629. private _prepareWebGLTexture;
  37630. /** @hidden */
  37631. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37632. private _getDepthStencilBuffer;
  37633. /** @hidden */
  37634. _releaseFramebufferObjects(texture: InternalTexture): void;
  37635. /** @hidden */
  37636. _releaseTexture(texture: InternalTexture): void;
  37637. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37638. protected _setProgram(program: WebGLProgram): void;
  37639. protected _boundUniforms: {
  37640. [key: number]: WebGLUniformLocation;
  37641. };
  37642. /**
  37643. * Binds an effect to the webGL context
  37644. * @param effect defines the effect to bind
  37645. */
  37646. bindSamplers(effect: Effect): void;
  37647. private _activateCurrentTexture;
  37648. /** @hidden */
  37649. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37650. /** @hidden */
  37651. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37652. /**
  37653. * Unbind all textures from the webGL context
  37654. */
  37655. unbindAllTextures(): void;
  37656. /**
  37657. * Sets a texture to the according uniform.
  37658. * @param channel The texture channel
  37659. * @param uniform The uniform to set
  37660. * @param texture The texture to apply
  37661. */
  37662. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37663. private _bindSamplerUniformToChannel;
  37664. private _getTextureWrapMode;
  37665. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37666. /**
  37667. * Sets an array of texture to the webGL context
  37668. * @param channel defines the channel where the texture array must be set
  37669. * @param uniform defines the associated uniform location
  37670. * @param textures defines the array of textures to bind
  37671. */
  37672. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37673. /** @hidden */
  37674. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37675. private _setTextureParameterFloat;
  37676. private _setTextureParameterInteger;
  37677. /**
  37678. * Unbind all vertex attributes from the webGL context
  37679. */
  37680. unbindAllAttributes(): void;
  37681. /**
  37682. * 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
  37683. */
  37684. releaseEffects(): void;
  37685. /**
  37686. * Dispose and release all associated resources
  37687. */
  37688. dispose(): void;
  37689. /**
  37690. * Attach a new callback raised when context lost event is fired
  37691. * @param callback defines the callback to call
  37692. */
  37693. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37694. /**
  37695. * Attach a new callback raised when context restored event is fired
  37696. * @param callback defines the callback to call
  37697. */
  37698. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37699. /**
  37700. * Get the current error code of the webGL context
  37701. * @returns the error code
  37702. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37703. */
  37704. getError(): number;
  37705. private _canRenderToFloatFramebuffer;
  37706. private _canRenderToHalfFloatFramebuffer;
  37707. private _canRenderToFramebuffer;
  37708. /** @hidden */
  37709. _getWebGLTextureType(type: number): number;
  37710. /** @hidden */
  37711. _getInternalFormat(format: number): number;
  37712. /** @hidden */
  37713. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37714. /** @hidden */
  37715. _getRGBAMultiSampleBufferFormat(type: number): number;
  37716. /** @hidden */
  37717. _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;
  37718. /**
  37719. * Loads a file from a url
  37720. * @param url url to load
  37721. * @param onSuccess callback called when the file successfully loads
  37722. * @param onProgress callback called while file is loading (if the server supports this mode)
  37723. * @param offlineProvider defines the offline provider for caching
  37724. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37725. * @param onError callback called when the file fails to load
  37726. * @returns a file request object
  37727. * @hidden
  37728. */
  37729. 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;
  37730. /**
  37731. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37732. * @param x defines the x coordinate of the rectangle where pixels must be read
  37733. * @param y defines the y coordinate of the rectangle where pixels must be read
  37734. * @param width defines the width of the rectangle where pixels must be read
  37735. * @param height defines the height of the rectangle where pixels must be read
  37736. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37737. * @returns a Uint8Array containing RGBA colors
  37738. */
  37739. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37740. private static _IsSupported;
  37741. private static _HasMajorPerformanceCaveat;
  37742. /**
  37743. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37744. */
  37745. static get IsSupported(): boolean;
  37746. /**
  37747. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37748. * @returns true if the engine can be created
  37749. * @ignorenaming
  37750. */
  37751. static isSupported(): boolean;
  37752. /**
  37753. * 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)
  37754. */
  37755. static get HasMajorPerformanceCaveat(): boolean;
  37756. /**
  37757. * Find the next highest power of two.
  37758. * @param x Number to start search from.
  37759. * @return Next highest power of two.
  37760. */
  37761. static CeilingPOT(x: number): number;
  37762. /**
  37763. * Find the next lowest power of two.
  37764. * @param x Number to start search from.
  37765. * @return Next lowest power of two.
  37766. */
  37767. static FloorPOT(x: number): number;
  37768. /**
  37769. * Find the nearest power of two.
  37770. * @param x Number to start search from.
  37771. * @return Next nearest power of two.
  37772. */
  37773. static NearestPOT(x: number): number;
  37774. /**
  37775. * Get the closest exponent of two
  37776. * @param value defines the value to approximate
  37777. * @param max defines the maximum value to return
  37778. * @param mode defines how to define the closest value
  37779. * @returns closest exponent of two of the given value
  37780. */
  37781. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37782. /**
  37783. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37784. * @param func - the function to be called
  37785. * @param requester - the object that will request the next frame. Falls back to window.
  37786. * @returns frame number
  37787. */
  37788. static QueueNewFrame(func: () => void, requester?: any): number;
  37789. /**
  37790. * Gets host document
  37791. * @returns the host document object
  37792. */
  37793. getHostDocument(): Nullable<Document>;
  37794. }
  37795. }
  37796. declare module "babylonjs/Maths/sphericalPolynomial" {
  37797. import { Vector3 } from "babylonjs/Maths/math.vector";
  37798. import { Color3 } from "babylonjs/Maths/math.color";
  37799. /**
  37800. * Class representing spherical harmonics coefficients to the 3rd degree
  37801. */
  37802. export class SphericalHarmonics {
  37803. /**
  37804. * Defines whether or not the harmonics have been prescaled for rendering.
  37805. */
  37806. preScaled: boolean;
  37807. /**
  37808. * The l0,0 coefficients of the spherical harmonics
  37809. */
  37810. l00: Vector3;
  37811. /**
  37812. * The l1,-1 coefficients of the spherical harmonics
  37813. */
  37814. l1_1: Vector3;
  37815. /**
  37816. * The l1,0 coefficients of the spherical harmonics
  37817. */
  37818. l10: Vector3;
  37819. /**
  37820. * The l1,1 coefficients of the spherical harmonics
  37821. */
  37822. l11: Vector3;
  37823. /**
  37824. * The l2,-2 coefficients of the spherical harmonics
  37825. */
  37826. l2_2: Vector3;
  37827. /**
  37828. * The l2,-1 coefficients of the spherical harmonics
  37829. */
  37830. l2_1: Vector3;
  37831. /**
  37832. * The l2,0 coefficients of the spherical harmonics
  37833. */
  37834. l20: Vector3;
  37835. /**
  37836. * The l2,1 coefficients of the spherical harmonics
  37837. */
  37838. l21: Vector3;
  37839. /**
  37840. * The l2,2 coefficients of the spherical harmonics
  37841. */
  37842. l22: Vector3;
  37843. /**
  37844. * Adds a light to the spherical harmonics
  37845. * @param direction the direction of the light
  37846. * @param color the color of the light
  37847. * @param deltaSolidAngle the delta solid angle of the light
  37848. */
  37849. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37850. /**
  37851. * Scales the spherical harmonics by the given amount
  37852. * @param scale the amount to scale
  37853. */
  37854. scaleInPlace(scale: number): void;
  37855. /**
  37856. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37857. *
  37858. * ```
  37859. * E_lm = A_l * L_lm
  37860. * ```
  37861. *
  37862. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37863. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37864. * the scaling factors are given in equation 9.
  37865. */
  37866. convertIncidentRadianceToIrradiance(): void;
  37867. /**
  37868. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37869. *
  37870. * ```
  37871. * L = (1/pi) * E * rho
  37872. * ```
  37873. *
  37874. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37875. */
  37876. convertIrradianceToLambertianRadiance(): void;
  37877. /**
  37878. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37879. * required operations at run time.
  37880. *
  37881. * This is simply done by scaling back the SH with Ylm constants parameter.
  37882. * The trigonometric part being applied by the shader at run time.
  37883. */
  37884. preScaleForRendering(): void;
  37885. /**
  37886. * Constructs a spherical harmonics from an array.
  37887. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37888. * @returns the spherical harmonics
  37889. */
  37890. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37891. /**
  37892. * Gets the spherical harmonics from polynomial
  37893. * @param polynomial the spherical polynomial
  37894. * @returns the spherical harmonics
  37895. */
  37896. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37897. }
  37898. /**
  37899. * Class representing spherical polynomial coefficients to the 3rd degree
  37900. */
  37901. export class SphericalPolynomial {
  37902. private _harmonics;
  37903. /**
  37904. * The spherical harmonics used to create the polynomials.
  37905. */
  37906. get preScaledHarmonics(): SphericalHarmonics;
  37907. /**
  37908. * The x coefficients of the spherical polynomial
  37909. */
  37910. x: Vector3;
  37911. /**
  37912. * The y coefficients of the spherical polynomial
  37913. */
  37914. y: Vector3;
  37915. /**
  37916. * The z coefficients of the spherical polynomial
  37917. */
  37918. z: Vector3;
  37919. /**
  37920. * The xx coefficients of the spherical polynomial
  37921. */
  37922. xx: Vector3;
  37923. /**
  37924. * The yy coefficients of the spherical polynomial
  37925. */
  37926. yy: Vector3;
  37927. /**
  37928. * The zz coefficients of the spherical polynomial
  37929. */
  37930. zz: Vector3;
  37931. /**
  37932. * The xy coefficients of the spherical polynomial
  37933. */
  37934. xy: Vector3;
  37935. /**
  37936. * The yz coefficients of the spherical polynomial
  37937. */
  37938. yz: Vector3;
  37939. /**
  37940. * The zx coefficients of the spherical polynomial
  37941. */
  37942. zx: Vector3;
  37943. /**
  37944. * Adds an ambient color to the spherical polynomial
  37945. * @param color the color to add
  37946. */
  37947. addAmbient(color: Color3): void;
  37948. /**
  37949. * Scales the spherical polynomial by the given amount
  37950. * @param scale the amount to scale
  37951. */
  37952. scaleInPlace(scale: number): void;
  37953. /**
  37954. * Gets the spherical polynomial from harmonics
  37955. * @param harmonics the spherical harmonics
  37956. * @returns the spherical polynomial
  37957. */
  37958. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37959. /**
  37960. * Constructs a spherical polynomial from an array.
  37961. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37962. * @returns the spherical polynomial
  37963. */
  37964. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37965. }
  37966. }
  37967. declare module "babylonjs/Materials/Textures/internalTexture" {
  37968. import { Observable } from "babylonjs/Misc/observable";
  37969. import { Nullable, int } from "babylonjs/types";
  37970. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37972. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37973. /**
  37974. * Defines the source of the internal texture
  37975. */
  37976. export enum InternalTextureSource {
  37977. /**
  37978. * The source of the texture data is unknown
  37979. */
  37980. Unknown = 0,
  37981. /**
  37982. * Texture data comes from an URL
  37983. */
  37984. Url = 1,
  37985. /**
  37986. * Texture data is only used for temporary storage
  37987. */
  37988. Temp = 2,
  37989. /**
  37990. * Texture data comes from raw data (ArrayBuffer)
  37991. */
  37992. Raw = 3,
  37993. /**
  37994. * Texture content is dynamic (video or dynamic texture)
  37995. */
  37996. Dynamic = 4,
  37997. /**
  37998. * Texture content is generated by rendering to it
  37999. */
  38000. RenderTarget = 5,
  38001. /**
  38002. * Texture content is part of a multi render target process
  38003. */
  38004. MultiRenderTarget = 6,
  38005. /**
  38006. * Texture data comes from a cube data file
  38007. */
  38008. Cube = 7,
  38009. /**
  38010. * Texture data comes from a raw cube data
  38011. */
  38012. CubeRaw = 8,
  38013. /**
  38014. * Texture data come from a prefiltered cube data file
  38015. */
  38016. CubePrefiltered = 9,
  38017. /**
  38018. * Texture content is raw 3D data
  38019. */
  38020. Raw3D = 10,
  38021. /**
  38022. * Texture content is raw 2D array data
  38023. */
  38024. Raw2DArray = 11,
  38025. /**
  38026. * Texture content is a depth texture
  38027. */
  38028. Depth = 12,
  38029. /**
  38030. * Texture data comes from a raw cube data encoded with RGBD
  38031. */
  38032. CubeRawRGBD = 13
  38033. }
  38034. /**
  38035. * Class used to store data associated with WebGL texture data for the engine
  38036. * This class should not be used directly
  38037. */
  38038. export class InternalTexture {
  38039. /** @hidden */
  38040. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  38041. /**
  38042. * Defines if the texture is ready
  38043. */
  38044. isReady: boolean;
  38045. /**
  38046. * Defines if the texture is a cube texture
  38047. */
  38048. isCube: boolean;
  38049. /**
  38050. * Defines if the texture contains 3D data
  38051. */
  38052. is3D: boolean;
  38053. /**
  38054. * Defines if the texture contains 2D array data
  38055. */
  38056. is2DArray: boolean;
  38057. /**
  38058. * Defines if the texture contains multiview data
  38059. */
  38060. isMultiview: boolean;
  38061. /**
  38062. * Gets the URL used to load this texture
  38063. */
  38064. url: string;
  38065. /**
  38066. * Gets the sampling mode of the texture
  38067. */
  38068. samplingMode: number;
  38069. /**
  38070. * Gets a boolean indicating if the texture needs mipmaps generation
  38071. */
  38072. generateMipMaps: boolean;
  38073. /**
  38074. * Gets the number of samples used by the texture (WebGL2+ only)
  38075. */
  38076. samples: number;
  38077. /**
  38078. * Gets the type of the texture (int, float...)
  38079. */
  38080. type: number;
  38081. /**
  38082. * Gets the format of the texture (RGB, RGBA...)
  38083. */
  38084. format: number;
  38085. /**
  38086. * Observable called when the texture is loaded
  38087. */
  38088. onLoadedObservable: Observable<InternalTexture>;
  38089. /**
  38090. * Gets the width of the texture
  38091. */
  38092. width: number;
  38093. /**
  38094. * Gets the height of the texture
  38095. */
  38096. height: number;
  38097. /**
  38098. * Gets the depth of the texture
  38099. */
  38100. depth: number;
  38101. /**
  38102. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38103. */
  38104. baseWidth: number;
  38105. /**
  38106. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38107. */
  38108. baseHeight: number;
  38109. /**
  38110. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38111. */
  38112. baseDepth: number;
  38113. /**
  38114. * Gets a boolean indicating if the texture is inverted on Y axis
  38115. */
  38116. invertY: boolean;
  38117. /** @hidden */
  38118. _invertVScale: boolean;
  38119. /** @hidden */
  38120. _associatedChannel: number;
  38121. /** @hidden */
  38122. _source: InternalTextureSource;
  38123. /** @hidden */
  38124. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38125. /** @hidden */
  38126. _bufferView: Nullable<ArrayBufferView>;
  38127. /** @hidden */
  38128. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38129. /** @hidden */
  38130. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38131. /** @hidden */
  38132. _size: number;
  38133. /** @hidden */
  38134. _extension: string;
  38135. /** @hidden */
  38136. _files: Nullable<string[]>;
  38137. /** @hidden */
  38138. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38139. /** @hidden */
  38140. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38141. /** @hidden */
  38142. _framebuffer: Nullable<WebGLFramebuffer>;
  38143. /** @hidden */
  38144. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38145. /** @hidden */
  38146. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38147. /** @hidden */
  38148. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38149. /** @hidden */
  38150. _attachments: Nullable<number[]>;
  38151. /** @hidden */
  38152. _textureArray: Nullable<InternalTexture[]>;
  38153. /** @hidden */
  38154. _cachedCoordinatesMode: Nullable<number>;
  38155. /** @hidden */
  38156. _cachedWrapU: Nullable<number>;
  38157. /** @hidden */
  38158. _cachedWrapV: Nullable<number>;
  38159. /** @hidden */
  38160. _cachedWrapR: Nullable<number>;
  38161. /** @hidden */
  38162. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38163. /** @hidden */
  38164. _isDisabled: boolean;
  38165. /** @hidden */
  38166. _compression: Nullable<string>;
  38167. /** @hidden */
  38168. _generateStencilBuffer: boolean;
  38169. /** @hidden */
  38170. _generateDepthBuffer: boolean;
  38171. /** @hidden */
  38172. _comparisonFunction: number;
  38173. /** @hidden */
  38174. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38175. /** @hidden */
  38176. _lodGenerationScale: number;
  38177. /** @hidden */
  38178. _lodGenerationOffset: number;
  38179. /** @hidden */
  38180. _depthStencilTexture: Nullable<InternalTexture>;
  38181. /** @hidden */
  38182. _colorTextureArray: Nullable<WebGLTexture>;
  38183. /** @hidden */
  38184. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38185. /** @hidden */
  38186. _lodTextureHigh: Nullable<BaseTexture>;
  38187. /** @hidden */
  38188. _lodTextureMid: Nullable<BaseTexture>;
  38189. /** @hidden */
  38190. _lodTextureLow: Nullable<BaseTexture>;
  38191. /** @hidden */
  38192. _isRGBD: boolean;
  38193. /** @hidden */
  38194. _linearSpecularLOD: boolean;
  38195. /** @hidden */
  38196. _irradianceTexture: Nullable<BaseTexture>;
  38197. /** @hidden */
  38198. _webGLTexture: Nullable<WebGLTexture>;
  38199. /** @hidden */
  38200. _references: number;
  38201. /** @hidden */
  38202. _gammaSpace: Nullable<boolean>;
  38203. private _engine;
  38204. /**
  38205. * Gets the Engine the texture belongs to.
  38206. * @returns The babylon engine
  38207. */
  38208. getEngine(): ThinEngine;
  38209. /**
  38210. * Gets the data source type of the texture
  38211. */
  38212. get source(): InternalTextureSource;
  38213. /**
  38214. * Creates a new InternalTexture
  38215. * @param engine defines the engine to use
  38216. * @param source defines the type of data that will be used
  38217. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38218. */
  38219. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38220. /**
  38221. * Increments the number of references (ie. the number of Texture that point to it)
  38222. */
  38223. incrementReferences(): void;
  38224. /**
  38225. * Change the size of the texture (not the size of the content)
  38226. * @param width defines the new width
  38227. * @param height defines the new height
  38228. * @param depth defines the new depth (1 by default)
  38229. */
  38230. updateSize(width: int, height: int, depth?: int): void;
  38231. /** @hidden */
  38232. _rebuild(): void;
  38233. /** @hidden */
  38234. _swapAndDie(target: InternalTexture): void;
  38235. /**
  38236. * Dispose the current allocated resources
  38237. */
  38238. dispose(): void;
  38239. }
  38240. }
  38241. declare module "babylonjs/Audio/analyser" {
  38242. import { Scene } from "babylonjs/scene";
  38243. /**
  38244. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38246. */
  38247. export class Analyser {
  38248. /**
  38249. * Gets or sets the smoothing
  38250. * @ignorenaming
  38251. */
  38252. SMOOTHING: number;
  38253. /**
  38254. * Gets or sets the FFT table size
  38255. * @ignorenaming
  38256. */
  38257. FFT_SIZE: number;
  38258. /**
  38259. * Gets or sets the bar graph amplitude
  38260. * @ignorenaming
  38261. */
  38262. BARGRAPHAMPLITUDE: number;
  38263. /**
  38264. * Gets or sets the position of the debug canvas
  38265. * @ignorenaming
  38266. */
  38267. DEBUGCANVASPOS: {
  38268. x: number;
  38269. y: number;
  38270. };
  38271. /**
  38272. * Gets or sets the debug canvas size
  38273. * @ignorenaming
  38274. */
  38275. DEBUGCANVASSIZE: {
  38276. width: number;
  38277. height: number;
  38278. };
  38279. private _byteFreqs;
  38280. private _byteTime;
  38281. private _floatFreqs;
  38282. private _webAudioAnalyser;
  38283. private _debugCanvas;
  38284. private _debugCanvasContext;
  38285. private _scene;
  38286. private _registerFunc;
  38287. private _audioEngine;
  38288. /**
  38289. * Creates a new analyser
  38290. * @param scene defines hosting scene
  38291. */
  38292. constructor(scene: Scene);
  38293. /**
  38294. * Get the number of data values you will have to play with for the visualization
  38295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38296. * @returns a number
  38297. */
  38298. getFrequencyBinCount(): number;
  38299. /**
  38300. * Gets the current frequency data as a byte array
  38301. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38302. * @returns a Uint8Array
  38303. */
  38304. getByteFrequencyData(): Uint8Array;
  38305. /**
  38306. * Gets the current waveform as a byte array
  38307. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38308. * @returns a Uint8Array
  38309. */
  38310. getByteTimeDomainData(): Uint8Array;
  38311. /**
  38312. * Gets the current frequency data as a float array
  38313. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38314. * @returns a Float32Array
  38315. */
  38316. getFloatFrequencyData(): Float32Array;
  38317. /**
  38318. * Renders the debug canvas
  38319. */
  38320. drawDebugCanvas(): void;
  38321. /**
  38322. * Stops rendering the debug canvas and removes it
  38323. */
  38324. stopDebugCanvas(): void;
  38325. /**
  38326. * Connects two audio nodes
  38327. * @param inputAudioNode defines first node to connect
  38328. * @param outputAudioNode defines second node to connect
  38329. */
  38330. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38331. /**
  38332. * Releases all associated resources
  38333. */
  38334. dispose(): void;
  38335. }
  38336. }
  38337. declare module "babylonjs/Audio/audioEngine" {
  38338. import { IDisposable } from "babylonjs/scene";
  38339. import { Analyser } from "babylonjs/Audio/analyser";
  38340. import { Nullable } from "babylonjs/types";
  38341. import { Observable } from "babylonjs/Misc/observable";
  38342. /**
  38343. * This represents an audio engine and it is responsible
  38344. * to play, synchronize and analyse sounds throughout the application.
  38345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38346. */
  38347. export interface IAudioEngine extends IDisposable {
  38348. /**
  38349. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38350. */
  38351. readonly canUseWebAudio: boolean;
  38352. /**
  38353. * Gets the current AudioContext if available.
  38354. */
  38355. readonly audioContext: Nullable<AudioContext>;
  38356. /**
  38357. * The master gain node defines the global audio volume of your audio engine.
  38358. */
  38359. readonly masterGain: GainNode;
  38360. /**
  38361. * Gets whether or not mp3 are supported by your browser.
  38362. */
  38363. readonly isMP3supported: boolean;
  38364. /**
  38365. * Gets whether or not ogg are supported by your browser.
  38366. */
  38367. readonly isOGGsupported: boolean;
  38368. /**
  38369. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38370. * @ignoreNaming
  38371. */
  38372. WarnedWebAudioUnsupported: boolean;
  38373. /**
  38374. * Defines if the audio engine relies on a custom unlocked button.
  38375. * In this case, the embedded button will not be displayed.
  38376. */
  38377. useCustomUnlockedButton: boolean;
  38378. /**
  38379. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38380. */
  38381. readonly unlocked: boolean;
  38382. /**
  38383. * Event raised when audio has been unlocked on the browser.
  38384. */
  38385. onAudioUnlockedObservable: Observable<AudioEngine>;
  38386. /**
  38387. * Event raised when audio has been locked on the browser.
  38388. */
  38389. onAudioLockedObservable: Observable<AudioEngine>;
  38390. /**
  38391. * Flags the audio engine in Locked state.
  38392. * This happens due to new browser policies preventing audio to autoplay.
  38393. */
  38394. lock(): void;
  38395. /**
  38396. * Unlocks the audio engine once a user action has been done on the dom.
  38397. * This is helpful to resume play once browser policies have been satisfied.
  38398. */
  38399. unlock(): void;
  38400. /**
  38401. * Gets the global volume sets on the master gain.
  38402. * @returns the global volume if set or -1 otherwise
  38403. */
  38404. getGlobalVolume(): number;
  38405. /**
  38406. * Sets the global volume of your experience (sets on the master gain).
  38407. * @param newVolume Defines the new global volume of the application
  38408. */
  38409. setGlobalVolume(newVolume: number): void;
  38410. /**
  38411. * Connect the audio engine to an audio analyser allowing some amazing
  38412. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38413. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38414. * @param analyser The analyser to connect to the engine
  38415. */
  38416. connectToAnalyser(analyser: Analyser): void;
  38417. }
  38418. /**
  38419. * This represents the default audio engine used in babylon.
  38420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38421. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38422. */
  38423. export class AudioEngine implements IAudioEngine {
  38424. private _audioContext;
  38425. private _audioContextInitialized;
  38426. private _muteButton;
  38427. private _hostElement;
  38428. /**
  38429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38430. */
  38431. canUseWebAudio: boolean;
  38432. /**
  38433. * The master gain node defines the global audio volume of your audio engine.
  38434. */
  38435. masterGain: GainNode;
  38436. /**
  38437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38438. * @ignoreNaming
  38439. */
  38440. WarnedWebAudioUnsupported: boolean;
  38441. /**
  38442. * Gets whether or not mp3 are supported by your browser.
  38443. */
  38444. isMP3supported: boolean;
  38445. /**
  38446. * Gets whether or not ogg are supported by your browser.
  38447. */
  38448. isOGGsupported: boolean;
  38449. /**
  38450. * Gets whether audio has been unlocked on the device.
  38451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38452. * a user interaction has happened.
  38453. */
  38454. unlocked: boolean;
  38455. /**
  38456. * Defines if the audio engine relies on a custom unlocked button.
  38457. * In this case, the embedded button will not be displayed.
  38458. */
  38459. useCustomUnlockedButton: boolean;
  38460. /**
  38461. * Event raised when audio has been unlocked on the browser.
  38462. */
  38463. onAudioUnlockedObservable: Observable<AudioEngine>;
  38464. /**
  38465. * Event raised when audio has been locked on the browser.
  38466. */
  38467. onAudioLockedObservable: Observable<AudioEngine>;
  38468. /**
  38469. * Gets the current AudioContext if available.
  38470. */
  38471. get audioContext(): Nullable<AudioContext>;
  38472. private _connectedAnalyser;
  38473. /**
  38474. * Instantiates a new audio engine.
  38475. *
  38476. * There should be only one per page as some browsers restrict the number
  38477. * of audio contexts you can create.
  38478. * @param hostElement defines the host element where to display the mute icon if necessary
  38479. */
  38480. constructor(hostElement?: Nullable<HTMLElement>);
  38481. /**
  38482. * Flags the audio engine in Locked state.
  38483. * This happens due to new browser policies preventing audio to autoplay.
  38484. */
  38485. lock(): void;
  38486. /**
  38487. * Unlocks the audio engine once a user action has been done on the dom.
  38488. * This is helpful to resume play once browser policies have been satisfied.
  38489. */
  38490. unlock(): void;
  38491. private _resumeAudioContext;
  38492. private _initializeAudioContext;
  38493. private _tryToRun;
  38494. private _triggerRunningState;
  38495. private _triggerSuspendedState;
  38496. private _displayMuteButton;
  38497. private _moveButtonToTopLeft;
  38498. private _onResize;
  38499. private _hideMuteButton;
  38500. /**
  38501. * Destroy and release the resources associated with the audio ccontext.
  38502. */
  38503. dispose(): void;
  38504. /**
  38505. * Gets the global volume sets on the master gain.
  38506. * @returns the global volume if set or -1 otherwise
  38507. */
  38508. getGlobalVolume(): number;
  38509. /**
  38510. * Sets the global volume of your experience (sets on the master gain).
  38511. * @param newVolume Defines the new global volume of the application
  38512. */
  38513. setGlobalVolume(newVolume: number): void;
  38514. /**
  38515. * Connect the audio engine to an audio analyser allowing some amazing
  38516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38518. * @param analyser The analyser to connect to the engine
  38519. */
  38520. connectToAnalyser(analyser: Analyser): void;
  38521. }
  38522. }
  38523. declare module "babylonjs/Loading/loadingScreen" {
  38524. /**
  38525. * Interface used to present a loading screen while loading a scene
  38526. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38527. */
  38528. export interface ILoadingScreen {
  38529. /**
  38530. * Function called to display the loading screen
  38531. */
  38532. displayLoadingUI: () => void;
  38533. /**
  38534. * Function called to hide the loading screen
  38535. */
  38536. hideLoadingUI: () => void;
  38537. /**
  38538. * Gets or sets the color to use for the background
  38539. */
  38540. loadingUIBackgroundColor: string;
  38541. /**
  38542. * Gets or sets the text to display while loading
  38543. */
  38544. loadingUIText: string;
  38545. }
  38546. /**
  38547. * Class used for the default loading screen
  38548. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38549. */
  38550. export class DefaultLoadingScreen implements ILoadingScreen {
  38551. private _renderingCanvas;
  38552. private _loadingText;
  38553. private _loadingDivBackgroundColor;
  38554. private _loadingDiv;
  38555. private _loadingTextDiv;
  38556. /** Gets or sets the logo url to use for the default loading screen */
  38557. static DefaultLogoUrl: string;
  38558. /** Gets or sets the spinner url to use for the default loading screen */
  38559. static DefaultSpinnerUrl: string;
  38560. /**
  38561. * Creates a new default loading screen
  38562. * @param _renderingCanvas defines the canvas used to render the scene
  38563. * @param _loadingText defines the default text to display
  38564. * @param _loadingDivBackgroundColor defines the default background color
  38565. */
  38566. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38567. /**
  38568. * Function called to display the loading screen
  38569. */
  38570. displayLoadingUI(): void;
  38571. /**
  38572. * Function called to hide the loading screen
  38573. */
  38574. hideLoadingUI(): void;
  38575. /**
  38576. * Gets or sets the text to display while loading
  38577. */
  38578. set loadingUIText(text: string);
  38579. get loadingUIText(): string;
  38580. /**
  38581. * Gets or sets the color to use for the background
  38582. */
  38583. get loadingUIBackgroundColor(): string;
  38584. set loadingUIBackgroundColor(color: string);
  38585. private _resizeLoadingUI;
  38586. }
  38587. }
  38588. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38589. /**
  38590. * Interface for any object that can request an animation frame
  38591. */
  38592. export interface ICustomAnimationFrameRequester {
  38593. /**
  38594. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38595. */
  38596. renderFunction?: Function;
  38597. /**
  38598. * Called to request the next frame to render to
  38599. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38600. */
  38601. requestAnimationFrame: Function;
  38602. /**
  38603. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38604. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38605. */
  38606. requestID?: number;
  38607. }
  38608. }
  38609. declare module "babylonjs/Misc/performanceMonitor" {
  38610. /**
  38611. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38612. */
  38613. export class PerformanceMonitor {
  38614. private _enabled;
  38615. private _rollingFrameTime;
  38616. private _lastFrameTimeMs;
  38617. /**
  38618. * constructor
  38619. * @param frameSampleSize The number of samples required to saturate the sliding window
  38620. */
  38621. constructor(frameSampleSize?: number);
  38622. /**
  38623. * Samples current frame
  38624. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38625. */
  38626. sampleFrame(timeMs?: number): void;
  38627. /**
  38628. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38629. */
  38630. get averageFrameTime(): number;
  38631. /**
  38632. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38633. */
  38634. get averageFrameTimeVariance(): number;
  38635. /**
  38636. * Returns the frame time of the most recent frame
  38637. */
  38638. get instantaneousFrameTime(): number;
  38639. /**
  38640. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38641. */
  38642. get averageFPS(): number;
  38643. /**
  38644. * Returns the average framerate in frames per second using the most recent frame time
  38645. */
  38646. get instantaneousFPS(): number;
  38647. /**
  38648. * Returns true if enough samples have been taken to completely fill the sliding window
  38649. */
  38650. get isSaturated(): boolean;
  38651. /**
  38652. * Enables contributions to the sliding window sample set
  38653. */
  38654. enable(): void;
  38655. /**
  38656. * Disables contributions to the sliding window sample set
  38657. * Samples will not be interpolated over the disabled period
  38658. */
  38659. disable(): void;
  38660. /**
  38661. * Returns true if sampling is enabled
  38662. */
  38663. get isEnabled(): boolean;
  38664. /**
  38665. * Resets performance monitor
  38666. */
  38667. reset(): void;
  38668. }
  38669. /**
  38670. * RollingAverage
  38671. *
  38672. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38673. */
  38674. export class RollingAverage {
  38675. /**
  38676. * Current average
  38677. */
  38678. average: number;
  38679. /**
  38680. * Current variance
  38681. */
  38682. variance: number;
  38683. protected _samples: Array<number>;
  38684. protected _sampleCount: number;
  38685. protected _pos: number;
  38686. protected _m2: number;
  38687. /**
  38688. * constructor
  38689. * @param length The number of samples required to saturate the sliding window
  38690. */
  38691. constructor(length: number);
  38692. /**
  38693. * Adds a sample to the sample set
  38694. * @param v The sample value
  38695. */
  38696. add(v: number): void;
  38697. /**
  38698. * Returns previously added values or null if outside of history or outside the sliding window domain
  38699. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38700. * @return Value previously recorded with add() or null if outside of range
  38701. */
  38702. history(i: number): number;
  38703. /**
  38704. * Returns true if enough samples have been taken to completely fill the sliding window
  38705. * @return true if sample-set saturated
  38706. */
  38707. isSaturated(): boolean;
  38708. /**
  38709. * Resets the rolling average (equivalent to 0 samples taken so far)
  38710. */
  38711. reset(): void;
  38712. /**
  38713. * Wraps a value around the sample range boundaries
  38714. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38715. * @return Wrapped position in sample range
  38716. */
  38717. protected _wrapPosition(i: number): number;
  38718. }
  38719. }
  38720. declare module "babylonjs/Misc/perfCounter" {
  38721. /**
  38722. * This class is used to track a performance counter which is number based.
  38723. * The user has access to many properties which give statistics of different nature.
  38724. *
  38725. * The implementer can track two kinds of Performance Counter: time and count.
  38726. * 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.
  38727. * 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.
  38728. */
  38729. export class PerfCounter {
  38730. /**
  38731. * Gets or sets a global boolean to turn on and off all the counters
  38732. */
  38733. static Enabled: boolean;
  38734. /**
  38735. * Returns the smallest value ever
  38736. */
  38737. get min(): number;
  38738. /**
  38739. * Returns the biggest value ever
  38740. */
  38741. get max(): number;
  38742. /**
  38743. * Returns the average value since the performance counter is running
  38744. */
  38745. get average(): number;
  38746. /**
  38747. * Returns the average value of the last second the counter was monitored
  38748. */
  38749. get lastSecAverage(): number;
  38750. /**
  38751. * Returns the current value
  38752. */
  38753. get current(): number;
  38754. /**
  38755. * Gets the accumulated total
  38756. */
  38757. get total(): number;
  38758. /**
  38759. * Gets the total value count
  38760. */
  38761. get count(): number;
  38762. /**
  38763. * Creates a new counter
  38764. */
  38765. constructor();
  38766. /**
  38767. * Call this method to start monitoring a new frame.
  38768. * 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.
  38769. */
  38770. fetchNewFrame(): void;
  38771. /**
  38772. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38773. * @param newCount the count value to add to the monitored count
  38774. * @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.
  38775. */
  38776. addCount(newCount: number, fetchResult: boolean): void;
  38777. /**
  38778. * Start monitoring this performance counter
  38779. */
  38780. beginMonitoring(): void;
  38781. /**
  38782. * Compute the time lapsed since the previous beginMonitoring() call.
  38783. * @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
  38784. */
  38785. endMonitoring(newFrame?: boolean): void;
  38786. private _fetchResult;
  38787. private _startMonitoringTime;
  38788. private _min;
  38789. private _max;
  38790. private _average;
  38791. private _current;
  38792. private _totalValueCount;
  38793. private _totalAccumulated;
  38794. private _lastSecAverage;
  38795. private _lastSecAccumulated;
  38796. private _lastSecTime;
  38797. private _lastSecValueCount;
  38798. }
  38799. }
  38800. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38802. import { Nullable } from "babylonjs/types";
  38803. module "babylonjs/Engines/thinEngine" {
  38804. interface ThinEngine {
  38805. /** @hidden */
  38806. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38807. }
  38808. }
  38809. }
  38810. declare module "babylonjs/Engines/engine" {
  38811. import { Observable } from "babylonjs/Misc/observable";
  38812. import { Nullable } from "babylonjs/types";
  38813. import { Scene } from "babylonjs/scene";
  38814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38815. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38816. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38817. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38818. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38819. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38820. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38821. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38822. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38823. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38824. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38825. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38826. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38827. import "babylonjs/Engines/Extensions/engine.alpha";
  38828. import "babylonjs/Engines/Extensions/engine.readTexture";
  38829. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38830. import { Material } from "babylonjs/Materials/material";
  38831. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38832. /**
  38833. * Defines the interface used by display changed events
  38834. */
  38835. export interface IDisplayChangedEventArgs {
  38836. /** Gets the vrDisplay object (if any) */
  38837. vrDisplay: Nullable<any>;
  38838. /** Gets a boolean indicating if webVR is supported */
  38839. vrSupported: boolean;
  38840. }
  38841. /**
  38842. * Defines the interface used by objects containing a viewport (like a camera)
  38843. */
  38844. interface IViewportOwnerLike {
  38845. /**
  38846. * Gets or sets the viewport
  38847. */
  38848. viewport: IViewportLike;
  38849. }
  38850. /**
  38851. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38852. */
  38853. export class Engine extends ThinEngine {
  38854. /** Defines that alpha blending is disabled */
  38855. static readonly ALPHA_DISABLE: number;
  38856. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38857. static readonly ALPHA_ADD: number;
  38858. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38859. static readonly ALPHA_COMBINE: number;
  38860. /** Defines that alpha blending to DEST - SRC * DEST */
  38861. static readonly ALPHA_SUBTRACT: number;
  38862. /** Defines that alpha blending to SRC * DEST */
  38863. static readonly ALPHA_MULTIPLY: number;
  38864. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38865. static readonly ALPHA_MAXIMIZED: number;
  38866. /** Defines that alpha blending to SRC + DEST */
  38867. static readonly ALPHA_ONEONE: number;
  38868. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38869. static readonly ALPHA_PREMULTIPLIED: number;
  38870. /**
  38871. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38872. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38873. */
  38874. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38875. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38876. static readonly ALPHA_INTERPOLATE: number;
  38877. /**
  38878. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38879. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38880. */
  38881. static readonly ALPHA_SCREENMODE: number;
  38882. /** Defines that the ressource is not delayed*/
  38883. static readonly DELAYLOADSTATE_NONE: number;
  38884. /** Defines that the ressource was successfully delay loaded */
  38885. static readonly DELAYLOADSTATE_LOADED: number;
  38886. /** Defines that the ressource is currently delay loading */
  38887. static readonly DELAYLOADSTATE_LOADING: number;
  38888. /** Defines that the ressource is delayed and has not started loading */
  38889. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38891. static readonly NEVER: number;
  38892. /** 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 */
  38893. static readonly ALWAYS: number;
  38894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38895. static readonly LESS: number;
  38896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38897. static readonly EQUAL: number;
  38898. /** 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 */
  38899. static readonly LEQUAL: number;
  38900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38901. static readonly GREATER: number;
  38902. /** 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 */
  38903. static readonly GEQUAL: number;
  38904. /** 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 */
  38905. static readonly NOTEQUAL: number;
  38906. /** Passed to stencilOperation to specify that stencil value must be kept */
  38907. static readonly KEEP: number;
  38908. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38909. static readonly REPLACE: number;
  38910. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38911. static readonly INCR: number;
  38912. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38913. static readonly DECR: number;
  38914. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38915. static readonly INVERT: number;
  38916. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38917. static readonly INCR_WRAP: number;
  38918. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38919. static readonly DECR_WRAP: number;
  38920. /** Texture is not repeating outside of 0..1 UVs */
  38921. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38922. /** Texture is repeating outside of 0..1 UVs */
  38923. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38924. /** Texture is repeating and mirrored */
  38925. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38926. /** ALPHA */
  38927. static readonly TEXTUREFORMAT_ALPHA: number;
  38928. /** LUMINANCE */
  38929. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38930. /** LUMINANCE_ALPHA */
  38931. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38932. /** RGB */
  38933. static readonly TEXTUREFORMAT_RGB: number;
  38934. /** RGBA */
  38935. static readonly TEXTUREFORMAT_RGBA: number;
  38936. /** RED */
  38937. static readonly TEXTUREFORMAT_RED: number;
  38938. /** RED (2nd reference) */
  38939. static readonly TEXTUREFORMAT_R: number;
  38940. /** RG */
  38941. static readonly TEXTUREFORMAT_RG: number;
  38942. /** RED_INTEGER */
  38943. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38944. /** RED_INTEGER (2nd reference) */
  38945. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38946. /** RG_INTEGER */
  38947. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38948. /** RGB_INTEGER */
  38949. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38950. /** RGBA_INTEGER */
  38951. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38952. /** UNSIGNED_BYTE */
  38953. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38954. /** UNSIGNED_BYTE (2nd reference) */
  38955. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38956. /** FLOAT */
  38957. static readonly TEXTURETYPE_FLOAT: number;
  38958. /** HALF_FLOAT */
  38959. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38960. /** BYTE */
  38961. static readonly TEXTURETYPE_BYTE: number;
  38962. /** SHORT */
  38963. static readonly TEXTURETYPE_SHORT: number;
  38964. /** UNSIGNED_SHORT */
  38965. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38966. /** INT */
  38967. static readonly TEXTURETYPE_INT: number;
  38968. /** UNSIGNED_INT */
  38969. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38970. /** UNSIGNED_SHORT_4_4_4_4 */
  38971. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38972. /** UNSIGNED_SHORT_5_5_5_1 */
  38973. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38974. /** UNSIGNED_SHORT_5_6_5 */
  38975. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38976. /** UNSIGNED_INT_2_10_10_10_REV */
  38977. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38978. /** UNSIGNED_INT_24_8 */
  38979. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38980. /** UNSIGNED_INT_10F_11F_11F_REV */
  38981. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38982. /** UNSIGNED_INT_5_9_9_9_REV */
  38983. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38984. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38985. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38986. /** nearest is mag = nearest and min = nearest and mip = linear */
  38987. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38989. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38990. /** Trilinear is mag = linear and min = linear and mip = linear */
  38991. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38992. /** nearest is mag = nearest and min = nearest and mip = linear */
  38993. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38994. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38995. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38996. /** Trilinear is mag = linear and min = linear and mip = linear */
  38997. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38998. /** mag = nearest and min = nearest and mip = nearest */
  38999. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  39000. /** mag = nearest and min = linear and mip = nearest */
  39001. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  39002. /** mag = nearest and min = linear and mip = linear */
  39003. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  39004. /** mag = nearest and min = linear and mip = none */
  39005. static readonly TEXTURE_NEAREST_LINEAR: number;
  39006. /** mag = nearest and min = nearest and mip = none */
  39007. static readonly TEXTURE_NEAREST_NEAREST: number;
  39008. /** mag = linear and min = nearest and mip = nearest */
  39009. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  39010. /** mag = linear and min = nearest and mip = linear */
  39011. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  39012. /** mag = linear and min = linear and mip = none */
  39013. static readonly TEXTURE_LINEAR_LINEAR: number;
  39014. /** mag = linear and min = nearest and mip = none */
  39015. static readonly TEXTURE_LINEAR_NEAREST: number;
  39016. /** Explicit coordinates mode */
  39017. static readonly TEXTURE_EXPLICIT_MODE: number;
  39018. /** Spherical coordinates mode */
  39019. static readonly TEXTURE_SPHERICAL_MODE: number;
  39020. /** Planar coordinates mode */
  39021. static readonly TEXTURE_PLANAR_MODE: number;
  39022. /** Cubic coordinates mode */
  39023. static readonly TEXTURE_CUBIC_MODE: number;
  39024. /** Projection coordinates mode */
  39025. static readonly TEXTURE_PROJECTION_MODE: number;
  39026. /** Skybox coordinates mode */
  39027. static readonly TEXTURE_SKYBOX_MODE: number;
  39028. /** Inverse Cubic coordinates mode */
  39029. static readonly TEXTURE_INVCUBIC_MODE: number;
  39030. /** Equirectangular coordinates mode */
  39031. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  39032. /** Equirectangular Fixed coordinates mode */
  39033. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  39034. /** Equirectangular Fixed Mirrored coordinates mode */
  39035. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  39036. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  39037. static readonly SCALEMODE_FLOOR: number;
  39038. /** Defines that texture rescaling will look for the nearest power of 2 size */
  39039. static readonly SCALEMODE_NEAREST: number;
  39040. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  39041. static readonly SCALEMODE_CEILING: number;
  39042. /**
  39043. * Returns the current npm package of the sdk
  39044. */
  39045. static get NpmPackage(): string;
  39046. /**
  39047. * Returns the current version of the framework
  39048. */
  39049. static get Version(): string;
  39050. /** Gets the list of created engines */
  39051. static get Instances(): Engine[];
  39052. /**
  39053. * Gets the latest created engine
  39054. */
  39055. static get LastCreatedEngine(): Nullable<Engine>;
  39056. /**
  39057. * Gets the latest created scene
  39058. */
  39059. static get LastCreatedScene(): Nullable<Scene>;
  39060. /**
  39061. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  39062. * @param flag defines which part of the materials must be marked as dirty
  39063. * @param predicate defines a predicate used to filter which materials should be affected
  39064. */
  39065. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39066. /**
  39067. * Method called to create the default loading screen.
  39068. * This can be overriden in your own app.
  39069. * @param canvas The rendering canvas element
  39070. * @returns The loading screen
  39071. */
  39072. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  39073. /**
  39074. * Method called to create the default rescale post process on each engine.
  39075. */
  39076. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  39077. /**
  39078. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  39079. **/
  39080. enableOfflineSupport: boolean;
  39081. /**
  39082. * 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)
  39083. **/
  39084. disableManifestCheck: boolean;
  39085. /**
  39086. * Gets the list of created scenes
  39087. */
  39088. scenes: Scene[];
  39089. /**
  39090. * Event raised when a new scene is created
  39091. */
  39092. onNewSceneAddedObservable: Observable<Scene>;
  39093. /**
  39094. * Gets the list of created postprocesses
  39095. */
  39096. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  39097. /**
  39098. * Gets a boolean indicating if the pointer is currently locked
  39099. */
  39100. isPointerLock: boolean;
  39101. /**
  39102. * Observable event triggered each time the rendering canvas is resized
  39103. */
  39104. onResizeObservable: Observable<Engine>;
  39105. /**
  39106. * Observable event triggered each time the canvas loses focus
  39107. */
  39108. onCanvasBlurObservable: Observable<Engine>;
  39109. /**
  39110. * Observable event triggered each time the canvas gains focus
  39111. */
  39112. onCanvasFocusObservable: Observable<Engine>;
  39113. /**
  39114. * Observable event triggered each time the canvas receives pointerout event
  39115. */
  39116. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39117. /**
  39118. * Observable raised when the engine begins a new frame
  39119. */
  39120. onBeginFrameObservable: Observable<Engine>;
  39121. /**
  39122. * If set, will be used to request the next animation frame for the render loop
  39123. */
  39124. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39125. /**
  39126. * Observable raised when the engine ends the current frame
  39127. */
  39128. onEndFrameObservable: Observable<Engine>;
  39129. /**
  39130. * Observable raised when the engine is about to compile a shader
  39131. */
  39132. onBeforeShaderCompilationObservable: Observable<Engine>;
  39133. /**
  39134. * Observable raised when the engine has jsut compiled a shader
  39135. */
  39136. onAfterShaderCompilationObservable: Observable<Engine>;
  39137. /**
  39138. * Gets the audio engine
  39139. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39140. * @ignorenaming
  39141. */
  39142. static audioEngine: IAudioEngine;
  39143. /**
  39144. * Default AudioEngine factory responsible of creating the Audio Engine.
  39145. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39146. */
  39147. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39148. /**
  39149. * Default offline support factory responsible of creating a tool used to store data locally.
  39150. * By default, this will create a Database object if the workload has been embedded.
  39151. */
  39152. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39153. private _loadingScreen;
  39154. private _pointerLockRequested;
  39155. private _rescalePostProcess;
  39156. private _deterministicLockstep;
  39157. private _lockstepMaxSteps;
  39158. private _timeStep;
  39159. protected get _supportsHardwareTextureRescaling(): boolean;
  39160. private _fps;
  39161. private _deltaTime;
  39162. /** @hidden */
  39163. _drawCalls: PerfCounter;
  39164. /** 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 */
  39165. canvasTabIndex: number;
  39166. /**
  39167. * Turn this value on if you want to pause FPS computation when in background
  39168. */
  39169. disablePerformanceMonitorInBackground: boolean;
  39170. private _performanceMonitor;
  39171. /**
  39172. * Gets the performance monitor attached to this engine
  39173. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39174. */
  39175. get performanceMonitor(): PerformanceMonitor;
  39176. private _onFocus;
  39177. private _onBlur;
  39178. private _onCanvasPointerOut;
  39179. private _onCanvasBlur;
  39180. private _onCanvasFocus;
  39181. private _onFullscreenChange;
  39182. private _onPointerLockChange;
  39183. /**
  39184. * Gets the HTML element used to attach event listeners
  39185. * @returns a HTML element
  39186. */
  39187. getInputElement(): Nullable<HTMLElement>;
  39188. /**
  39189. * Creates a new engine
  39190. * @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
  39191. * @param antialias defines enable antialiasing (default: false)
  39192. * @param options defines further options to be sent to the getContext() function
  39193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39194. */
  39195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39196. /**
  39197. * Gets current aspect ratio
  39198. * @param viewportOwner defines the camera to use to get the aspect ratio
  39199. * @param useScreen defines if screen size must be used (or the current render target if any)
  39200. * @returns a number defining the aspect ratio
  39201. */
  39202. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39203. /**
  39204. * Gets current screen aspect ratio
  39205. * @returns a number defining the aspect ratio
  39206. */
  39207. getScreenAspectRatio(): number;
  39208. /**
  39209. * Gets the client rect of the HTML canvas attached with the current webGL context
  39210. * @returns a client rectanglee
  39211. */
  39212. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39213. /**
  39214. * Gets the client rect of the HTML element used for events
  39215. * @returns a client rectanglee
  39216. */
  39217. getInputElementClientRect(): Nullable<ClientRect>;
  39218. /**
  39219. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39220. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39221. * @returns true if engine is in deterministic lock step mode
  39222. */
  39223. isDeterministicLockStep(): boolean;
  39224. /**
  39225. * Gets the max steps when engine is running in deterministic lock step
  39226. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39227. * @returns the max steps
  39228. */
  39229. getLockstepMaxSteps(): number;
  39230. /**
  39231. * Returns the time in ms between steps when using deterministic lock step.
  39232. * @returns time step in (ms)
  39233. */
  39234. getTimeStep(): number;
  39235. /**
  39236. * Force the mipmap generation for the given render target texture
  39237. * @param texture defines the render target texture to use
  39238. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39239. */
  39240. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39241. /** States */
  39242. /**
  39243. * Set various states to the webGL context
  39244. * @param culling defines backface culling state
  39245. * @param zOffset defines the value to apply to zOffset (0 by default)
  39246. * @param force defines if states must be applied even if cache is up to date
  39247. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39248. */
  39249. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39250. /**
  39251. * Set the z offset to apply to current rendering
  39252. * @param value defines the offset to apply
  39253. */
  39254. setZOffset(value: number): void;
  39255. /**
  39256. * Gets the current value of the zOffset
  39257. * @returns the current zOffset state
  39258. */
  39259. getZOffset(): number;
  39260. /**
  39261. * Enable or disable depth buffering
  39262. * @param enable defines the state to set
  39263. */
  39264. setDepthBuffer(enable: boolean): void;
  39265. /**
  39266. * Gets a boolean indicating if depth writing is enabled
  39267. * @returns the current depth writing state
  39268. */
  39269. getDepthWrite(): boolean;
  39270. /**
  39271. * Enable or disable depth writing
  39272. * @param enable defines the state to set
  39273. */
  39274. setDepthWrite(enable: boolean): void;
  39275. /**
  39276. * Gets a boolean indicating if stencil buffer is enabled
  39277. * @returns the current stencil buffer state
  39278. */
  39279. getStencilBuffer(): boolean;
  39280. /**
  39281. * Enable or disable the stencil buffer
  39282. * @param enable defines if the stencil buffer must be enabled or disabled
  39283. */
  39284. setStencilBuffer(enable: boolean): void;
  39285. /**
  39286. * Gets the current stencil mask
  39287. * @returns a number defining the new stencil mask to use
  39288. */
  39289. getStencilMask(): number;
  39290. /**
  39291. * Sets the current stencil mask
  39292. * @param mask defines the new stencil mask to use
  39293. */
  39294. setStencilMask(mask: number): void;
  39295. /**
  39296. * Gets the current stencil function
  39297. * @returns a number defining the stencil function to use
  39298. */
  39299. getStencilFunction(): number;
  39300. /**
  39301. * Gets the current stencil reference value
  39302. * @returns a number defining the stencil reference value to use
  39303. */
  39304. getStencilFunctionReference(): number;
  39305. /**
  39306. * Gets the current stencil mask
  39307. * @returns a number defining the stencil mask to use
  39308. */
  39309. getStencilFunctionMask(): number;
  39310. /**
  39311. * Sets the current stencil function
  39312. * @param stencilFunc defines the new stencil function to use
  39313. */
  39314. setStencilFunction(stencilFunc: number): void;
  39315. /**
  39316. * Sets the current stencil reference
  39317. * @param reference defines the new stencil reference to use
  39318. */
  39319. setStencilFunctionReference(reference: number): void;
  39320. /**
  39321. * Sets the current stencil mask
  39322. * @param mask defines the new stencil mask to use
  39323. */
  39324. setStencilFunctionMask(mask: number): void;
  39325. /**
  39326. * Gets the current stencil operation when stencil fails
  39327. * @returns a number defining stencil operation to use when stencil fails
  39328. */
  39329. getStencilOperationFail(): number;
  39330. /**
  39331. * Gets the current stencil operation when depth fails
  39332. * @returns a number defining stencil operation to use when depth fails
  39333. */
  39334. getStencilOperationDepthFail(): number;
  39335. /**
  39336. * Gets the current stencil operation when stencil passes
  39337. * @returns a number defining stencil operation to use when stencil passes
  39338. */
  39339. getStencilOperationPass(): number;
  39340. /**
  39341. * Sets the stencil operation to use when stencil fails
  39342. * @param operation defines the stencil operation to use when stencil fails
  39343. */
  39344. setStencilOperationFail(operation: number): void;
  39345. /**
  39346. * Sets the stencil operation to use when depth fails
  39347. * @param operation defines the stencil operation to use when depth fails
  39348. */
  39349. setStencilOperationDepthFail(operation: number): void;
  39350. /**
  39351. * Sets the stencil operation to use when stencil passes
  39352. * @param operation defines the stencil operation to use when stencil passes
  39353. */
  39354. setStencilOperationPass(operation: number): void;
  39355. /**
  39356. * Sets a boolean indicating if the dithering state is enabled or disabled
  39357. * @param value defines the dithering state
  39358. */
  39359. setDitheringState(value: boolean): void;
  39360. /**
  39361. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39362. * @param value defines the rasterizer state
  39363. */
  39364. setRasterizerState(value: boolean): void;
  39365. /**
  39366. * Gets the current depth function
  39367. * @returns a number defining the depth function
  39368. */
  39369. getDepthFunction(): Nullable<number>;
  39370. /**
  39371. * Sets the current depth function
  39372. * @param depthFunc defines the function to use
  39373. */
  39374. setDepthFunction(depthFunc: number): void;
  39375. /**
  39376. * Sets the current depth function to GREATER
  39377. */
  39378. setDepthFunctionToGreater(): void;
  39379. /**
  39380. * Sets the current depth function to GEQUAL
  39381. */
  39382. setDepthFunctionToGreaterOrEqual(): void;
  39383. /**
  39384. * Sets the current depth function to LESS
  39385. */
  39386. setDepthFunctionToLess(): void;
  39387. /**
  39388. * Sets the current depth function to LEQUAL
  39389. */
  39390. setDepthFunctionToLessOrEqual(): void;
  39391. private _cachedStencilBuffer;
  39392. private _cachedStencilFunction;
  39393. private _cachedStencilMask;
  39394. private _cachedStencilOperationPass;
  39395. private _cachedStencilOperationFail;
  39396. private _cachedStencilOperationDepthFail;
  39397. private _cachedStencilReference;
  39398. /**
  39399. * Caches the the state of the stencil buffer
  39400. */
  39401. cacheStencilState(): void;
  39402. /**
  39403. * Restores the state of the stencil buffer
  39404. */
  39405. restoreStencilState(): void;
  39406. /**
  39407. * Directly set the WebGL Viewport
  39408. * @param x defines the x coordinate of the viewport (in screen space)
  39409. * @param y defines the y coordinate of the viewport (in screen space)
  39410. * @param width defines the width of the viewport (in screen space)
  39411. * @param height defines the height of the viewport (in screen space)
  39412. * @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
  39413. */
  39414. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39415. /**
  39416. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39417. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39418. * @param y defines the y-coordinate of the corner of the clear rectangle
  39419. * @param width defines the width of the clear rectangle
  39420. * @param height defines the height of the clear rectangle
  39421. * @param clearColor defines the clear color
  39422. */
  39423. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39424. /**
  39425. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39426. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39427. * @param y defines the y-coordinate of the corner of the clear rectangle
  39428. * @param width defines the width of the clear rectangle
  39429. * @param height defines the height of the clear rectangle
  39430. */
  39431. enableScissor(x: number, y: number, width: number, height: number): void;
  39432. /**
  39433. * Disable previously set scissor test rectangle
  39434. */
  39435. disableScissor(): void;
  39436. protected _reportDrawCall(): void;
  39437. /**
  39438. * Initializes a webVR display and starts listening to display change events
  39439. * The onVRDisplayChangedObservable will be notified upon these changes
  39440. * @returns The onVRDisplayChangedObservable
  39441. */
  39442. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39443. /** @hidden */
  39444. _prepareVRComponent(): void;
  39445. /** @hidden */
  39446. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39447. /** @hidden */
  39448. _submitVRFrame(): void;
  39449. /**
  39450. * Call this function to leave webVR mode
  39451. * Will do nothing if webVR is not supported or if there is no webVR device
  39452. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39453. */
  39454. disableVR(): void;
  39455. /**
  39456. * Gets a boolean indicating that the system is in VR mode and is presenting
  39457. * @returns true if VR mode is engaged
  39458. */
  39459. isVRPresenting(): boolean;
  39460. /** @hidden */
  39461. _requestVRFrame(): void;
  39462. /** @hidden */
  39463. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39464. /**
  39465. * Gets the source code of the vertex shader associated with a specific webGL program
  39466. * @param program defines the program to use
  39467. * @returns a string containing the source code of the vertex shader associated with the program
  39468. */
  39469. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39470. /**
  39471. * Gets the source code of the fragment shader associated with a specific webGL program
  39472. * @param program defines the program to use
  39473. * @returns a string containing the source code of the fragment shader associated with the program
  39474. */
  39475. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39476. /**
  39477. * Sets a depth stencil texture from a render target to the according uniform.
  39478. * @param channel The texture channel
  39479. * @param uniform The uniform to set
  39480. * @param texture The render target texture containing the depth stencil texture to apply
  39481. */
  39482. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39483. /**
  39484. * Sets a texture to the webGL context from a postprocess
  39485. * @param channel defines the channel to use
  39486. * @param postProcess defines the source postprocess
  39487. */
  39488. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39489. /**
  39490. * Binds the output of the passed in post process to the texture channel specified
  39491. * @param channel The channel the texture should be bound to
  39492. * @param postProcess The post process which's output should be bound
  39493. */
  39494. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39495. protected _rebuildBuffers(): void;
  39496. /** @hidden */
  39497. _renderFrame(): void;
  39498. _renderLoop(): void;
  39499. /** @hidden */
  39500. _renderViews(): boolean;
  39501. /**
  39502. * Toggle full screen mode
  39503. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39504. */
  39505. switchFullscreen(requestPointerLock: boolean): void;
  39506. /**
  39507. * Enters full screen mode
  39508. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39509. */
  39510. enterFullscreen(requestPointerLock: boolean): void;
  39511. /**
  39512. * Exits full screen mode
  39513. */
  39514. exitFullscreen(): void;
  39515. /**
  39516. * Enters Pointerlock mode
  39517. */
  39518. enterPointerlock(): void;
  39519. /**
  39520. * Exits Pointerlock mode
  39521. */
  39522. exitPointerlock(): void;
  39523. /**
  39524. * Begin a new frame
  39525. */
  39526. beginFrame(): void;
  39527. /**
  39528. * Enf the current frame
  39529. */
  39530. endFrame(): void;
  39531. resize(): void;
  39532. /**
  39533. * Force a specific size of the canvas
  39534. * @param width defines the new canvas' width
  39535. * @param height defines the new canvas' height
  39536. * @returns true if the size was changed
  39537. */
  39538. setSize(width: number, height: number): boolean;
  39539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39540. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39541. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39542. _releaseTexture(texture: InternalTexture): void;
  39543. /**
  39544. * @hidden
  39545. * Rescales a texture
  39546. * @param source input texutre
  39547. * @param destination destination texture
  39548. * @param scene scene to use to render the resize
  39549. * @param internalFormat format to use when resizing
  39550. * @param onComplete callback to be called when resize has completed
  39551. */
  39552. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39553. /**
  39554. * Gets the current framerate
  39555. * @returns a number representing the framerate
  39556. */
  39557. getFps(): number;
  39558. /**
  39559. * Gets the time spent between current and previous frame
  39560. * @returns a number representing the delta time in ms
  39561. */
  39562. getDeltaTime(): number;
  39563. private _measureFps;
  39564. /** @hidden */
  39565. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39566. /**
  39567. * Updates the sample count of a render target texture
  39568. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39569. * @param texture defines the texture to update
  39570. * @param samples defines the sample count to set
  39571. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39572. */
  39573. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39574. /**
  39575. * Updates a depth texture Comparison Mode and Function.
  39576. * If the comparison Function is equal to 0, the mode will be set to none.
  39577. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39578. * @param texture The texture to set the comparison function for
  39579. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39580. */
  39581. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39582. /**
  39583. * Creates a webGL buffer to use with instanciation
  39584. * @param capacity defines the size of the buffer
  39585. * @returns the webGL buffer
  39586. */
  39587. createInstancesBuffer(capacity: number): DataBuffer;
  39588. /**
  39589. * Delete a webGL buffer used with instanciation
  39590. * @param buffer defines the webGL buffer to delete
  39591. */
  39592. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39593. private _clientWaitAsync;
  39594. /** @hidden */
  39595. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39596. dispose(): void;
  39597. private _disableTouchAction;
  39598. /**
  39599. * Display the loading screen
  39600. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39601. */
  39602. displayLoadingUI(): void;
  39603. /**
  39604. * Hide the loading screen
  39605. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39606. */
  39607. hideLoadingUI(): void;
  39608. /**
  39609. * Gets the current loading screen object
  39610. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39611. */
  39612. get loadingScreen(): ILoadingScreen;
  39613. /**
  39614. * Sets the current loading screen object
  39615. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39616. */
  39617. set loadingScreen(loadingScreen: ILoadingScreen);
  39618. /**
  39619. * Sets the current loading screen text
  39620. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39621. */
  39622. set loadingUIText(text: string);
  39623. /**
  39624. * Sets the current loading screen background color
  39625. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39626. */
  39627. set loadingUIBackgroundColor(color: string);
  39628. /** Pointerlock and fullscreen */
  39629. /**
  39630. * Ask the browser to promote the current element to pointerlock mode
  39631. * @param element defines the DOM element to promote
  39632. */
  39633. static _RequestPointerlock(element: HTMLElement): void;
  39634. /**
  39635. * Asks the browser to exit pointerlock mode
  39636. */
  39637. static _ExitPointerlock(): void;
  39638. /**
  39639. * Ask the browser to promote the current element to fullscreen rendering mode
  39640. * @param element defines the DOM element to promote
  39641. */
  39642. static _RequestFullscreen(element: HTMLElement): void;
  39643. /**
  39644. * Asks the browser to exit fullscreen mode
  39645. */
  39646. static _ExitFullscreen(): void;
  39647. }
  39648. }
  39649. declare module "babylonjs/Engines/engineStore" {
  39650. import { Nullable } from "babylonjs/types";
  39651. import { Engine } from "babylonjs/Engines/engine";
  39652. import { Scene } from "babylonjs/scene";
  39653. /**
  39654. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39655. * during the life time of the application.
  39656. */
  39657. export class EngineStore {
  39658. /** Gets the list of created engines */
  39659. static Instances: import("babylonjs/Engines/engine").Engine[];
  39660. /** @hidden */
  39661. static _LastCreatedScene: Nullable<Scene>;
  39662. /**
  39663. * Gets the latest created engine
  39664. */
  39665. static get LastCreatedEngine(): Nullable<Engine>;
  39666. /**
  39667. * Gets the latest created scene
  39668. */
  39669. static get LastCreatedScene(): Nullable<Scene>;
  39670. /**
  39671. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39672. * @ignorenaming
  39673. */
  39674. static UseFallbackTexture: boolean;
  39675. /**
  39676. * Texture content used if a texture cannot loaded
  39677. * @ignorenaming
  39678. */
  39679. static FallbackTexture: string;
  39680. }
  39681. }
  39682. declare module "babylonjs/Misc/promise" {
  39683. /**
  39684. * Helper class that provides a small promise polyfill
  39685. */
  39686. export class PromisePolyfill {
  39687. /**
  39688. * Static function used to check if the polyfill is required
  39689. * If this is the case then the function will inject the polyfill to window.Promise
  39690. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39691. */
  39692. static Apply(force?: boolean): void;
  39693. }
  39694. }
  39695. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39696. /**
  39697. * Interface for screenshot methods with describe argument called `size` as object with options
  39698. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39699. */
  39700. export interface IScreenshotSize {
  39701. /**
  39702. * number in pixels for canvas height
  39703. */
  39704. height?: number;
  39705. /**
  39706. * multiplier allowing render at a higher or lower resolution
  39707. * If value is defined then height and width will be ignored and taken from camera
  39708. */
  39709. precision?: number;
  39710. /**
  39711. * number in pixels for canvas width
  39712. */
  39713. width?: number;
  39714. }
  39715. }
  39716. declare module "babylonjs/Misc/tools" {
  39717. import { Nullable, float } from "babylonjs/types";
  39718. import { DomManagement } from "babylonjs/Misc/domManagement";
  39719. import { WebRequest } from "babylonjs/Misc/webRequest";
  39720. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39721. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39723. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39724. import { Camera } from "babylonjs/Cameras/camera";
  39725. import { Engine } from "babylonjs/Engines/engine";
  39726. interface IColor4Like {
  39727. r: float;
  39728. g: float;
  39729. b: float;
  39730. a: float;
  39731. }
  39732. /**
  39733. * Class containing a set of static utilities functions
  39734. */
  39735. export class Tools {
  39736. /**
  39737. * Gets or sets the base URL to use to load assets
  39738. */
  39739. static get BaseUrl(): string;
  39740. static set BaseUrl(value: string);
  39741. /**
  39742. * Enable/Disable Custom HTTP Request Headers globally.
  39743. * default = false
  39744. * @see CustomRequestHeaders
  39745. */
  39746. static UseCustomRequestHeaders: boolean;
  39747. /**
  39748. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39749. * i.e. when loading files, where the server/service expects an Authorization header
  39750. */
  39751. static CustomRequestHeaders: {
  39752. [key: string]: string;
  39753. };
  39754. /**
  39755. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39756. */
  39757. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39758. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39759. /**
  39760. * Default behaviour for cors in the application.
  39761. * It can be a string if the expected behavior is identical in the entire app.
  39762. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39763. */
  39764. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39765. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39766. /**
  39767. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39768. * @ignorenaming
  39769. */
  39770. static get UseFallbackTexture(): boolean;
  39771. static set UseFallbackTexture(value: boolean);
  39772. /**
  39773. * Use this object to register external classes like custom textures or material
  39774. * to allow the laoders to instantiate them
  39775. */
  39776. static get RegisteredExternalClasses(): {
  39777. [key: string]: Object;
  39778. };
  39779. static set RegisteredExternalClasses(classes: {
  39780. [key: string]: Object;
  39781. });
  39782. /**
  39783. * Texture content used if a texture cannot loaded
  39784. * @ignorenaming
  39785. */
  39786. static get fallbackTexture(): string;
  39787. static set fallbackTexture(value: string);
  39788. /**
  39789. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39790. * @param u defines the coordinate on X axis
  39791. * @param v defines the coordinate on Y axis
  39792. * @param width defines the width of the source data
  39793. * @param height defines the height of the source data
  39794. * @param pixels defines the source byte array
  39795. * @param color defines the output color
  39796. */
  39797. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39798. /**
  39799. * Interpolates between a and b via alpha
  39800. * @param a The lower value (returned when alpha = 0)
  39801. * @param b The upper value (returned when alpha = 1)
  39802. * @param alpha The interpolation-factor
  39803. * @return The mixed value
  39804. */
  39805. static Mix(a: number, b: number, alpha: number): number;
  39806. /**
  39807. * Tries to instantiate a new object from a given class name
  39808. * @param className defines the class name to instantiate
  39809. * @returns the new object or null if the system was not able to do the instantiation
  39810. */
  39811. static Instantiate(className: string): any;
  39812. /**
  39813. * Provides a slice function that will work even on IE
  39814. * @param data defines the array to slice
  39815. * @param start defines the start of the data (optional)
  39816. * @param end defines the end of the data (optional)
  39817. * @returns the new sliced array
  39818. */
  39819. static Slice<T>(data: T, start?: number, end?: number): T;
  39820. /**
  39821. * Polyfill for setImmediate
  39822. * @param action defines the action to execute after the current execution block
  39823. */
  39824. static SetImmediate(action: () => void): void;
  39825. /**
  39826. * Function indicating if a number is an exponent of 2
  39827. * @param value defines the value to test
  39828. * @returns true if the value is an exponent of 2
  39829. */
  39830. static IsExponentOfTwo(value: number): boolean;
  39831. private static _tmpFloatArray;
  39832. /**
  39833. * Returns the nearest 32-bit single precision float representation of a Number
  39834. * @param value A Number. If the parameter is of a different type, it will get converted
  39835. * to a number or to NaN if it cannot be converted
  39836. * @returns number
  39837. */
  39838. static FloatRound(value: number): number;
  39839. /**
  39840. * Extracts the filename from a path
  39841. * @param path defines the path to use
  39842. * @returns the filename
  39843. */
  39844. static GetFilename(path: string): string;
  39845. /**
  39846. * Extracts the "folder" part of a path (everything before the filename).
  39847. * @param uri The URI to extract the info from
  39848. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39849. * @returns The "folder" part of the path
  39850. */
  39851. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39852. /**
  39853. * Extracts text content from a DOM element hierarchy
  39854. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39855. */
  39856. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39857. /**
  39858. * Convert an angle in radians to degrees
  39859. * @param angle defines the angle to convert
  39860. * @returns the angle in degrees
  39861. */
  39862. static ToDegrees(angle: number): number;
  39863. /**
  39864. * Convert an angle in degrees to radians
  39865. * @param angle defines the angle to convert
  39866. * @returns the angle in radians
  39867. */
  39868. static ToRadians(angle: number): number;
  39869. /**
  39870. * Returns an array if obj is not an array
  39871. * @param obj defines the object to evaluate as an array
  39872. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39873. * @returns either obj directly if obj is an array or a new array containing obj
  39874. */
  39875. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39876. /**
  39877. * Gets the pointer prefix to use
  39878. * @param engine defines the engine we are finding the prefix for
  39879. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39880. */
  39881. static GetPointerPrefix(engine: Engine): string;
  39882. /**
  39883. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39884. * @param url define the url we are trying
  39885. * @param element define the dom element where to configure the cors policy
  39886. */
  39887. static SetCorsBehavior(url: string | string[], element: {
  39888. crossOrigin: string | null;
  39889. }): void;
  39890. /**
  39891. * Removes unwanted characters from an url
  39892. * @param url defines the url to clean
  39893. * @returns the cleaned url
  39894. */
  39895. static CleanUrl(url: string): string;
  39896. /**
  39897. * Gets or sets a function used to pre-process url before using them to load assets
  39898. */
  39899. static get PreprocessUrl(): (url: string) => string;
  39900. static set PreprocessUrl(processor: (url: string) => string);
  39901. /**
  39902. * Loads an image as an HTMLImageElement.
  39903. * @param input url string, ArrayBuffer, or Blob to load
  39904. * @param onLoad callback called when the image successfully loads
  39905. * @param onError callback called when the image fails to load
  39906. * @param offlineProvider offline provider for caching
  39907. * @param mimeType optional mime type
  39908. * @returns the HTMLImageElement of the loaded image
  39909. */
  39910. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39911. /**
  39912. * Loads a file from a url
  39913. * @param url url string, ArrayBuffer, or Blob to load
  39914. * @param onSuccess callback called when the file successfully loads
  39915. * @param onProgress callback called while file is loading (if the server supports this mode)
  39916. * @param offlineProvider defines the offline provider for caching
  39917. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39918. * @param onError callback called when the file fails to load
  39919. * @returns a file request object
  39920. */
  39921. 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;
  39922. /**
  39923. * Loads a file from a url
  39924. * @param url the file url to load
  39925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39926. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39927. */
  39928. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39929. /**
  39930. * Load a script (identified by an url). When the url returns, the
  39931. * content of this file is added into a new script element, attached to the DOM (body element)
  39932. * @param scriptUrl defines the url of the script to laod
  39933. * @param onSuccess defines the callback called when the script is loaded
  39934. * @param onError defines the callback to call if an error occurs
  39935. * @param scriptId defines the id of the script element
  39936. */
  39937. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39938. /**
  39939. * Load an asynchronous script (identified by an url). When the url returns, the
  39940. * content of this file is added into a new script element, attached to the DOM (body element)
  39941. * @param scriptUrl defines the url of the script to laod
  39942. * @param scriptId defines the id of the script element
  39943. * @returns a promise request object
  39944. */
  39945. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39946. /**
  39947. * Loads a file from a blob
  39948. * @param fileToLoad defines the blob to use
  39949. * @param callback defines the callback to call when data is loaded
  39950. * @param progressCallback defines the callback to call during loading process
  39951. * @returns a file request object
  39952. */
  39953. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39954. /**
  39955. * Reads a file from a File object
  39956. * @param file defines the file to load
  39957. * @param onSuccess defines the callback to call when data is loaded
  39958. * @param onProgress defines the callback to call during loading process
  39959. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39960. * @param onError defines the callback to call when an error occurs
  39961. * @returns a file request object
  39962. */
  39963. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39964. /**
  39965. * Creates a data url from a given string content
  39966. * @param content defines the content to convert
  39967. * @returns the new data url link
  39968. */
  39969. static FileAsURL(content: string): string;
  39970. /**
  39971. * Format the given number to a specific decimal format
  39972. * @param value defines the number to format
  39973. * @param decimals defines the number of decimals to use
  39974. * @returns the formatted string
  39975. */
  39976. static Format(value: number, decimals?: number): string;
  39977. /**
  39978. * Tries to copy an object by duplicating every property
  39979. * @param source defines the source object
  39980. * @param destination defines the target object
  39981. * @param doNotCopyList defines a list of properties to avoid
  39982. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39983. */
  39984. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39985. /**
  39986. * Gets a boolean indicating if the given object has no own property
  39987. * @param obj defines the object to test
  39988. * @returns true if object has no own property
  39989. */
  39990. static IsEmpty(obj: any): boolean;
  39991. /**
  39992. * Function used to register events at window level
  39993. * @param windowElement defines the Window object to use
  39994. * @param events defines the events to register
  39995. */
  39996. static RegisterTopRootEvents(windowElement: Window, events: {
  39997. name: string;
  39998. handler: Nullable<(e: FocusEvent) => any>;
  39999. }[]): void;
  40000. /**
  40001. * Function used to unregister events from window level
  40002. * @param windowElement defines the Window object to use
  40003. * @param events defines the events to unregister
  40004. */
  40005. static UnregisterTopRootEvents(windowElement: Window, events: {
  40006. name: string;
  40007. handler: Nullable<(e: FocusEvent) => any>;
  40008. }[]): void;
  40009. /**
  40010. * @ignore
  40011. */
  40012. static _ScreenshotCanvas: HTMLCanvasElement;
  40013. /**
  40014. * Dumps the current bound framebuffer
  40015. * @param width defines the rendering width
  40016. * @param height defines the rendering height
  40017. * @param engine defines the hosting engine
  40018. * @param successCallback defines the callback triggered once the data are available
  40019. * @param mimeType defines the mime type of the result
  40020. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40021. */
  40022. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40023. /**
  40024. * Converts the canvas data to blob.
  40025. * This acts as a polyfill for browsers not supporting the to blob function.
  40026. * @param canvas Defines the canvas to extract the data from
  40027. * @param successCallback Defines the callback triggered once the data are available
  40028. * @param mimeType Defines the mime type of the result
  40029. */
  40030. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40031. /**
  40032. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40033. * @param successCallback defines the callback triggered once the data are available
  40034. * @param mimeType defines the mime type of the result
  40035. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40036. */
  40037. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40038. /**
  40039. * Downloads a blob in the browser
  40040. * @param blob defines the blob to download
  40041. * @param fileName defines the name of the downloaded file
  40042. */
  40043. static Download(blob: Blob, fileName: string): void;
  40044. /**
  40045. * Captures a screenshot of the current rendering
  40046. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40047. * @param engine defines the rendering engine
  40048. * @param camera defines the source camera
  40049. * @param size This parameter can be set to a single number or to an object with the
  40050. * following (optional) properties: precision, width, height. If a single number is passed,
  40051. * it will be used for both width and height. If an object is passed, the screenshot size
  40052. * will be derived from the parameters. The precision property is a multiplier allowing
  40053. * rendering at a higher or lower resolution
  40054. * @param successCallback defines the callback receives a single parameter which contains the
  40055. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40056. * src parameter of an <img> to display it
  40057. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40058. * Check your browser for supported MIME types
  40059. */
  40060. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  40061. /**
  40062. * Captures a screenshot of the current rendering
  40063. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40064. * @param engine defines the rendering engine
  40065. * @param camera defines the source camera
  40066. * @param size This parameter can be set to a single number or to an object with the
  40067. * following (optional) properties: precision, width, height. If a single number is passed,
  40068. * it will be used for both width and height. If an object is passed, the screenshot size
  40069. * will be derived from the parameters. The precision property is a multiplier allowing
  40070. * rendering at a higher or lower resolution
  40071. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40072. * Check your browser for supported MIME types
  40073. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40074. * to the src parameter of an <img> to display it
  40075. */
  40076. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  40077. /**
  40078. * Generates an image screenshot from the specified camera.
  40079. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40080. * @param engine The engine to use for rendering
  40081. * @param camera The camera to use for rendering
  40082. * @param size This parameter can be set to a single number or to an object with the
  40083. * following (optional) properties: precision, width, height. If a single number is passed,
  40084. * it will be used for both width and height. If an object is passed, the screenshot size
  40085. * will be derived from the parameters. The precision property is a multiplier allowing
  40086. * rendering at a higher or lower resolution
  40087. * @param successCallback The callback receives a single parameter which contains the
  40088. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40089. * src parameter of an <img> to display it
  40090. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40091. * Check your browser for supported MIME types
  40092. * @param samples Texture samples (default: 1)
  40093. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40094. * @param fileName A name for for the downloaded file.
  40095. */
  40096. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40097. /**
  40098. * Generates an image screenshot from the specified camera.
  40099. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40100. * @param engine The engine to use for rendering
  40101. * @param camera The camera to use for rendering
  40102. * @param size This parameter can be set to a single number or to an object with the
  40103. * following (optional) properties: precision, width, height. If a single number is passed,
  40104. * it will be used for both width and height. If an object is passed, the screenshot size
  40105. * will be derived from the parameters. The precision property is a multiplier allowing
  40106. * rendering at a higher or lower resolution
  40107. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40108. * Check your browser for supported MIME types
  40109. * @param samples Texture samples (default: 1)
  40110. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40111. * @param fileName A name for for the downloaded file.
  40112. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40113. * to the src parameter of an <img> to display it
  40114. */
  40115. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40116. /**
  40117. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40118. * Be aware Math.random() could cause collisions, but:
  40119. * "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"
  40120. * @returns a pseudo random id
  40121. */
  40122. static RandomId(): string;
  40123. /**
  40124. * Test if the given uri is a base64 string
  40125. * @param uri The uri to test
  40126. * @return True if the uri is a base64 string or false otherwise
  40127. */
  40128. static IsBase64(uri: string): boolean;
  40129. /**
  40130. * Decode the given base64 uri.
  40131. * @param uri The uri to decode
  40132. * @return The decoded base64 data.
  40133. */
  40134. static DecodeBase64(uri: string): ArrayBuffer;
  40135. /**
  40136. * Gets the absolute url.
  40137. * @param url the input url
  40138. * @return the absolute url
  40139. */
  40140. static GetAbsoluteUrl(url: string): string;
  40141. /**
  40142. * No log
  40143. */
  40144. static readonly NoneLogLevel: number;
  40145. /**
  40146. * Only message logs
  40147. */
  40148. static readonly MessageLogLevel: number;
  40149. /**
  40150. * Only warning logs
  40151. */
  40152. static readonly WarningLogLevel: number;
  40153. /**
  40154. * Only error logs
  40155. */
  40156. static readonly ErrorLogLevel: number;
  40157. /**
  40158. * All logs
  40159. */
  40160. static readonly AllLogLevel: number;
  40161. /**
  40162. * Gets a value indicating the number of loading errors
  40163. * @ignorenaming
  40164. */
  40165. static get errorsCount(): number;
  40166. /**
  40167. * Callback called when a new log is added
  40168. */
  40169. static OnNewCacheEntry: (entry: string) => void;
  40170. /**
  40171. * Log a message to the console
  40172. * @param message defines the message to log
  40173. */
  40174. static Log(message: string): void;
  40175. /**
  40176. * Write a warning message to the console
  40177. * @param message defines the message to log
  40178. */
  40179. static Warn(message: string): void;
  40180. /**
  40181. * Write an error message to the console
  40182. * @param message defines the message to log
  40183. */
  40184. static Error(message: string): void;
  40185. /**
  40186. * Gets current log cache (list of logs)
  40187. */
  40188. static get LogCache(): string;
  40189. /**
  40190. * Clears the log cache
  40191. */
  40192. static ClearLogCache(): void;
  40193. /**
  40194. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40195. */
  40196. static set LogLevels(level: number);
  40197. /**
  40198. * Checks if the window object exists
  40199. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40200. */
  40201. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40202. /**
  40203. * No performance log
  40204. */
  40205. static readonly PerformanceNoneLogLevel: number;
  40206. /**
  40207. * Use user marks to log performance
  40208. */
  40209. static readonly PerformanceUserMarkLogLevel: number;
  40210. /**
  40211. * Log performance to the console
  40212. */
  40213. static readonly PerformanceConsoleLogLevel: number;
  40214. private static _performance;
  40215. /**
  40216. * Sets the current performance log level
  40217. */
  40218. static set PerformanceLogLevel(level: number);
  40219. private static _StartPerformanceCounterDisabled;
  40220. private static _EndPerformanceCounterDisabled;
  40221. private static _StartUserMark;
  40222. private static _EndUserMark;
  40223. private static _StartPerformanceConsole;
  40224. private static _EndPerformanceConsole;
  40225. /**
  40226. * Starts a performance counter
  40227. */
  40228. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40229. /**
  40230. * Ends a specific performance coutner
  40231. */
  40232. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40233. /**
  40234. * Gets either window.performance.now() if supported or Date.now() else
  40235. */
  40236. static get Now(): number;
  40237. /**
  40238. * This method will return the name of the class used to create the instance of the given object.
  40239. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40240. * @param object the object to get the class name from
  40241. * @param isType defines if the object is actually a type
  40242. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40243. */
  40244. static GetClassName(object: any, isType?: boolean): string;
  40245. /**
  40246. * Gets the first element of an array satisfying a given predicate
  40247. * @param array defines the array to browse
  40248. * @param predicate defines the predicate to use
  40249. * @returns null if not found or the element
  40250. */
  40251. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40252. /**
  40253. * This method will return the name of the full name of the class, including its owning module (if any).
  40254. * 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).
  40255. * @param object the object to get the class name from
  40256. * @param isType defines if the object is actually a type
  40257. * @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.
  40258. * @ignorenaming
  40259. */
  40260. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40261. /**
  40262. * Returns a promise that resolves after the given amount of time.
  40263. * @param delay Number of milliseconds to delay
  40264. * @returns Promise that resolves after the given amount of time
  40265. */
  40266. static DelayAsync(delay: number): Promise<void>;
  40267. /**
  40268. * Utility function to detect if the current user agent is Safari
  40269. * @returns whether or not the current user agent is safari
  40270. */
  40271. static IsSafari(): boolean;
  40272. }
  40273. /**
  40274. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40275. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40276. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40277. * @param name The name of the class, case should be preserved
  40278. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40279. */
  40280. export function className(name: string, module?: string): (target: Object) => void;
  40281. /**
  40282. * An implementation of a loop for asynchronous functions.
  40283. */
  40284. export class AsyncLoop {
  40285. /**
  40286. * Defines the number of iterations for the loop
  40287. */
  40288. iterations: number;
  40289. /**
  40290. * Defines the current index of the loop.
  40291. */
  40292. index: number;
  40293. private _done;
  40294. private _fn;
  40295. private _successCallback;
  40296. /**
  40297. * Constructor.
  40298. * @param iterations the number of iterations.
  40299. * @param func the function to run each iteration
  40300. * @param successCallback the callback that will be called upon succesful execution
  40301. * @param offset starting offset.
  40302. */
  40303. constructor(
  40304. /**
  40305. * Defines the number of iterations for the loop
  40306. */
  40307. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40308. /**
  40309. * Execute the next iteration. Must be called after the last iteration was finished.
  40310. */
  40311. executeNext(): void;
  40312. /**
  40313. * Break the loop and run the success callback.
  40314. */
  40315. breakLoop(): void;
  40316. /**
  40317. * Create and run an async loop.
  40318. * @param iterations the number of iterations.
  40319. * @param fn the function to run each iteration
  40320. * @param successCallback the callback that will be called upon succesful execution
  40321. * @param offset starting offset.
  40322. * @returns the created async loop object
  40323. */
  40324. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40325. /**
  40326. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40327. * @param iterations total number of iterations
  40328. * @param syncedIterations number of synchronous iterations in each async iteration.
  40329. * @param fn the function to call each iteration.
  40330. * @param callback a success call back that will be called when iterating stops.
  40331. * @param breakFunction a break condition (optional)
  40332. * @param timeout timeout settings for the setTimeout function. default - 0.
  40333. * @returns the created async loop object
  40334. */
  40335. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40336. }
  40337. }
  40338. declare module "babylonjs/Misc/stringDictionary" {
  40339. import { Nullable } from "babylonjs/types";
  40340. /**
  40341. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40342. * The underlying implementation relies on an associative array to ensure the best performances.
  40343. * The value can be anything including 'null' but except 'undefined'
  40344. */
  40345. export class StringDictionary<T> {
  40346. /**
  40347. * This will clear this dictionary and copy the content from the 'source' one.
  40348. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40349. * @param source the dictionary to take the content from and copy to this dictionary
  40350. */
  40351. copyFrom(source: StringDictionary<T>): void;
  40352. /**
  40353. * Get a value based from its key
  40354. * @param key the given key to get the matching value from
  40355. * @return the value if found, otherwise undefined is returned
  40356. */
  40357. get(key: string): T | undefined;
  40358. /**
  40359. * Get a value from its key or add it if it doesn't exist.
  40360. * This method will ensure you that a given key/data will be present in the dictionary.
  40361. * @param key the given key to get the matching value from
  40362. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40363. * The factory will only be invoked if there's no data for the given key.
  40364. * @return the value corresponding to the key.
  40365. */
  40366. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40367. /**
  40368. * Get a value from its key if present in the dictionary otherwise add it
  40369. * @param key the key to get the value from
  40370. * @param val if there's no such key/value pair in the dictionary add it with this value
  40371. * @return the value corresponding to the key
  40372. */
  40373. getOrAdd(key: string, val: T): T;
  40374. /**
  40375. * Check if there's a given key in the dictionary
  40376. * @param key the key to check for
  40377. * @return true if the key is present, false otherwise
  40378. */
  40379. contains(key: string): boolean;
  40380. /**
  40381. * Add a new key and its corresponding value
  40382. * @param key the key to add
  40383. * @param value the value corresponding to the key
  40384. * @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
  40385. */
  40386. add(key: string, value: T): boolean;
  40387. /**
  40388. * Update a specific value associated to a key
  40389. * @param key defines the key to use
  40390. * @param value defines the value to store
  40391. * @returns true if the value was updated (or false if the key was not found)
  40392. */
  40393. set(key: string, value: T): boolean;
  40394. /**
  40395. * Get the element of the given key and remove it from the dictionary
  40396. * @param key defines the key to search
  40397. * @returns the value associated with the key or null if not found
  40398. */
  40399. getAndRemove(key: string): Nullable<T>;
  40400. /**
  40401. * Remove a key/value from the dictionary.
  40402. * @param key the key to remove
  40403. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40404. */
  40405. remove(key: string): boolean;
  40406. /**
  40407. * Clear the whole content of the dictionary
  40408. */
  40409. clear(): void;
  40410. /**
  40411. * Gets the current count
  40412. */
  40413. get count(): number;
  40414. /**
  40415. * Execute a callback on each key/val of the dictionary.
  40416. * Note that you can remove any element in this dictionary in the callback implementation
  40417. * @param callback the callback to execute on a given key/value pair
  40418. */
  40419. forEach(callback: (key: string, val: T) => void): void;
  40420. /**
  40421. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40422. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40423. * Note that you can remove any element in this dictionary in the callback implementation
  40424. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40425. * @returns the first item
  40426. */
  40427. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40428. private _count;
  40429. private _data;
  40430. }
  40431. }
  40432. declare module "babylonjs/Collisions/collisionCoordinator" {
  40433. import { Nullable } from "babylonjs/types";
  40434. import { Scene } from "babylonjs/scene";
  40435. import { Vector3 } from "babylonjs/Maths/math.vector";
  40436. import { Collider } from "babylonjs/Collisions/collider";
  40437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40438. /** @hidden */
  40439. export interface ICollisionCoordinator {
  40440. createCollider(): Collider;
  40441. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40442. init(scene: Scene): void;
  40443. }
  40444. /** @hidden */
  40445. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40446. private _scene;
  40447. private _scaledPosition;
  40448. private _scaledVelocity;
  40449. private _finalPosition;
  40450. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40451. createCollider(): Collider;
  40452. init(scene: Scene): void;
  40453. private _collideWithWorld;
  40454. }
  40455. }
  40456. declare module "babylonjs/Inputs/scene.inputManager" {
  40457. import { Nullable } from "babylonjs/types";
  40458. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40459. import { Vector2 } from "babylonjs/Maths/math.vector";
  40460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40461. import { Scene } from "babylonjs/scene";
  40462. /**
  40463. * Class used to manage all inputs for the scene.
  40464. */
  40465. export class InputManager {
  40466. /** The distance in pixel that you have to move to prevent some events */
  40467. static DragMovementThreshold: number;
  40468. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40469. static LongPressDelay: number;
  40470. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40471. static DoubleClickDelay: number;
  40472. /** If you need to check double click without raising a single click at first click, enable this flag */
  40473. static ExclusiveDoubleClickMode: boolean;
  40474. /** 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. */
  40475. private _alreadyAttached;
  40476. private _wheelEventName;
  40477. private _onPointerMove;
  40478. private _onPointerDown;
  40479. private _onPointerUp;
  40480. private _initClickEvent;
  40481. private _initActionManager;
  40482. private _delayedSimpleClick;
  40483. private _delayedSimpleClickTimeout;
  40484. private _previousDelayedSimpleClickTimeout;
  40485. private _meshPickProceed;
  40486. private _previousButtonPressed;
  40487. private _currentPickResult;
  40488. private _previousPickResult;
  40489. private _totalPointersPressed;
  40490. private _doubleClickOccured;
  40491. private _pointerOverMesh;
  40492. private _pickedDownMesh;
  40493. private _pickedUpMesh;
  40494. private _pointerX;
  40495. private _pointerY;
  40496. private _unTranslatedPointerX;
  40497. private _unTranslatedPointerY;
  40498. private _startingPointerPosition;
  40499. private _previousStartingPointerPosition;
  40500. private _startingPointerTime;
  40501. private _previousStartingPointerTime;
  40502. private _pointerCaptures;
  40503. private _meshUnderPointerId;
  40504. private _onKeyDown;
  40505. private _onKeyUp;
  40506. private _onCanvasFocusObserver;
  40507. private _onCanvasBlurObserver;
  40508. private _scene;
  40509. /**
  40510. * Creates a new InputManager
  40511. * @param scene defines the hosting scene
  40512. */
  40513. constructor(scene: Scene);
  40514. /**
  40515. * Gets the mesh that is currently under the pointer
  40516. */
  40517. get meshUnderPointer(): Nullable<AbstractMesh>;
  40518. /**
  40519. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40520. * @param pointerId the pointer id to use
  40521. * @returns The mesh under this pointer id or null if not found
  40522. */
  40523. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40524. /**
  40525. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40526. */
  40527. get unTranslatedPointer(): Vector2;
  40528. /**
  40529. * Gets or sets the current on-screen X position of the pointer
  40530. */
  40531. get pointerX(): number;
  40532. set pointerX(value: number);
  40533. /**
  40534. * Gets or sets the current on-screen Y position of the pointer
  40535. */
  40536. get pointerY(): number;
  40537. set pointerY(value: number);
  40538. private _updatePointerPosition;
  40539. private _processPointerMove;
  40540. private _setRayOnPointerInfo;
  40541. private _checkPrePointerObservable;
  40542. /**
  40543. * Use this method to simulate a pointer move on a mesh
  40544. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40545. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40546. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40547. */
  40548. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40549. /**
  40550. * Use this method to simulate a pointer down on a mesh
  40551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40554. */
  40555. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40556. private _processPointerDown;
  40557. /** @hidden */
  40558. _isPointerSwiping(): boolean;
  40559. /**
  40560. * Use this method to simulate a pointer up on a mesh
  40561. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40562. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40563. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40564. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40565. */
  40566. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40567. private _processPointerUp;
  40568. /**
  40569. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40570. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40571. * @returns true if the pointer was captured
  40572. */
  40573. isPointerCaptured(pointerId?: number): boolean;
  40574. /**
  40575. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40576. * @param attachUp defines if you want to attach events to pointerup
  40577. * @param attachDown defines if you want to attach events to pointerdown
  40578. * @param attachMove defines if you want to attach events to pointermove
  40579. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40580. */
  40581. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40582. /**
  40583. * Detaches all event handlers
  40584. */
  40585. detachControl(): void;
  40586. /**
  40587. * Force the value of meshUnderPointer
  40588. * @param mesh defines the mesh to use
  40589. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40590. */
  40591. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40592. /**
  40593. * Gets the mesh under the pointer
  40594. * @returns a Mesh or null if no mesh is under the pointer
  40595. */
  40596. getPointerOverMesh(): Nullable<AbstractMesh>;
  40597. }
  40598. }
  40599. declare module "babylonjs/Animations/animationGroup" {
  40600. import { Animatable } from "babylonjs/Animations/animatable";
  40601. import { Animation } from "babylonjs/Animations/animation";
  40602. import { Scene, IDisposable } from "babylonjs/scene";
  40603. import { Observable } from "babylonjs/Misc/observable";
  40604. import { Nullable } from "babylonjs/types";
  40605. import "babylonjs/Animations/animatable";
  40606. /**
  40607. * This class defines the direct association between an animation and a target
  40608. */
  40609. export class TargetedAnimation {
  40610. /**
  40611. * Animation to perform
  40612. */
  40613. animation: Animation;
  40614. /**
  40615. * Target to animate
  40616. */
  40617. target: any;
  40618. /**
  40619. * Returns the string "TargetedAnimation"
  40620. * @returns "TargetedAnimation"
  40621. */
  40622. getClassName(): string;
  40623. /**
  40624. * Serialize the object
  40625. * @returns the JSON object representing the current entity
  40626. */
  40627. serialize(): any;
  40628. }
  40629. /**
  40630. * Use this class to create coordinated animations on multiple targets
  40631. */
  40632. export class AnimationGroup implements IDisposable {
  40633. /** The name of the animation group */
  40634. name: string;
  40635. private _scene;
  40636. private _targetedAnimations;
  40637. private _animatables;
  40638. private _from;
  40639. private _to;
  40640. private _isStarted;
  40641. private _isPaused;
  40642. private _speedRatio;
  40643. private _loopAnimation;
  40644. private _isAdditive;
  40645. /**
  40646. * Gets or sets the unique id of the node
  40647. */
  40648. uniqueId: number;
  40649. /**
  40650. * This observable will notify when one animation have ended
  40651. */
  40652. onAnimationEndObservable: Observable<TargetedAnimation>;
  40653. /**
  40654. * Observer raised when one animation loops
  40655. */
  40656. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40657. /**
  40658. * Observer raised when all animations have looped
  40659. */
  40660. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40661. /**
  40662. * This observable will notify when all animations have ended.
  40663. */
  40664. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40665. /**
  40666. * This observable will notify when all animations have paused.
  40667. */
  40668. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40669. /**
  40670. * This observable will notify when all animations are playing.
  40671. */
  40672. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40673. /**
  40674. * Gets the first frame
  40675. */
  40676. get from(): number;
  40677. /**
  40678. * Gets the last frame
  40679. */
  40680. get to(): number;
  40681. /**
  40682. * Define if the animations are started
  40683. */
  40684. get isStarted(): boolean;
  40685. /**
  40686. * Gets a value indicating that the current group is playing
  40687. */
  40688. get isPlaying(): boolean;
  40689. /**
  40690. * Gets or sets the speed ratio to use for all animations
  40691. */
  40692. get speedRatio(): number;
  40693. /**
  40694. * Gets or sets the speed ratio to use for all animations
  40695. */
  40696. set speedRatio(value: number);
  40697. /**
  40698. * Gets or sets if all animations should loop or not
  40699. */
  40700. get loopAnimation(): boolean;
  40701. set loopAnimation(value: boolean);
  40702. /**
  40703. * Gets or sets if all animations should be evaluated additively
  40704. */
  40705. get isAdditive(): boolean;
  40706. set isAdditive(value: boolean);
  40707. /**
  40708. * Gets the targeted animations for this animation group
  40709. */
  40710. get targetedAnimations(): Array<TargetedAnimation>;
  40711. /**
  40712. * returning the list of animatables controlled by this animation group.
  40713. */
  40714. get animatables(): Array<Animatable>;
  40715. /**
  40716. * Gets the list of target animations
  40717. */
  40718. get children(): TargetedAnimation[];
  40719. /**
  40720. * Instantiates a new Animation Group.
  40721. * This helps managing several animations at once.
  40722. * @see https://doc.babylonjs.com/how_to/group
  40723. * @param name Defines the name of the group
  40724. * @param scene Defines the scene the group belongs to
  40725. */
  40726. constructor(
  40727. /** The name of the animation group */
  40728. name: string, scene?: Nullable<Scene>);
  40729. /**
  40730. * Add an animation (with its target) in the group
  40731. * @param animation defines the animation we want to add
  40732. * @param target defines the target of the animation
  40733. * @returns the TargetedAnimation object
  40734. */
  40735. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40736. /**
  40737. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40738. * It can add constant keys at begin or end
  40739. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40740. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40741. * @returns the animation group
  40742. */
  40743. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40744. private _animationLoopCount;
  40745. private _animationLoopFlags;
  40746. private _processLoop;
  40747. /**
  40748. * Start all animations on given targets
  40749. * @param loop defines if animations must loop
  40750. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40751. * @param from defines the from key (optional)
  40752. * @param to defines the to key (optional)
  40753. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40754. * @returns the current animation group
  40755. */
  40756. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40757. /**
  40758. * Pause all animations
  40759. * @returns the animation group
  40760. */
  40761. pause(): AnimationGroup;
  40762. /**
  40763. * Play all animations to initial state
  40764. * This function will start() the animations if they were not started or will restart() them if they were paused
  40765. * @param loop defines if animations must loop
  40766. * @returns the animation group
  40767. */
  40768. play(loop?: boolean): AnimationGroup;
  40769. /**
  40770. * Reset all animations to initial state
  40771. * @returns the animation group
  40772. */
  40773. reset(): AnimationGroup;
  40774. /**
  40775. * Restart animations from key 0
  40776. * @returns the animation group
  40777. */
  40778. restart(): AnimationGroup;
  40779. /**
  40780. * Stop all animations
  40781. * @returns the animation group
  40782. */
  40783. stop(): AnimationGroup;
  40784. /**
  40785. * Set animation weight for all animatables
  40786. * @param weight defines the weight to use
  40787. * @return the animationGroup
  40788. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40789. */
  40790. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40791. /**
  40792. * Synchronize and normalize all animatables with a source animatable
  40793. * @param root defines the root animatable to synchronize with
  40794. * @return the animationGroup
  40795. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40796. */
  40797. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40798. /**
  40799. * Goes to a specific frame in this animation group
  40800. * @param frame the frame number to go to
  40801. * @return the animationGroup
  40802. */
  40803. goToFrame(frame: number): AnimationGroup;
  40804. /**
  40805. * Dispose all associated resources
  40806. */
  40807. dispose(): void;
  40808. private _checkAnimationGroupEnded;
  40809. /**
  40810. * Clone the current animation group and returns a copy
  40811. * @param newName defines the name of the new group
  40812. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40813. * @returns the new aniamtion group
  40814. */
  40815. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40816. /**
  40817. * Serializes the animationGroup to an object
  40818. * @returns Serialized object
  40819. */
  40820. serialize(): any;
  40821. /**
  40822. * Returns a new AnimationGroup object parsed from the source provided.
  40823. * @param parsedAnimationGroup defines the source
  40824. * @param scene defines the scene that will receive the animationGroup
  40825. * @returns a new AnimationGroup
  40826. */
  40827. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40828. /**
  40829. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40830. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40831. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40832. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40833. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40834. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40835. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40836. */
  40837. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40838. /**
  40839. * Returns the string "AnimationGroup"
  40840. * @returns "AnimationGroup"
  40841. */
  40842. getClassName(): string;
  40843. /**
  40844. * Creates a detailled string about the object
  40845. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40846. * @returns a string representing the object
  40847. */
  40848. toString(fullDetails?: boolean): string;
  40849. }
  40850. }
  40851. declare module "babylonjs/scene" {
  40852. import { Nullable } from "babylonjs/types";
  40853. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40854. import { Observable } from "babylonjs/Misc/observable";
  40855. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40856. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40857. import { Geometry } from "babylonjs/Meshes/geometry";
  40858. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40861. import { Mesh } from "babylonjs/Meshes/mesh";
  40862. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40863. import { Bone } from "babylonjs/Bones/bone";
  40864. import { Skeleton } from "babylonjs/Bones/skeleton";
  40865. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40866. import { Camera } from "babylonjs/Cameras/camera";
  40867. import { AbstractScene } from "babylonjs/abstractScene";
  40868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40870. import { Material } from "babylonjs/Materials/material";
  40871. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40872. import { Effect } from "babylonjs/Materials/effect";
  40873. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40874. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40875. import { Light } from "babylonjs/Lights/light";
  40876. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40877. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40878. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40879. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40880. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40881. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40882. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40883. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40884. import { Engine } from "babylonjs/Engines/engine";
  40885. import { Node } from "babylonjs/node";
  40886. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40887. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40888. import { WebRequest } from "babylonjs/Misc/webRequest";
  40889. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40890. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40891. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40892. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40893. import { Plane } from "babylonjs/Maths/math.plane";
  40894. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40895. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40896. import { Ray } from "babylonjs/Culling/ray";
  40897. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40898. import { Animation } from "babylonjs/Animations/animation";
  40899. import { Animatable } from "babylonjs/Animations/animatable";
  40900. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40901. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40902. import { Collider } from "babylonjs/Collisions/collider";
  40903. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40904. /**
  40905. * Define an interface for all classes that will hold resources
  40906. */
  40907. export interface IDisposable {
  40908. /**
  40909. * Releases all held resources
  40910. */
  40911. dispose(): void;
  40912. }
  40913. /** Interface defining initialization parameters for Scene class */
  40914. export interface SceneOptions {
  40915. /**
  40916. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40917. * It will improve performance when the number of geometries becomes important.
  40918. */
  40919. useGeometryUniqueIdsMap?: boolean;
  40920. /**
  40921. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40922. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40923. */
  40924. useMaterialMeshMap?: boolean;
  40925. /**
  40926. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40927. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40928. */
  40929. useClonedMeshMap?: boolean;
  40930. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40931. virtual?: boolean;
  40932. }
  40933. /**
  40934. * Represents a scene to be rendered by the engine.
  40935. * @see https://doc.babylonjs.com/features/scene
  40936. */
  40937. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40938. /** The fog is deactivated */
  40939. static readonly FOGMODE_NONE: number;
  40940. /** The fog density is following an exponential function */
  40941. static readonly FOGMODE_EXP: number;
  40942. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40943. static readonly FOGMODE_EXP2: number;
  40944. /** The fog density is following a linear function. */
  40945. static readonly FOGMODE_LINEAR: number;
  40946. /**
  40947. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40949. */
  40950. static MinDeltaTime: number;
  40951. /**
  40952. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40954. */
  40955. static MaxDeltaTime: number;
  40956. /**
  40957. * Factory used to create the default material.
  40958. * @param name The name of the material to create
  40959. * @param scene The scene to create the material for
  40960. * @returns The default material
  40961. */
  40962. static DefaultMaterialFactory(scene: Scene): Material;
  40963. /**
  40964. * Factory used to create the a collision coordinator.
  40965. * @returns The collision coordinator
  40966. */
  40967. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40968. /** @hidden */
  40969. _inputManager: InputManager;
  40970. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40971. cameraToUseForPointers: Nullable<Camera>;
  40972. /** @hidden */
  40973. readonly _isScene: boolean;
  40974. /** @hidden */
  40975. _blockEntityCollection: boolean;
  40976. /**
  40977. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40978. */
  40979. autoClear: boolean;
  40980. /**
  40981. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40982. */
  40983. autoClearDepthAndStencil: boolean;
  40984. /**
  40985. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40986. */
  40987. clearColor: Color4;
  40988. /**
  40989. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40990. */
  40991. ambientColor: Color3;
  40992. /**
  40993. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40994. * It should only be one of the following (if not the default embedded one):
  40995. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40996. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40997. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40998. * The material properties need to be setup according to the type of texture in use.
  40999. */
  41000. environmentBRDFTexture: BaseTexture;
  41001. /**
  41002. * Texture used in all pbr material as the reflection texture.
  41003. * As in the majority of the scene they are the same (exception for multi room and so on),
  41004. * this is easier to reference from here than from all the materials.
  41005. */
  41006. get environmentTexture(): Nullable<BaseTexture>;
  41007. /**
  41008. * Texture used in all pbr material as the reflection texture.
  41009. * As in the majority of the scene they are the same (exception for multi room and so on),
  41010. * this is easier to set here than in all the materials.
  41011. */
  41012. set environmentTexture(value: Nullable<BaseTexture>);
  41013. /** @hidden */
  41014. protected _environmentIntensity: number;
  41015. /**
  41016. * Intensity of the environment in all pbr material.
  41017. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41018. * As in the majority of the scene they are the same (exception for multi room and so on),
  41019. * this is easier to reference from here than from all the materials.
  41020. */
  41021. get environmentIntensity(): number;
  41022. /**
  41023. * Intensity of the environment in all pbr material.
  41024. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41025. * As in the majority of the scene they are the same (exception for multi room and so on),
  41026. * this is easier to set here than in all the materials.
  41027. */
  41028. set environmentIntensity(value: number);
  41029. /** @hidden */
  41030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41031. /**
  41032. * Default image processing configuration used either in the rendering
  41033. * Forward main pass or through the imageProcessingPostProcess if present.
  41034. * As in the majority of the scene they are the same (exception for multi camera),
  41035. * this is easier to reference from here than from all the materials and post process.
  41036. *
  41037. * No setter as we it is a shared configuration, you can set the values instead.
  41038. */
  41039. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41040. private _forceWireframe;
  41041. /**
  41042. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  41043. */
  41044. set forceWireframe(value: boolean);
  41045. get forceWireframe(): boolean;
  41046. private _skipFrustumClipping;
  41047. /**
  41048. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  41049. */
  41050. set skipFrustumClipping(value: boolean);
  41051. get skipFrustumClipping(): boolean;
  41052. private _forcePointsCloud;
  41053. /**
  41054. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  41055. */
  41056. set forcePointsCloud(value: boolean);
  41057. get forcePointsCloud(): boolean;
  41058. /**
  41059. * Gets or sets the active clipplane 1
  41060. */
  41061. clipPlane: Nullable<Plane>;
  41062. /**
  41063. * Gets or sets the active clipplane 2
  41064. */
  41065. clipPlane2: Nullable<Plane>;
  41066. /**
  41067. * Gets or sets the active clipplane 3
  41068. */
  41069. clipPlane3: Nullable<Plane>;
  41070. /**
  41071. * Gets or sets the active clipplane 4
  41072. */
  41073. clipPlane4: Nullable<Plane>;
  41074. /**
  41075. * Gets or sets the active clipplane 5
  41076. */
  41077. clipPlane5: Nullable<Plane>;
  41078. /**
  41079. * Gets or sets the active clipplane 6
  41080. */
  41081. clipPlane6: Nullable<Plane>;
  41082. /**
  41083. * Gets or sets a boolean indicating if animations are enabled
  41084. */
  41085. animationsEnabled: boolean;
  41086. private _animationPropertiesOverride;
  41087. /**
  41088. * Gets or sets the animation properties override
  41089. */
  41090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  41091. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  41092. /**
  41093. * Gets or sets a boolean indicating if a constant deltatime has to be used
  41094. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  41095. */
  41096. useConstantAnimationDeltaTime: boolean;
  41097. /**
  41098. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  41099. * Please note that it requires to run a ray cast through the scene on every frame
  41100. */
  41101. constantlyUpdateMeshUnderPointer: boolean;
  41102. /**
  41103. * Defines the HTML cursor to use when hovering over interactive elements
  41104. */
  41105. hoverCursor: string;
  41106. /**
  41107. * Defines the HTML default cursor to use (empty by default)
  41108. */
  41109. defaultCursor: string;
  41110. /**
  41111. * Defines whether cursors are handled by the scene.
  41112. */
  41113. doNotHandleCursors: boolean;
  41114. /**
  41115. * This is used to call preventDefault() on pointer down
  41116. * in order to block unwanted artifacts like system double clicks
  41117. */
  41118. preventDefaultOnPointerDown: boolean;
  41119. /**
  41120. * This is used to call preventDefault() on pointer up
  41121. * in order to block unwanted artifacts like system double clicks
  41122. */
  41123. preventDefaultOnPointerUp: boolean;
  41124. /**
  41125. * Gets or sets user defined metadata
  41126. */
  41127. metadata: any;
  41128. /**
  41129. * For internal use only. Please do not use.
  41130. */
  41131. reservedDataStore: any;
  41132. /**
  41133. * Gets the name of the plugin used to load this scene (null by default)
  41134. */
  41135. loadingPluginName: string;
  41136. /**
  41137. * Use this array to add regular expressions used to disable offline support for specific urls
  41138. */
  41139. disableOfflineSupportExceptionRules: RegExp[];
  41140. /**
  41141. * An event triggered when the scene is disposed.
  41142. */
  41143. onDisposeObservable: Observable<Scene>;
  41144. private _onDisposeObserver;
  41145. /** Sets a function to be executed when this scene is disposed. */
  41146. set onDispose(callback: () => void);
  41147. /**
  41148. * An event triggered before rendering the scene (right after animations and physics)
  41149. */
  41150. onBeforeRenderObservable: Observable<Scene>;
  41151. private _onBeforeRenderObserver;
  41152. /** Sets a function to be executed before rendering this scene */
  41153. set beforeRender(callback: Nullable<() => void>);
  41154. /**
  41155. * An event triggered after rendering the scene
  41156. */
  41157. onAfterRenderObservable: Observable<Scene>;
  41158. /**
  41159. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41160. */
  41161. onAfterRenderCameraObservable: Observable<Camera>;
  41162. private _onAfterRenderObserver;
  41163. /** Sets a function to be executed after rendering this scene */
  41164. set afterRender(callback: Nullable<() => void>);
  41165. /**
  41166. * An event triggered before animating the scene
  41167. */
  41168. onBeforeAnimationsObservable: Observable<Scene>;
  41169. /**
  41170. * An event triggered after animations processing
  41171. */
  41172. onAfterAnimationsObservable: Observable<Scene>;
  41173. /**
  41174. * An event triggered before draw calls are ready to be sent
  41175. */
  41176. onBeforeDrawPhaseObservable: Observable<Scene>;
  41177. /**
  41178. * An event triggered after draw calls have been sent
  41179. */
  41180. onAfterDrawPhaseObservable: Observable<Scene>;
  41181. /**
  41182. * An event triggered when the scene is ready
  41183. */
  41184. onReadyObservable: Observable<Scene>;
  41185. /**
  41186. * An event triggered before rendering a camera
  41187. */
  41188. onBeforeCameraRenderObservable: Observable<Camera>;
  41189. private _onBeforeCameraRenderObserver;
  41190. /** Sets a function to be executed before rendering a camera*/
  41191. set beforeCameraRender(callback: () => void);
  41192. /**
  41193. * An event triggered after rendering a camera
  41194. */
  41195. onAfterCameraRenderObservable: Observable<Camera>;
  41196. private _onAfterCameraRenderObserver;
  41197. /** Sets a function to be executed after rendering a camera*/
  41198. set afterCameraRender(callback: () => void);
  41199. /**
  41200. * An event triggered when active meshes evaluation is about to start
  41201. */
  41202. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41203. /**
  41204. * An event triggered when active meshes evaluation is done
  41205. */
  41206. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41207. /**
  41208. * An event triggered when particles rendering is about to start
  41209. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41210. */
  41211. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41212. /**
  41213. * An event triggered when particles rendering is done
  41214. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41215. */
  41216. onAfterParticlesRenderingObservable: Observable<Scene>;
  41217. /**
  41218. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41219. */
  41220. onDataLoadedObservable: Observable<Scene>;
  41221. /**
  41222. * An event triggered when a camera is created
  41223. */
  41224. onNewCameraAddedObservable: Observable<Camera>;
  41225. /**
  41226. * An event triggered when a camera is removed
  41227. */
  41228. onCameraRemovedObservable: Observable<Camera>;
  41229. /**
  41230. * An event triggered when a light is created
  41231. */
  41232. onNewLightAddedObservable: Observable<Light>;
  41233. /**
  41234. * An event triggered when a light is removed
  41235. */
  41236. onLightRemovedObservable: Observable<Light>;
  41237. /**
  41238. * An event triggered when a geometry is created
  41239. */
  41240. onNewGeometryAddedObservable: Observable<Geometry>;
  41241. /**
  41242. * An event triggered when a geometry is removed
  41243. */
  41244. onGeometryRemovedObservable: Observable<Geometry>;
  41245. /**
  41246. * An event triggered when a transform node is created
  41247. */
  41248. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41249. /**
  41250. * An event triggered when a transform node is removed
  41251. */
  41252. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41253. /**
  41254. * An event triggered when a mesh is created
  41255. */
  41256. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41257. /**
  41258. * An event triggered when a mesh is removed
  41259. */
  41260. onMeshRemovedObservable: Observable<AbstractMesh>;
  41261. /**
  41262. * An event triggered when a skeleton is created
  41263. */
  41264. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41265. /**
  41266. * An event triggered when a skeleton is removed
  41267. */
  41268. onSkeletonRemovedObservable: Observable<Skeleton>;
  41269. /**
  41270. * An event triggered when a material is created
  41271. */
  41272. onNewMaterialAddedObservable: Observable<Material>;
  41273. /**
  41274. * An event triggered when a material is removed
  41275. */
  41276. onMaterialRemovedObservable: Observable<Material>;
  41277. /**
  41278. * An event triggered when a texture is created
  41279. */
  41280. onNewTextureAddedObservable: Observable<BaseTexture>;
  41281. /**
  41282. * An event triggered when a texture is removed
  41283. */
  41284. onTextureRemovedObservable: Observable<BaseTexture>;
  41285. /**
  41286. * An event triggered when render targets are about to be rendered
  41287. * Can happen multiple times per frame.
  41288. */
  41289. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41290. /**
  41291. * An event triggered when render targets were rendered.
  41292. * Can happen multiple times per frame.
  41293. */
  41294. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41295. /**
  41296. * An event triggered before calculating deterministic simulation step
  41297. */
  41298. onBeforeStepObservable: Observable<Scene>;
  41299. /**
  41300. * An event triggered after calculating deterministic simulation step
  41301. */
  41302. onAfterStepObservable: Observable<Scene>;
  41303. /**
  41304. * An event triggered when the activeCamera property is updated
  41305. */
  41306. onActiveCameraChanged: Observable<Scene>;
  41307. /**
  41308. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41309. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41310. * 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)
  41311. */
  41312. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41313. /**
  41314. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41315. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41316. * 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)
  41317. */
  41318. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41319. /**
  41320. * This Observable will when a mesh has been imported into the scene.
  41321. */
  41322. onMeshImportedObservable: Observable<AbstractMesh>;
  41323. /**
  41324. * This Observable will when an animation file has been imported into the scene.
  41325. */
  41326. onAnimationFileImportedObservable: Observable<Scene>;
  41327. /**
  41328. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41329. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41330. */
  41331. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41332. /** @hidden */
  41333. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41334. /**
  41335. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41336. */
  41337. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41338. /**
  41339. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41340. */
  41341. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41342. /**
  41343. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41344. */
  41345. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41346. /** Callback called when a pointer move is detected */
  41347. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41348. /** Callback called when a pointer down is detected */
  41349. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41350. /** Callback called when a pointer up is detected */
  41351. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41352. /** Callback called when a pointer pick is detected */
  41353. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41354. /**
  41355. * 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).
  41356. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41357. */
  41358. onPrePointerObservable: Observable<PointerInfoPre>;
  41359. /**
  41360. * Observable event triggered each time an input event is received from the rendering canvas
  41361. */
  41362. onPointerObservable: Observable<PointerInfo>;
  41363. /**
  41364. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41365. */
  41366. get unTranslatedPointer(): Vector2;
  41367. /**
  41368. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41369. */
  41370. static get DragMovementThreshold(): number;
  41371. static set DragMovementThreshold(value: number);
  41372. /**
  41373. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41374. */
  41375. static get LongPressDelay(): number;
  41376. static set LongPressDelay(value: number);
  41377. /**
  41378. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41379. */
  41380. static get DoubleClickDelay(): number;
  41381. static set DoubleClickDelay(value: number);
  41382. /** If you need to check double click without raising a single click at first click, enable this flag */
  41383. static get ExclusiveDoubleClickMode(): boolean;
  41384. static set ExclusiveDoubleClickMode(value: boolean);
  41385. /** @hidden */
  41386. _mirroredCameraPosition: Nullable<Vector3>;
  41387. /**
  41388. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41389. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41390. */
  41391. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41392. /**
  41393. * Observable event triggered each time an keyboard event is received from the hosting window
  41394. */
  41395. onKeyboardObservable: Observable<KeyboardInfo>;
  41396. private _useRightHandedSystem;
  41397. /**
  41398. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41399. */
  41400. set useRightHandedSystem(value: boolean);
  41401. get useRightHandedSystem(): boolean;
  41402. private _timeAccumulator;
  41403. private _currentStepId;
  41404. private _currentInternalStep;
  41405. /**
  41406. * Sets the step Id used by deterministic lock step
  41407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41408. * @param newStepId defines the step Id
  41409. */
  41410. setStepId(newStepId: number): void;
  41411. /**
  41412. * Gets the step Id used by deterministic lock step
  41413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41414. * @returns the step Id
  41415. */
  41416. getStepId(): number;
  41417. /**
  41418. * Gets the internal step used by deterministic lock step
  41419. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41420. * @returns the internal step
  41421. */
  41422. getInternalStep(): number;
  41423. private _fogEnabled;
  41424. /**
  41425. * Gets or sets a boolean indicating if fog is enabled on this scene
  41426. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41427. * (Default is true)
  41428. */
  41429. set fogEnabled(value: boolean);
  41430. get fogEnabled(): boolean;
  41431. private _fogMode;
  41432. /**
  41433. * Gets or sets the fog mode to use
  41434. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41435. * | mode | value |
  41436. * | --- | --- |
  41437. * | FOGMODE_NONE | 0 |
  41438. * | FOGMODE_EXP | 1 |
  41439. * | FOGMODE_EXP2 | 2 |
  41440. * | FOGMODE_LINEAR | 3 |
  41441. */
  41442. set fogMode(value: number);
  41443. get fogMode(): number;
  41444. /**
  41445. * Gets or sets the fog color to use
  41446. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41447. * (Default is Color3(0.2, 0.2, 0.3))
  41448. */
  41449. fogColor: Color3;
  41450. /**
  41451. * Gets or sets the fog density to use
  41452. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41453. * (Default is 0.1)
  41454. */
  41455. fogDensity: number;
  41456. /**
  41457. * Gets or sets the fog start distance to use
  41458. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41459. * (Default is 0)
  41460. */
  41461. fogStart: number;
  41462. /**
  41463. * Gets or sets the fog end distance to use
  41464. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41465. * (Default is 1000)
  41466. */
  41467. fogEnd: number;
  41468. /**
  41469. * Flag indicating that the frame buffer binding is handled by another component
  41470. */
  41471. prePass: boolean;
  41472. private _shadowsEnabled;
  41473. /**
  41474. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41475. */
  41476. set shadowsEnabled(value: boolean);
  41477. get shadowsEnabled(): boolean;
  41478. private _lightsEnabled;
  41479. /**
  41480. * Gets or sets a boolean indicating if lights are enabled on this scene
  41481. */
  41482. set lightsEnabled(value: boolean);
  41483. get lightsEnabled(): boolean;
  41484. /** All of the active cameras added to this scene. */
  41485. activeCameras: Camera[];
  41486. /** @hidden */
  41487. _activeCamera: Nullable<Camera>;
  41488. /** Gets or sets the current active camera */
  41489. get activeCamera(): Nullable<Camera>;
  41490. set activeCamera(value: Nullable<Camera>);
  41491. private _defaultMaterial;
  41492. /** The default material used on meshes when no material is affected */
  41493. get defaultMaterial(): Material;
  41494. /** The default material used on meshes when no material is affected */
  41495. set defaultMaterial(value: Material);
  41496. private _texturesEnabled;
  41497. /**
  41498. * Gets or sets a boolean indicating if textures are enabled on this scene
  41499. */
  41500. set texturesEnabled(value: boolean);
  41501. get texturesEnabled(): boolean;
  41502. /**
  41503. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41504. */
  41505. physicsEnabled: boolean;
  41506. /**
  41507. * Gets or sets a boolean indicating if particles are enabled on this scene
  41508. */
  41509. particlesEnabled: boolean;
  41510. /**
  41511. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41512. */
  41513. spritesEnabled: boolean;
  41514. private _skeletonsEnabled;
  41515. /**
  41516. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41517. */
  41518. set skeletonsEnabled(value: boolean);
  41519. get skeletonsEnabled(): boolean;
  41520. /**
  41521. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41522. */
  41523. lensFlaresEnabled: boolean;
  41524. /**
  41525. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41526. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41527. */
  41528. collisionsEnabled: boolean;
  41529. private _collisionCoordinator;
  41530. /** @hidden */
  41531. get collisionCoordinator(): ICollisionCoordinator;
  41532. /**
  41533. * Defines the gravity applied to this scene (used only for collisions)
  41534. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41535. */
  41536. gravity: Vector3;
  41537. /**
  41538. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41539. */
  41540. postProcessesEnabled: boolean;
  41541. /**
  41542. * Gets the current postprocess manager
  41543. */
  41544. postProcessManager: PostProcessManager;
  41545. /**
  41546. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41547. */
  41548. renderTargetsEnabled: boolean;
  41549. /**
  41550. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41551. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41552. */
  41553. dumpNextRenderTargets: boolean;
  41554. /**
  41555. * The list of user defined render targets added to the scene
  41556. */
  41557. customRenderTargets: RenderTargetTexture[];
  41558. /**
  41559. * Defines if texture loading must be delayed
  41560. * If true, textures will only be loaded when they need to be rendered
  41561. */
  41562. useDelayedTextureLoading: boolean;
  41563. /**
  41564. * Gets the list of meshes imported to the scene through SceneLoader
  41565. */
  41566. importedMeshesFiles: String[];
  41567. /**
  41568. * Gets or sets a boolean indicating if probes are enabled on this scene
  41569. */
  41570. probesEnabled: boolean;
  41571. /**
  41572. * Gets or sets the current offline provider to use to store scene data
  41573. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41574. */
  41575. offlineProvider: IOfflineProvider;
  41576. /**
  41577. * Gets or sets the action manager associated with the scene
  41578. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41579. */
  41580. actionManager: AbstractActionManager;
  41581. private _meshesForIntersections;
  41582. /**
  41583. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41584. */
  41585. proceduralTexturesEnabled: boolean;
  41586. private _engine;
  41587. private _totalVertices;
  41588. /** @hidden */
  41589. _activeIndices: PerfCounter;
  41590. /** @hidden */
  41591. _activeParticles: PerfCounter;
  41592. /** @hidden */
  41593. _activeBones: PerfCounter;
  41594. private _animationRatio;
  41595. /** @hidden */
  41596. _animationTimeLast: number;
  41597. /** @hidden */
  41598. _animationTime: number;
  41599. /**
  41600. * Gets or sets a general scale for animation speed
  41601. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41602. */
  41603. animationTimeScale: number;
  41604. /** @hidden */
  41605. _cachedMaterial: Nullable<Material>;
  41606. /** @hidden */
  41607. _cachedEffect: Nullable<Effect>;
  41608. /** @hidden */
  41609. _cachedVisibility: Nullable<number>;
  41610. private _renderId;
  41611. private _frameId;
  41612. private _executeWhenReadyTimeoutId;
  41613. private _intermediateRendering;
  41614. private _viewUpdateFlag;
  41615. private _projectionUpdateFlag;
  41616. /** @hidden */
  41617. _toBeDisposed: Nullable<IDisposable>[];
  41618. private _activeRequests;
  41619. /** @hidden */
  41620. _pendingData: any[];
  41621. private _isDisposed;
  41622. /**
  41623. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41624. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41625. */
  41626. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41627. private _activeMeshes;
  41628. private _processedMaterials;
  41629. private _renderTargets;
  41630. /** @hidden */
  41631. _activeParticleSystems: SmartArray<IParticleSystem>;
  41632. private _activeSkeletons;
  41633. private _softwareSkinnedMeshes;
  41634. private _renderingManager;
  41635. /** @hidden */
  41636. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41637. private _transformMatrix;
  41638. private _sceneUbo;
  41639. /** @hidden */
  41640. _viewMatrix: Matrix;
  41641. private _projectionMatrix;
  41642. /** @hidden */
  41643. _forcedViewPosition: Nullable<Vector3>;
  41644. /** @hidden */
  41645. _frustumPlanes: Plane[];
  41646. /**
  41647. * Gets the list of frustum planes (built from the active camera)
  41648. */
  41649. get frustumPlanes(): Plane[];
  41650. /**
  41651. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41652. * This is useful if there are more lights that the maximum simulteanous authorized
  41653. */
  41654. requireLightSorting: boolean;
  41655. /** @hidden */
  41656. readonly useMaterialMeshMap: boolean;
  41657. /** @hidden */
  41658. readonly useClonedMeshMap: boolean;
  41659. private _externalData;
  41660. private _uid;
  41661. /**
  41662. * @hidden
  41663. * Backing store of defined scene components.
  41664. */
  41665. _components: ISceneComponent[];
  41666. /**
  41667. * @hidden
  41668. * Backing store of defined scene components.
  41669. */
  41670. _serializableComponents: ISceneSerializableComponent[];
  41671. /**
  41672. * List of components to register on the next registration step.
  41673. */
  41674. private _transientComponents;
  41675. /**
  41676. * Registers the transient components if needed.
  41677. */
  41678. private _registerTransientComponents;
  41679. /**
  41680. * @hidden
  41681. * Add a component to the scene.
  41682. * Note that the ccomponent could be registered on th next frame if this is called after
  41683. * the register component stage.
  41684. * @param component Defines the component to add to the scene
  41685. */
  41686. _addComponent(component: ISceneComponent): void;
  41687. /**
  41688. * @hidden
  41689. * Gets a component from the scene.
  41690. * @param name defines the name of the component to retrieve
  41691. * @returns the component or null if not present
  41692. */
  41693. _getComponent(name: string): Nullable<ISceneComponent>;
  41694. /**
  41695. * @hidden
  41696. * Defines the actions happening before camera updates.
  41697. */
  41698. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41699. /**
  41700. * @hidden
  41701. * Defines the actions happening before clear the canvas.
  41702. */
  41703. _beforeClearStage: Stage<SimpleStageAction>;
  41704. /**
  41705. * @hidden
  41706. * Defines the actions when collecting render targets for the frame.
  41707. */
  41708. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41709. /**
  41710. * @hidden
  41711. * Defines the actions happening for one camera in the frame.
  41712. */
  41713. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41714. /**
  41715. * @hidden
  41716. * Defines the actions happening during the per mesh ready checks.
  41717. */
  41718. _isReadyForMeshStage: Stage<MeshStageAction>;
  41719. /**
  41720. * @hidden
  41721. * Defines the actions happening before evaluate active mesh checks.
  41722. */
  41723. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41724. /**
  41725. * @hidden
  41726. * Defines the actions happening during the evaluate sub mesh checks.
  41727. */
  41728. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41729. /**
  41730. * @hidden
  41731. * Defines the actions happening during the active mesh stage.
  41732. */
  41733. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41734. /**
  41735. * @hidden
  41736. * Defines the actions happening during the per camera render target step.
  41737. */
  41738. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41739. /**
  41740. * @hidden
  41741. * Defines the actions happening just before the active camera is drawing.
  41742. */
  41743. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41744. /**
  41745. * @hidden
  41746. * Defines the actions happening just before a render target is drawing.
  41747. */
  41748. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41749. /**
  41750. * @hidden
  41751. * Defines the actions happening just before a rendering group is drawing.
  41752. */
  41753. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41754. /**
  41755. * @hidden
  41756. * Defines the actions happening just before a mesh is drawing.
  41757. */
  41758. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41759. /**
  41760. * @hidden
  41761. * Defines the actions happening just after a mesh has been drawn.
  41762. */
  41763. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41764. /**
  41765. * @hidden
  41766. * Defines the actions happening just after a rendering group has been drawn.
  41767. */
  41768. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41769. /**
  41770. * @hidden
  41771. * Defines the actions happening just after the active camera has been drawn.
  41772. */
  41773. _afterCameraDrawStage: Stage<CameraStageAction>;
  41774. /**
  41775. * @hidden
  41776. * Defines the actions happening just after a render target has been drawn.
  41777. */
  41778. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41779. /**
  41780. * @hidden
  41781. * Defines the actions happening just after rendering all cameras and computing intersections.
  41782. */
  41783. _afterRenderStage: Stage<SimpleStageAction>;
  41784. /**
  41785. * @hidden
  41786. * Defines the actions happening when a pointer move event happens.
  41787. */
  41788. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41789. /**
  41790. * @hidden
  41791. * Defines the actions happening when a pointer down event happens.
  41792. */
  41793. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41794. /**
  41795. * @hidden
  41796. * Defines the actions happening when a pointer up event happens.
  41797. */
  41798. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41799. /**
  41800. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41801. */
  41802. private geometriesByUniqueId;
  41803. /**
  41804. * Creates a new Scene
  41805. * @param engine defines the engine to use to render this scene
  41806. * @param options defines the scene options
  41807. */
  41808. constructor(engine: Engine, options?: SceneOptions);
  41809. /**
  41810. * Gets a string identifying the name of the class
  41811. * @returns "Scene" string
  41812. */
  41813. getClassName(): string;
  41814. private _defaultMeshCandidates;
  41815. /**
  41816. * @hidden
  41817. */
  41818. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41819. private _defaultSubMeshCandidates;
  41820. /**
  41821. * @hidden
  41822. */
  41823. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41824. /**
  41825. * Sets the default candidate providers for the scene.
  41826. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41827. * and getCollidingSubMeshCandidates to their default function
  41828. */
  41829. setDefaultCandidateProviders(): void;
  41830. /**
  41831. * Gets the mesh that is currently under the pointer
  41832. */
  41833. get meshUnderPointer(): Nullable<AbstractMesh>;
  41834. /**
  41835. * Gets or sets the current on-screen X position of the pointer
  41836. */
  41837. get pointerX(): number;
  41838. set pointerX(value: number);
  41839. /**
  41840. * Gets or sets the current on-screen Y position of the pointer
  41841. */
  41842. get pointerY(): number;
  41843. set pointerY(value: number);
  41844. /**
  41845. * Gets the cached material (ie. the latest rendered one)
  41846. * @returns the cached material
  41847. */
  41848. getCachedMaterial(): Nullable<Material>;
  41849. /**
  41850. * Gets the cached effect (ie. the latest rendered one)
  41851. * @returns the cached effect
  41852. */
  41853. getCachedEffect(): Nullable<Effect>;
  41854. /**
  41855. * Gets the cached visibility state (ie. the latest rendered one)
  41856. * @returns the cached visibility state
  41857. */
  41858. getCachedVisibility(): Nullable<number>;
  41859. /**
  41860. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41861. * @param material defines the current material
  41862. * @param effect defines the current effect
  41863. * @param visibility defines the current visibility state
  41864. * @returns true if one parameter is not cached
  41865. */
  41866. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41867. /**
  41868. * Gets the engine associated with the scene
  41869. * @returns an Engine
  41870. */
  41871. getEngine(): Engine;
  41872. /**
  41873. * Gets the total number of vertices rendered per frame
  41874. * @returns the total number of vertices rendered per frame
  41875. */
  41876. getTotalVertices(): number;
  41877. /**
  41878. * Gets the performance counter for total vertices
  41879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41880. */
  41881. get totalVerticesPerfCounter(): PerfCounter;
  41882. /**
  41883. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41884. * @returns the total number of active indices rendered per frame
  41885. */
  41886. getActiveIndices(): number;
  41887. /**
  41888. * Gets the performance counter for active indices
  41889. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41890. */
  41891. get totalActiveIndicesPerfCounter(): PerfCounter;
  41892. /**
  41893. * Gets the total number of active particles rendered per frame
  41894. * @returns the total number of active particles rendered per frame
  41895. */
  41896. getActiveParticles(): number;
  41897. /**
  41898. * Gets the performance counter for active particles
  41899. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41900. */
  41901. get activeParticlesPerfCounter(): PerfCounter;
  41902. /**
  41903. * Gets the total number of active bones rendered per frame
  41904. * @returns the total number of active bones rendered per frame
  41905. */
  41906. getActiveBones(): number;
  41907. /**
  41908. * Gets the performance counter for active bones
  41909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41910. */
  41911. get activeBonesPerfCounter(): PerfCounter;
  41912. /**
  41913. * Gets the array of active meshes
  41914. * @returns an array of AbstractMesh
  41915. */
  41916. getActiveMeshes(): SmartArray<AbstractMesh>;
  41917. /**
  41918. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41919. * @returns a number
  41920. */
  41921. getAnimationRatio(): number;
  41922. /**
  41923. * Gets an unique Id for the current render phase
  41924. * @returns a number
  41925. */
  41926. getRenderId(): number;
  41927. /**
  41928. * Gets an unique Id for the current frame
  41929. * @returns a number
  41930. */
  41931. getFrameId(): number;
  41932. /** Call this function if you want to manually increment the render Id*/
  41933. incrementRenderId(): void;
  41934. private _createUbo;
  41935. /**
  41936. * Use this method to simulate a pointer move on a mesh
  41937. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41938. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41939. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41940. * @returns the current scene
  41941. */
  41942. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41943. /**
  41944. * Use this method to simulate a pointer down on a mesh
  41945. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41946. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41947. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41948. * @returns the current scene
  41949. */
  41950. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41951. /**
  41952. * Use this method to simulate a pointer up on a mesh
  41953. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41954. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41955. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41956. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41957. * @returns the current scene
  41958. */
  41959. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41960. /**
  41961. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41962. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41963. * @returns true if the pointer was captured
  41964. */
  41965. isPointerCaptured(pointerId?: number): boolean;
  41966. /**
  41967. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41968. * @param attachUp defines if you want to attach events to pointerup
  41969. * @param attachDown defines if you want to attach events to pointerdown
  41970. * @param attachMove defines if you want to attach events to pointermove
  41971. */
  41972. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41973. /** Detaches all event handlers*/
  41974. detachControl(): void;
  41975. /**
  41976. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41977. * Delay loaded resources are not taking in account
  41978. * @return true if all required resources are ready
  41979. */
  41980. isReady(): boolean;
  41981. /** Resets all cached information relative to material (including effect and visibility) */
  41982. resetCachedMaterial(): void;
  41983. /**
  41984. * Registers a function to be called before every frame render
  41985. * @param func defines the function to register
  41986. */
  41987. registerBeforeRender(func: () => void): void;
  41988. /**
  41989. * Unregisters a function called before every frame render
  41990. * @param func defines the function to unregister
  41991. */
  41992. unregisterBeforeRender(func: () => void): void;
  41993. /**
  41994. * Registers a function to be called after every frame render
  41995. * @param func defines the function to register
  41996. */
  41997. registerAfterRender(func: () => void): void;
  41998. /**
  41999. * Unregisters a function called after every frame render
  42000. * @param func defines the function to unregister
  42001. */
  42002. unregisterAfterRender(func: () => void): void;
  42003. private _executeOnceBeforeRender;
  42004. /**
  42005. * The provided function will run before render once and will be disposed afterwards.
  42006. * A timeout delay can be provided so that the function will be executed in N ms.
  42007. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  42008. * @param func The function to be executed.
  42009. * @param timeout optional delay in ms
  42010. */
  42011. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  42012. /** @hidden */
  42013. _addPendingData(data: any): void;
  42014. /** @hidden */
  42015. _removePendingData(data: any): void;
  42016. /**
  42017. * Returns the number of items waiting to be loaded
  42018. * @returns the number of items waiting to be loaded
  42019. */
  42020. getWaitingItemsCount(): number;
  42021. /**
  42022. * Returns a boolean indicating if the scene is still loading data
  42023. */
  42024. get isLoading(): boolean;
  42025. /**
  42026. * Registers a function to be executed when the scene is ready
  42027. * @param {Function} func - the function to be executed
  42028. */
  42029. executeWhenReady(func: () => void): void;
  42030. /**
  42031. * Returns a promise that resolves when the scene is ready
  42032. * @returns A promise that resolves when the scene is ready
  42033. */
  42034. whenReadyAsync(): Promise<void>;
  42035. /** @hidden */
  42036. _checkIsReady(): void;
  42037. /**
  42038. * Gets all animatable attached to the scene
  42039. */
  42040. get animatables(): Animatable[];
  42041. /**
  42042. * Resets the last animation time frame.
  42043. * Useful to override when animations start running when loading a scene for the first time.
  42044. */
  42045. resetLastAnimationTimeFrame(): void;
  42046. /**
  42047. * Gets the current view matrix
  42048. * @returns a Matrix
  42049. */
  42050. getViewMatrix(): Matrix;
  42051. /**
  42052. * Gets the current projection matrix
  42053. * @returns a Matrix
  42054. */
  42055. getProjectionMatrix(): Matrix;
  42056. /**
  42057. * Gets the current transform matrix
  42058. * @returns a Matrix made of View * Projection
  42059. */
  42060. getTransformMatrix(): Matrix;
  42061. /**
  42062. * Sets the current transform matrix
  42063. * @param viewL defines the View matrix to use
  42064. * @param projectionL defines the Projection matrix to use
  42065. * @param viewR defines the right View matrix to use (if provided)
  42066. * @param projectionR defines the right Projection matrix to use (if provided)
  42067. */
  42068. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  42069. /**
  42070. * Gets the uniform buffer used to store scene data
  42071. * @returns a UniformBuffer
  42072. */
  42073. getSceneUniformBuffer(): UniformBuffer;
  42074. /**
  42075. * Gets an unique (relatively to the current scene) Id
  42076. * @returns an unique number for the scene
  42077. */
  42078. getUniqueId(): number;
  42079. /**
  42080. * Add a mesh to the list of scene's meshes
  42081. * @param newMesh defines the mesh to add
  42082. * @param recursive if all child meshes should also be added to the scene
  42083. */
  42084. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  42085. /**
  42086. * Remove a mesh for the list of scene's meshes
  42087. * @param toRemove defines the mesh to remove
  42088. * @param recursive if all child meshes should also be removed from the scene
  42089. * @returns the index where the mesh was in the mesh list
  42090. */
  42091. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  42092. /**
  42093. * Add a transform node to the list of scene's transform nodes
  42094. * @param newTransformNode defines the transform node to add
  42095. */
  42096. addTransformNode(newTransformNode: TransformNode): void;
  42097. /**
  42098. * Remove a transform node for the list of scene's transform nodes
  42099. * @param toRemove defines the transform node to remove
  42100. * @returns the index where the transform node was in the transform node list
  42101. */
  42102. removeTransformNode(toRemove: TransformNode): number;
  42103. /**
  42104. * Remove a skeleton for the list of scene's skeletons
  42105. * @param toRemove defines the skeleton to remove
  42106. * @returns the index where the skeleton was in the skeleton list
  42107. */
  42108. removeSkeleton(toRemove: Skeleton): number;
  42109. /**
  42110. * Remove a morph target for the list of scene's morph targets
  42111. * @param toRemove defines the morph target to remove
  42112. * @returns the index where the morph target was in the morph target list
  42113. */
  42114. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42115. /**
  42116. * Remove a light for the list of scene's lights
  42117. * @param toRemove defines the light to remove
  42118. * @returns the index where the light was in the light list
  42119. */
  42120. removeLight(toRemove: Light): number;
  42121. /**
  42122. * Remove a camera for the list of scene's cameras
  42123. * @param toRemove defines the camera to remove
  42124. * @returns the index where the camera was in the camera list
  42125. */
  42126. removeCamera(toRemove: Camera): number;
  42127. /**
  42128. * Remove a particle system for the list of scene's particle systems
  42129. * @param toRemove defines the particle system to remove
  42130. * @returns the index where the particle system was in the particle system list
  42131. */
  42132. removeParticleSystem(toRemove: IParticleSystem): number;
  42133. /**
  42134. * Remove a animation for the list of scene's animations
  42135. * @param toRemove defines the animation to remove
  42136. * @returns the index where the animation was in the animation list
  42137. */
  42138. removeAnimation(toRemove: Animation): number;
  42139. /**
  42140. * Will stop the animation of the given target
  42141. * @param target - the target
  42142. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42143. * @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)
  42144. */
  42145. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42146. /**
  42147. * Removes the given animation group from this scene.
  42148. * @param toRemove The animation group to remove
  42149. * @returns The index of the removed animation group
  42150. */
  42151. removeAnimationGroup(toRemove: AnimationGroup): number;
  42152. /**
  42153. * Removes the given multi-material from this scene.
  42154. * @param toRemove The multi-material to remove
  42155. * @returns The index of the removed multi-material
  42156. */
  42157. removeMultiMaterial(toRemove: MultiMaterial): number;
  42158. /**
  42159. * Removes the given material from this scene.
  42160. * @param toRemove The material to remove
  42161. * @returns The index of the removed material
  42162. */
  42163. removeMaterial(toRemove: Material): number;
  42164. /**
  42165. * Removes the given action manager from this scene.
  42166. * @param toRemove The action manager to remove
  42167. * @returns The index of the removed action manager
  42168. */
  42169. removeActionManager(toRemove: AbstractActionManager): number;
  42170. /**
  42171. * Removes the given texture from this scene.
  42172. * @param toRemove The texture to remove
  42173. * @returns The index of the removed texture
  42174. */
  42175. removeTexture(toRemove: BaseTexture): number;
  42176. /**
  42177. * Adds the given light to this scene
  42178. * @param newLight The light to add
  42179. */
  42180. addLight(newLight: Light): void;
  42181. /**
  42182. * Sorts the list list based on light priorities
  42183. */
  42184. sortLightsByPriority(): void;
  42185. /**
  42186. * Adds the given camera to this scene
  42187. * @param newCamera The camera to add
  42188. */
  42189. addCamera(newCamera: Camera): void;
  42190. /**
  42191. * Adds the given skeleton to this scene
  42192. * @param newSkeleton The skeleton to add
  42193. */
  42194. addSkeleton(newSkeleton: Skeleton): void;
  42195. /**
  42196. * Adds the given particle system to this scene
  42197. * @param newParticleSystem The particle system to add
  42198. */
  42199. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42200. /**
  42201. * Adds the given animation to this scene
  42202. * @param newAnimation The animation to add
  42203. */
  42204. addAnimation(newAnimation: Animation): void;
  42205. /**
  42206. * Adds the given animation group to this scene.
  42207. * @param newAnimationGroup The animation group to add
  42208. */
  42209. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42210. /**
  42211. * Adds the given multi-material to this scene
  42212. * @param newMultiMaterial The multi-material to add
  42213. */
  42214. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42215. /**
  42216. * Adds the given material to this scene
  42217. * @param newMaterial The material to add
  42218. */
  42219. addMaterial(newMaterial: Material): void;
  42220. /**
  42221. * Adds the given morph target to this scene
  42222. * @param newMorphTargetManager The morph target to add
  42223. */
  42224. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42225. /**
  42226. * Adds the given geometry to this scene
  42227. * @param newGeometry The geometry to add
  42228. */
  42229. addGeometry(newGeometry: Geometry): void;
  42230. /**
  42231. * Adds the given action manager to this scene
  42232. * @param newActionManager The action manager to add
  42233. */
  42234. addActionManager(newActionManager: AbstractActionManager): void;
  42235. /**
  42236. * Adds the given texture to this scene.
  42237. * @param newTexture The texture to add
  42238. */
  42239. addTexture(newTexture: BaseTexture): void;
  42240. /**
  42241. * Switch active camera
  42242. * @param newCamera defines the new active camera
  42243. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42244. */
  42245. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42246. /**
  42247. * sets the active camera of the scene using its ID
  42248. * @param id defines the camera's ID
  42249. * @return the new active camera or null if none found.
  42250. */
  42251. setActiveCameraByID(id: string): Nullable<Camera>;
  42252. /**
  42253. * sets the active camera of the scene using its name
  42254. * @param name defines the camera's name
  42255. * @returns the new active camera or null if none found.
  42256. */
  42257. setActiveCameraByName(name: string): Nullable<Camera>;
  42258. /**
  42259. * get an animation group using its name
  42260. * @param name defines the material's name
  42261. * @return the animation group or null if none found.
  42262. */
  42263. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42264. /**
  42265. * Get a material using its unique id
  42266. * @param uniqueId defines the material's unique id
  42267. * @return the material or null if none found.
  42268. */
  42269. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42270. /**
  42271. * get a material using its id
  42272. * @param id defines the material's ID
  42273. * @return the material or null if none found.
  42274. */
  42275. getMaterialByID(id: string): Nullable<Material>;
  42276. /**
  42277. * Gets a the last added material using a given id
  42278. * @param id defines the material's ID
  42279. * @return the last material with the given id or null if none found.
  42280. */
  42281. getLastMaterialByID(id: string): Nullable<Material>;
  42282. /**
  42283. * Gets a material using its name
  42284. * @param name defines the material's name
  42285. * @return the material or null if none found.
  42286. */
  42287. getMaterialByName(name: string): Nullable<Material>;
  42288. /**
  42289. * Get a texture using its unique id
  42290. * @param uniqueId defines the texture's unique id
  42291. * @return the texture or null if none found.
  42292. */
  42293. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42294. /**
  42295. * Gets a camera using its id
  42296. * @param id defines the id to look for
  42297. * @returns the camera or null if not found
  42298. */
  42299. getCameraByID(id: string): Nullable<Camera>;
  42300. /**
  42301. * Gets a camera using its unique id
  42302. * @param uniqueId defines the unique id to look for
  42303. * @returns the camera or null if not found
  42304. */
  42305. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42306. /**
  42307. * Gets a camera using its name
  42308. * @param name defines the camera's name
  42309. * @return the camera or null if none found.
  42310. */
  42311. getCameraByName(name: string): Nullable<Camera>;
  42312. /**
  42313. * Gets a bone using its id
  42314. * @param id defines the bone's id
  42315. * @return the bone or null if not found
  42316. */
  42317. getBoneByID(id: string): Nullable<Bone>;
  42318. /**
  42319. * Gets a bone using its id
  42320. * @param name defines the bone's name
  42321. * @return the bone or null if not found
  42322. */
  42323. getBoneByName(name: string): Nullable<Bone>;
  42324. /**
  42325. * Gets a light node using its name
  42326. * @param name defines the the light's name
  42327. * @return the light or null if none found.
  42328. */
  42329. getLightByName(name: string): Nullable<Light>;
  42330. /**
  42331. * Gets a light node using its id
  42332. * @param id defines the light's id
  42333. * @return the light or null if none found.
  42334. */
  42335. getLightByID(id: string): Nullable<Light>;
  42336. /**
  42337. * Gets a light node using its scene-generated unique ID
  42338. * @param uniqueId defines the light's unique id
  42339. * @return the light or null if none found.
  42340. */
  42341. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42342. /**
  42343. * Gets a particle system by id
  42344. * @param id defines the particle system id
  42345. * @return the corresponding system or null if none found
  42346. */
  42347. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42348. /**
  42349. * Gets a geometry using its ID
  42350. * @param id defines the geometry's id
  42351. * @return the geometry or null if none found.
  42352. */
  42353. getGeometryByID(id: string): Nullable<Geometry>;
  42354. private _getGeometryByUniqueID;
  42355. /**
  42356. * Add a new geometry to this scene
  42357. * @param geometry defines the geometry to be added to the scene.
  42358. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42359. * @return a boolean defining if the geometry was added or not
  42360. */
  42361. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42362. /**
  42363. * Removes an existing geometry
  42364. * @param geometry defines the geometry to be removed from the scene
  42365. * @return a boolean defining if the geometry was removed or not
  42366. */
  42367. removeGeometry(geometry: Geometry): boolean;
  42368. /**
  42369. * Gets the list of geometries attached to the scene
  42370. * @returns an array of Geometry
  42371. */
  42372. getGeometries(): Geometry[];
  42373. /**
  42374. * Gets the first added mesh found of a given ID
  42375. * @param id defines the id to search for
  42376. * @return the mesh found or null if not found at all
  42377. */
  42378. getMeshByID(id: string): Nullable<AbstractMesh>;
  42379. /**
  42380. * Gets a list of meshes using their id
  42381. * @param id defines the id to search for
  42382. * @returns a list of meshes
  42383. */
  42384. getMeshesByID(id: string): Array<AbstractMesh>;
  42385. /**
  42386. * Gets the first added transform node found of a given ID
  42387. * @param id defines the id to search for
  42388. * @return the found transform node or null if not found at all.
  42389. */
  42390. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42391. /**
  42392. * Gets a transform node with its auto-generated unique id
  42393. * @param uniqueId efines the unique id to search for
  42394. * @return the found transform node or null if not found at all.
  42395. */
  42396. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42397. /**
  42398. * Gets a list of transform nodes using their id
  42399. * @param id defines the id to search for
  42400. * @returns a list of transform nodes
  42401. */
  42402. getTransformNodesByID(id: string): Array<TransformNode>;
  42403. /**
  42404. * Gets a mesh with its auto-generated unique id
  42405. * @param uniqueId defines the unique id to search for
  42406. * @return the found mesh or null if not found at all.
  42407. */
  42408. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42409. /**
  42410. * Gets a the last added mesh using a given id
  42411. * @param id defines the id to search for
  42412. * @return the found mesh or null if not found at all.
  42413. */
  42414. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42415. /**
  42416. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42417. * @param id defines the id to search for
  42418. * @return the found node or null if not found at all
  42419. */
  42420. getLastEntryByID(id: string): Nullable<Node>;
  42421. /**
  42422. * Gets a node (Mesh, Camera, Light) using a given id
  42423. * @param id defines the id to search for
  42424. * @return the found node or null if not found at all
  42425. */
  42426. getNodeByID(id: string): Nullable<Node>;
  42427. /**
  42428. * Gets a node (Mesh, Camera, Light) using a given name
  42429. * @param name defines the name to search for
  42430. * @return the found node or null if not found at all.
  42431. */
  42432. getNodeByName(name: string): Nullable<Node>;
  42433. /**
  42434. * Gets a mesh using a given name
  42435. * @param name defines the name to search for
  42436. * @return the found mesh or null if not found at all.
  42437. */
  42438. getMeshByName(name: string): Nullable<AbstractMesh>;
  42439. /**
  42440. * Gets a transform node using a given name
  42441. * @param name defines the name to search for
  42442. * @return the found transform node or null if not found at all.
  42443. */
  42444. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42445. /**
  42446. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42447. * @param id defines the id to search for
  42448. * @return the found skeleton or null if not found at all.
  42449. */
  42450. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42451. /**
  42452. * Gets a skeleton using a given auto generated unique id
  42453. * @param uniqueId defines the unique id to search for
  42454. * @return the found skeleton or null if not found at all.
  42455. */
  42456. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42457. /**
  42458. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42459. * @param id defines the id to search for
  42460. * @return the found skeleton or null if not found at all.
  42461. */
  42462. getSkeletonById(id: string): Nullable<Skeleton>;
  42463. /**
  42464. * Gets a skeleton using a given name
  42465. * @param name defines the name to search for
  42466. * @return the found skeleton or null if not found at all.
  42467. */
  42468. getSkeletonByName(name: string): Nullable<Skeleton>;
  42469. /**
  42470. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42471. * @param id defines the id to search for
  42472. * @return the found morph target manager or null if not found at all.
  42473. */
  42474. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42475. /**
  42476. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42477. * @param id defines the id to search for
  42478. * @return the found morph target or null if not found at all.
  42479. */
  42480. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42481. /**
  42482. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42483. * @param name defines the name to search for
  42484. * @return the found morph target or null if not found at all.
  42485. */
  42486. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42487. /**
  42488. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42489. * @param name defines the name to search for
  42490. * @return the found post process or null if not found at all.
  42491. */
  42492. getPostProcessByName(name: string): Nullable<PostProcess>;
  42493. /**
  42494. * Gets a boolean indicating if the given mesh is active
  42495. * @param mesh defines the mesh to look for
  42496. * @returns true if the mesh is in the active list
  42497. */
  42498. isActiveMesh(mesh: AbstractMesh): boolean;
  42499. /**
  42500. * Return a unique id as a string which can serve as an identifier for the scene
  42501. */
  42502. get uid(): string;
  42503. /**
  42504. * Add an externaly attached data from its key.
  42505. * This method call will fail and return false, if such key already exists.
  42506. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42507. * @param key the unique key that identifies the data
  42508. * @param data the data object to associate to the key for this Engine instance
  42509. * @return true if no such key were already present and the data was added successfully, false otherwise
  42510. */
  42511. addExternalData<T>(key: string, data: T): boolean;
  42512. /**
  42513. * Get an externaly attached data from its key
  42514. * @param key the unique key that identifies the data
  42515. * @return the associated data, if present (can be null), or undefined if not present
  42516. */
  42517. getExternalData<T>(key: string): Nullable<T>;
  42518. /**
  42519. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42520. * @param key the unique key that identifies the data
  42521. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42522. * @return the associated data, can be null if the factory returned null.
  42523. */
  42524. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42525. /**
  42526. * Remove an externaly attached data from the Engine instance
  42527. * @param key the unique key that identifies the data
  42528. * @return true if the data was successfully removed, false if it doesn't exist
  42529. */
  42530. removeExternalData(key: string): boolean;
  42531. private _evaluateSubMesh;
  42532. /**
  42533. * Clear the processed materials smart array preventing retention point in material dispose.
  42534. */
  42535. freeProcessedMaterials(): void;
  42536. private _preventFreeActiveMeshesAndRenderingGroups;
  42537. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42538. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42539. * when disposing several meshes in a row or a hierarchy of meshes.
  42540. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42541. */
  42542. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42543. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42544. /**
  42545. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42546. */
  42547. freeActiveMeshes(): void;
  42548. /**
  42549. * Clear the info related to rendering groups preventing retention points during dispose.
  42550. */
  42551. freeRenderingGroups(): void;
  42552. /** @hidden */
  42553. _isInIntermediateRendering(): boolean;
  42554. /**
  42555. * Lambda returning the list of potentially active meshes.
  42556. */
  42557. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42558. /**
  42559. * Lambda returning the list of potentially active sub meshes.
  42560. */
  42561. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42562. /**
  42563. * Lambda returning the list of potentially intersecting sub meshes.
  42564. */
  42565. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42566. /**
  42567. * Lambda returning the list of potentially colliding sub meshes.
  42568. */
  42569. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42570. private _activeMeshesFrozen;
  42571. private _skipEvaluateActiveMeshesCompletely;
  42572. /**
  42573. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42574. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42575. * @returns the current scene
  42576. */
  42577. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42578. /**
  42579. * Use this function to restart evaluating active meshes on every frame
  42580. * @returns the current scene
  42581. */
  42582. unfreezeActiveMeshes(): Scene;
  42583. private _evaluateActiveMeshes;
  42584. private _activeMesh;
  42585. /**
  42586. * Update the transform matrix to update from the current active camera
  42587. * @param force defines a boolean used to force the update even if cache is up to date
  42588. */
  42589. updateTransformMatrix(force?: boolean): void;
  42590. private _bindFrameBuffer;
  42591. /** @hidden */
  42592. _allowPostProcessClearColor: boolean;
  42593. /** @hidden */
  42594. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42595. private _processSubCameras;
  42596. private _checkIntersections;
  42597. /** @hidden */
  42598. _advancePhysicsEngineStep(step: number): void;
  42599. /**
  42600. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42601. */
  42602. getDeterministicFrameTime: () => number;
  42603. /** @hidden */
  42604. _animate(): void;
  42605. /** Execute all animations (for a frame) */
  42606. animate(): void;
  42607. /**
  42608. * Render the scene
  42609. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42610. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42611. */
  42612. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42613. /**
  42614. * Freeze all materials
  42615. * A frozen material will not be updatable but should be faster to render
  42616. */
  42617. freezeMaterials(): void;
  42618. /**
  42619. * Unfreeze all materials
  42620. * A frozen material will not be updatable but should be faster to render
  42621. */
  42622. unfreezeMaterials(): void;
  42623. /**
  42624. * Releases all held ressources
  42625. */
  42626. dispose(): void;
  42627. /**
  42628. * Gets if the scene is already disposed
  42629. */
  42630. get isDisposed(): boolean;
  42631. /**
  42632. * Call this function to reduce memory footprint of the scene.
  42633. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42634. */
  42635. clearCachedVertexData(): void;
  42636. /**
  42637. * This function will remove the local cached buffer data from texture.
  42638. * It will save memory but will prevent the texture from being rebuilt
  42639. */
  42640. cleanCachedTextureBuffer(): void;
  42641. /**
  42642. * Get the world extend vectors with an optional filter
  42643. *
  42644. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42645. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42646. */
  42647. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42648. min: Vector3;
  42649. max: Vector3;
  42650. };
  42651. /**
  42652. * Creates a ray that can be used to pick in the scene
  42653. * @param x defines the x coordinate of the origin (on-screen)
  42654. * @param y defines the y coordinate of the origin (on-screen)
  42655. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42656. * @param camera defines the camera to use for the picking
  42657. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42658. * @returns a Ray
  42659. */
  42660. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42661. /**
  42662. * Creates a ray that can be used to pick in the scene
  42663. * @param x defines the x coordinate of the origin (on-screen)
  42664. * @param y defines the y coordinate of the origin (on-screen)
  42665. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42666. * @param result defines the ray where to store the picking ray
  42667. * @param camera defines the camera to use for the picking
  42668. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42669. * @returns the current scene
  42670. */
  42671. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42672. /**
  42673. * Creates a ray that can be used to pick in the scene
  42674. * @param x defines the x coordinate of the origin (on-screen)
  42675. * @param y defines the y coordinate of the origin (on-screen)
  42676. * @param camera defines the camera to use for the picking
  42677. * @returns a Ray
  42678. */
  42679. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42680. /**
  42681. * Creates a ray that can be used to pick in the scene
  42682. * @param x defines the x coordinate of the origin (on-screen)
  42683. * @param y defines the y coordinate of the origin (on-screen)
  42684. * @param result defines the ray where to store the picking ray
  42685. * @param camera defines the camera to use for the picking
  42686. * @returns the current scene
  42687. */
  42688. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42689. /** Launch a ray to try to pick a mesh in the scene
  42690. * @param x position on screen
  42691. * @param y position on screen
  42692. * @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
  42693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42694. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42696. * @returns a PickingInfo
  42697. */
  42698. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42699. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42700. * @param x position on screen
  42701. * @param y position on screen
  42702. * @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
  42703. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42704. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42705. * @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)
  42706. */
  42707. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42708. /** Use the given ray to pick a mesh in the scene
  42709. * @param ray The ray to use to pick meshes
  42710. * @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
  42711. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42713. * @returns a PickingInfo
  42714. */
  42715. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42716. /**
  42717. * Launch a ray to try to pick a mesh in the scene
  42718. * @param x X position on screen
  42719. * @param y Y position on screen
  42720. * @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
  42721. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42722. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42723. * @returns an array of PickingInfo
  42724. */
  42725. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42726. /**
  42727. * Launch a ray to try to pick a mesh in the scene
  42728. * @param ray Ray to use
  42729. * @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
  42730. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42731. * @returns an array of PickingInfo
  42732. */
  42733. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42734. /**
  42735. * Force the value of meshUnderPointer
  42736. * @param mesh defines the mesh to use
  42737. * @param pointerId optional pointer id when using more than one pointer
  42738. */
  42739. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42740. /**
  42741. * Gets the mesh under the pointer
  42742. * @returns a Mesh or null if no mesh is under the pointer
  42743. */
  42744. getPointerOverMesh(): Nullable<AbstractMesh>;
  42745. /** @hidden */
  42746. _rebuildGeometries(): void;
  42747. /** @hidden */
  42748. _rebuildTextures(): void;
  42749. private _getByTags;
  42750. /**
  42751. * Get a list of meshes by tags
  42752. * @param tagsQuery defines the tags query to use
  42753. * @param forEach defines a predicate used to filter results
  42754. * @returns an array of Mesh
  42755. */
  42756. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42757. /**
  42758. * Get a list of cameras by tags
  42759. * @param tagsQuery defines the tags query to use
  42760. * @param forEach defines a predicate used to filter results
  42761. * @returns an array of Camera
  42762. */
  42763. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42764. /**
  42765. * Get a list of lights by tags
  42766. * @param tagsQuery defines the tags query to use
  42767. * @param forEach defines a predicate used to filter results
  42768. * @returns an array of Light
  42769. */
  42770. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42771. /**
  42772. * Get a list of materials by tags
  42773. * @param tagsQuery defines the tags query to use
  42774. * @param forEach defines a predicate used to filter results
  42775. * @returns an array of Material
  42776. */
  42777. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42778. /**
  42779. * Get a list of transform nodes by tags
  42780. * @param tagsQuery defines the tags query to use
  42781. * @param forEach defines a predicate used to filter results
  42782. * @returns an array of TransformNode
  42783. */
  42784. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42785. /**
  42786. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42787. * This allowed control for front to back rendering or reversly depending of the special needs.
  42788. *
  42789. * @param renderingGroupId The rendering group id corresponding to its index
  42790. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42791. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42792. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42793. */
  42794. 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;
  42795. /**
  42796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42797. *
  42798. * @param renderingGroupId The rendering group id corresponding to its index
  42799. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42800. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42801. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42802. */
  42803. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42804. /**
  42805. * Gets the current auto clear configuration for one rendering group of the rendering
  42806. * manager.
  42807. * @param index the rendering group index to get the information for
  42808. * @returns The auto clear setup for the requested rendering group
  42809. */
  42810. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42811. private _blockMaterialDirtyMechanism;
  42812. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42813. get blockMaterialDirtyMechanism(): boolean;
  42814. set blockMaterialDirtyMechanism(value: boolean);
  42815. /**
  42816. * Will flag all materials as dirty to trigger new shader compilation
  42817. * @param flag defines the flag used to specify which material part must be marked as dirty
  42818. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42819. */
  42820. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42821. /** @hidden */
  42822. _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;
  42823. /** @hidden */
  42824. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42825. /** @hidden */
  42826. _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;
  42827. /** @hidden */
  42828. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42829. /** @hidden */
  42830. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42831. /** @hidden */
  42832. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42833. }
  42834. }
  42835. declare module "babylonjs/assetContainer" {
  42836. import { AbstractScene } from "babylonjs/abstractScene";
  42837. import { Scene } from "babylonjs/scene";
  42838. import { Mesh } from "babylonjs/Meshes/mesh";
  42839. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42840. import { Skeleton } from "babylonjs/Bones/skeleton";
  42841. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42842. import { Animatable } from "babylonjs/Animations/animatable";
  42843. import { Nullable } from "babylonjs/types";
  42844. import { Node } from "babylonjs/node";
  42845. /**
  42846. * Set of assets to keep when moving a scene into an asset container.
  42847. */
  42848. export class KeepAssets extends AbstractScene {
  42849. }
  42850. /**
  42851. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42852. */
  42853. export class InstantiatedEntries {
  42854. /**
  42855. * List of new root nodes (eg. nodes with no parent)
  42856. */
  42857. rootNodes: TransformNode[];
  42858. /**
  42859. * List of new skeletons
  42860. */
  42861. skeletons: Skeleton[];
  42862. /**
  42863. * List of new animation groups
  42864. */
  42865. animationGroups: AnimationGroup[];
  42866. }
  42867. /**
  42868. * Container with a set of assets that can be added or removed from a scene.
  42869. */
  42870. export class AssetContainer extends AbstractScene {
  42871. private _wasAddedToScene;
  42872. /**
  42873. * The scene the AssetContainer belongs to.
  42874. */
  42875. scene: Scene;
  42876. /**
  42877. * Instantiates an AssetContainer.
  42878. * @param scene The scene the AssetContainer belongs to.
  42879. */
  42880. constructor(scene: Scene);
  42881. /**
  42882. * Instantiate or clone all meshes and add the new ones to the scene.
  42883. * Skeletons and animation groups will all be cloned
  42884. * @param nameFunction defines an optional function used to get new names for clones
  42885. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42886. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42887. */
  42888. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42889. /**
  42890. * Adds all the assets from the container to the scene.
  42891. */
  42892. addAllToScene(): void;
  42893. /**
  42894. * Removes all the assets in the container from the scene
  42895. */
  42896. removeAllFromScene(): void;
  42897. /**
  42898. * Disposes all the assets in the container
  42899. */
  42900. dispose(): void;
  42901. private _moveAssets;
  42902. /**
  42903. * Removes all the assets contained in the scene and adds them to the container.
  42904. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42905. */
  42906. moveAllFromScene(keepAssets?: KeepAssets): void;
  42907. /**
  42908. * 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.
  42909. * @returns the root mesh
  42910. */
  42911. createRootMesh(): Mesh;
  42912. /**
  42913. * Merge animations (direct and animation groups) from this asset container into a scene
  42914. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42915. * @param animatables set of animatables to retarget to a node from the scene
  42916. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42917. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42918. */
  42919. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42920. }
  42921. }
  42922. declare module "babylonjs/abstractScene" {
  42923. import { Scene } from "babylonjs/scene";
  42924. import { Nullable } from "babylonjs/types";
  42925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42926. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42927. import { Geometry } from "babylonjs/Meshes/geometry";
  42928. import { Skeleton } from "babylonjs/Bones/skeleton";
  42929. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42930. import { AssetContainer } from "babylonjs/assetContainer";
  42931. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42932. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42934. import { Material } from "babylonjs/Materials/material";
  42935. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42937. import { Camera } from "babylonjs/Cameras/camera";
  42938. import { Light } from "babylonjs/Lights/light";
  42939. import { Node } from "babylonjs/node";
  42940. import { Animation } from "babylonjs/Animations/animation";
  42941. /**
  42942. * Defines how the parser contract is defined.
  42943. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42944. */
  42945. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42946. /**
  42947. * Defines how the individual parser contract is defined.
  42948. * These parser can parse an individual asset
  42949. */
  42950. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42951. /**
  42952. * Base class of the scene acting as a container for the different elements composing a scene.
  42953. * This class is dynamically extended by the different components of the scene increasing
  42954. * flexibility and reducing coupling
  42955. */
  42956. export abstract class AbstractScene {
  42957. /**
  42958. * Stores the list of available parsers in the application.
  42959. */
  42960. private static _BabylonFileParsers;
  42961. /**
  42962. * Stores the list of available individual parsers in the application.
  42963. */
  42964. private static _IndividualBabylonFileParsers;
  42965. /**
  42966. * Adds a parser in the list of available ones
  42967. * @param name Defines the name of the parser
  42968. * @param parser Defines the parser to add
  42969. */
  42970. static AddParser(name: string, parser: BabylonFileParser): void;
  42971. /**
  42972. * Gets a general parser from the list of avaialble ones
  42973. * @param name Defines the name of the parser
  42974. * @returns the requested parser or null
  42975. */
  42976. static GetParser(name: string): Nullable<BabylonFileParser>;
  42977. /**
  42978. * Adds n individual parser in the list of available ones
  42979. * @param name Defines the name of the parser
  42980. * @param parser Defines the parser to add
  42981. */
  42982. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42983. /**
  42984. * Gets an individual parser from the list of avaialble ones
  42985. * @param name Defines the name of the parser
  42986. * @returns the requested parser or null
  42987. */
  42988. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42989. /**
  42990. * Parser json data and populate both a scene and its associated container object
  42991. * @param jsonData Defines the data to parse
  42992. * @param scene Defines the scene to parse the data for
  42993. * @param container Defines the container attached to the parsing sequence
  42994. * @param rootUrl Defines the root url of the data
  42995. */
  42996. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42997. /**
  42998. * Gets the list of root nodes (ie. nodes with no parent)
  42999. */
  43000. rootNodes: Node[];
  43001. /** All of the cameras added to this scene
  43002. * @see https://doc.babylonjs.com/babylon101/cameras
  43003. */
  43004. cameras: Camera[];
  43005. /**
  43006. * All of the lights added to this scene
  43007. * @see https://doc.babylonjs.com/babylon101/lights
  43008. */
  43009. lights: Light[];
  43010. /**
  43011. * All of the (abstract) meshes added to this scene
  43012. */
  43013. meshes: AbstractMesh[];
  43014. /**
  43015. * The list of skeletons added to the scene
  43016. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  43017. */
  43018. skeletons: Skeleton[];
  43019. /**
  43020. * All of the particle systems added to this scene
  43021. * @see https://doc.babylonjs.com/babylon101/particles
  43022. */
  43023. particleSystems: IParticleSystem[];
  43024. /**
  43025. * Gets a list of Animations associated with the scene
  43026. */
  43027. animations: Animation[];
  43028. /**
  43029. * All of the animation groups added to this scene
  43030. * @see https://doc.babylonjs.com/how_to/group
  43031. */
  43032. animationGroups: AnimationGroup[];
  43033. /**
  43034. * All of the multi-materials added to this scene
  43035. * @see https://doc.babylonjs.com/how_to/multi_materials
  43036. */
  43037. multiMaterials: MultiMaterial[];
  43038. /**
  43039. * All of the materials added to this scene
  43040. * In the context of a Scene, it is not supposed to be modified manually.
  43041. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  43042. * Note also that the order of the Material within the array is not significant and might change.
  43043. * @see https://doc.babylonjs.com/babylon101/materials
  43044. */
  43045. materials: Material[];
  43046. /**
  43047. * The list of morph target managers added to the scene
  43048. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  43049. */
  43050. morphTargetManagers: MorphTargetManager[];
  43051. /**
  43052. * The list of geometries used in the scene.
  43053. */
  43054. geometries: Geometry[];
  43055. /**
  43056. * All of the tranform nodes added to this scene
  43057. * In the context of a Scene, it is not supposed to be modified manually.
  43058. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  43059. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  43060. * @see https://doc.babylonjs.com/how_to/transformnode
  43061. */
  43062. transformNodes: TransformNode[];
  43063. /**
  43064. * ActionManagers available on the scene.
  43065. */
  43066. actionManagers: AbstractActionManager[];
  43067. /**
  43068. * Textures to keep.
  43069. */
  43070. textures: BaseTexture[];
  43071. /** @hidden */
  43072. protected _environmentTexture: Nullable<BaseTexture>;
  43073. /**
  43074. * Texture used in all pbr material as the reflection texture.
  43075. * As in the majority of the scene they are the same (exception for multi room and so on),
  43076. * this is easier to reference from here than from all the materials.
  43077. */
  43078. get environmentTexture(): Nullable<BaseTexture>;
  43079. set environmentTexture(value: Nullable<BaseTexture>);
  43080. /**
  43081. * The list of postprocesses added to the scene
  43082. */
  43083. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43084. /**
  43085. * @returns all meshes, lights, cameras, transformNodes and bones
  43086. */
  43087. getNodes(): Array<Node>;
  43088. }
  43089. }
  43090. declare module "babylonjs/Audio/sound" {
  43091. import { Observable } from "babylonjs/Misc/observable";
  43092. import { Vector3 } from "babylonjs/Maths/math.vector";
  43093. import { Nullable } from "babylonjs/types";
  43094. import { Scene } from "babylonjs/scene";
  43095. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43096. /**
  43097. * Interface used to define options for Sound class
  43098. */
  43099. export interface ISoundOptions {
  43100. /**
  43101. * Does the sound autoplay once loaded.
  43102. */
  43103. autoplay?: boolean;
  43104. /**
  43105. * Does the sound loop after it finishes playing once.
  43106. */
  43107. loop?: boolean;
  43108. /**
  43109. * Sound's volume
  43110. */
  43111. volume?: number;
  43112. /**
  43113. * Is it a spatial sound?
  43114. */
  43115. spatialSound?: boolean;
  43116. /**
  43117. * Maximum distance to hear that sound
  43118. */
  43119. maxDistance?: number;
  43120. /**
  43121. * Uses user defined attenuation function
  43122. */
  43123. useCustomAttenuation?: boolean;
  43124. /**
  43125. * Define the roll off factor of spatial sounds.
  43126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43127. */
  43128. rolloffFactor?: number;
  43129. /**
  43130. * Define the reference distance the sound should be heard perfectly.
  43131. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43132. */
  43133. refDistance?: number;
  43134. /**
  43135. * Define the distance attenuation model the sound will follow.
  43136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43137. */
  43138. distanceModel?: string;
  43139. /**
  43140. * Defines the playback speed (1 by default)
  43141. */
  43142. playbackRate?: number;
  43143. /**
  43144. * Defines if the sound is from a streaming source
  43145. */
  43146. streaming?: boolean;
  43147. /**
  43148. * Defines an optional length (in seconds) inside the sound file
  43149. */
  43150. length?: number;
  43151. /**
  43152. * Defines an optional offset (in seconds) inside the sound file
  43153. */
  43154. offset?: number;
  43155. /**
  43156. * If true, URLs will not be required to state the audio file codec to use.
  43157. */
  43158. skipCodecCheck?: boolean;
  43159. }
  43160. /**
  43161. * Defines a sound that can be played in the application.
  43162. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43164. */
  43165. export class Sound {
  43166. /**
  43167. * The name of the sound in the scene.
  43168. */
  43169. name: string;
  43170. /**
  43171. * Does the sound autoplay once loaded.
  43172. */
  43173. autoplay: boolean;
  43174. /**
  43175. * Does the sound loop after it finishes playing once.
  43176. */
  43177. loop: boolean;
  43178. /**
  43179. * Does the sound use a custom attenuation curve to simulate the falloff
  43180. * happening when the source gets further away from the camera.
  43181. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43182. */
  43183. useCustomAttenuation: boolean;
  43184. /**
  43185. * The sound track id this sound belongs to.
  43186. */
  43187. soundTrackId: number;
  43188. /**
  43189. * Is this sound currently played.
  43190. */
  43191. isPlaying: boolean;
  43192. /**
  43193. * Is this sound currently paused.
  43194. */
  43195. isPaused: boolean;
  43196. /**
  43197. * Does this sound enables spatial sound.
  43198. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43199. */
  43200. spatialSound: boolean;
  43201. /**
  43202. * Define the reference distance the sound should be heard perfectly.
  43203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43204. */
  43205. refDistance: number;
  43206. /**
  43207. * Define the roll off factor of spatial sounds.
  43208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43209. */
  43210. rolloffFactor: number;
  43211. /**
  43212. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43214. */
  43215. maxDistance: number;
  43216. /**
  43217. * Define the distance attenuation model the sound will follow.
  43218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43219. */
  43220. distanceModel: string;
  43221. /**
  43222. * @hidden
  43223. * Back Compat
  43224. **/
  43225. onended: () => any;
  43226. /**
  43227. * Gets or sets an object used to store user defined information for the sound.
  43228. */
  43229. metadata: any;
  43230. /**
  43231. * Observable event when the current playing sound finishes.
  43232. */
  43233. onEndedObservable: Observable<Sound>;
  43234. private _panningModel;
  43235. private _playbackRate;
  43236. private _streaming;
  43237. private _startTime;
  43238. private _startOffset;
  43239. private _position;
  43240. /** @hidden */
  43241. _positionInEmitterSpace: boolean;
  43242. private _localDirection;
  43243. private _volume;
  43244. private _isReadyToPlay;
  43245. private _isDirectional;
  43246. private _readyToPlayCallback;
  43247. private _audioBuffer;
  43248. private _soundSource;
  43249. private _streamingSource;
  43250. private _soundPanner;
  43251. private _soundGain;
  43252. private _inputAudioNode;
  43253. private _outputAudioNode;
  43254. private _coneInnerAngle;
  43255. private _coneOuterAngle;
  43256. private _coneOuterGain;
  43257. private _scene;
  43258. private _connectedTransformNode;
  43259. private _customAttenuationFunction;
  43260. private _registerFunc;
  43261. private _isOutputConnected;
  43262. private _htmlAudioElement;
  43263. private _urlType;
  43264. private _length?;
  43265. private _offset?;
  43266. /** @hidden */
  43267. static _SceneComponentInitialization: (scene: Scene) => void;
  43268. /**
  43269. * Create a sound and attach it to a scene
  43270. * @param name Name of your sound
  43271. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43272. * @param scene defines the scene the sound belongs to
  43273. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43274. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43275. */
  43276. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43277. /**
  43278. * Release the sound and its associated resources
  43279. */
  43280. dispose(): void;
  43281. /**
  43282. * Gets if the sounds is ready to be played or not.
  43283. * @returns true if ready, otherwise false
  43284. */
  43285. isReady(): boolean;
  43286. private _soundLoaded;
  43287. /**
  43288. * Sets the data of the sound from an audiobuffer
  43289. * @param audioBuffer The audioBuffer containing the data
  43290. */
  43291. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43292. /**
  43293. * Updates the current sounds options such as maxdistance, loop...
  43294. * @param options A JSON object containing values named as the object properties
  43295. */
  43296. updateOptions(options: ISoundOptions): void;
  43297. private _createSpatialParameters;
  43298. private _updateSpatialParameters;
  43299. /**
  43300. * Switch the panning model to HRTF:
  43301. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43303. */
  43304. switchPanningModelToHRTF(): void;
  43305. /**
  43306. * Switch the panning model to Equal Power:
  43307. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43308. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43309. */
  43310. switchPanningModelToEqualPower(): void;
  43311. private _switchPanningModel;
  43312. /**
  43313. * Connect this sound to a sound track audio node like gain...
  43314. * @param soundTrackAudioNode the sound track audio node to connect to
  43315. */
  43316. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43317. /**
  43318. * Transform this sound into a directional source
  43319. * @param coneInnerAngle Size of the inner cone in degree
  43320. * @param coneOuterAngle Size of the outer cone in degree
  43321. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43322. */
  43323. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43324. /**
  43325. * Gets or sets the inner angle for the directional cone.
  43326. */
  43327. get directionalConeInnerAngle(): number;
  43328. /**
  43329. * Gets or sets the inner angle for the directional cone.
  43330. */
  43331. set directionalConeInnerAngle(value: number);
  43332. /**
  43333. * Gets or sets the outer angle for the directional cone.
  43334. */
  43335. get directionalConeOuterAngle(): number;
  43336. /**
  43337. * Gets or sets the outer angle for the directional cone.
  43338. */
  43339. set directionalConeOuterAngle(value: number);
  43340. /**
  43341. * Sets the position of the emitter if spatial sound is enabled
  43342. * @param newPosition Defines the new posisiton
  43343. */
  43344. setPosition(newPosition: Vector3): void;
  43345. /**
  43346. * Sets the local direction of the emitter if spatial sound is enabled
  43347. * @param newLocalDirection Defines the new local direction
  43348. */
  43349. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43350. private _updateDirection;
  43351. /** @hidden */
  43352. updateDistanceFromListener(): void;
  43353. /**
  43354. * Sets a new custom attenuation function for the sound.
  43355. * @param callback Defines the function used for the attenuation
  43356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43357. */
  43358. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43359. /**
  43360. * Play the sound
  43361. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43362. * @param offset (optional) Start the sound at a specific time in seconds
  43363. * @param length (optional) Sound duration (in seconds)
  43364. */
  43365. play(time?: number, offset?: number, length?: number): void;
  43366. private _onended;
  43367. /**
  43368. * Stop the sound
  43369. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43370. */
  43371. stop(time?: number): void;
  43372. /**
  43373. * Put the sound in pause
  43374. */
  43375. pause(): void;
  43376. /**
  43377. * Sets a dedicated volume for this sounds
  43378. * @param newVolume Define the new volume of the sound
  43379. * @param time Define time for gradual change to new volume
  43380. */
  43381. setVolume(newVolume: number, time?: number): void;
  43382. /**
  43383. * Set the sound play back rate
  43384. * @param newPlaybackRate Define the playback rate the sound should be played at
  43385. */
  43386. setPlaybackRate(newPlaybackRate: number): void;
  43387. /**
  43388. * Gets the volume of the sound.
  43389. * @returns the volume of the sound
  43390. */
  43391. getVolume(): number;
  43392. /**
  43393. * Attach the sound to a dedicated mesh
  43394. * @param transformNode The transform node to connect the sound with
  43395. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43396. */
  43397. attachToMesh(transformNode: TransformNode): void;
  43398. /**
  43399. * Detach the sound from the previously attached mesh
  43400. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43401. */
  43402. detachFromMesh(): void;
  43403. private _onRegisterAfterWorldMatrixUpdate;
  43404. /**
  43405. * Clone the current sound in the scene.
  43406. * @returns the new sound clone
  43407. */
  43408. clone(): Nullable<Sound>;
  43409. /**
  43410. * Gets the current underlying audio buffer containing the data
  43411. * @returns the audio buffer
  43412. */
  43413. getAudioBuffer(): Nullable<AudioBuffer>;
  43414. /**
  43415. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43416. * @returns the source node
  43417. */
  43418. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43419. /**
  43420. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43421. * @returns the gain node
  43422. */
  43423. getSoundGain(): Nullable<GainNode>;
  43424. /**
  43425. * Serializes the Sound in a JSON representation
  43426. * @returns the JSON representation of the sound
  43427. */
  43428. serialize(): any;
  43429. /**
  43430. * Parse a JSON representation of a sound to innstantiate in a given scene
  43431. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43432. * @param scene Define the scene the new parsed sound should be created in
  43433. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43434. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43435. * @returns the newly parsed sound
  43436. */
  43437. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43438. }
  43439. }
  43440. declare module "babylonjs/Actions/directAudioActions" {
  43441. import { Action } from "babylonjs/Actions/action";
  43442. import { Condition } from "babylonjs/Actions/condition";
  43443. import { Sound } from "babylonjs/Audio/sound";
  43444. /**
  43445. * This defines an action helpful to play a defined sound on a triggered action.
  43446. */
  43447. export class PlaySoundAction extends Action {
  43448. private _sound;
  43449. /**
  43450. * Instantiate the action
  43451. * @param triggerOptions defines the trigger options
  43452. * @param sound defines the sound to play
  43453. * @param condition defines the trigger related conditions
  43454. */
  43455. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43456. /** @hidden */
  43457. _prepare(): void;
  43458. /**
  43459. * Execute the action and play the sound.
  43460. */
  43461. execute(): void;
  43462. /**
  43463. * Serializes the actions and its related information.
  43464. * @param parent defines the object to serialize in
  43465. * @returns the serialized object
  43466. */
  43467. serialize(parent: any): any;
  43468. }
  43469. /**
  43470. * This defines an action helpful to stop a defined sound on a triggered action.
  43471. */
  43472. export class StopSoundAction extends Action {
  43473. private _sound;
  43474. /**
  43475. * Instantiate the action
  43476. * @param triggerOptions defines the trigger options
  43477. * @param sound defines the sound to stop
  43478. * @param condition defines the trigger related conditions
  43479. */
  43480. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43481. /** @hidden */
  43482. _prepare(): void;
  43483. /**
  43484. * Execute the action and stop the sound.
  43485. */
  43486. execute(): void;
  43487. /**
  43488. * Serializes the actions and its related information.
  43489. * @param parent defines the object to serialize in
  43490. * @returns the serialized object
  43491. */
  43492. serialize(parent: any): any;
  43493. }
  43494. }
  43495. declare module "babylonjs/Actions/interpolateValueAction" {
  43496. import { Action } from "babylonjs/Actions/action";
  43497. import { Condition } from "babylonjs/Actions/condition";
  43498. import { Observable } from "babylonjs/Misc/observable";
  43499. /**
  43500. * This defines an action responsible to change the value of a property
  43501. * by interpolating between its current value and the newly set one once triggered.
  43502. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43503. */
  43504. export class InterpolateValueAction extends Action {
  43505. /**
  43506. * Defines the path of the property where the value should be interpolated
  43507. */
  43508. propertyPath: string;
  43509. /**
  43510. * Defines the target value at the end of the interpolation.
  43511. */
  43512. value: any;
  43513. /**
  43514. * Defines the time it will take for the property to interpolate to the value.
  43515. */
  43516. duration: number;
  43517. /**
  43518. * Defines if the other scene animations should be stopped when the action has been triggered
  43519. */
  43520. stopOtherAnimations?: boolean;
  43521. /**
  43522. * Defines a callback raised once the interpolation animation has been done.
  43523. */
  43524. onInterpolationDone?: () => void;
  43525. /**
  43526. * Observable triggered once the interpolation animation has been done.
  43527. */
  43528. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43529. private _target;
  43530. private _effectiveTarget;
  43531. private _property;
  43532. /**
  43533. * Instantiate the action
  43534. * @param triggerOptions defines the trigger options
  43535. * @param target defines the object containing the value to interpolate
  43536. * @param propertyPath defines the path to the property in the target object
  43537. * @param value defines the target value at the end of the interpolation
  43538. * @param duration deines the time it will take for the property to interpolate to the value.
  43539. * @param condition defines the trigger related conditions
  43540. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43541. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43542. */
  43543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43544. /** @hidden */
  43545. _prepare(): void;
  43546. /**
  43547. * Execute the action starts the value interpolation.
  43548. */
  43549. execute(): void;
  43550. /**
  43551. * Serializes the actions and its related information.
  43552. * @param parent defines the object to serialize in
  43553. * @returns the serialized object
  43554. */
  43555. serialize(parent: any): any;
  43556. }
  43557. }
  43558. declare module "babylonjs/Actions/index" {
  43559. export * from "babylonjs/Actions/abstractActionManager";
  43560. export * from "babylonjs/Actions/action";
  43561. export * from "babylonjs/Actions/actionEvent";
  43562. export * from "babylonjs/Actions/actionManager";
  43563. export * from "babylonjs/Actions/condition";
  43564. export * from "babylonjs/Actions/directActions";
  43565. export * from "babylonjs/Actions/directAudioActions";
  43566. export * from "babylonjs/Actions/interpolateValueAction";
  43567. }
  43568. declare module "babylonjs/Animations/index" {
  43569. export * from "babylonjs/Animations/animatable";
  43570. export * from "babylonjs/Animations/animation";
  43571. export * from "babylonjs/Animations/animationGroup";
  43572. export * from "babylonjs/Animations/animationPropertiesOverride";
  43573. export * from "babylonjs/Animations/easing";
  43574. export * from "babylonjs/Animations/runtimeAnimation";
  43575. export * from "babylonjs/Animations/animationEvent";
  43576. export * from "babylonjs/Animations/animationGroup";
  43577. export * from "babylonjs/Animations/animationKey";
  43578. export * from "babylonjs/Animations/animationRange";
  43579. export * from "babylonjs/Animations/animatable.interface";
  43580. }
  43581. declare module "babylonjs/Audio/soundTrack" {
  43582. import { Sound } from "babylonjs/Audio/sound";
  43583. import { Analyser } from "babylonjs/Audio/analyser";
  43584. import { Scene } from "babylonjs/scene";
  43585. /**
  43586. * Options allowed during the creation of a sound track.
  43587. */
  43588. export interface ISoundTrackOptions {
  43589. /**
  43590. * The volume the sound track should take during creation
  43591. */
  43592. volume?: number;
  43593. /**
  43594. * Define if the sound track is the main sound track of the scene
  43595. */
  43596. mainTrack?: boolean;
  43597. }
  43598. /**
  43599. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43600. * It will be also used in a future release to apply effects on a specific track.
  43601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43602. */
  43603. export class SoundTrack {
  43604. /**
  43605. * The unique identifier of the sound track in the scene.
  43606. */
  43607. id: number;
  43608. /**
  43609. * The list of sounds included in the sound track.
  43610. */
  43611. soundCollection: Array<Sound>;
  43612. private _outputAudioNode;
  43613. private _scene;
  43614. private _connectedAnalyser;
  43615. private _options;
  43616. private _isInitialized;
  43617. /**
  43618. * Creates a new sound track.
  43619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43620. * @param scene Define the scene the sound track belongs to
  43621. * @param options
  43622. */
  43623. constructor(scene: Scene, options?: ISoundTrackOptions);
  43624. private _initializeSoundTrackAudioGraph;
  43625. /**
  43626. * Release the sound track and its associated resources
  43627. */
  43628. dispose(): void;
  43629. /**
  43630. * Adds a sound to this sound track
  43631. * @param sound define the cound to add
  43632. * @ignoreNaming
  43633. */
  43634. AddSound(sound: Sound): void;
  43635. /**
  43636. * Removes a sound to this sound track
  43637. * @param sound define the cound to remove
  43638. * @ignoreNaming
  43639. */
  43640. RemoveSound(sound: Sound): void;
  43641. /**
  43642. * Set a global volume for the full sound track.
  43643. * @param newVolume Define the new volume of the sound track
  43644. */
  43645. setVolume(newVolume: number): void;
  43646. /**
  43647. * Switch the panning model to HRTF:
  43648. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43650. */
  43651. switchPanningModelToHRTF(): void;
  43652. /**
  43653. * Switch the panning model to Equal Power:
  43654. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43656. */
  43657. switchPanningModelToEqualPower(): void;
  43658. /**
  43659. * Connect the sound track to an audio analyser allowing some amazing
  43660. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43661. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43662. * @param analyser The analyser to connect to the engine
  43663. */
  43664. connectToAnalyser(analyser: Analyser): void;
  43665. }
  43666. }
  43667. declare module "babylonjs/Audio/audioSceneComponent" {
  43668. import { Sound } from "babylonjs/Audio/sound";
  43669. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43670. import { Nullable } from "babylonjs/types";
  43671. import { Vector3 } from "babylonjs/Maths/math.vector";
  43672. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43673. import { Scene } from "babylonjs/scene";
  43674. import { AbstractScene } from "babylonjs/abstractScene";
  43675. import "babylonjs/Audio/audioEngine";
  43676. module "babylonjs/abstractScene" {
  43677. interface AbstractScene {
  43678. /**
  43679. * The list of sounds used in the scene.
  43680. */
  43681. sounds: Nullable<Array<Sound>>;
  43682. }
  43683. }
  43684. module "babylonjs/scene" {
  43685. interface Scene {
  43686. /**
  43687. * @hidden
  43688. * Backing field
  43689. */
  43690. _mainSoundTrack: SoundTrack;
  43691. /**
  43692. * The main sound track played by the scene.
  43693. * It cotains your primary collection of sounds.
  43694. */
  43695. mainSoundTrack: SoundTrack;
  43696. /**
  43697. * The list of sound tracks added to the scene
  43698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43699. */
  43700. soundTracks: Nullable<Array<SoundTrack>>;
  43701. /**
  43702. * Gets a sound using a given name
  43703. * @param name defines the name to search for
  43704. * @return the found sound or null if not found at all.
  43705. */
  43706. getSoundByName(name: string): Nullable<Sound>;
  43707. /**
  43708. * Gets or sets if audio support is enabled
  43709. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43710. */
  43711. audioEnabled: boolean;
  43712. /**
  43713. * Gets or sets if audio will be output to headphones
  43714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43715. */
  43716. headphone: boolean;
  43717. /**
  43718. * Gets or sets custom audio listener position provider
  43719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43720. */
  43721. audioListenerPositionProvider: Nullable<() => Vector3>;
  43722. /**
  43723. * Gets or sets a refresh rate when using 3D audio positioning
  43724. */
  43725. audioPositioningRefreshRate: number;
  43726. }
  43727. }
  43728. /**
  43729. * Defines the sound scene component responsible to manage any sounds
  43730. * in a given scene.
  43731. */
  43732. export class AudioSceneComponent implements ISceneSerializableComponent {
  43733. private static _CameraDirectionLH;
  43734. private static _CameraDirectionRH;
  43735. /**
  43736. * The component name helpfull to identify the component in the list of scene components.
  43737. */
  43738. readonly name: string;
  43739. /**
  43740. * The scene the component belongs to.
  43741. */
  43742. scene: Scene;
  43743. private _audioEnabled;
  43744. /**
  43745. * Gets whether audio is enabled or not.
  43746. * Please use related enable/disable method to switch state.
  43747. */
  43748. get audioEnabled(): boolean;
  43749. private _headphone;
  43750. /**
  43751. * Gets whether audio is outputing to headphone or not.
  43752. * Please use the according Switch methods to change output.
  43753. */
  43754. get headphone(): boolean;
  43755. /**
  43756. * Gets or sets a refresh rate when using 3D audio positioning
  43757. */
  43758. audioPositioningRefreshRate: number;
  43759. private _audioListenerPositionProvider;
  43760. /**
  43761. * Gets the current audio listener position provider
  43762. */
  43763. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43764. /**
  43765. * Sets a custom listener position for all sounds in the scene
  43766. * By default, this is the position of the first active camera
  43767. */
  43768. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43769. /**
  43770. * Creates a new instance of the component for the given scene
  43771. * @param scene Defines the scene to register the component in
  43772. */
  43773. constructor(scene: Scene);
  43774. /**
  43775. * Registers the component in a given scene
  43776. */
  43777. register(): void;
  43778. /**
  43779. * Rebuilds the elements related to this component in case of
  43780. * context lost for instance.
  43781. */
  43782. rebuild(): void;
  43783. /**
  43784. * Serializes the component data to the specified json object
  43785. * @param serializationObject The object to serialize to
  43786. */
  43787. serialize(serializationObject: any): void;
  43788. /**
  43789. * Adds all the elements from the container to the scene
  43790. * @param container the container holding the elements
  43791. */
  43792. addFromContainer(container: AbstractScene): void;
  43793. /**
  43794. * Removes all the elements in the container from the scene
  43795. * @param container contains the elements to remove
  43796. * @param dispose if the removed element should be disposed (default: false)
  43797. */
  43798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43799. /**
  43800. * Disposes the component and the associated ressources.
  43801. */
  43802. dispose(): void;
  43803. /**
  43804. * Disables audio in the associated scene.
  43805. */
  43806. disableAudio(): void;
  43807. /**
  43808. * Enables audio in the associated scene.
  43809. */
  43810. enableAudio(): void;
  43811. /**
  43812. * Switch audio to headphone output.
  43813. */
  43814. switchAudioModeForHeadphones(): void;
  43815. /**
  43816. * Switch audio to normal speakers.
  43817. */
  43818. switchAudioModeForNormalSpeakers(): void;
  43819. private _cachedCameraDirection;
  43820. private _cachedCameraPosition;
  43821. private _lastCheck;
  43822. private _afterRender;
  43823. }
  43824. }
  43825. declare module "babylonjs/Audio/weightedsound" {
  43826. import { Sound } from "babylonjs/Audio/sound";
  43827. /**
  43828. * Wraps one or more Sound objects and selects one with random weight for playback.
  43829. */
  43830. export class WeightedSound {
  43831. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43832. loop: boolean;
  43833. private _coneInnerAngle;
  43834. private _coneOuterAngle;
  43835. private _volume;
  43836. /** A Sound is currently playing. */
  43837. isPlaying: boolean;
  43838. /** A Sound is currently paused. */
  43839. isPaused: boolean;
  43840. private _sounds;
  43841. private _weights;
  43842. private _currentIndex?;
  43843. /**
  43844. * Creates a new WeightedSound from the list of sounds given.
  43845. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43846. * @param sounds Array of Sounds that will be selected from.
  43847. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43848. */
  43849. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43850. /**
  43851. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43852. */
  43853. get directionalConeInnerAngle(): number;
  43854. /**
  43855. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43856. */
  43857. set directionalConeInnerAngle(value: number);
  43858. /**
  43859. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43860. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43861. */
  43862. get directionalConeOuterAngle(): number;
  43863. /**
  43864. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43865. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43866. */
  43867. set directionalConeOuterAngle(value: number);
  43868. /**
  43869. * Playback volume.
  43870. */
  43871. get volume(): number;
  43872. /**
  43873. * Playback volume.
  43874. */
  43875. set volume(value: number);
  43876. private _onended;
  43877. /**
  43878. * Suspend playback
  43879. */
  43880. pause(): void;
  43881. /**
  43882. * Stop playback
  43883. */
  43884. stop(): void;
  43885. /**
  43886. * Start playback.
  43887. * @param startOffset Position the clip head at a specific time in seconds.
  43888. */
  43889. play(startOffset?: number): void;
  43890. }
  43891. }
  43892. declare module "babylonjs/Audio/index" {
  43893. export * from "babylonjs/Audio/analyser";
  43894. export * from "babylonjs/Audio/audioEngine";
  43895. export * from "babylonjs/Audio/audioSceneComponent";
  43896. export * from "babylonjs/Audio/sound";
  43897. export * from "babylonjs/Audio/soundTrack";
  43898. export * from "babylonjs/Audio/weightedsound";
  43899. }
  43900. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43901. import { Behavior } from "babylonjs/Behaviors/behavior";
  43902. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43903. import { BackEase } from "babylonjs/Animations/easing";
  43904. /**
  43905. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43906. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43907. */
  43908. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43909. /**
  43910. * Gets the name of the behavior.
  43911. */
  43912. get name(): string;
  43913. /**
  43914. * The easing function used by animations
  43915. */
  43916. static EasingFunction: BackEase;
  43917. /**
  43918. * The easing mode used by animations
  43919. */
  43920. static EasingMode: number;
  43921. /**
  43922. * The duration of the animation, in milliseconds
  43923. */
  43924. transitionDuration: number;
  43925. /**
  43926. * Length of the distance animated by the transition when lower radius is reached
  43927. */
  43928. lowerRadiusTransitionRange: number;
  43929. /**
  43930. * Length of the distance animated by the transition when upper radius is reached
  43931. */
  43932. upperRadiusTransitionRange: number;
  43933. private _autoTransitionRange;
  43934. /**
  43935. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43936. */
  43937. get autoTransitionRange(): boolean;
  43938. /**
  43939. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43940. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43941. */
  43942. set autoTransitionRange(value: boolean);
  43943. private _attachedCamera;
  43944. private _onAfterCheckInputsObserver;
  43945. private _onMeshTargetChangedObserver;
  43946. /**
  43947. * Initializes the behavior.
  43948. */
  43949. init(): void;
  43950. /**
  43951. * Attaches the behavior to its arc rotate camera.
  43952. * @param camera Defines the camera to attach the behavior to
  43953. */
  43954. attach(camera: ArcRotateCamera): void;
  43955. /**
  43956. * Detaches the behavior from its current arc rotate camera.
  43957. */
  43958. detach(): void;
  43959. private _radiusIsAnimating;
  43960. private _radiusBounceTransition;
  43961. private _animatables;
  43962. private _cachedWheelPrecision;
  43963. /**
  43964. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43965. * @param radiusLimit The limit to check against.
  43966. * @return Bool to indicate if at limit.
  43967. */
  43968. private _isRadiusAtLimit;
  43969. /**
  43970. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43971. * @param radiusDelta The delta by which to animate to. Can be negative.
  43972. */
  43973. private _applyBoundRadiusAnimation;
  43974. /**
  43975. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43976. */
  43977. protected _clearAnimationLocks(): void;
  43978. /**
  43979. * Stops and removes all animations that have been applied to the camera
  43980. */
  43981. stopAllAnimations(): void;
  43982. }
  43983. }
  43984. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43985. import { Behavior } from "babylonjs/Behaviors/behavior";
  43986. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43987. import { ExponentialEase } from "babylonjs/Animations/easing";
  43988. import { Nullable } from "babylonjs/types";
  43989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43990. import { Vector3 } from "babylonjs/Maths/math.vector";
  43991. /**
  43992. * 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.
  43993. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43994. */
  43995. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43996. /**
  43997. * Gets the name of the behavior.
  43998. */
  43999. get name(): string;
  44000. private _mode;
  44001. private _radiusScale;
  44002. private _positionScale;
  44003. private _defaultElevation;
  44004. private _elevationReturnTime;
  44005. private _elevationReturnWaitTime;
  44006. private _zoomStopsAnimation;
  44007. private _framingTime;
  44008. /**
  44009. * The easing function used by animations
  44010. */
  44011. static EasingFunction: ExponentialEase;
  44012. /**
  44013. * The easing mode used by animations
  44014. */
  44015. static EasingMode: number;
  44016. /**
  44017. * Sets the current mode used by the behavior
  44018. */
  44019. set mode(mode: number);
  44020. /**
  44021. * Gets current mode used by the behavior.
  44022. */
  44023. get mode(): number;
  44024. /**
  44025. * Sets the scale applied to the radius (1 by default)
  44026. */
  44027. set radiusScale(radius: number);
  44028. /**
  44029. * Gets the scale applied to the radius
  44030. */
  44031. get radiusScale(): number;
  44032. /**
  44033. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44034. */
  44035. set positionScale(scale: number);
  44036. /**
  44037. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44038. */
  44039. get positionScale(): number;
  44040. /**
  44041. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44042. * behaviour is triggered, in radians.
  44043. */
  44044. set defaultElevation(elevation: number);
  44045. /**
  44046. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44047. * behaviour is triggered, in radians.
  44048. */
  44049. get defaultElevation(): number;
  44050. /**
  44051. * Sets the time (in milliseconds) taken to return to the default beta position.
  44052. * Negative value indicates camera should not return to default.
  44053. */
  44054. set elevationReturnTime(speed: number);
  44055. /**
  44056. * Gets the time (in milliseconds) taken to return to the default beta position.
  44057. * Negative value indicates camera should not return to default.
  44058. */
  44059. get elevationReturnTime(): number;
  44060. /**
  44061. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44062. */
  44063. set elevationReturnWaitTime(time: number);
  44064. /**
  44065. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44066. */
  44067. get elevationReturnWaitTime(): number;
  44068. /**
  44069. * Sets the flag that indicates if user zooming should stop animation.
  44070. */
  44071. set zoomStopsAnimation(flag: boolean);
  44072. /**
  44073. * Gets the flag that indicates if user zooming should stop animation.
  44074. */
  44075. get zoomStopsAnimation(): boolean;
  44076. /**
  44077. * Sets the transition time when framing the mesh, in milliseconds
  44078. */
  44079. set framingTime(time: number);
  44080. /**
  44081. * Gets the transition time when framing the mesh, in milliseconds
  44082. */
  44083. get framingTime(): number;
  44084. /**
  44085. * Define if the behavior should automatically change the configured
  44086. * camera limits and sensibilities.
  44087. */
  44088. autoCorrectCameraLimitsAndSensibility: boolean;
  44089. private _onPrePointerObservableObserver;
  44090. private _onAfterCheckInputsObserver;
  44091. private _onMeshTargetChangedObserver;
  44092. private _attachedCamera;
  44093. private _isPointerDown;
  44094. private _lastInteractionTime;
  44095. /**
  44096. * Initializes the behavior.
  44097. */
  44098. init(): void;
  44099. /**
  44100. * Attaches the behavior to its arc rotate camera.
  44101. * @param camera Defines the camera to attach the behavior to
  44102. */
  44103. attach(camera: ArcRotateCamera): void;
  44104. /**
  44105. * Detaches the behavior from its current arc rotate camera.
  44106. */
  44107. detach(): void;
  44108. private _animatables;
  44109. private _betaIsAnimating;
  44110. private _betaTransition;
  44111. private _radiusTransition;
  44112. private _vectorTransition;
  44113. /**
  44114. * Targets the given mesh and updates zoom level accordingly.
  44115. * @param mesh The mesh to target.
  44116. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44117. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44118. */
  44119. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44120. /**
  44121. * Targets the given mesh with its children and updates zoom level accordingly.
  44122. * @param mesh The mesh to target.
  44123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44125. */
  44126. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44127. /**
  44128. * Targets the given meshes with their children and updates zoom level accordingly.
  44129. * @param meshes The mesh to target.
  44130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44132. */
  44133. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44134. /**
  44135. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44136. * @param minimumWorld Determines the smaller position of the bounding box extend
  44137. * @param maximumWorld Determines the bigger position of the bounding box extend
  44138. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44139. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44140. */
  44141. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44142. /**
  44143. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44144. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44145. * frustum width.
  44146. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44147. * to fully enclose the mesh in the viewing frustum.
  44148. */
  44149. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44150. /**
  44151. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44152. * is automatically returned to its default position (expected to be above ground plane).
  44153. */
  44154. private _maintainCameraAboveGround;
  44155. /**
  44156. * Returns the frustum slope based on the canvas ratio and camera FOV
  44157. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44158. */
  44159. private _getFrustumSlope;
  44160. /**
  44161. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44162. */
  44163. private _clearAnimationLocks;
  44164. /**
  44165. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44166. */
  44167. private _applyUserInteraction;
  44168. /**
  44169. * Stops and removes all animations that have been applied to the camera
  44170. */
  44171. stopAllAnimations(): void;
  44172. /**
  44173. * Gets a value indicating if the user is moving the camera
  44174. */
  44175. get isUserIsMoving(): boolean;
  44176. /**
  44177. * The camera can move all the way towards the mesh.
  44178. */
  44179. static IgnoreBoundsSizeMode: number;
  44180. /**
  44181. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44182. */
  44183. static FitFrustumSidesMode: number;
  44184. }
  44185. }
  44186. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44187. import { Nullable } from "babylonjs/types";
  44188. import { Camera } from "babylonjs/Cameras/camera";
  44189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44190. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44191. /**
  44192. * Base class for Camera Pointer Inputs.
  44193. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44194. * for example usage.
  44195. */
  44196. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44197. /**
  44198. * Defines the camera the input is attached to.
  44199. */
  44200. abstract camera: Camera;
  44201. /**
  44202. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44203. */
  44204. protected _altKey: boolean;
  44205. protected _ctrlKey: boolean;
  44206. protected _metaKey: boolean;
  44207. protected _shiftKey: boolean;
  44208. /**
  44209. * Which mouse buttons were pressed at time of last mouse event.
  44210. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44211. */
  44212. protected _buttonsPressed: number;
  44213. /**
  44214. * Defines the buttons associated with the input to handle camera move.
  44215. */
  44216. buttons: number[];
  44217. /**
  44218. * Attach the input controls to a specific dom element to get the input from.
  44219. * @param element Defines the element the controls should be listened from
  44220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44221. */
  44222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44223. /**
  44224. * Detach the current controls from the specified dom element.
  44225. * @param element Defines the element to stop listening the inputs from
  44226. */
  44227. detachControl(element: Nullable<HTMLElement>): void;
  44228. /**
  44229. * Gets the class name of the current input.
  44230. * @returns the class name
  44231. */
  44232. getClassName(): string;
  44233. /**
  44234. * Get the friendly name associated with the input class.
  44235. * @returns the input friendly name
  44236. */
  44237. getSimpleName(): string;
  44238. /**
  44239. * Called on pointer POINTERDOUBLETAP event.
  44240. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44241. */
  44242. protected onDoubleTap(type: string): void;
  44243. /**
  44244. * Called on pointer POINTERMOVE event if only a single touch is active.
  44245. * Override this method to provide functionality.
  44246. */
  44247. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44248. /**
  44249. * Called on pointer POINTERMOVE event if multiple touches are active.
  44250. * Override this method to provide functionality.
  44251. */
  44252. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44253. /**
  44254. * Called on JS contextmenu event.
  44255. * Override this method to provide functionality.
  44256. */
  44257. protected onContextMenu(evt: PointerEvent): void;
  44258. /**
  44259. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44260. * press.
  44261. * Override this method to provide functionality.
  44262. */
  44263. protected onButtonDown(evt: PointerEvent): void;
  44264. /**
  44265. * Called each time a new POINTERUP event occurs. Ie, for each button
  44266. * release.
  44267. * Override this method to provide functionality.
  44268. */
  44269. protected onButtonUp(evt: PointerEvent): void;
  44270. /**
  44271. * Called when window becomes inactive.
  44272. * Override this method to provide functionality.
  44273. */
  44274. protected onLostFocus(): void;
  44275. private _pointerInput;
  44276. private _observer;
  44277. private _onLostFocus;
  44278. private pointA;
  44279. private pointB;
  44280. }
  44281. }
  44282. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44283. import { Nullable } from "babylonjs/types";
  44284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44285. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44286. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44287. /**
  44288. * Manage the pointers inputs to control an arc rotate camera.
  44289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44290. */
  44291. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44292. /**
  44293. * Defines the camera the input is attached to.
  44294. */
  44295. camera: ArcRotateCamera;
  44296. /**
  44297. * Gets the class name of the current input.
  44298. * @returns the class name
  44299. */
  44300. getClassName(): string;
  44301. /**
  44302. * Defines the buttons associated with the input to handle camera move.
  44303. */
  44304. buttons: number[];
  44305. /**
  44306. * Defines the pointer angular sensibility along the X axis or how fast is
  44307. * the camera rotating.
  44308. */
  44309. angularSensibilityX: number;
  44310. /**
  44311. * Defines the pointer angular sensibility along the Y axis or how fast is
  44312. * the camera rotating.
  44313. */
  44314. angularSensibilityY: number;
  44315. /**
  44316. * Defines the pointer pinch precision or how fast is the camera zooming.
  44317. */
  44318. pinchPrecision: number;
  44319. /**
  44320. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44321. * from 0.
  44322. * It defines the percentage of current camera.radius to use as delta when
  44323. * pinch zoom is used.
  44324. */
  44325. pinchDeltaPercentage: number;
  44326. /**
  44327. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44328. * that any object in the plane at the camera's target point will scale
  44329. * perfectly with finger motion.
  44330. * Overrides pinchDeltaPercentage and pinchPrecision.
  44331. */
  44332. useNaturalPinchZoom: boolean;
  44333. /**
  44334. * Defines the pointer panning sensibility or how fast is the camera moving.
  44335. */
  44336. panningSensibility: number;
  44337. /**
  44338. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44339. */
  44340. multiTouchPanning: boolean;
  44341. /**
  44342. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44343. * zoom (pinch) through multitouch.
  44344. */
  44345. multiTouchPanAndZoom: boolean;
  44346. /**
  44347. * Revers pinch action direction.
  44348. */
  44349. pinchInwards: boolean;
  44350. private _isPanClick;
  44351. private _twoFingerActivityCount;
  44352. private _isPinching;
  44353. /**
  44354. * Called on pointer POINTERMOVE event if only a single touch is active.
  44355. */
  44356. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44357. /**
  44358. * Called on pointer POINTERDOUBLETAP event.
  44359. */
  44360. protected onDoubleTap(type: string): void;
  44361. /**
  44362. * Called on pointer POINTERMOVE event if multiple touches are active.
  44363. */
  44364. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44365. /**
  44366. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44367. * press.
  44368. */
  44369. protected onButtonDown(evt: PointerEvent): void;
  44370. /**
  44371. * Called each time a new POINTERUP event occurs. Ie, for each button
  44372. * release.
  44373. */
  44374. protected onButtonUp(evt: PointerEvent): void;
  44375. /**
  44376. * Called when window becomes inactive.
  44377. */
  44378. protected onLostFocus(): void;
  44379. }
  44380. }
  44381. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44382. import { Nullable } from "babylonjs/types";
  44383. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44384. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44385. /**
  44386. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44387. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44388. */
  44389. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44390. /**
  44391. * Defines the camera the input is attached to.
  44392. */
  44393. camera: ArcRotateCamera;
  44394. /**
  44395. * Defines the list of key codes associated with the up action (increase alpha)
  44396. */
  44397. keysUp: number[];
  44398. /**
  44399. * Defines the list of key codes associated with the down action (decrease alpha)
  44400. */
  44401. keysDown: number[];
  44402. /**
  44403. * Defines the list of key codes associated with the left action (increase beta)
  44404. */
  44405. keysLeft: number[];
  44406. /**
  44407. * Defines the list of key codes associated with the right action (decrease beta)
  44408. */
  44409. keysRight: number[];
  44410. /**
  44411. * Defines the list of key codes associated with the reset action.
  44412. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44413. */
  44414. keysReset: number[];
  44415. /**
  44416. * Defines the panning sensibility of the inputs.
  44417. * (How fast is the camera panning)
  44418. */
  44419. panningSensibility: number;
  44420. /**
  44421. * Defines the zooming sensibility of the inputs.
  44422. * (How fast is the camera zooming)
  44423. */
  44424. zoomingSensibility: number;
  44425. /**
  44426. * Defines whether maintaining the alt key down switch the movement mode from
  44427. * orientation to zoom.
  44428. */
  44429. useAltToZoom: boolean;
  44430. /**
  44431. * Rotation speed of the camera
  44432. */
  44433. angularSpeed: number;
  44434. private _keys;
  44435. private _ctrlPressed;
  44436. private _altPressed;
  44437. private _onCanvasBlurObserver;
  44438. private _onKeyboardObserver;
  44439. private _engine;
  44440. private _scene;
  44441. /**
  44442. * Attach the input controls to a specific dom element to get the input from.
  44443. * @param element Defines the element the controls should be listened from
  44444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44445. */
  44446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44447. /**
  44448. * Detach the current controls from the specified dom element.
  44449. * @param element Defines the element to stop listening the inputs from
  44450. */
  44451. detachControl(element: Nullable<HTMLElement>): void;
  44452. /**
  44453. * Update the current camera state depending on the inputs that have been used this frame.
  44454. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44455. */
  44456. checkInputs(): void;
  44457. /**
  44458. * Gets the class name of the current intput.
  44459. * @returns the class name
  44460. */
  44461. getClassName(): string;
  44462. /**
  44463. * Get the friendly name associated with the input class.
  44464. * @returns the input friendly name
  44465. */
  44466. getSimpleName(): string;
  44467. }
  44468. }
  44469. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44470. import { Nullable } from "babylonjs/types";
  44471. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44472. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44473. /**
  44474. * Manage the mouse wheel inputs to control an arc rotate camera.
  44475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44476. */
  44477. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44478. /**
  44479. * Defines the camera the input is attached to.
  44480. */
  44481. camera: ArcRotateCamera;
  44482. /**
  44483. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44484. */
  44485. wheelPrecision: number;
  44486. /**
  44487. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44488. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44489. */
  44490. wheelDeltaPercentage: number;
  44491. private _wheel;
  44492. private _observer;
  44493. private computeDeltaFromMouseWheelLegacyEvent;
  44494. /**
  44495. * Attach the input controls to a specific dom element to get the input from.
  44496. * @param element Defines the element the controls should be listened from
  44497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44498. */
  44499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44500. /**
  44501. * Detach the current controls from the specified dom element.
  44502. * @param element Defines the element to stop listening the inputs from
  44503. */
  44504. detachControl(element: Nullable<HTMLElement>): void;
  44505. /**
  44506. * Gets the class name of the current intput.
  44507. * @returns the class name
  44508. */
  44509. getClassName(): string;
  44510. /**
  44511. * Get the friendly name associated with the input class.
  44512. * @returns the input friendly name
  44513. */
  44514. getSimpleName(): string;
  44515. }
  44516. }
  44517. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44518. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44519. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44520. /**
  44521. * Default Inputs manager for the ArcRotateCamera.
  44522. * It groups all the default supported inputs for ease of use.
  44523. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44524. */
  44525. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44526. /**
  44527. * Instantiates a new ArcRotateCameraInputsManager.
  44528. * @param camera Defines the camera the inputs belong to
  44529. */
  44530. constructor(camera: ArcRotateCamera);
  44531. /**
  44532. * Add mouse wheel input support to the input manager.
  44533. * @returns the current input manager
  44534. */
  44535. addMouseWheel(): ArcRotateCameraInputsManager;
  44536. /**
  44537. * Add pointers input support to the input manager.
  44538. * @returns the current input manager
  44539. */
  44540. addPointers(): ArcRotateCameraInputsManager;
  44541. /**
  44542. * Add keyboard input support to the input manager.
  44543. * @returns the current input manager
  44544. */
  44545. addKeyboard(): ArcRotateCameraInputsManager;
  44546. }
  44547. }
  44548. declare module "babylonjs/Cameras/arcRotateCamera" {
  44549. import { Observable } from "babylonjs/Misc/observable";
  44550. import { Nullable } from "babylonjs/types";
  44551. import { Scene } from "babylonjs/scene";
  44552. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44554. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44555. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44556. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44557. import { Camera } from "babylonjs/Cameras/camera";
  44558. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44559. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44560. import { Collider } from "babylonjs/Collisions/collider";
  44561. /**
  44562. * This represents an orbital type of camera.
  44563. *
  44564. * 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.
  44565. * 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.
  44566. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44567. */
  44568. export class ArcRotateCamera extends TargetCamera {
  44569. /**
  44570. * Defines the rotation angle of the camera along the longitudinal axis.
  44571. */
  44572. alpha: number;
  44573. /**
  44574. * Defines the rotation angle of the camera along the latitudinal axis.
  44575. */
  44576. beta: number;
  44577. /**
  44578. * Defines the radius of the camera from it s target point.
  44579. */
  44580. radius: number;
  44581. protected _target: Vector3;
  44582. protected _targetHost: Nullable<AbstractMesh>;
  44583. /**
  44584. * Defines the target point of the camera.
  44585. * The camera looks towards it form the radius distance.
  44586. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44587. */
  44588. get target(): Vector3;
  44589. set target(value: Vector3);
  44590. /**
  44591. * Define the current local position of the camera in the scene
  44592. */
  44593. get position(): Vector3;
  44594. set position(newPosition: Vector3);
  44595. protected _upToYMatrix: Matrix;
  44596. protected _YToUpMatrix: Matrix;
  44597. /**
  44598. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44599. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44600. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44601. */
  44602. set upVector(vec: Vector3);
  44603. get upVector(): Vector3;
  44604. /**
  44605. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44606. */
  44607. setMatUp(): void;
  44608. /**
  44609. * Current inertia value on the longitudinal axis.
  44610. * The bigger this number the longer it will take for the camera to stop.
  44611. */
  44612. inertialAlphaOffset: number;
  44613. /**
  44614. * Current inertia value on the latitudinal axis.
  44615. * The bigger this number the longer it will take for the camera to stop.
  44616. */
  44617. inertialBetaOffset: number;
  44618. /**
  44619. * Current inertia value on the radius axis.
  44620. * The bigger this number the longer it will take for the camera to stop.
  44621. */
  44622. inertialRadiusOffset: number;
  44623. /**
  44624. * Minimum allowed angle on the longitudinal axis.
  44625. * This can help limiting how the Camera is able to move in the scene.
  44626. */
  44627. lowerAlphaLimit: Nullable<number>;
  44628. /**
  44629. * Maximum allowed angle on the longitudinal axis.
  44630. * This can help limiting how the Camera is able to move in the scene.
  44631. */
  44632. upperAlphaLimit: Nullable<number>;
  44633. /**
  44634. * Minimum allowed angle on the latitudinal axis.
  44635. * This can help limiting how the Camera is able to move in the scene.
  44636. */
  44637. lowerBetaLimit: number;
  44638. /**
  44639. * Maximum allowed angle on the latitudinal axis.
  44640. * This can help limiting how the Camera is able to move in the scene.
  44641. */
  44642. upperBetaLimit: number;
  44643. /**
  44644. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44645. * This can help limiting how the Camera is able to move in the scene.
  44646. */
  44647. lowerRadiusLimit: Nullable<number>;
  44648. /**
  44649. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44650. * This can help limiting how the Camera is able to move in the scene.
  44651. */
  44652. upperRadiusLimit: Nullable<number>;
  44653. /**
  44654. * Defines the current inertia value used during panning of the camera along the X axis.
  44655. */
  44656. inertialPanningX: number;
  44657. /**
  44658. * Defines the current inertia value used during panning of the camera along the Y axis.
  44659. */
  44660. inertialPanningY: number;
  44661. /**
  44662. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44663. * Basically if your fingers moves away from more than this distance you will be considered
  44664. * in pinch mode.
  44665. */
  44666. pinchToPanMaxDistance: number;
  44667. /**
  44668. * Defines the maximum distance the camera can pan.
  44669. * This could help keeping the cammera always in your scene.
  44670. */
  44671. panningDistanceLimit: Nullable<number>;
  44672. /**
  44673. * Defines the target of the camera before paning.
  44674. */
  44675. panningOriginTarget: Vector3;
  44676. /**
  44677. * Defines the value of the inertia used during panning.
  44678. * 0 would mean stop inertia and one would mean no decelleration at all.
  44679. */
  44680. panningInertia: number;
  44681. /**
  44682. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44683. */
  44684. get angularSensibilityX(): number;
  44685. set angularSensibilityX(value: number);
  44686. /**
  44687. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44688. */
  44689. get angularSensibilityY(): number;
  44690. set angularSensibilityY(value: number);
  44691. /**
  44692. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44693. */
  44694. get pinchPrecision(): number;
  44695. set pinchPrecision(value: number);
  44696. /**
  44697. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44698. * It will be used instead of pinchDeltaPrecision if different from 0.
  44699. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44700. */
  44701. get pinchDeltaPercentage(): number;
  44702. set pinchDeltaPercentage(value: number);
  44703. /**
  44704. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44705. * and pinch delta percentage.
  44706. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44707. * that any object in the plane at the camera's target point will scale
  44708. * perfectly with finger motion.
  44709. */
  44710. get useNaturalPinchZoom(): boolean;
  44711. set useNaturalPinchZoom(value: boolean);
  44712. /**
  44713. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44714. */
  44715. get panningSensibility(): number;
  44716. set panningSensibility(value: number);
  44717. /**
  44718. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44719. */
  44720. get keysUp(): number[];
  44721. set keysUp(value: number[]);
  44722. /**
  44723. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44724. */
  44725. get keysDown(): number[];
  44726. set keysDown(value: number[]);
  44727. /**
  44728. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44729. */
  44730. get keysLeft(): number[];
  44731. set keysLeft(value: number[]);
  44732. /**
  44733. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44734. */
  44735. get keysRight(): number[];
  44736. set keysRight(value: number[]);
  44737. /**
  44738. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44739. */
  44740. get wheelPrecision(): number;
  44741. set wheelPrecision(value: number);
  44742. /**
  44743. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44744. * It will be used instead of pinchDeltaPrecision if different from 0.
  44745. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44746. */
  44747. get wheelDeltaPercentage(): number;
  44748. set wheelDeltaPercentage(value: number);
  44749. /**
  44750. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44751. */
  44752. zoomOnFactor: number;
  44753. /**
  44754. * Defines a screen offset for the camera position.
  44755. */
  44756. targetScreenOffset: Vector2;
  44757. /**
  44758. * Allows the camera to be completely reversed.
  44759. * If false the camera can not arrive upside down.
  44760. */
  44761. allowUpsideDown: boolean;
  44762. /**
  44763. * Define if double tap/click is used to restore the previously saved state of the camera.
  44764. */
  44765. useInputToRestoreState: boolean;
  44766. /** @hidden */
  44767. _viewMatrix: Matrix;
  44768. /** @hidden */
  44769. _useCtrlForPanning: boolean;
  44770. /** @hidden */
  44771. _panningMouseButton: number;
  44772. /**
  44773. * Defines the input associated to the camera.
  44774. */
  44775. inputs: ArcRotateCameraInputsManager;
  44776. /** @hidden */
  44777. _reset: () => void;
  44778. /**
  44779. * Defines the allowed panning axis.
  44780. */
  44781. panningAxis: Vector3;
  44782. protected _localDirection: Vector3;
  44783. protected _transformedDirection: Vector3;
  44784. private _bouncingBehavior;
  44785. /**
  44786. * Gets the bouncing behavior of the camera if it has been enabled.
  44787. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44788. */
  44789. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44790. /**
  44791. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44792. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44793. */
  44794. get useBouncingBehavior(): boolean;
  44795. set useBouncingBehavior(value: boolean);
  44796. private _framingBehavior;
  44797. /**
  44798. * Gets the framing behavior of the camera if it has been enabled.
  44799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44800. */
  44801. get framingBehavior(): Nullable<FramingBehavior>;
  44802. /**
  44803. * Defines if the framing behavior of the camera is enabled on the camera.
  44804. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44805. */
  44806. get useFramingBehavior(): boolean;
  44807. set useFramingBehavior(value: boolean);
  44808. private _autoRotationBehavior;
  44809. /**
  44810. * Gets the auto rotation behavior of the camera if it has been enabled.
  44811. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44812. */
  44813. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44814. /**
  44815. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44816. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44817. */
  44818. get useAutoRotationBehavior(): boolean;
  44819. set useAutoRotationBehavior(value: boolean);
  44820. /**
  44821. * Observable triggered when the mesh target has been changed on the camera.
  44822. */
  44823. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44824. /**
  44825. * Event raised when the camera is colliding with a mesh.
  44826. */
  44827. onCollide: (collidedMesh: AbstractMesh) => void;
  44828. /**
  44829. * Defines whether the camera should check collision with the objects oh the scene.
  44830. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44831. */
  44832. checkCollisions: boolean;
  44833. /**
  44834. * Defines the collision radius of the camera.
  44835. * This simulates a sphere around the camera.
  44836. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44837. */
  44838. collisionRadius: Vector3;
  44839. protected _collider: Collider;
  44840. protected _previousPosition: Vector3;
  44841. protected _collisionVelocity: Vector3;
  44842. protected _newPosition: Vector3;
  44843. protected _previousAlpha: number;
  44844. protected _previousBeta: number;
  44845. protected _previousRadius: number;
  44846. protected _collisionTriggered: boolean;
  44847. protected _targetBoundingCenter: Nullable<Vector3>;
  44848. private _computationVector;
  44849. /**
  44850. * Instantiates a new ArcRotateCamera in a given scene
  44851. * @param name Defines the name of the camera
  44852. * @param alpha Defines the camera rotation along the logitudinal axis
  44853. * @param beta Defines the camera rotation along the latitudinal axis
  44854. * @param radius Defines the camera distance from its target
  44855. * @param target Defines the camera target
  44856. * @param scene Defines the scene the camera belongs to
  44857. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44858. */
  44859. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44860. /** @hidden */
  44861. _initCache(): void;
  44862. /** @hidden */
  44863. _updateCache(ignoreParentClass?: boolean): void;
  44864. protected _getTargetPosition(): Vector3;
  44865. private _storedAlpha;
  44866. private _storedBeta;
  44867. private _storedRadius;
  44868. private _storedTarget;
  44869. private _storedTargetScreenOffset;
  44870. /**
  44871. * Stores the current state of the camera (alpha, beta, radius and target)
  44872. * @returns the camera itself
  44873. */
  44874. storeState(): Camera;
  44875. /**
  44876. * @hidden
  44877. * Restored camera state. You must call storeState() first
  44878. */
  44879. _restoreStateValues(): boolean;
  44880. /** @hidden */
  44881. _isSynchronizedViewMatrix(): boolean;
  44882. /**
  44883. * Attached controls to the current camera.
  44884. * @param element Defines the element the controls should be listened from
  44885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44886. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44887. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44888. */
  44889. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44890. /**
  44891. * Detach the current controls from the camera.
  44892. * The camera will stop reacting to inputs.
  44893. * @param element Defines the element to stop listening the inputs from
  44894. */
  44895. detachControl(element: HTMLElement): void;
  44896. /** @hidden */
  44897. _checkInputs(): void;
  44898. protected _checkLimits(): void;
  44899. /**
  44900. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44901. */
  44902. rebuildAnglesAndRadius(): void;
  44903. /**
  44904. * Use a position to define the current camera related information like alpha, beta and radius
  44905. * @param position Defines the position to set the camera at
  44906. */
  44907. setPosition(position: Vector3): void;
  44908. /**
  44909. * Defines the target the camera should look at.
  44910. * This will automatically adapt alpha beta and radius to fit within the new target.
  44911. * @param target Defines the new target as a Vector or a mesh
  44912. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44913. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44914. */
  44915. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44916. /** @hidden */
  44917. _getViewMatrix(): Matrix;
  44918. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44919. /**
  44920. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44921. * @param meshes Defines the mesh to zoom on
  44922. * @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)
  44923. */
  44924. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44925. /**
  44926. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44927. * The target will be changed but the radius
  44928. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44929. * @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)
  44930. */
  44931. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44932. min: Vector3;
  44933. max: Vector3;
  44934. distance: number;
  44935. }, doNotUpdateMaxZ?: boolean): void;
  44936. /**
  44937. * @override
  44938. * Override Camera.createRigCamera
  44939. */
  44940. createRigCamera(name: string, cameraIndex: number): Camera;
  44941. /**
  44942. * @hidden
  44943. * @override
  44944. * Override Camera._updateRigCameras
  44945. */
  44946. _updateRigCameras(): void;
  44947. /**
  44948. * Destroy the camera and release the current resources hold by it.
  44949. */
  44950. dispose(): void;
  44951. /**
  44952. * Gets the current object class name.
  44953. * @return the class name
  44954. */
  44955. getClassName(): string;
  44956. }
  44957. }
  44958. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44959. import { Behavior } from "babylonjs/Behaviors/behavior";
  44960. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44961. /**
  44962. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44963. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44964. */
  44965. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44966. /**
  44967. * Gets the name of the behavior.
  44968. */
  44969. get name(): string;
  44970. private _zoomStopsAnimation;
  44971. private _idleRotationSpeed;
  44972. private _idleRotationWaitTime;
  44973. private _idleRotationSpinupTime;
  44974. /**
  44975. * Sets the flag that indicates if user zooming should stop animation.
  44976. */
  44977. set zoomStopsAnimation(flag: boolean);
  44978. /**
  44979. * Gets the flag that indicates if user zooming should stop animation.
  44980. */
  44981. get zoomStopsAnimation(): boolean;
  44982. /**
  44983. * Sets the default speed at which the camera rotates around the model.
  44984. */
  44985. set idleRotationSpeed(speed: number);
  44986. /**
  44987. * Gets the default speed at which the camera rotates around the model.
  44988. */
  44989. get idleRotationSpeed(): number;
  44990. /**
  44991. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44992. */
  44993. set idleRotationWaitTime(time: number);
  44994. /**
  44995. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44996. */
  44997. get idleRotationWaitTime(): number;
  44998. /**
  44999. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45000. */
  45001. set idleRotationSpinupTime(time: number);
  45002. /**
  45003. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45004. */
  45005. get idleRotationSpinupTime(): number;
  45006. /**
  45007. * Gets a value indicating if the camera is currently rotating because of this behavior
  45008. */
  45009. get rotationInProgress(): boolean;
  45010. private _onPrePointerObservableObserver;
  45011. private _onAfterCheckInputsObserver;
  45012. private _attachedCamera;
  45013. private _isPointerDown;
  45014. private _lastFrameTime;
  45015. private _lastInteractionTime;
  45016. private _cameraRotationSpeed;
  45017. /**
  45018. * Initializes the behavior.
  45019. */
  45020. init(): void;
  45021. /**
  45022. * Attaches the behavior to its arc rotate camera.
  45023. * @param camera Defines the camera to attach the behavior to
  45024. */
  45025. attach(camera: ArcRotateCamera): void;
  45026. /**
  45027. * Detaches the behavior from its current arc rotate camera.
  45028. */
  45029. detach(): void;
  45030. /**
  45031. * Returns true if user is scrolling.
  45032. * @return true if user is scrolling.
  45033. */
  45034. private _userIsZooming;
  45035. private _lastFrameRadius;
  45036. private _shouldAnimationStopForInteraction;
  45037. /**
  45038. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45039. */
  45040. private _applyUserInteraction;
  45041. private _userIsMoving;
  45042. }
  45043. }
  45044. declare module "babylonjs/Behaviors/Cameras/index" {
  45045. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  45046. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  45047. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  45048. }
  45049. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  45050. import { Mesh } from "babylonjs/Meshes/mesh";
  45051. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45052. import { Behavior } from "babylonjs/Behaviors/behavior";
  45053. /**
  45054. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  45055. */
  45056. export class AttachToBoxBehavior implements Behavior<Mesh> {
  45057. private ui;
  45058. /**
  45059. * The name of the behavior
  45060. */
  45061. name: string;
  45062. /**
  45063. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  45064. */
  45065. distanceAwayFromFace: number;
  45066. /**
  45067. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  45068. */
  45069. distanceAwayFromBottomOfFace: number;
  45070. private _faceVectors;
  45071. private _target;
  45072. private _scene;
  45073. private _onRenderObserver;
  45074. private _tmpMatrix;
  45075. private _tmpVector;
  45076. /**
  45077. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  45078. * @param ui The transform node that should be attched to the mesh
  45079. */
  45080. constructor(ui: TransformNode);
  45081. /**
  45082. * Initializes the behavior
  45083. */
  45084. init(): void;
  45085. private _closestFace;
  45086. private _zeroVector;
  45087. private _lookAtTmpMatrix;
  45088. private _lookAtToRef;
  45089. /**
  45090. * Attaches the AttachToBoxBehavior to the passed in mesh
  45091. * @param target The mesh that the specified node will be attached to
  45092. */
  45093. attach(target: Mesh): void;
  45094. /**
  45095. * Detaches the behavior from the mesh
  45096. */
  45097. detach(): void;
  45098. }
  45099. }
  45100. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  45101. import { Behavior } from "babylonjs/Behaviors/behavior";
  45102. import { Mesh } from "babylonjs/Meshes/mesh";
  45103. /**
  45104. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  45105. */
  45106. export class FadeInOutBehavior implements Behavior<Mesh> {
  45107. /**
  45108. * Time in milliseconds to delay before fading in (Default: 0)
  45109. */
  45110. delay: number;
  45111. /**
  45112. * Time in milliseconds for the mesh to fade in (Default: 300)
  45113. */
  45114. fadeInTime: number;
  45115. private _millisecondsPerFrame;
  45116. private _hovered;
  45117. private _hoverValue;
  45118. private _ownerNode;
  45119. /**
  45120. * Instatiates the FadeInOutBehavior
  45121. */
  45122. constructor();
  45123. /**
  45124. * The name of the behavior
  45125. */
  45126. get name(): string;
  45127. /**
  45128. * Initializes the behavior
  45129. */
  45130. init(): void;
  45131. /**
  45132. * Attaches the fade behavior on the passed in mesh
  45133. * @param ownerNode The mesh that will be faded in/out once attached
  45134. */
  45135. attach(ownerNode: Mesh): void;
  45136. /**
  45137. * Detaches the behavior from the mesh
  45138. */
  45139. detach(): void;
  45140. /**
  45141. * Triggers the mesh to begin fading in or out
  45142. * @param value if the object should fade in or out (true to fade in)
  45143. */
  45144. fadeIn(value: boolean): void;
  45145. private _update;
  45146. private _setAllVisibility;
  45147. }
  45148. }
  45149. declare module "babylonjs/Misc/pivotTools" {
  45150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45151. /**
  45152. * Class containing a set of static utilities functions for managing Pivots
  45153. * @hidden
  45154. */
  45155. export class PivotTools {
  45156. private static _PivotCached;
  45157. private static _OldPivotPoint;
  45158. private static _PivotTranslation;
  45159. private static _PivotTmpVector;
  45160. private static _PivotPostMultiplyPivotMatrix;
  45161. /** @hidden */
  45162. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45163. /** @hidden */
  45164. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45165. }
  45166. }
  45167. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45168. import { Scene } from "babylonjs/scene";
  45169. import { Vector4 } from "babylonjs/Maths/math.vector";
  45170. import { Mesh } from "babylonjs/Meshes/mesh";
  45171. import { Nullable } from "babylonjs/types";
  45172. import { Plane } from "babylonjs/Maths/math.plane";
  45173. /**
  45174. * Class containing static functions to help procedurally build meshes
  45175. */
  45176. export class PlaneBuilder {
  45177. /**
  45178. * Creates a plane mesh
  45179. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45180. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45181. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45185. * @param name defines the name of the mesh
  45186. * @param options defines the options used to create the mesh
  45187. * @param scene defines the hosting scene
  45188. * @returns the plane mesh
  45189. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45190. */
  45191. static CreatePlane(name: string, options: {
  45192. size?: number;
  45193. width?: number;
  45194. height?: number;
  45195. sideOrientation?: number;
  45196. frontUVs?: Vector4;
  45197. backUVs?: Vector4;
  45198. updatable?: boolean;
  45199. sourcePlane?: Plane;
  45200. }, scene?: Nullable<Scene>): Mesh;
  45201. }
  45202. }
  45203. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45204. import { Behavior } from "babylonjs/Behaviors/behavior";
  45205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45206. import { Observable } from "babylonjs/Misc/observable";
  45207. import { Vector3 } from "babylonjs/Maths/math.vector";
  45208. import { Ray } from "babylonjs/Culling/ray";
  45209. import "babylonjs/Meshes/Builders/planeBuilder";
  45210. /**
  45211. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45212. */
  45213. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45214. private static _AnyMouseID;
  45215. /**
  45216. * Abstract mesh the behavior is set on
  45217. */
  45218. attachedNode: AbstractMesh;
  45219. private _dragPlane;
  45220. private _scene;
  45221. private _pointerObserver;
  45222. private _beforeRenderObserver;
  45223. private static _planeScene;
  45224. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45225. /**
  45226. * 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)
  45227. */
  45228. maxDragAngle: number;
  45229. /**
  45230. * @hidden
  45231. */
  45232. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45233. /**
  45234. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45235. */
  45236. currentDraggingPointerID: number;
  45237. /**
  45238. * The last position where the pointer hit the drag plane in world space
  45239. */
  45240. lastDragPosition: Vector3;
  45241. /**
  45242. * If the behavior is currently in a dragging state
  45243. */
  45244. dragging: boolean;
  45245. /**
  45246. * 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)
  45247. */
  45248. dragDeltaRatio: number;
  45249. /**
  45250. * If the drag plane orientation should be updated during the dragging (Default: true)
  45251. */
  45252. updateDragPlane: boolean;
  45253. private _debugMode;
  45254. private _moving;
  45255. /**
  45256. * Fires each time the attached mesh is dragged with the pointer
  45257. * * delta between last drag position and current drag position in world space
  45258. * * dragDistance along the drag axis
  45259. * * dragPlaneNormal normal of the current drag plane used during the drag
  45260. * * dragPlanePoint in world space where the drag intersects the drag plane
  45261. */
  45262. onDragObservable: Observable<{
  45263. delta: Vector3;
  45264. dragPlanePoint: Vector3;
  45265. dragPlaneNormal: Vector3;
  45266. dragDistance: number;
  45267. pointerId: number;
  45268. }>;
  45269. /**
  45270. * Fires each time a drag begins (eg. mouse down on mesh)
  45271. */
  45272. onDragStartObservable: Observable<{
  45273. dragPlanePoint: Vector3;
  45274. pointerId: number;
  45275. }>;
  45276. /**
  45277. * Fires each time a drag ends (eg. mouse release after drag)
  45278. */
  45279. onDragEndObservable: Observable<{
  45280. dragPlanePoint: Vector3;
  45281. pointerId: number;
  45282. }>;
  45283. /**
  45284. * If the attached mesh should be moved when dragged
  45285. */
  45286. moveAttached: boolean;
  45287. /**
  45288. * If the drag behavior will react to drag events (Default: true)
  45289. */
  45290. enabled: boolean;
  45291. /**
  45292. * If pointer events should start and release the drag (Default: true)
  45293. */
  45294. startAndReleaseDragOnPointerEvents: boolean;
  45295. /**
  45296. * If camera controls should be detached during the drag
  45297. */
  45298. detachCameraControls: boolean;
  45299. /**
  45300. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45301. */
  45302. useObjectOrientationForDragging: boolean;
  45303. private _options;
  45304. /**
  45305. * Gets the options used by the behavior
  45306. */
  45307. get options(): {
  45308. dragAxis?: Vector3;
  45309. dragPlaneNormal?: Vector3;
  45310. };
  45311. /**
  45312. * Sets the options used by the behavior
  45313. */
  45314. set options(options: {
  45315. dragAxis?: Vector3;
  45316. dragPlaneNormal?: Vector3;
  45317. });
  45318. /**
  45319. * Creates a pointer drag behavior that can be attached to a mesh
  45320. * @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)
  45321. */
  45322. constructor(options?: {
  45323. dragAxis?: Vector3;
  45324. dragPlaneNormal?: Vector3;
  45325. });
  45326. /**
  45327. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45328. */
  45329. validateDrag: (targetPosition: Vector3) => boolean;
  45330. /**
  45331. * The name of the behavior
  45332. */
  45333. get name(): string;
  45334. /**
  45335. * Initializes the behavior
  45336. */
  45337. init(): void;
  45338. private _tmpVector;
  45339. private _alternatePickedPoint;
  45340. private _worldDragAxis;
  45341. private _targetPosition;
  45342. private _attachedElement;
  45343. /**
  45344. * Attaches the drag behavior the passed in mesh
  45345. * @param ownerNode The mesh that will be dragged around once attached
  45346. * @param predicate Predicate to use for pick filtering
  45347. */
  45348. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45349. /**
  45350. * Force relase the drag action by code.
  45351. */
  45352. releaseDrag(): void;
  45353. private _startDragRay;
  45354. private _lastPointerRay;
  45355. /**
  45356. * Simulates the start of a pointer drag event on the behavior
  45357. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45358. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45359. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45360. */
  45361. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45362. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45363. private _dragDelta;
  45364. protected _moveDrag(ray: Ray): void;
  45365. private _pickWithRayOnDragPlane;
  45366. private _pointA;
  45367. private _pointC;
  45368. private _localAxis;
  45369. private _lookAt;
  45370. private _updateDragPlanePosition;
  45371. /**
  45372. * Detaches the behavior from the mesh
  45373. */
  45374. detach(): void;
  45375. }
  45376. }
  45377. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45378. import { Mesh } from "babylonjs/Meshes/mesh";
  45379. import { Behavior } from "babylonjs/Behaviors/behavior";
  45380. /**
  45381. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45382. */
  45383. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45384. private _dragBehaviorA;
  45385. private _dragBehaviorB;
  45386. private _startDistance;
  45387. private _initialScale;
  45388. private _targetScale;
  45389. private _ownerNode;
  45390. private _sceneRenderObserver;
  45391. /**
  45392. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45393. */
  45394. constructor();
  45395. /**
  45396. * The name of the behavior
  45397. */
  45398. get name(): string;
  45399. /**
  45400. * Initializes the behavior
  45401. */
  45402. init(): void;
  45403. private _getCurrentDistance;
  45404. /**
  45405. * Attaches the scale behavior the passed in mesh
  45406. * @param ownerNode The mesh that will be scaled around once attached
  45407. */
  45408. attach(ownerNode: Mesh): void;
  45409. /**
  45410. * Detaches the behavior from the mesh
  45411. */
  45412. detach(): void;
  45413. }
  45414. }
  45415. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45416. import { Behavior } from "babylonjs/Behaviors/behavior";
  45417. import { Mesh } from "babylonjs/Meshes/mesh";
  45418. import { Observable } from "babylonjs/Misc/observable";
  45419. /**
  45420. * 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
  45421. */
  45422. export class SixDofDragBehavior implements Behavior<Mesh> {
  45423. private static _virtualScene;
  45424. private _ownerNode;
  45425. private _sceneRenderObserver;
  45426. private _scene;
  45427. private _targetPosition;
  45428. private _virtualOriginMesh;
  45429. private _virtualDragMesh;
  45430. private _pointerObserver;
  45431. private _moving;
  45432. private _startingOrientation;
  45433. private _attachedElement;
  45434. /**
  45435. * 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)
  45436. */
  45437. private zDragFactor;
  45438. /**
  45439. * If the object should rotate to face the drag origin
  45440. */
  45441. rotateDraggedObject: boolean;
  45442. /**
  45443. * If the behavior is currently in a dragging state
  45444. */
  45445. dragging: boolean;
  45446. /**
  45447. * 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)
  45448. */
  45449. dragDeltaRatio: number;
  45450. /**
  45451. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45452. */
  45453. currentDraggingPointerID: number;
  45454. /**
  45455. * If camera controls should be detached during the drag
  45456. */
  45457. detachCameraControls: boolean;
  45458. /**
  45459. * Fires each time a drag starts
  45460. */
  45461. onDragStartObservable: Observable<{}>;
  45462. /**
  45463. * Fires each time a drag ends (eg. mouse release after drag)
  45464. */
  45465. onDragEndObservable: Observable<{}>;
  45466. /**
  45467. * 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
  45468. */
  45469. constructor();
  45470. /**
  45471. * The name of the behavior
  45472. */
  45473. get name(): string;
  45474. /**
  45475. * Initializes the behavior
  45476. */
  45477. init(): void;
  45478. /**
  45479. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45480. */
  45481. private get _pointerCamera();
  45482. /**
  45483. * Attaches the scale behavior the passed in mesh
  45484. * @param ownerNode The mesh that will be scaled around once attached
  45485. */
  45486. attach(ownerNode: Mesh): void;
  45487. /**
  45488. * Detaches the behavior from the mesh
  45489. */
  45490. detach(): void;
  45491. }
  45492. }
  45493. declare module "babylonjs/Behaviors/Meshes/index" {
  45494. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45495. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45496. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45497. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45498. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45499. }
  45500. declare module "babylonjs/Behaviors/index" {
  45501. export * from "babylonjs/Behaviors/behavior";
  45502. export * from "babylonjs/Behaviors/Cameras/index";
  45503. export * from "babylonjs/Behaviors/Meshes/index";
  45504. }
  45505. declare module "babylonjs/Bones/boneIKController" {
  45506. import { Bone } from "babylonjs/Bones/bone";
  45507. import { Vector3 } from "babylonjs/Maths/math.vector";
  45508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45509. import { Nullable } from "babylonjs/types";
  45510. /**
  45511. * Class used to apply inverse kinematics to bones
  45512. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45513. */
  45514. export class BoneIKController {
  45515. private static _tmpVecs;
  45516. private static _tmpQuat;
  45517. private static _tmpMats;
  45518. /**
  45519. * Gets or sets the target mesh
  45520. */
  45521. targetMesh: AbstractMesh;
  45522. /** Gets or sets the mesh used as pole */
  45523. poleTargetMesh: AbstractMesh;
  45524. /**
  45525. * Gets or sets the bone used as pole
  45526. */
  45527. poleTargetBone: Nullable<Bone>;
  45528. /**
  45529. * Gets or sets the target position
  45530. */
  45531. targetPosition: Vector3;
  45532. /**
  45533. * Gets or sets the pole target position
  45534. */
  45535. poleTargetPosition: Vector3;
  45536. /**
  45537. * Gets or sets the pole target local offset
  45538. */
  45539. poleTargetLocalOffset: Vector3;
  45540. /**
  45541. * Gets or sets the pole angle
  45542. */
  45543. poleAngle: number;
  45544. /**
  45545. * Gets or sets the mesh associated with the controller
  45546. */
  45547. mesh: AbstractMesh;
  45548. /**
  45549. * 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)
  45550. */
  45551. slerpAmount: number;
  45552. private _bone1Quat;
  45553. private _bone1Mat;
  45554. private _bone2Ang;
  45555. private _bone1;
  45556. private _bone2;
  45557. private _bone1Length;
  45558. private _bone2Length;
  45559. private _maxAngle;
  45560. private _maxReach;
  45561. private _rightHandedSystem;
  45562. private _bendAxis;
  45563. private _slerping;
  45564. private _adjustRoll;
  45565. /**
  45566. * Gets or sets maximum allowed angle
  45567. */
  45568. get maxAngle(): number;
  45569. set maxAngle(value: number);
  45570. /**
  45571. * Creates a new BoneIKController
  45572. * @param mesh defines the mesh to control
  45573. * @param bone defines the bone to control
  45574. * @param options defines options to set up the controller
  45575. */
  45576. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45577. targetMesh?: AbstractMesh;
  45578. poleTargetMesh?: AbstractMesh;
  45579. poleTargetBone?: Bone;
  45580. poleTargetLocalOffset?: Vector3;
  45581. poleAngle?: number;
  45582. bendAxis?: Vector3;
  45583. maxAngle?: number;
  45584. slerpAmount?: number;
  45585. });
  45586. private _setMaxAngle;
  45587. /**
  45588. * Force the controller to update the bones
  45589. */
  45590. update(): void;
  45591. }
  45592. }
  45593. declare module "babylonjs/Bones/boneLookController" {
  45594. import { Vector3 } from "babylonjs/Maths/math.vector";
  45595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45596. import { Bone } from "babylonjs/Bones/bone";
  45597. import { Space } from "babylonjs/Maths/math.axis";
  45598. /**
  45599. * Class used to make a bone look toward a point in space
  45600. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45601. */
  45602. export class BoneLookController {
  45603. private static _tmpVecs;
  45604. private static _tmpQuat;
  45605. private static _tmpMats;
  45606. /**
  45607. * The target Vector3 that the bone will look at
  45608. */
  45609. target: Vector3;
  45610. /**
  45611. * The mesh that the bone is attached to
  45612. */
  45613. mesh: AbstractMesh;
  45614. /**
  45615. * The bone that will be looking to the target
  45616. */
  45617. bone: Bone;
  45618. /**
  45619. * The up axis of the coordinate system that is used when the bone is rotated
  45620. */
  45621. upAxis: Vector3;
  45622. /**
  45623. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45624. */
  45625. upAxisSpace: Space;
  45626. /**
  45627. * Used to make an adjustment to the yaw of the bone
  45628. */
  45629. adjustYaw: number;
  45630. /**
  45631. * Used to make an adjustment to the pitch of the bone
  45632. */
  45633. adjustPitch: number;
  45634. /**
  45635. * Used to make an adjustment to the roll of the bone
  45636. */
  45637. adjustRoll: number;
  45638. /**
  45639. * 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)
  45640. */
  45641. slerpAmount: number;
  45642. private _minYaw;
  45643. private _maxYaw;
  45644. private _minPitch;
  45645. private _maxPitch;
  45646. private _minYawSin;
  45647. private _minYawCos;
  45648. private _maxYawSin;
  45649. private _maxYawCos;
  45650. private _midYawConstraint;
  45651. private _minPitchTan;
  45652. private _maxPitchTan;
  45653. private _boneQuat;
  45654. private _slerping;
  45655. private _transformYawPitch;
  45656. private _transformYawPitchInv;
  45657. private _firstFrameSkipped;
  45658. private _yawRange;
  45659. private _fowardAxis;
  45660. /**
  45661. * Gets or sets the minimum yaw angle that the bone can look to
  45662. */
  45663. get minYaw(): number;
  45664. set minYaw(value: number);
  45665. /**
  45666. * Gets or sets the maximum yaw angle that the bone can look to
  45667. */
  45668. get maxYaw(): number;
  45669. set maxYaw(value: number);
  45670. /**
  45671. * Gets or sets the minimum pitch angle that the bone can look to
  45672. */
  45673. get minPitch(): number;
  45674. set minPitch(value: number);
  45675. /**
  45676. * Gets or sets the maximum pitch angle that the bone can look to
  45677. */
  45678. get maxPitch(): number;
  45679. set maxPitch(value: number);
  45680. /**
  45681. * Create a BoneLookController
  45682. * @param mesh the mesh that the bone belongs to
  45683. * @param bone the bone that will be looking to the target
  45684. * @param target the target Vector3 to look at
  45685. * @param options optional settings:
  45686. * * maxYaw: the maximum angle the bone will yaw to
  45687. * * minYaw: the minimum angle the bone will yaw to
  45688. * * maxPitch: the maximum angle the bone will pitch to
  45689. * * minPitch: the minimum angle the bone will yaw to
  45690. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45691. * * upAxis: the up axis of the coordinate system
  45692. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45693. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45694. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45695. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45696. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45697. * * adjustRoll: used to make an adjustment to the roll of the bone
  45698. **/
  45699. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45700. maxYaw?: number;
  45701. minYaw?: number;
  45702. maxPitch?: number;
  45703. minPitch?: number;
  45704. slerpAmount?: number;
  45705. upAxis?: Vector3;
  45706. upAxisSpace?: Space;
  45707. yawAxis?: Vector3;
  45708. pitchAxis?: Vector3;
  45709. adjustYaw?: number;
  45710. adjustPitch?: number;
  45711. adjustRoll?: number;
  45712. });
  45713. /**
  45714. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45715. */
  45716. update(): void;
  45717. private _getAngleDiff;
  45718. private _getAngleBetween;
  45719. private _isAngleBetween;
  45720. }
  45721. }
  45722. declare module "babylonjs/Bones/index" {
  45723. export * from "babylonjs/Bones/bone";
  45724. export * from "babylonjs/Bones/boneIKController";
  45725. export * from "babylonjs/Bones/boneLookController";
  45726. export * from "babylonjs/Bones/skeleton";
  45727. }
  45728. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45729. import { Nullable } from "babylonjs/types";
  45730. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45731. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45732. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45733. /**
  45734. * Manage the gamepad inputs to control an arc rotate camera.
  45735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45736. */
  45737. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45738. /**
  45739. * Defines the camera the input is attached to.
  45740. */
  45741. camera: ArcRotateCamera;
  45742. /**
  45743. * Defines the gamepad the input is gathering event from.
  45744. */
  45745. gamepad: Nullable<Gamepad>;
  45746. /**
  45747. * Defines the gamepad rotation sensiblity.
  45748. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45749. */
  45750. gamepadRotationSensibility: number;
  45751. /**
  45752. * Defines the gamepad move sensiblity.
  45753. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45754. */
  45755. gamepadMoveSensibility: number;
  45756. private _yAxisScale;
  45757. /**
  45758. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45759. */
  45760. get invertYAxis(): boolean;
  45761. set invertYAxis(value: boolean);
  45762. private _onGamepadConnectedObserver;
  45763. private _onGamepadDisconnectedObserver;
  45764. /**
  45765. * Attach the input controls to a specific dom element to get the input from.
  45766. * @param element Defines the element the controls should be listened from
  45767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45768. */
  45769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45770. /**
  45771. * Detach the current controls from the specified dom element.
  45772. * @param element Defines the element to stop listening the inputs from
  45773. */
  45774. detachControl(element: Nullable<HTMLElement>): void;
  45775. /**
  45776. * Update the current camera state depending on the inputs that have been used this frame.
  45777. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45778. */
  45779. checkInputs(): void;
  45780. /**
  45781. * Gets the class name of the current intput.
  45782. * @returns the class name
  45783. */
  45784. getClassName(): string;
  45785. /**
  45786. * Get the friendly name associated with the input class.
  45787. * @returns the input friendly name
  45788. */
  45789. getSimpleName(): string;
  45790. }
  45791. }
  45792. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45793. import { Nullable } from "babylonjs/types";
  45794. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45795. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45796. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45797. interface ArcRotateCameraInputsManager {
  45798. /**
  45799. * Add orientation input support to the input manager.
  45800. * @returns the current input manager
  45801. */
  45802. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45803. }
  45804. }
  45805. /**
  45806. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45808. */
  45809. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45810. /**
  45811. * Defines the camera the input is attached to.
  45812. */
  45813. camera: ArcRotateCamera;
  45814. /**
  45815. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45816. */
  45817. alphaCorrection: number;
  45818. /**
  45819. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45820. */
  45821. gammaCorrection: number;
  45822. private _alpha;
  45823. private _gamma;
  45824. private _dirty;
  45825. private _deviceOrientationHandler;
  45826. /**
  45827. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45828. */
  45829. constructor();
  45830. /**
  45831. * Attach the input controls to a specific dom element to get the input from.
  45832. * @param element Defines the element the controls should be listened from
  45833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45834. */
  45835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45836. /** @hidden */
  45837. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45838. /**
  45839. * Update the current camera state depending on the inputs that have been used this frame.
  45840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45841. */
  45842. checkInputs(): void;
  45843. /**
  45844. * Detach the current controls from the specified dom element.
  45845. * @param element Defines the element to stop listening the inputs from
  45846. */
  45847. detachControl(element: Nullable<HTMLElement>): void;
  45848. /**
  45849. * Gets the class name of the current intput.
  45850. * @returns the class name
  45851. */
  45852. getClassName(): string;
  45853. /**
  45854. * Get the friendly name associated with the input class.
  45855. * @returns the input friendly name
  45856. */
  45857. getSimpleName(): string;
  45858. }
  45859. }
  45860. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45861. import { Nullable } from "babylonjs/types";
  45862. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45863. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45864. /**
  45865. * Listen to mouse events to control the camera.
  45866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45867. */
  45868. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45869. /**
  45870. * Defines the camera the input is attached to.
  45871. */
  45872. camera: FlyCamera;
  45873. /**
  45874. * Defines if touch is enabled. (Default is true.)
  45875. */
  45876. touchEnabled: boolean;
  45877. /**
  45878. * Defines the buttons associated with the input to handle camera rotation.
  45879. */
  45880. buttons: number[];
  45881. /**
  45882. * Assign buttons for Yaw control.
  45883. */
  45884. buttonsYaw: number[];
  45885. /**
  45886. * Assign buttons for Pitch control.
  45887. */
  45888. buttonsPitch: number[];
  45889. /**
  45890. * Assign buttons for Roll control.
  45891. */
  45892. buttonsRoll: number[];
  45893. /**
  45894. * Detect if any button is being pressed while mouse is moved.
  45895. * -1 = Mouse locked.
  45896. * 0 = Left button.
  45897. * 1 = Middle Button.
  45898. * 2 = Right Button.
  45899. */
  45900. activeButton: number;
  45901. /**
  45902. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45903. * Higher values reduce its sensitivity.
  45904. */
  45905. angularSensibility: number;
  45906. private _mousemoveCallback;
  45907. private _observer;
  45908. private _rollObserver;
  45909. private previousPosition;
  45910. private noPreventDefault;
  45911. private element;
  45912. /**
  45913. * Listen to mouse events to control the camera.
  45914. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45916. */
  45917. constructor(touchEnabled?: boolean);
  45918. /**
  45919. * Attach the mouse control to the HTML DOM element.
  45920. * @param element Defines the element that listens to the input events.
  45921. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45922. */
  45923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45924. /**
  45925. * Detach the current controls from the specified dom element.
  45926. * @param element Defines the element to stop listening the inputs from
  45927. */
  45928. detachControl(element: Nullable<HTMLElement>): void;
  45929. /**
  45930. * Gets the class name of the current input.
  45931. * @returns the class name.
  45932. */
  45933. getClassName(): string;
  45934. /**
  45935. * Get the friendly name associated with the input class.
  45936. * @returns the input's friendly name.
  45937. */
  45938. getSimpleName(): string;
  45939. private _pointerInput;
  45940. private _onMouseMove;
  45941. /**
  45942. * Rotate camera by mouse offset.
  45943. */
  45944. private rotateCamera;
  45945. }
  45946. }
  45947. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45948. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45949. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45950. /**
  45951. * Default Inputs manager for the FlyCamera.
  45952. * It groups all the default supported inputs for ease of use.
  45953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45954. */
  45955. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45956. /**
  45957. * Instantiates a new FlyCameraInputsManager.
  45958. * @param camera Defines the camera the inputs belong to.
  45959. */
  45960. constructor(camera: FlyCamera);
  45961. /**
  45962. * Add keyboard input support to the input manager.
  45963. * @returns the new FlyCameraKeyboardMoveInput().
  45964. */
  45965. addKeyboard(): FlyCameraInputsManager;
  45966. /**
  45967. * Add mouse input support to the input manager.
  45968. * @param touchEnabled Enable touch screen support.
  45969. * @returns the new FlyCameraMouseInput().
  45970. */
  45971. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45972. }
  45973. }
  45974. declare module "babylonjs/Cameras/flyCamera" {
  45975. import { Scene } from "babylonjs/scene";
  45976. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45978. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45979. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45980. /**
  45981. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45982. * such as in a 3D Space Shooter or a Flight Simulator.
  45983. */
  45984. export class FlyCamera extends TargetCamera {
  45985. /**
  45986. * Define the collision ellipsoid of the camera.
  45987. * This is helpful for simulating a camera body, like a player's body.
  45988. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45989. */
  45990. ellipsoid: Vector3;
  45991. /**
  45992. * Define an offset for the position of the ellipsoid around the camera.
  45993. * This can be helpful if the camera is attached away from the player's body center,
  45994. * such as at its head.
  45995. */
  45996. ellipsoidOffset: Vector3;
  45997. /**
  45998. * Enable or disable collisions of the camera with the rest of the scene objects.
  45999. */
  46000. checkCollisions: boolean;
  46001. /**
  46002. * Enable or disable gravity on the camera.
  46003. */
  46004. applyGravity: boolean;
  46005. /**
  46006. * Define the current direction the camera is moving to.
  46007. */
  46008. cameraDirection: Vector3;
  46009. /**
  46010. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  46011. * This overrides and empties cameraRotation.
  46012. */
  46013. rotationQuaternion: Quaternion;
  46014. /**
  46015. * Track Roll to maintain the wanted Rolling when looking around.
  46016. */
  46017. _trackRoll: number;
  46018. /**
  46019. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  46020. */
  46021. rollCorrect: number;
  46022. /**
  46023. * Mimic a banked turn, Rolling the camera when Yawing.
  46024. * It's recommended to use rollCorrect = 10 for faster banking correction.
  46025. */
  46026. bankedTurn: boolean;
  46027. /**
  46028. * Limit in radians for how much Roll banking will add. (Default: 90°)
  46029. */
  46030. bankedTurnLimit: number;
  46031. /**
  46032. * Value of 0 disables the banked Roll.
  46033. * Value of 1 is equal to the Yaw angle in radians.
  46034. */
  46035. bankedTurnMultiplier: number;
  46036. /**
  46037. * The inputs manager loads all the input sources, such as keyboard and mouse.
  46038. */
  46039. inputs: FlyCameraInputsManager;
  46040. /**
  46041. * Gets the input sensibility for mouse input.
  46042. * Higher values reduce sensitivity.
  46043. */
  46044. get angularSensibility(): number;
  46045. /**
  46046. * Sets the input sensibility for a mouse input.
  46047. * Higher values reduce sensitivity.
  46048. */
  46049. set angularSensibility(value: number);
  46050. /**
  46051. * Get the keys for camera movement forward.
  46052. */
  46053. get keysForward(): number[];
  46054. /**
  46055. * Set the keys for camera movement forward.
  46056. */
  46057. set keysForward(value: number[]);
  46058. /**
  46059. * Get the keys for camera movement backward.
  46060. */
  46061. get keysBackward(): number[];
  46062. set keysBackward(value: number[]);
  46063. /**
  46064. * Get the keys for camera movement up.
  46065. */
  46066. get keysUp(): number[];
  46067. /**
  46068. * Set the keys for camera movement up.
  46069. */
  46070. set keysUp(value: number[]);
  46071. /**
  46072. * Get the keys for camera movement down.
  46073. */
  46074. get keysDown(): number[];
  46075. /**
  46076. * Set the keys for camera movement down.
  46077. */
  46078. set keysDown(value: number[]);
  46079. /**
  46080. * Get the keys for camera movement left.
  46081. */
  46082. get keysLeft(): number[];
  46083. /**
  46084. * Set the keys for camera movement left.
  46085. */
  46086. set keysLeft(value: number[]);
  46087. /**
  46088. * Set the keys for camera movement right.
  46089. */
  46090. get keysRight(): number[];
  46091. /**
  46092. * Set the keys for camera movement right.
  46093. */
  46094. set keysRight(value: number[]);
  46095. /**
  46096. * Event raised when the camera collides with a mesh in the scene.
  46097. */
  46098. onCollide: (collidedMesh: AbstractMesh) => void;
  46099. private _collider;
  46100. private _needMoveForGravity;
  46101. private _oldPosition;
  46102. private _diffPosition;
  46103. private _newPosition;
  46104. /** @hidden */
  46105. _localDirection: Vector3;
  46106. /** @hidden */
  46107. _transformedDirection: Vector3;
  46108. /**
  46109. * Instantiates a FlyCamera.
  46110. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46111. * such as in a 3D Space Shooter or a Flight Simulator.
  46112. * @param name Define the name of the camera in the scene.
  46113. * @param position Define the starting position of the camera in the scene.
  46114. * @param scene Define the scene the camera belongs to.
  46115. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46116. */
  46117. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46118. /**
  46119. * Attach a control to the HTML DOM element.
  46120. * @param element Defines the element that listens to the input events.
  46121. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46122. */
  46123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46124. /**
  46125. * Detach a control from the HTML DOM element.
  46126. * The camera will stop reacting to that input.
  46127. * @param element Defines the element that listens to the input events.
  46128. */
  46129. detachControl(element: HTMLElement): void;
  46130. private _collisionMask;
  46131. /**
  46132. * Get the mask that the camera ignores in collision events.
  46133. */
  46134. get collisionMask(): number;
  46135. /**
  46136. * Set the mask that the camera ignores in collision events.
  46137. */
  46138. set collisionMask(mask: number);
  46139. /** @hidden */
  46140. _collideWithWorld(displacement: Vector3): void;
  46141. /** @hidden */
  46142. private _onCollisionPositionChange;
  46143. /** @hidden */
  46144. _checkInputs(): void;
  46145. /** @hidden */
  46146. _decideIfNeedsToMove(): boolean;
  46147. /** @hidden */
  46148. _updatePosition(): void;
  46149. /**
  46150. * Restore the Roll to its target value at the rate specified.
  46151. * @param rate - Higher means slower restoring.
  46152. * @hidden
  46153. */
  46154. restoreRoll(rate: number): void;
  46155. /**
  46156. * Destroy the camera and release the current resources held by it.
  46157. */
  46158. dispose(): void;
  46159. /**
  46160. * Get the current object class name.
  46161. * @returns the class name.
  46162. */
  46163. getClassName(): string;
  46164. }
  46165. }
  46166. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46167. import { Nullable } from "babylonjs/types";
  46168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46169. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46170. /**
  46171. * Listen to keyboard events to control the camera.
  46172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46173. */
  46174. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46175. /**
  46176. * Defines the camera the input is attached to.
  46177. */
  46178. camera: FlyCamera;
  46179. /**
  46180. * The list of keyboard keys used to control the forward move of the camera.
  46181. */
  46182. keysForward: number[];
  46183. /**
  46184. * The list of keyboard keys used to control the backward move of the camera.
  46185. */
  46186. keysBackward: number[];
  46187. /**
  46188. * The list of keyboard keys used to control the forward move of the camera.
  46189. */
  46190. keysUp: number[];
  46191. /**
  46192. * The list of keyboard keys used to control the backward move of the camera.
  46193. */
  46194. keysDown: number[];
  46195. /**
  46196. * The list of keyboard keys used to control the right strafe move of the camera.
  46197. */
  46198. keysRight: number[];
  46199. /**
  46200. * The list of keyboard keys used to control the left strafe move of the camera.
  46201. */
  46202. keysLeft: number[];
  46203. private _keys;
  46204. private _onCanvasBlurObserver;
  46205. private _onKeyboardObserver;
  46206. private _engine;
  46207. private _scene;
  46208. /**
  46209. * Attach the input controls to a specific dom element to get the input from.
  46210. * @param element Defines the element the controls should be listened from
  46211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46212. */
  46213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46214. /**
  46215. * Detach the current controls from the specified dom element.
  46216. * @param element Defines the element to stop listening the inputs from
  46217. */
  46218. detachControl(element: Nullable<HTMLElement>): void;
  46219. /**
  46220. * Gets the class name of the current intput.
  46221. * @returns the class name
  46222. */
  46223. getClassName(): string;
  46224. /** @hidden */
  46225. _onLostFocus(e: FocusEvent): void;
  46226. /**
  46227. * Get the friendly name associated with the input class.
  46228. * @returns the input friendly name
  46229. */
  46230. getSimpleName(): string;
  46231. /**
  46232. * Update the current camera state depending on the inputs that have been used this frame.
  46233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46234. */
  46235. checkInputs(): void;
  46236. }
  46237. }
  46238. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46239. import { Nullable } from "babylonjs/types";
  46240. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46242. /**
  46243. * Manage the mouse wheel inputs to control a follow camera.
  46244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46245. */
  46246. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46247. /**
  46248. * Defines the camera the input is attached to.
  46249. */
  46250. camera: FollowCamera;
  46251. /**
  46252. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46253. */
  46254. axisControlRadius: boolean;
  46255. /**
  46256. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46257. */
  46258. axisControlHeight: boolean;
  46259. /**
  46260. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46261. */
  46262. axisControlRotation: boolean;
  46263. /**
  46264. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46265. * relation to mouseWheel events.
  46266. */
  46267. wheelPrecision: number;
  46268. /**
  46269. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46270. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46271. */
  46272. wheelDeltaPercentage: number;
  46273. private _wheel;
  46274. private _observer;
  46275. /**
  46276. * Attach the input controls to a specific dom element to get the input from.
  46277. * @param element Defines the element the controls should be listened from
  46278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46279. */
  46280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46281. /**
  46282. * Detach the current controls from the specified dom element.
  46283. * @param element Defines the element to stop listening the inputs from
  46284. */
  46285. detachControl(element: Nullable<HTMLElement>): void;
  46286. /**
  46287. * Gets the class name of the current intput.
  46288. * @returns the class name
  46289. */
  46290. getClassName(): string;
  46291. /**
  46292. * Get the friendly name associated with the input class.
  46293. * @returns the input friendly name
  46294. */
  46295. getSimpleName(): string;
  46296. }
  46297. }
  46298. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46299. import { Nullable } from "babylonjs/types";
  46300. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46301. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46302. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46303. /**
  46304. * Manage the pointers inputs to control an follow camera.
  46305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46306. */
  46307. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46308. /**
  46309. * Defines the camera the input is attached to.
  46310. */
  46311. camera: FollowCamera;
  46312. /**
  46313. * Gets the class name of the current input.
  46314. * @returns the class name
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Defines the pointer angular sensibility along the X axis or how fast is
  46319. * the camera rotating.
  46320. * A negative number will reverse the axis direction.
  46321. */
  46322. angularSensibilityX: number;
  46323. /**
  46324. * Defines the pointer angular sensibility along the Y axis or how fast is
  46325. * the camera rotating.
  46326. * A negative number will reverse the axis direction.
  46327. */
  46328. angularSensibilityY: number;
  46329. /**
  46330. * Defines the pointer pinch precision or how fast is the camera zooming.
  46331. * A negative number will reverse the axis direction.
  46332. */
  46333. pinchPrecision: number;
  46334. /**
  46335. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46336. * from 0.
  46337. * It defines the percentage of current camera.radius to use as delta when
  46338. * pinch zoom is used.
  46339. */
  46340. pinchDeltaPercentage: number;
  46341. /**
  46342. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46343. */
  46344. axisXControlRadius: boolean;
  46345. /**
  46346. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46347. */
  46348. axisXControlHeight: boolean;
  46349. /**
  46350. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46351. */
  46352. axisXControlRotation: boolean;
  46353. /**
  46354. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46355. */
  46356. axisYControlRadius: boolean;
  46357. /**
  46358. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46359. */
  46360. axisYControlHeight: boolean;
  46361. /**
  46362. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46363. */
  46364. axisYControlRotation: boolean;
  46365. /**
  46366. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46367. */
  46368. axisPinchControlRadius: boolean;
  46369. /**
  46370. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46371. */
  46372. axisPinchControlHeight: boolean;
  46373. /**
  46374. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46375. */
  46376. axisPinchControlRotation: boolean;
  46377. /**
  46378. * Log error messages if basic misconfiguration has occurred.
  46379. */
  46380. warningEnable: boolean;
  46381. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46382. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46383. private _warningCounter;
  46384. private _warning;
  46385. }
  46386. }
  46387. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46388. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46389. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46390. /**
  46391. * Default Inputs manager for the FollowCamera.
  46392. * It groups all the default supported inputs for ease of use.
  46393. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46394. */
  46395. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46396. /**
  46397. * Instantiates a new FollowCameraInputsManager.
  46398. * @param camera Defines the camera the inputs belong to
  46399. */
  46400. constructor(camera: FollowCamera);
  46401. /**
  46402. * Add keyboard input support to the input manager.
  46403. * @returns the current input manager
  46404. */
  46405. addKeyboard(): FollowCameraInputsManager;
  46406. /**
  46407. * Add mouse wheel input support to the input manager.
  46408. * @returns the current input manager
  46409. */
  46410. addMouseWheel(): FollowCameraInputsManager;
  46411. /**
  46412. * Add pointers input support to the input manager.
  46413. * @returns the current input manager
  46414. */
  46415. addPointers(): FollowCameraInputsManager;
  46416. /**
  46417. * Add orientation input support to the input manager.
  46418. * @returns the current input manager
  46419. */
  46420. addVRDeviceOrientation(): FollowCameraInputsManager;
  46421. }
  46422. }
  46423. declare module "babylonjs/Cameras/followCamera" {
  46424. import { Nullable } from "babylonjs/types";
  46425. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46426. import { Scene } from "babylonjs/scene";
  46427. import { Vector3 } from "babylonjs/Maths/math.vector";
  46428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46429. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46430. /**
  46431. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46432. * an arc rotate version arcFollowCamera are available.
  46433. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46434. */
  46435. export class FollowCamera extends TargetCamera {
  46436. /**
  46437. * Distance the follow camera should follow an object at
  46438. */
  46439. radius: number;
  46440. /**
  46441. * Minimum allowed distance of the camera to the axis of rotation
  46442. * (The camera can not get closer).
  46443. * This can help limiting how the Camera is able to move in the scene.
  46444. */
  46445. lowerRadiusLimit: Nullable<number>;
  46446. /**
  46447. * Maximum allowed distance of the camera to the axis of rotation
  46448. * (The camera can not get further).
  46449. * This can help limiting how the Camera is able to move in the scene.
  46450. */
  46451. upperRadiusLimit: Nullable<number>;
  46452. /**
  46453. * Define a rotation offset between the camera and the object it follows
  46454. */
  46455. rotationOffset: number;
  46456. /**
  46457. * Minimum allowed angle to camera position relative to target object.
  46458. * This can help limiting how the Camera is able to move in the scene.
  46459. */
  46460. lowerRotationOffsetLimit: Nullable<number>;
  46461. /**
  46462. * Maximum allowed angle to camera position relative to target object.
  46463. * This can help limiting how the Camera is able to move in the scene.
  46464. */
  46465. upperRotationOffsetLimit: Nullable<number>;
  46466. /**
  46467. * Define a height offset between the camera and the object it follows.
  46468. * It can help following an object from the top (like a car chaing a plane)
  46469. */
  46470. heightOffset: number;
  46471. /**
  46472. * Minimum allowed height of camera position relative to target object.
  46473. * This can help limiting how the Camera is able to move in the scene.
  46474. */
  46475. lowerHeightOffsetLimit: Nullable<number>;
  46476. /**
  46477. * Maximum allowed height of camera position relative to target object.
  46478. * This can help limiting how the Camera is able to move in the scene.
  46479. */
  46480. upperHeightOffsetLimit: Nullable<number>;
  46481. /**
  46482. * Define how fast the camera can accelerate to follow it s target.
  46483. */
  46484. cameraAcceleration: number;
  46485. /**
  46486. * Define the speed limit of the camera following an object.
  46487. */
  46488. maxCameraSpeed: number;
  46489. /**
  46490. * Define the target of the camera.
  46491. */
  46492. lockedTarget: Nullable<AbstractMesh>;
  46493. /**
  46494. * Defines the input associated with the camera.
  46495. */
  46496. inputs: FollowCameraInputsManager;
  46497. /**
  46498. * Instantiates the follow camera.
  46499. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46500. * @param name Define the name of the camera in the scene
  46501. * @param position Define the position of the camera
  46502. * @param scene Define the scene the camera belong to
  46503. * @param lockedTarget Define the target of the camera
  46504. */
  46505. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46506. private _follow;
  46507. /**
  46508. * Attached controls to the current camera.
  46509. * @param element Defines the element the controls should be listened from
  46510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46511. */
  46512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46513. /**
  46514. * Detach the current controls from the camera.
  46515. * The camera will stop reacting to inputs.
  46516. * @param element Defines the element to stop listening the inputs from
  46517. */
  46518. detachControl(element: HTMLElement): void;
  46519. /** @hidden */
  46520. _checkInputs(): void;
  46521. private _checkLimits;
  46522. /**
  46523. * Gets the camera class name.
  46524. * @returns the class name
  46525. */
  46526. getClassName(): string;
  46527. }
  46528. /**
  46529. * Arc Rotate version of the follow camera.
  46530. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46531. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46532. */
  46533. export class ArcFollowCamera extends TargetCamera {
  46534. /** The longitudinal angle of the camera */
  46535. alpha: number;
  46536. /** The latitudinal angle of the camera */
  46537. beta: number;
  46538. /** The radius of the camera from its target */
  46539. radius: number;
  46540. private _cartesianCoordinates;
  46541. /** Define the camera target (the mesh it should follow) */
  46542. private _meshTarget;
  46543. /**
  46544. * Instantiates a new ArcFollowCamera
  46545. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46546. * @param name Define the name of the camera
  46547. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46548. * @param beta Define the rotation angle of the camera around the elevation axis
  46549. * @param radius Define the radius of the camera from its target point
  46550. * @param target Define the target of the camera
  46551. * @param scene Define the scene the camera belongs to
  46552. */
  46553. constructor(name: string,
  46554. /** The longitudinal angle of the camera */
  46555. alpha: number,
  46556. /** The latitudinal angle of the camera */
  46557. beta: number,
  46558. /** The radius of the camera from its target */
  46559. radius: number,
  46560. /** Define the camera target (the mesh it should follow) */
  46561. target: Nullable<AbstractMesh>, scene: Scene);
  46562. private _follow;
  46563. /** @hidden */
  46564. _checkInputs(): void;
  46565. /**
  46566. * Returns the class name of the object.
  46567. * It is mostly used internally for serialization purposes.
  46568. */
  46569. getClassName(): string;
  46570. }
  46571. }
  46572. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46574. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46575. import { Nullable } from "babylonjs/types";
  46576. /**
  46577. * Manage the keyboard inputs to control the movement of a follow camera.
  46578. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46579. */
  46580. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46581. /**
  46582. * Defines the camera the input is attached to.
  46583. */
  46584. camera: FollowCamera;
  46585. /**
  46586. * Defines the list of key codes associated with the up action (increase heightOffset)
  46587. */
  46588. keysHeightOffsetIncr: number[];
  46589. /**
  46590. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46591. */
  46592. keysHeightOffsetDecr: number[];
  46593. /**
  46594. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46595. */
  46596. keysHeightOffsetModifierAlt: boolean;
  46597. /**
  46598. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46599. */
  46600. keysHeightOffsetModifierCtrl: boolean;
  46601. /**
  46602. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46603. */
  46604. keysHeightOffsetModifierShift: boolean;
  46605. /**
  46606. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46607. */
  46608. keysRotationOffsetIncr: number[];
  46609. /**
  46610. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46611. */
  46612. keysRotationOffsetDecr: number[];
  46613. /**
  46614. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46615. */
  46616. keysRotationOffsetModifierAlt: boolean;
  46617. /**
  46618. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46619. */
  46620. keysRotationOffsetModifierCtrl: boolean;
  46621. /**
  46622. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46623. */
  46624. keysRotationOffsetModifierShift: boolean;
  46625. /**
  46626. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46627. */
  46628. keysRadiusIncr: number[];
  46629. /**
  46630. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46631. */
  46632. keysRadiusDecr: number[];
  46633. /**
  46634. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46635. */
  46636. keysRadiusModifierAlt: boolean;
  46637. /**
  46638. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46639. */
  46640. keysRadiusModifierCtrl: boolean;
  46641. /**
  46642. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46643. */
  46644. keysRadiusModifierShift: boolean;
  46645. /**
  46646. * Defines the rate of change of heightOffset.
  46647. */
  46648. heightSensibility: number;
  46649. /**
  46650. * Defines the rate of change of rotationOffset.
  46651. */
  46652. rotationSensibility: number;
  46653. /**
  46654. * Defines the rate of change of radius.
  46655. */
  46656. radiusSensibility: number;
  46657. private _keys;
  46658. private _ctrlPressed;
  46659. private _altPressed;
  46660. private _shiftPressed;
  46661. private _onCanvasBlurObserver;
  46662. private _onKeyboardObserver;
  46663. private _engine;
  46664. private _scene;
  46665. /**
  46666. * Attach the input controls to a specific dom element to get the input from.
  46667. * @param element Defines the element the controls should be listened from
  46668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46669. */
  46670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46671. /**
  46672. * Detach the current controls from the specified dom element.
  46673. * @param element Defines the element to stop listening the inputs from
  46674. */
  46675. detachControl(element: Nullable<HTMLElement>): void;
  46676. /**
  46677. * Update the current camera state depending on the inputs that have been used this frame.
  46678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46679. */
  46680. checkInputs(): void;
  46681. /**
  46682. * Gets the class name of the current input.
  46683. * @returns the class name
  46684. */
  46685. getClassName(): string;
  46686. /**
  46687. * Get the friendly name associated with the input class.
  46688. * @returns the input friendly name
  46689. */
  46690. getSimpleName(): string;
  46691. /**
  46692. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46693. * allow modification of the heightOffset value.
  46694. */
  46695. private _modifierHeightOffset;
  46696. /**
  46697. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46698. * allow modification of the rotationOffset value.
  46699. */
  46700. private _modifierRotationOffset;
  46701. /**
  46702. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46703. * allow modification of the radius value.
  46704. */
  46705. private _modifierRadius;
  46706. }
  46707. }
  46708. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46709. import { Nullable } from "babylonjs/types";
  46710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46711. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46712. import { Observable } from "babylonjs/Misc/observable";
  46713. module "babylonjs/Cameras/freeCameraInputsManager" {
  46714. interface FreeCameraInputsManager {
  46715. /**
  46716. * @hidden
  46717. */
  46718. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46719. /**
  46720. * Add orientation input support to the input manager.
  46721. * @returns the current input manager
  46722. */
  46723. addDeviceOrientation(): FreeCameraInputsManager;
  46724. }
  46725. }
  46726. /**
  46727. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46728. * Screen rotation is taken into account.
  46729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46730. */
  46731. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46732. private _camera;
  46733. private _screenOrientationAngle;
  46734. private _constantTranform;
  46735. private _screenQuaternion;
  46736. private _alpha;
  46737. private _beta;
  46738. private _gamma;
  46739. /**
  46740. * Can be used to detect if a device orientation sensor is available on a device
  46741. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46742. * @returns a promise that will resolve on orientation change
  46743. */
  46744. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46745. /**
  46746. * @hidden
  46747. */
  46748. _onDeviceOrientationChangedObservable: Observable<void>;
  46749. /**
  46750. * Instantiates a new input
  46751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46752. */
  46753. constructor();
  46754. /**
  46755. * Define the camera controlled by the input.
  46756. */
  46757. get camera(): FreeCamera;
  46758. set camera(camera: FreeCamera);
  46759. /**
  46760. * Attach the input controls to a specific dom element to get the input from.
  46761. * @param element Defines the element the controls should be listened from
  46762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46763. */
  46764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46765. private _orientationChanged;
  46766. private _deviceOrientation;
  46767. /**
  46768. * Detach the current controls from the specified dom element.
  46769. * @param element Defines the element to stop listening the inputs from
  46770. */
  46771. detachControl(element: Nullable<HTMLElement>): void;
  46772. /**
  46773. * Update the current camera state depending on the inputs that have been used this frame.
  46774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46775. */
  46776. checkInputs(): void;
  46777. /**
  46778. * Gets the class name of the current intput.
  46779. * @returns the class name
  46780. */
  46781. getClassName(): string;
  46782. /**
  46783. * Get the friendly name associated with the input class.
  46784. * @returns the input friendly name
  46785. */
  46786. getSimpleName(): string;
  46787. }
  46788. }
  46789. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46790. import { Nullable } from "babylonjs/types";
  46791. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46792. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46793. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46794. /**
  46795. * Manage the gamepad inputs to control a free camera.
  46796. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46797. */
  46798. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46799. /**
  46800. * Define the camera the input is attached to.
  46801. */
  46802. camera: FreeCamera;
  46803. /**
  46804. * Define the Gamepad controlling the input
  46805. */
  46806. gamepad: Nullable<Gamepad>;
  46807. /**
  46808. * Defines the gamepad rotation sensiblity.
  46809. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46810. */
  46811. gamepadAngularSensibility: number;
  46812. /**
  46813. * Defines the gamepad move sensiblity.
  46814. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46815. */
  46816. gamepadMoveSensibility: number;
  46817. private _yAxisScale;
  46818. /**
  46819. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46820. */
  46821. get invertYAxis(): boolean;
  46822. set invertYAxis(value: boolean);
  46823. private _onGamepadConnectedObserver;
  46824. private _onGamepadDisconnectedObserver;
  46825. private _cameraTransform;
  46826. private _deltaTransform;
  46827. private _vector3;
  46828. private _vector2;
  46829. /**
  46830. * Attach the input controls to a specific dom element to get the input from.
  46831. * @param element Defines the element the controls should be listened from
  46832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46833. */
  46834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46835. /**
  46836. * Detach the current controls from the specified dom element.
  46837. * @param element Defines the element to stop listening the inputs from
  46838. */
  46839. detachControl(element: Nullable<HTMLElement>): void;
  46840. /**
  46841. * Update the current camera state depending on the inputs that have been used this frame.
  46842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46843. */
  46844. checkInputs(): void;
  46845. /**
  46846. * Gets the class name of the current intput.
  46847. * @returns the class name
  46848. */
  46849. getClassName(): string;
  46850. /**
  46851. * Get the friendly name associated with the input class.
  46852. * @returns the input friendly name
  46853. */
  46854. getSimpleName(): string;
  46855. }
  46856. }
  46857. declare module "babylonjs/Misc/virtualJoystick" {
  46858. import { Nullable } from "babylonjs/types";
  46859. import { Vector3 } from "babylonjs/Maths/math.vector";
  46860. /**
  46861. * Defines the potential axis of a Joystick
  46862. */
  46863. export enum JoystickAxis {
  46864. /** X axis */
  46865. X = 0,
  46866. /** Y axis */
  46867. Y = 1,
  46868. /** Z axis */
  46869. Z = 2
  46870. }
  46871. /**
  46872. * Represents the different customization options available
  46873. * for VirtualJoystick
  46874. */
  46875. interface VirtualJoystickCustomizations {
  46876. /**
  46877. * Size of the joystick's puck
  46878. */
  46879. puckSize: number;
  46880. /**
  46881. * Size of the joystick's container
  46882. */
  46883. containerSize: number;
  46884. /**
  46885. * Color of the joystick && puck
  46886. */
  46887. color: string;
  46888. /**
  46889. * Image URL for the joystick's puck
  46890. */
  46891. puckImage?: string;
  46892. /**
  46893. * Image URL for the joystick's container
  46894. */
  46895. containerImage?: string;
  46896. /**
  46897. * Defines the unmoving position of the joystick container
  46898. */
  46899. position?: {
  46900. x: number;
  46901. y: number;
  46902. };
  46903. /**
  46904. * Defines whether or not the joystick container is always visible
  46905. */
  46906. alwaysVisible: boolean;
  46907. /**
  46908. * Defines whether or not to limit the movement of the puck to the joystick's container
  46909. */
  46910. limitToContainer: boolean;
  46911. }
  46912. /**
  46913. * Class used to define virtual joystick (used in touch mode)
  46914. */
  46915. export class VirtualJoystick {
  46916. /**
  46917. * Gets or sets a boolean indicating that left and right values must be inverted
  46918. */
  46919. reverseLeftRight: boolean;
  46920. /**
  46921. * Gets or sets a boolean indicating that up and down values must be inverted
  46922. */
  46923. reverseUpDown: boolean;
  46924. /**
  46925. * Gets the offset value for the position (ie. the change of the position value)
  46926. */
  46927. deltaPosition: Vector3;
  46928. /**
  46929. * Gets a boolean indicating if the virtual joystick was pressed
  46930. */
  46931. pressed: boolean;
  46932. /**
  46933. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46934. */
  46935. static Canvas: Nullable<HTMLCanvasElement>;
  46936. /**
  46937. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46938. */
  46939. limitToContainer: boolean;
  46940. private static _globalJoystickIndex;
  46941. private static _alwaysVisibleSticks;
  46942. private static vjCanvasContext;
  46943. private static vjCanvasWidth;
  46944. private static vjCanvasHeight;
  46945. private static halfWidth;
  46946. private static _GetDefaultOptions;
  46947. private _action;
  46948. private _axisTargetedByLeftAndRight;
  46949. private _axisTargetedByUpAndDown;
  46950. private _joystickSensibility;
  46951. private _inversedSensibility;
  46952. private _joystickPointerID;
  46953. private _joystickColor;
  46954. private _joystickPointerPos;
  46955. private _joystickPreviousPointerPos;
  46956. private _joystickPointerStartPos;
  46957. private _deltaJoystickVector;
  46958. private _leftJoystick;
  46959. private _touches;
  46960. private _joystickPosition;
  46961. private _alwaysVisible;
  46962. private _puckImage;
  46963. private _containerImage;
  46964. private _joystickPuckSize;
  46965. private _joystickContainerSize;
  46966. private _clearPuckSize;
  46967. private _clearContainerSize;
  46968. private _clearPuckSizeOffset;
  46969. private _clearContainerSizeOffset;
  46970. private _onPointerDownHandlerRef;
  46971. private _onPointerMoveHandlerRef;
  46972. private _onPointerUpHandlerRef;
  46973. private _onResize;
  46974. /**
  46975. * Creates a new virtual joystick
  46976. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46977. * @param customizations Defines the options we want to customize the VirtualJoystick
  46978. */
  46979. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46980. /**
  46981. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46982. * @param newJoystickSensibility defines the new sensibility
  46983. */
  46984. setJoystickSensibility(newJoystickSensibility: number): void;
  46985. private _onPointerDown;
  46986. private _onPointerMove;
  46987. private _onPointerUp;
  46988. /**
  46989. * Change the color of the virtual joystick
  46990. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46991. */
  46992. setJoystickColor(newColor: string): void;
  46993. /**
  46994. * Size of the joystick's container
  46995. */
  46996. set containerSize(newSize: number);
  46997. get containerSize(): number;
  46998. /**
  46999. * Size of the joystick's puck
  47000. */
  47001. set puckSize(newSize: number);
  47002. get puckSize(): number;
  47003. /**
  47004. * Clears the set position of the joystick
  47005. */
  47006. clearPosition(): void;
  47007. /**
  47008. * Defines whether or not the joystick container is always visible
  47009. */
  47010. set alwaysVisible(value: boolean);
  47011. get alwaysVisible(): boolean;
  47012. /**
  47013. * Sets the constant position of the Joystick container
  47014. * @param x X axis coordinate
  47015. * @param y Y axis coordinate
  47016. */
  47017. setPosition(x: number, y: number): void;
  47018. /**
  47019. * Defines a callback to call when the joystick is touched
  47020. * @param action defines the callback
  47021. */
  47022. setActionOnTouch(action: () => any): void;
  47023. /**
  47024. * Defines which axis you'd like to control for left & right
  47025. * @param axis defines the axis to use
  47026. */
  47027. setAxisForLeftRight(axis: JoystickAxis): void;
  47028. /**
  47029. * Defines which axis you'd like to control for up & down
  47030. * @param axis defines the axis to use
  47031. */
  47032. setAxisForUpDown(axis: JoystickAxis): void;
  47033. /**
  47034. * Clears the canvas from the previous puck / container draw
  47035. */
  47036. private _clearPreviousDraw;
  47037. /**
  47038. * Loads `urlPath` to be used for the container's image
  47039. * @param urlPath defines the urlPath of an image to use
  47040. */
  47041. setContainerImage(urlPath: string): void;
  47042. /**
  47043. * Loads `urlPath` to be used for the puck's image
  47044. * @param urlPath defines the urlPath of an image to use
  47045. */
  47046. setPuckImage(urlPath: string): void;
  47047. /**
  47048. * Draws the Virtual Joystick's container
  47049. */
  47050. private _drawContainer;
  47051. /**
  47052. * Draws the Virtual Joystick's puck
  47053. */
  47054. private _drawPuck;
  47055. private _drawVirtualJoystick;
  47056. /**
  47057. * Release internal HTML canvas
  47058. */
  47059. releaseCanvas(): void;
  47060. }
  47061. }
  47062. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  47063. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  47064. import { Nullable } from "babylonjs/types";
  47065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47066. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47067. module "babylonjs/Cameras/freeCameraInputsManager" {
  47068. interface FreeCameraInputsManager {
  47069. /**
  47070. * Add virtual joystick input support to the input manager.
  47071. * @returns the current input manager
  47072. */
  47073. addVirtualJoystick(): FreeCameraInputsManager;
  47074. }
  47075. }
  47076. /**
  47077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  47078. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47079. */
  47080. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  47081. /**
  47082. * Defines the camera the input is attached to.
  47083. */
  47084. camera: FreeCamera;
  47085. private _leftjoystick;
  47086. private _rightjoystick;
  47087. /**
  47088. * Gets the left stick of the virtual joystick.
  47089. * @returns The virtual Joystick
  47090. */
  47091. getLeftJoystick(): VirtualJoystick;
  47092. /**
  47093. * Gets the right stick of the virtual joystick.
  47094. * @returns The virtual Joystick
  47095. */
  47096. getRightJoystick(): VirtualJoystick;
  47097. /**
  47098. * Update the current camera state depending on the inputs that have been used this frame.
  47099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47100. */
  47101. checkInputs(): void;
  47102. /**
  47103. * Attach the input controls to a specific dom element to get the input from.
  47104. * @param element Defines the element the controls should be listened from
  47105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47106. */
  47107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47108. /**
  47109. * Detach the current controls from the specified dom element.
  47110. * @param element Defines the element to stop listening the inputs from
  47111. */
  47112. detachControl(element: Nullable<HTMLElement>): void;
  47113. /**
  47114. * Gets the class name of the current intput.
  47115. * @returns the class name
  47116. */
  47117. getClassName(): string;
  47118. /**
  47119. * Get the friendly name associated with the input class.
  47120. * @returns the input friendly name
  47121. */
  47122. getSimpleName(): string;
  47123. }
  47124. }
  47125. declare module "babylonjs/Cameras/Inputs/index" {
  47126. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47127. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47128. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47129. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47130. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47131. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47132. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47133. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47134. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47135. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47136. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47137. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47138. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47139. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47140. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47141. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47142. }
  47143. declare module "babylonjs/Cameras/touchCamera" {
  47144. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47145. import { Scene } from "babylonjs/scene";
  47146. import { Vector3 } from "babylonjs/Maths/math.vector";
  47147. /**
  47148. * This represents a FPS type of camera controlled by touch.
  47149. * This is like a universal camera minus the Gamepad controls.
  47150. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47151. */
  47152. export class TouchCamera extends FreeCamera {
  47153. /**
  47154. * Defines the touch sensibility for rotation.
  47155. * The higher the faster.
  47156. */
  47157. get touchAngularSensibility(): number;
  47158. set touchAngularSensibility(value: number);
  47159. /**
  47160. * Defines the touch sensibility for move.
  47161. * The higher the faster.
  47162. */
  47163. get touchMoveSensibility(): number;
  47164. set touchMoveSensibility(value: number);
  47165. /**
  47166. * Instantiates a new touch camera.
  47167. * This represents a FPS type of camera controlled by touch.
  47168. * This is like a universal camera minus the Gamepad controls.
  47169. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47170. * @param name Define the name of the camera in the scene
  47171. * @param position Define the start position of the camera in the scene
  47172. * @param scene Define the scene the camera belongs to
  47173. */
  47174. constructor(name: string, position: Vector3, scene: Scene);
  47175. /**
  47176. * Gets the current object class name.
  47177. * @return the class name
  47178. */
  47179. getClassName(): string;
  47180. /** @hidden */
  47181. _setupInputs(): void;
  47182. }
  47183. }
  47184. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47186. import { Scene } from "babylonjs/scene";
  47187. import { Vector3 } from "babylonjs/Maths/math.vector";
  47188. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47189. import { Axis } from "babylonjs/Maths/math.axis";
  47190. /**
  47191. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47192. * being tilted forward or back and left or right.
  47193. */
  47194. export class DeviceOrientationCamera extends FreeCamera {
  47195. private _initialQuaternion;
  47196. private _quaternionCache;
  47197. private _tmpDragQuaternion;
  47198. private _disablePointerInputWhenUsingDeviceOrientation;
  47199. /**
  47200. * Creates a new device orientation camera
  47201. * @param name The name of the camera
  47202. * @param position The start position camera
  47203. * @param scene The scene the camera belongs to
  47204. */
  47205. constructor(name: string, position: Vector3, scene: Scene);
  47206. /**
  47207. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47208. */
  47209. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47210. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47211. private _dragFactor;
  47212. /**
  47213. * Enabled turning on the y axis when the orientation sensor is active
  47214. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47215. */
  47216. enableHorizontalDragging(dragFactor?: number): void;
  47217. /**
  47218. * Gets the current instance class name ("DeviceOrientationCamera").
  47219. * This helps avoiding instanceof at run time.
  47220. * @returns the class name
  47221. */
  47222. getClassName(): string;
  47223. /**
  47224. * @hidden
  47225. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47226. */
  47227. _checkInputs(): void;
  47228. /**
  47229. * Reset the camera to its default orientation on the specified axis only.
  47230. * @param axis The axis to reset
  47231. */
  47232. resetToCurrentRotation(axis?: Axis): void;
  47233. }
  47234. }
  47235. declare module "babylonjs/Gamepads/xboxGamepad" {
  47236. import { Observable } from "babylonjs/Misc/observable";
  47237. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47238. /**
  47239. * Defines supported buttons for XBox360 compatible gamepads
  47240. */
  47241. export enum Xbox360Button {
  47242. /** A */
  47243. A = 0,
  47244. /** B */
  47245. B = 1,
  47246. /** X */
  47247. X = 2,
  47248. /** Y */
  47249. Y = 3,
  47250. /** Left button */
  47251. LB = 4,
  47252. /** Right button */
  47253. RB = 5,
  47254. /** Back */
  47255. Back = 8,
  47256. /** Start */
  47257. Start = 9,
  47258. /** Left stick */
  47259. LeftStick = 10,
  47260. /** Right stick */
  47261. RightStick = 11
  47262. }
  47263. /** Defines values for XBox360 DPad */
  47264. export enum Xbox360Dpad {
  47265. /** Up */
  47266. Up = 12,
  47267. /** Down */
  47268. Down = 13,
  47269. /** Left */
  47270. Left = 14,
  47271. /** Right */
  47272. Right = 15
  47273. }
  47274. /**
  47275. * Defines a XBox360 gamepad
  47276. */
  47277. export class Xbox360Pad extends Gamepad {
  47278. private _leftTrigger;
  47279. private _rightTrigger;
  47280. private _onlefttriggerchanged;
  47281. private _onrighttriggerchanged;
  47282. private _onbuttondown;
  47283. private _onbuttonup;
  47284. private _ondpaddown;
  47285. private _ondpadup;
  47286. /** Observable raised when a button is pressed */
  47287. onButtonDownObservable: Observable<Xbox360Button>;
  47288. /** Observable raised when a button is released */
  47289. onButtonUpObservable: Observable<Xbox360Button>;
  47290. /** Observable raised when a pad is pressed */
  47291. onPadDownObservable: Observable<Xbox360Dpad>;
  47292. /** Observable raised when a pad is released */
  47293. onPadUpObservable: Observable<Xbox360Dpad>;
  47294. private _buttonA;
  47295. private _buttonB;
  47296. private _buttonX;
  47297. private _buttonY;
  47298. private _buttonBack;
  47299. private _buttonStart;
  47300. private _buttonLB;
  47301. private _buttonRB;
  47302. private _buttonLeftStick;
  47303. private _buttonRightStick;
  47304. private _dPadUp;
  47305. private _dPadDown;
  47306. private _dPadLeft;
  47307. private _dPadRight;
  47308. private _isXboxOnePad;
  47309. /**
  47310. * Creates a new XBox360 gamepad object
  47311. * @param id defines the id of this gamepad
  47312. * @param index defines its index
  47313. * @param gamepad defines the internal HTML gamepad object
  47314. * @param xboxOne defines if it is a XBox One gamepad
  47315. */
  47316. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47317. /**
  47318. * Defines the callback to call when left trigger is pressed
  47319. * @param callback defines the callback to use
  47320. */
  47321. onlefttriggerchanged(callback: (value: number) => void): void;
  47322. /**
  47323. * Defines the callback to call when right trigger is pressed
  47324. * @param callback defines the callback to use
  47325. */
  47326. onrighttriggerchanged(callback: (value: number) => void): void;
  47327. /**
  47328. * Gets the left trigger value
  47329. */
  47330. get leftTrigger(): number;
  47331. /**
  47332. * Sets the left trigger value
  47333. */
  47334. set leftTrigger(newValue: number);
  47335. /**
  47336. * Gets the right trigger value
  47337. */
  47338. get rightTrigger(): number;
  47339. /**
  47340. * Sets the right trigger value
  47341. */
  47342. set rightTrigger(newValue: number);
  47343. /**
  47344. * Defines the callback to call when a button is pressed
  47345. * @param callback defines the callback to use
  47346. */
  47347. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47348. /**
  47349. * Defines the callback to call when a button is released
  47350. * @param callback defines the callback to use
  47351. */
  47352. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47353. /**
  47354. * Defines the callback to call when a pad is pressed
  47355. * @param callback defines the callback to use
  47356. */
  47357. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47358. /**
  47359. * Defines the callback to call when a pad is released
  47360. * @param callback defines the callback to use
  47361. */
  47362. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47363. private _setButtonValue;
  47364. private _setDPadValue;
  47365. /**
  47366. * Gets the value of the `A` button
  47367. */
  47368. get buttonA(): number;
  47369. /**
  47370. * Sets the value of the `A` button
  47371. */
  47372. set buttonA(value: number);
  47373. /**
  47374. * Gets the value of the `B` button
  47375. */
  47376. get buttonB(): number;
  47377. /**
  47378. * Sets the value of the `B` button
  47379. */
  47380. set buttonB(value: number);
  47381. /**
  47382. * Gets the value of the `X` button
  47383. */
  47384. get buttonX(): number;
  47385. /**
  47386. * Sets the value of the `X` button
  47387. */
  47388. set buttonX(value: number);
  47389. /**
  47390. * Gets the value of the `Y` button
  47391. */
  47392. get buttonY(): number;
  47393. /**
  47394. * Sets the value of the `Y` button
  47395. */
  47396. set buttonY(value: number);
  47397. /**
  47398. * Gets the value of the `Start` button
  47399. */
  47400. get buttonStart(): number;
  47401. /**
  47402. * Sets the value of the `Start` button
  47403. */
  47404. set buttonStart(value: number);
  47405. /**
  47406. * Gets the value of the `Back` button
  47407. */
  47408. get buttonBack(): number;
  47409. /**
  47410. * Sets the value of the `Back` button
  47411. */
  47412. set buttonBack(value: number);
  47413. /**
  47414. * Gets the value of the `Left` button
  47415. */
  47416. get buttonLB(): number;
  47417. /**
  47418. * Sets the value of the `Left` button
  47419. */
  47420. set buttonLB(value: number);
  47421. /**
  47422. * Gets the value of the `Right` button
  47423. */
  47424. get buttonRB(): number;
  47425. /**
  47426. * Sets the value of the `Right` button
  47427. */
  47428. set buttonRB(value: number);
  47429. /**
  47430. * Gets the value of the Left joystick
  47431. */
  47432. get buttonLeftStick(): number;
  47433. /**
  47434. * Sets the value of the Left joystick
  47435. */
  47436. set buttonLeftStick(value: number);
  47437. /**
  47438. * Gets the value of the Right joystick
  47439. */
  47440. get buttonRightStick(): number;
  47441. /**
  47442. * Sets the value of the Right joystick
  47443. */
  47444. set buttonRightStick(value: number);
  47445. /**
  47446. * Gets the value of D-pad up
  47447. */
  47448. get dPadUp(): number;
  47449. /**
  47450. * Sets the value of D-pad up
  47451. */
  47452. set dPadUp(value: number);
  47453. /**
  47454. * Gets the value of D-pad down
  47455. */
  47456. get dPadDown(): number;
  47457. /**
  47458. * Sets the value of D-pad down
  47459. */
  47460. set dPadDown(value: number);
  47461. /**
  47462. * Gets the value of D-pad left
  47463. */
  47464. get dPadLeft(): number;
  47465. /**
  47466. * Sets the value of D-pad left
  47467. */
  47468. set dPadLeft(value: number);
  47469. /**
  47470. * Gets the value of D-pad right
  47471. */
  47472. get dPadRight(): number;
  47473. /**
  47474. * Sets the value of D-pad right
  47475. */
  47476. set dPadRight(value: number);
  47477. /**
  47478. * Force the gamepad to synchronize with device values
  47479. */
  47480. update(): void;
  47481. /**
  47482. * Disposes the gamepad
  47483. */
  47484. dispose(): void;
  47485. }
  47486. }
  47487. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47488. import { Observable } from "babylonjs/Misc/observable";
  47489. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47490. /**
  47491. * Defines supported buttons for DualShock compatible gamepads
  47492. */
  47493. export enum DualShockButton {
  47494. /** Cross */
  47495. Cross = 0,
  47496. /** Circle */
  47497. Circle = 1,
  47498. /** Square */
  47499. Square = 2,
  47500. /** Triangle */
  47501. Triangle = 3,
  47502. /** L1 */
  47503. L1 = 4,
  47504. /** R1 */
  47505. R1 = 5,
  47506. /** Share */
  47507. Share = 8,
  47508. /** Options */
  47509. Options = 9,
  47510. /** Left stick */
  47511. LeftStick = 10,
  47512. /** Right stick */
  47513. RightStick = 11
  47514. }
  47515. /** Defines values for DualShock DPad */
  47516. export enum DualShockDpad {
  47517. /** Up */
  47518. Up = 12,
  47519. /** Down */
  47520. Down = 13,
  47521. /** Left */
  47522. Left = 14,
  47523. /** Right */
  47524. Right = 15
  47525. }
  47526. /**
  47527. * Defines a DualShock gamepad
  47528. */
  47529. export class DualShockPad extends Gamepad {
  47530. private _leftTrigger;
  47531. private _rightTrigger;
  47532. private _onlefttriggerchanged;
  47533. private _onrighttriggerchanged;
  47534. private _onbuttondown;
  47535. private _onbuttonup;
  47536. private _ondpaddown;
  47537. private _ondpadup;
  47538. /** Observable raised when a button is pressed */
  47539. onButtonDownObservable: Observable<DualShockButton>;
  47540. /** Observable raised when a button is released */
  47541. onButtonUpObservable: Observable<DualShockButton>;
  47542. /** Observable raised when a pad is pressed */
  47543. onPadDownObservable: Observable<DualShockDpad>;
  47544. /** Observable raised when a pad is released */
  47545. onPadUpObservable: Observable<DualShockDpad>;
  47546. private _buttonCross;
  47547. private _buttonCircle;
  47548. private _buttonSquare;
  47549. private _buttonTriangle;
  47550. private _buttonShare;
  47551. private _buttonOptions;
  47552. private _buttonL1;
  47553. private _buttonR1;
  47554. private _buttonLeftStick;
  47555. private _buttonRightStick;
  47556. private _dPadUp;
  47557. private _dPadDown;
  47558. private _dPadLeft;
  47559. private _dPadRight;
  47560. /**
  47561. * Creates a new DualShock gamepad object
  47562. * @param id defines the id of this gamepad
  47563. * @param index defines its index
  47564. * @param gamepad defines the internal HTML gamepad object
  47565. */
  47566. constructor(id: string, index: number, gamepad: any);
  47567. /**
  47568. * Defines the callback to call when left trigger is pressed
  47569. * @param callback defines the callback to use
  47570. */
  47571. onlefttriggerchanged(callback: (value: number) => void): void;
  47572. /**
  47573. * Defines the callback to call when right trigger is pressed
  47574. * @param callback defines the callback to use
  47575. */
  47576. onrighttriggerchanged(callback: (value: number) => void): void;
  47577. /**
  47578. * Gets the left trigger value
  47579. */
  47580. get leftTrigger(): number;
  47581. /**
  47582. * Sets the left trigger value
  47583. */
  47584. set leftTrigger(newValue: number);
  47585. /**
  47586. * Gets the right trigger value
  47587. */
  47588. get rightTrigger(): number;
  47589. /**
  47590. * Sets the right trigger value
  47591. */
  47592. set rightTrigger(newValue: number);
  47593. /**
  47594. * Defines the callback to call when a button is pressed
  47595. * @param callback defines the callback to use
  47596. */
  47597. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47598. /**
  47599. * Defines the callback to call when a button is released
  47600. * @param callback defines the callback to use
  47601. */
  47602. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47603. /**
  47604. * Defines the callback to call when a pad is pressed
  47605. * @param callback defines the callback to use
  47606. */
  47607. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47608. /**
  47609. * Defines the callback to call when a pad is released
  47610. * @param callback defines the callback to use
  47611. */
  47612. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47613. private _setButtonValue;
  47614. private _setDPadValue;
  47615. /**
  47616. * Gets the value of the `Cross` button
  47617. */
  47618. get buttonCross(): number;
  47619. /**
  47620. * Sets the value of the `Cross` button
  47621. */
  47622. set buttonCross(value: number);
  47623. /**
  47624. * Gets the value of the `Circle` button
  47625. */
  47626. get buttonCircle(): number;
  47627. /**
  47628. * Sets the value of the `Circle` button
  47629. */
  47630. set buttonCircle(value: number);
  47631. /**
  47632. * Gets the value of the `Square` button
  47633. */
  47634. get buttonSquare(): number;
  47635. /**
  47636. * Sets the value of the `Square` button
  47637. */
  47638. set buttonSquare(value: number);
  47639. /**
  47640. * Gets the value of the `Triangle` button
  47641. */
  47642. get buttonTriangle(): number;
  47643. /**
  47644. * Sets the value of the `Triangle` button
  47645. */
  47646. set buttonTriangle(value: number);
  47647. /**
  47648. * Gets the value of the `Options` button
  47649. */
  47650. get buttonOptions(): number;
  47651. /**
  47652. * Sets the value of the `Options` button
  47653. */
  47654. set buttonOptions(value: number);
  47655. /**
  47656. * Gets the value of the `Share` button
  47657. */
  47658. get buttonShare(): number;
  47659. /**
  47660. * Sets the value of the `Share` button
  47661. */
  47662. set buttonShare(value: number);
  47663. /**
  47664. * Gets the value of the `L1` button
  47665. */
  47666. get buttonL1(): number;
  47667. /**
  47668. * Sets the value of the `L1` button
  47669. */
  47670. set buttonL1(value: number);
  47671. /**
  47672. * Gets the value of the `R1` button
  47673. */
  47674. get buttonR1(): number;
  47675. /**
  47676. * Sets the value of the `R1` button
  47677. */
  47678. set buttonR1(value: number);
  47679. /**
  47680. * Gets the value of the Left joystick
  47681. */
  47682. get buttonLeftStick(): number;
  47683. /**
  47684. * Sets the value of the Left joystick
  47685. */
  47686. set buttonLeftStick(value: number);
  47687. /**
  47688. * Gets the value of the Right joystick
  47689. */
  47690. get buttonRightStick(): number;
  47691. /**
  47692. * Sets the value of the Right joystick
  47693. */
  47694. set buttonRightStick(value: number);
  47695. /**
  47696. * Gets the value of D-pad up
  47697. */
  47698. get dPadUp(): number;
  47699. /**
  47700. * Sets the value of D-pad up
  47701. */
  47702. set dPadUp(value: number);
  47703. /**
  47704. * Gets the value of D-pad down
  47705. */
  47706. get dPadDown(): number;
  47707. /**
  47708. * Sets the value of D-pad down
  47709. */
  47710. set dPadDown(value: number);
  47711. /**
  47712. * Gets the value of D-pad left
  47713. */
  47714. get dPadLeft(): number;
  47715. /**
  47716. * Sets the value of D-pad left
  47717. */
  47718. set dPadLeft(value: number);
  47719. /**
  47720. * Gets the value of D-pad right
  47721. */
  47722. get dPadRight(): number;
  47723. /**
  47724. * Sets the value of D-pad right
  47725. */
  47726. set dPadRight(value: number);
  47727. /**
  47728. * Force the gamepad to synchronize with device values
  47729. */
  47730. update(): void;
  47731. /**
  47732. * Disposes the gamepad
  47733. */
  47734. dispose(): void;
  47735. }
  47736. }
  47737. declare module "babylonjs/Gamepads/gamepadManager" {
  47738. import { Observable } from "babylonjs/Misc/observable";
  47739. import { Nullable } from "babylonjs/types";
  47740. import { Scene } from "babylonjs/scene";
  47741. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47742. /**
  47743. * Manager for handling gamepads
  47744. */
  47745. export class GamepadManager {
  47746. private _scene?;
  47747. private _babylonGamepads;
  47748. private _oneGamepadConnected;
  47749. /** @hidden */
  47750. _isMonitoring: boolean;
  47751. private _gamepadEventSupported;
  47752. private _gamepadSupport?;
  47753. /**
  47754. * observable to be triggered when the gamepad controller has been connected
  47755. */
  47756. onGamepadConnectedObservable: Observable<Gamepad>;
  47757. /**
  47758. * observable to be triggered when the gamepad controller has been disconnected
  47759. */
  47760. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47761. private _onGamepadConnectedEvent;
  47762. private _onGamepadDisconnectedEvent;
  47763. /**
  47764. * Initializes the gamepad manager
  47765. * @param _scene BabylonJS scene
  47766. */
  47767. constructor(_scene?: Scene | undefined);
  47768. /**
  47769. * The gamepads in the game pad manager
  47770. */
  47771. get gamepads(): Gamepad[];
  47772. /**
  47773. * Get the gamepad controllers based on type
  47774. * @param type The type of gamepad controller
  47775. * @returns Nullable gamepad
  47776. */
  47777. getGamepadByType(type?: number): Nullable<Gamepad>;
  47778. /**
  47779. * Disposes the gamepad manager
  47780. */
  47781. dispose(): void;
  47782. private _addNewGamepad;
  47783. private _startMonitoringGamepads;
  47784. private _stopMonitoringGamepads;
  47785. /** @hidden */
  47786. _checkGamepadsStatus(): void;
  47787. private _updateGamepadObjects;
  47788. }
  47789. }
  47790. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47791. import { Nullable } from "babylonjs/types";
  47792. import { Scene } from "babylonjs/scene";
  47793. import { ISceneComponent } from "babylonjs/sceneComponent";
  47794. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47795. module "babylonjs/scene" {
  47796. interface Scene {
  47797. /** @hidden */
  47798. _gamepadManager: Nullable<GamepadManager>;
  47799. /**
  47800. * Gets the gamepad manager associated with the scene
  47801. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47802. */
  47803. gamepadManager: GamepadManager;
  47804. }
  47805. }
  47806. module "babylonjs/Cameras/freeCameraInputsManager" {
  47807. /**
  47808. * Interface representing a free camera inputs manager
  47809. */
  47810. interface FreeCameraInputsManager {
  47811. /**
  47812. * Adds gamepad input support to the FreeCameraInputsManager.
  47813. * @returns the FreeCameraInputsManager
  47814. */
  47815. addGamepad(): FreeCameraInputsManager;
  47816. }
  47817. }
  47818. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47819. /**
  47820. * Interface representing an arc rotate camera inputs manager
  47821. */
  47822. interface ArcRotateCameraInputsManager {
  47823. /**
  47824. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47825. * @returns the camera inputs manager
  47826. */
  47827. addGamepad(): ArcRotateCameraInputsManager;
  47828. }
  47829. }
  47830. /**
  47831. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47832. */
  47833. export class GamepadSystemSceneComponent implements ISceneComponent {
  47834. /**
  47835. * The component name helpfull to identify the component in the list of scene components.
  47836. */
  47837. readonly name: string;
  47838. /**
  47839. * The scene the component belongs to.
  47840. */
  47841. scene: Scene;
  47842. /**
  47843. * Creates a new instance of the component for the given scene
  47844. * @param scene Defines the scene to register the component in
  47845. */
  47846. constructor(scene: Scene);
  47847. /**
  47848. * Registers the component in a given scene
  47849. */
  47850. register(): void;
  47851. /**
  47852. * Rebuilds the elements related to this component in case of
  47853. * context lost for instance.
  47854. */
  47855. rebuild(): void;
  47856. /**
  47857. * Disposes the component and the associated ressources
  47858. */
  47859. dispose(): void;
  47860. private _beforeCameraUpdate;
  47861. }
  47862. }
  47863. declare module "babylonjs/Cameras/universalCamera" {
  47864. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47865. import { Scene } from "babylonjs/scene";
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import "babylonjs/Gamepads/gamepadSceneComponent";
  47868. /**
  47869. * 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,
  47870. * which still works and will still be found in many Playgrounds.
  47871. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47872. */
  47873. export class UniversalCamera extends TouchCamera {
  47874. /**
  47875. * Defines the gamepad rotation sensiblity.
  47876. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47877. */
  47878. get gamepadAngularSensibility(): number;
  47879. set gamepadAngularSensibility(value: number);
  47880. /**
  47881. * Defines the gamepad move sensiblity.
  47882. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47883. */
  47884. get gamepadMoveSensibility(): number;
  47885. set gamepadMoveSensibility(value: number);
  47886. /**
  47887. * 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,
  47888. * which still works and will still be found in many Playgrounds.
  47889. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47890. * @param name Define the name of the camera in the scene
  47891. * @param position Define the start position of the camera in the scene
  47892. * @param scene Define the scene the camera belongs to
  47893. */
  47894. constructor(name: string, position: Vector3, scene: Scene);
  47895. /**
  47896. * Gets the current object class name.
  47897. * @return the class name
  47898. */
  47899. getClassName(): string;
  47900. }
  47901. }
  47902. declare module "babylonjs/Cameras/gamepadCamera" {
  47903. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47904. import { Scene } from "babylonjs/scene";
  47905. import { Vector3 } from "babylonjs/Maths/math.vector";
  47906. /**
  47907. * This represents a FPS type of camera. This is only here for back compat purpose.
  47908. * Please use the UniversalCamera instead as both are identical.
  47909. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47910. */
  47911. export class GamepadCamera extends UniversalCamera {
  47912. /**
  47913. * Instantiates a new Gamepad Camera
  47914. * This represents a FPS type of camera. This is only here for back compat purpose.
  47915. * Please use the UniversalCamera instead as both are identical.
  47916. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47917. * @param name Define the name of the camera in the scene
  47918. * @param position Define the start position of the camera in the scene
  47919. * @param scene Define the scene the camera belongs to
  47920. */
  47921. constructor(name: string, position: Vector3, scene: Scene);
  47922. /**
  47923. * Gets the current object class name.
  47924. * @return the class name
  47925. */
  47926. getClassName(): string;
  47927. }
  47928. }
  47929. declare module "babylonjs/Shaders/pass.fragment" {
  47930. /** @hidden */
  47931. export var passPixelShader: {
  47932. name: string;
  47933. shader: string;
  47934. };
  47935. }
  47936. declare module "babylonjs/Shaders/passCube.fragment" {
  47937. /** @hidden */
  47938. export var passCubePixelShader: {
  47939. name: string;
  47940. shader: string;
  47941. };
  47942. }
  47943. declare module "babylonjs/PostProcesses/passPostProcess" {
  47944. import { Nullable } from "babylonjs/types";
  47945. import { Camera } from "babylonjs/Cameras/camera";
  47946. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47947. import { Engine } from "babylonjs/Engines/engine";
  47948. import "babylonjs/Shaders/pass.fragment";
  47949. import "babylonjs/Shaders/passCube.fragment";
  47950. import { Scene } from "babylonjs/scene";
  47951. /**
  47952. * PassPostProcess which produces an output the same as it's input
  47953. */
  47954. export class PassPostProcess extends PostProcess {
  47955. /**
  47956. * Gets a string identifying the name of the class
  47957. * @returns "PassPostProcess" string
  47958. */
  47959. getClassName(): string;
  47960. /**
  47961. * Creates the PassPostProcess
  47962. * @param name The name of the effect.
  47963. * @param options The required width/height ratio to downsize to before computing the render pass.
  47964. * @param camera The camera to apply the render pass to.
  47965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47966. * @param engine The engine which the post process will be applied. (default: current engine)
  47967. * @param reusable If the post process can be reused on the same frame. (default: false)
  47968. * @param textureType The type of texture to be used when performing the post processing.
  47969. * @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)
  47970. */
  47971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47972. /** @hidden */
  47973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47974. }
  47975. /**
  47976. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47977. */
  47978. export class PassCubePostProcess extends PostProcess {
  47979. private _face;
  47980. /**
  47981. * Gets or sets the cube face to display.
  47982. * * 0 is +X
  47983. * * 1 is -X
  47984. * * 2 is +Y
  47985. * * 3 is -Y
  47986. * * 4 is +Z
  47987. * * 5 is -Z
  47988. */
  47989. get face(): number;
  47990. set face(value: number);
  47991. /**
  47992. * Gets a string identifying the name of the class
  47993. * @returns "PassCubePostProcess" string
  47994. */
  47995. getClassName(): string;
  47996. /**
  47997. * Creates the PassCubePostProcess
  47998. * @param name The name of the effect.
  47999. * @param options The required width/height ratio to downsize to before computing the render pass.
  48000. * @param camera The camera to apply the render pass to.
  48001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48002. * @param engine The engine which the post process will be applied. (default: current engine)
  48003. * @param reusable If the post process can be reused on the same frame. (default: false)
  48004. * @param textureType The type of texture to be used when performing the post processing.
  48005. * @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)
  48006. */
  48007. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48008. /** @hidden */
  48009. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  48010. }
  48011. }
  48012. declare module "babylonjs/Shaders/anaglyph.fragment" {
  48013. /** @hidden */
  48014. export var anaglyphPixelShader: {
  48015. name: string;
  48016. shader: string;
  48017. };
  48018. }
  48019. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  48020. import { Engine } from "babylonjs/Engines/engine";
  48021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  48022. import { Camera } from "babylonjs/Cameras/camera";
  48023. import "babylonjs/Shaders/anaglyph.fragment";
  48024. /**
  48025. * Postprocess used to generate anaglyphic rendering
  48026. */
  48027. export class AnaglyphPostProcess extends PostProcess {
  48028. private _passedProcess;
  48029. /**
  48030. * Gets a string identifying the name of the class
  48031. * @returns "AnaglyphPostProcess" string
  48032. */
  48033. getClassName(): string;
  48034. /**
  48035. * Creates a new AnaglyphPostProcess
  48036. * @param name defines postprocess name
  48037. * @param options defines creation options or target ratio scale
  48038. * @param rigCameras defines cameras using this postprocess
  48039. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  48040. * @param engine defines hosting engine
  48041. * @param reusable defines if the postprocess will be reused multiple times per frame
  48042. */
  48043. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  48044. }
  48045. }
  48046. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  48047. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  48048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48049. import { Scene } from "babylonjs/scene";
  48050. import { Vector3 } from "babylonjs/Maths/math.vector";
  48051. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48052. /**
  48053. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  48054. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48055. */
  48056. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  48057. /**
  48058. * Creates a new AnaglyphArcRotateCamera
  48059. * @param name defines camera name
  48060. * @param alpha defines alpha angle (in radians)
  48061. * @param beta defines beta angle (in radians)
  48062. * @param radius defines radius
  48063. * @param target defines camera target
  48064. * @param interaxialDistance defines distance between each color axis
  48065. * @param scene defines the hosting scene
  48066. */
  48067. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  48068. /**
  48069. * Gets camera class name
  48070. * @returns AnaglyphArcRotateCamera
  48071. */
  48072. getClassName(): string;
  48073. }
  48074. }
  48075. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  48076. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48077. import { Scene } from "babylonjs/scene";
  48078. import { Vector3 } from "babylonjs/Maths/math.vector";
  48079. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48080. /**
  48081. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  48082. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48083. */
  48084. export class AnaglyphFreeCamera extends FreeCamera {
  48085. /**
  48086. * Creates a new AnaglyphFreeCamera
  48087. * @param name defines camera name
  48088. * @param position defines initial position
  48089. * @param interaxialDistance defines distance between each color axis
  48090. * @param scene defines the hosting scene
  48091. */
  48092. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48093. /**
  48094. * Gets camera class name
  48095. * @returns AnaglyphFreeCamera
  48096. */
  48097. getClassName(): string;
  48098. }
  48099. }
  48100. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  48101. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48102. import { Scene } from "babylonjs/scene";
  48103. import { Vector3 } from "babylonjs/Maths/math.vector";
  48104. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48105. /**
  48106. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  48107. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48108. */
  48109. export class AnaglyphGamepadCamera extends GamepadCamera {
  48110. /**
  48111. * Creates a new AnaglyphGamepadCamera
  48112. * @param name defines camera name
  48113. * @param position defines initial position
  48114. * @param interaxialDistance defines distance between each color axis
  48115. * @param scene defines the hosting scene
  48116. */
  48117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48118. /**
  48119. * Gets camera class name
  48120. * @returns AnaglyphGamepadCamera
  48121. */
  48122. getClassName(): string;
  48123. }
  48124. }
  48125. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48126. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48127. import { Scene } from "babylonjs/scene";
  48128. import { Vector3 } from "babylonjs/Maths/math.vector";
  48129. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48130. /**
  48131. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48132. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48133. */
  48134. export class AnaglyphUniversalCamera extends UniversalCamera {
  48135. /**
  48136. * Creates a new AnaglyphUniversalCamera
  48137. * @param name defines camera name
  48138. * @param position defines initial position
  48139. * @param interaxialDistance defines distance between each color axis
  48140. * @param scene defines the hosting scene
  48141. */
  48142. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48143. /**
  48144. * Gets camera class name
  48145. * @returns AnaglyphUniversalCamera
  48146. */
  48147. getClassName(): string;
  48148. }
  48149. }
  48150. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48151. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48152. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48153. import { Scene } from "babylonjs/scene";
  48154. import { Vector3 } from "babylonjs/Maths/math.vector";
  48155. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48156. /**
  48157. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48158. * @see https://doc.babylonjs.com/features/cameras
  48159. */
  48160. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48161. /**
  48162. * Creates a new StereoscopicArcRotateCamera
  48163. * @param name defines camera name
  48164. * @param alpha defines alpha angle (in radians)
  48165. * @param beta defines beta angle (in radians)
  48166. * @param radius defines radius
  48167. * @param target defines camera target
  48168. * @param interaxialDistance defines distance between each color axis
  48169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48170. * @param scene defines the hosting scene
  48171. */
  48172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48173. /**
  48174. * Gets camera class name
  48175. * @returns StereoscopicArcRotateCamera
  48176. */
  48177. getClassName(): string;
  48178. }
  48179. }
  48180. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48182. import { Scene } from "babylonjs/scene";
  48183. import { Vector3 } from "babylonjs/Maths/math.vector";
  48184. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48185. /**
  48186. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48187. * @see https://doc.babylonjs.com/features/cameras
  48188. */
  48189. export class StereoscopicFreeCamera extends FreeCamera {
  48190. /**
  48191. * Creates a new StereoscopicFreeCamera
  48192. * @param name defines camera name
  48193. * @param position defines initial position
  48194. * @param interaxialDistance defines distance between each color axis
  48195. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48196. * @param scene defines the hosting scene
  48197. */
  48198. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48199. /**
  48200. * Gets camera class name
  48201. * @returns StereoscopicFreeCamera
  48202. */
  48203. getClassName(): string;
  48204. }
  48205. }
  48206. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48207. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48208. import { Scene } from "babylonjs/scene";
  48209. import { Vector3 } from "babylonjs/Maths/math.vector";
  48210. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48211. /**
  48212. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48213. * @see https://doc.babylonjs.com/features/cameras
  48214. */
  48215. export class StereoscopicGamepadCamera extends GamepadCamera {
  48216. /**
  48217. * Creates a new StereoscopicGamepadCamera
  48218. * @param name defines camera name
  48219. * @param position defines initial position
  48220. * @param interaxialDistance defines distance between each color axis
  48221. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48222. * @param scene defines the hosting scene
  48223. */
  48224. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48225. /**
  48226. * Gets camera class name
  48227. * @returns StereoscopicGamepadCamera
  48228. */
  48229. getClassName(): string;
  48230. }
  48231. }
  48232. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48233. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48234. import { Scene } from "babylonjs/scene";
  48235. import { Vector3 } from "babylonjs/Maths/math.vector";
  48236. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48237. /**
  48238. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48239. * @see https://doc.babylonjs.com/features/cameras
  48240. */
  48241. export class StereoscopicUniversalCamera extends UniversalCamera {
  48242. /**
  48243. * Creates a new StereoscopicUniversalCamera
  48244. * @param name defines camera name
  48245. * @param position defines initial position
  48246. * @param interaxialDistance defines distance between each color axis
  48247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48248. * @param scene defines the hosting scene
  48249. */
  48250. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48251. /**
  48252. * Gets camera class name
  48253. * @returns StereoscopicUniversalCamera
  48254. */
  48255. getClassName(): string;
  48256. }
  48257. }
  48258. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48259. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48260. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48261. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48262. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48263. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48264. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48265. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48266. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48267. }
  48268. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48270. import { Scene } from "babylonjs/scene";
  48271. import { Vector3 } from "babylonjs/Maths/math.vector";
  48272. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48273. /**
  48274. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48275. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48276. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48277. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48278. */
  48279. export class VirtualJoysticksCamera extends FreeCamera {
  48280. /**
  48281. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48282. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48283. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48284. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48285. * @param name Define the name of the camera in the scene
  48286. * @param position Define the start position of the camera in the scene
  48287. * @param scene Define the scene the camera belongs to
  48288. */
  48289. constructor(name: string, position: Vector3, scene: Scene);
  48290. /**
  48291. * Gets the current object class name.
  48292. * @return the class name
  48293. */
  48294. getClassName(): string;
  48295. }
  48296. }
  48297. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48298. import { Matrix } from "babylonjs/Maths/math.vector";
  48299. /**
  48300. * This represents all the required metrics to create a VR camera.
  48301. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48302. */
  48303. export class VRCameraMetrics {
  48304. /**
  48305. * Define the horizontal resolution off the screen.
  48306. */
  48307. hResolution: number;
  48308. /**
  48309. * Define the vertical resolution off the screen.
  48310. */
  48311. vResolution: number;
  48312. /**
  48313. * Define the horizontal screen size.
  48314. */
  48315. hScreenSize: number;
  48316. /**
  48317. * Define the vertical screen size.
  48318. */
  48319. vScreenSize: number;
  48320. /**
  48321. * Define the vertical screen center position.
  48322. */
  48323. vScreenCenter: number;
  48324. /**
  48325. * Define the distance of the eyes to the screen.
  48326. */
  48327. eyeToScreenDistance: number;
  48328. /**
  48329. * Define the distance between both lenses
  48330. */
  48331. lensSeparationDistance: number;
  48332. /**
  48333. * Define the distance between both viewer's eyes.
  48334. */
  48335. interpupillaryDistance: number;
  48336. /**
  48337. * Define the distortion factor of the VR postprocess.
  48338. * Please, touch with care.
  48339. */
  48340. distortionK: number[];
  48341. /**
  48342. * Define the chromatic aberration correction factors for the VR post process.
  48343. */
  48344. chromaAbCorrection: number[];
  48345. /**
  48346. * Define the scale factor of the post process.
  48347. * The smaller the better but the slower.
  48348. */
  48349. postProcessScaleFactor: number;
  48350. /**
  48351. * Define an offset for the lens center.
  48352. */
  48353. lensCenterOffset: number;
  48354. /**
  48355. * Define if the current vr camera should compensate the distortion of the lense or not.
  48356. */
  48357. compensateDistortion: boolean;
  48358. /**
  48359. * Defines if multiview should be enabled when rendering (Default: false)
  48360. */
  48361. multiviewEnabled: boolean;
  48362. /**
  48363. * Gets the rendering aspect ratio based on the provided resolutions.
  48364. */
  48365. get aspectRatio(): number;
  48366. /**
  48367. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48368. */
  48369. get aspectRatioFov(): number;
  48370. /**
  48371. * @hidden
  48372. */
  48373. get leftHMatrix(): Matrix;
  48374. /**
  48375. * @hidden
  48376. */
  48377. get rightHMatrix(): Matrix;
  48378. /**
  48379. * @hidden
  48380. */
  48381. get leftPreViewMatrix(): Matrix;
  48382. /**
  48383. * @hidden
  48384. */
  48385. get rightPreViewMatrix(): Matrix;
  48386. /**
  48387. * Get the default VRMetrics based on the most generic setup.
  48388. * @returns the default vr metrics
  48389. */
  48390. static GetDefault(): VRCameraMetrics;
  48391. }
  48392. }
  48393. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48394. /** @hidden */
  48395. export var vrDistortionCorrectionPixelShader: {
  48396. name: string;
  48397. shader: string;
  48398. };
  48399. }
  48400. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48401. import { Camera } from "babylonjs/Cameras/camera";
  48402. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48404. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48405. /**
  48406. * VRDistortionCorrectionPostProcess used for mobile VR
  48407. */
  48408. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48409. private _isRightEye;
  48410. private _distortionFactors;
  48411. private _postProcessScaleFactor;
  48412. private _lensCenterOffset;
  48413. private _scaleIn;
  48414. private _scaleFactor;
  48415. private _lensCenter;
  48416. /**
  48417. * Gets a string identifying the name of the class
  48418. * @returns "VRDistortionCorrectionPostProcess" string
  48419. */
  48420. getClassName(): string;
  48421. /**
  48422. * Initializes the VRDistortionCorrectionPostProcess
  48423. * @param name The name of the effect.
  48424. * @param camera The camera to apply the render pass to.
  48425. * @param isRightEye If this is for the right eye distortion
  48426. * @param vrMetrics All the required metrics for the VR camera
  48427. */
  48428. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48429. }
  48430. }
  48431. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48432. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48433. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48434. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48435. import { Scene } from "babylonjs/scene";
  48436. import { Vector3 } from "babylonjs/Maths/math.vector";
  48437. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48438. import "babylonjs/Cameras/RigModes/vrRigMode";
  48439. /**
  48440. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48441. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48442. */
  48443. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48444. /**
  48445. * Creates a new VRDeviceOrientationArcRotateCamera
  48446. * @param name defines camera name
  48447. * @param alpha defines the camera rotation along the logitudinal axis
  48448. * @param beta defines the camera rotation along the latitudinal axis
  48449. * @param radius defines the camera distance from its target
  48450. * @param target defines the camera target
  48451. * @param scene defines the scene the camera belongs to
  48452. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48453. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48454. */
  48455. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48456. /**
  48457. * Gets camera class name
  48458. * @returns VRDeviceOrientationArcRotateCamera
  48459. */
  48460. getClassName(): string;
  48461. }
  48462. }
  48463. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48464. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48466. import { Scene } from "babylonjs/scene";
  48467. import { Vector3 } from "babylonjs/Maths/math.vector";
  48468. import "babylonjs/Cameras/RigModes/vrRigMode";
  48469. /**
  48470. * Camera used to simulate VR rendering (based on FreeCamera)
  48471. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48472. */
  48473. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48474. /**
  48475. * Creates a new VRDeviceOrientationFreeCamera
  48476. * @param name defines camera name
  48477. * @param position defines the start position of the camera
  48478. * @param scene defines the scene the camera belongs to
  48479. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48480. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48481. */
  48482. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48483. /**
  48484. * Gets camera class name
  48485. * @returns VRDeviceOrientationFreeCamera
  48486. */
  48487. getClassName(): string;
  48488. }
  48489. }
  48490. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48491. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48492. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48493. import { Scene } from "babylonjs/scene";
  48494. import { Vector3 } from "babylonjs/Maths/math.vector";
  48495. import "babylonjs/Gamepads/gamepadSceneComponent";
  48496. /**
  48497. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48498. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48499. */
  48500. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48501. /**
  48502. * Creates a new VRDeviceOrientationGamepadCamera
  48503. * @param name defines camera name
  48504. * @param position defines the start position of the camera
  48505. * @param scene defines the scene the camera belongs to
  48506. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48507. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48508. */
  48509. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48510. /**
  48511. * Gets camera class name
  48512. * @returns VRDeviceOrientationGamepadCamera
  48513. */
  48514. getClassName(): string;
  48515. }
  48516. }
  48517. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48518. import { Scene } from "babylonjs/scene";
  48519. import { Texture } from "babylonjs/Materials/Textures/texture";
  48520. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48521. /**
  48522. * A class extending Texture allowing drawing on a texture
  48523. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48524. */
  48525. export class DynamicTexture extends Texture {
  48526. private _generateMipMaps;
  48527. private _canvas;
  48528. private _context;
  48529. /**
  48530. * Creates a DynamicTexture
  48531. * @param name defines the name of the texture
  48532. * @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
  48533. * @param scene defines the scene where you want the texture
  48534. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48535. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48536. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48537. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  48538. */
  48539. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  48540. /**
  48541. * Get the current class name of the texture useful for serialization or dynamic coding.
  48542. * @returns "DynamicTexture"
  48543. */
  48544. getClassName(): string;
  48545. /**
  48546. * Gets the current state of canRescale
  48547. */
  48548. get canRescale(): boolean;
  48549. private _recreate;
  48550. /**
  48551. * Scales the texture
  48552. * @param ratio the scale factor to apply to both width and height
  48553. */
  48554. scale(ratio: number): void;
  48555. /**
  48556. * Resizes the texture
  48557. * @param width the new width
  48558. * @param height the new height
  48559. */
  48560. scaleTo(width: number, height: number): void;
  48561. /**
  48562. * Gets the context of the canvas used by the texture
  48563. * @returns the canvas context of the dynamic texture
  48564. */
  48565. getContext(): CanvasRenderingContext2D;
  48566. /**
  48567. * Clears the texture
  48568. */
  48569. clear(): void;
  48570. /**
  48571. * Updates the texture
  48572. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48573. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48574. */
  48575. update(invertY?: boolean, premulAlpha?: boolean): void;
  48576. /**
  48577. * Draws text onto the texture
  48578. * @param text defines the text to be drawn
  48579. * @param x defines the placement of the text from the left
  48580. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48581. * @param font defines the font to be used with font-style, font-size, font-name
  48582. * @param color defines the color used for the text
  48583. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48584. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48585. * @param update defines whether texture is immediately update (default is true)
  48586. */
  48587. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48588. /**
  48589. * Clones the texture
  48590. * @returns the clone of the texture.
  48591. */
  48592. clone(): DynamicTexture;
  48593. /**
  48594. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48595. * @returns a serialized dynamic texture object
  48596. */
  48597. serialize(): any;
  48598. private _IsCanvasElement;
  48599. /** @hidden */
  48600. _rebuild(): void;
  48601. }
  48602. }
  48603. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48604. import { Scene } from "babylonjs/scene";
  48605. import { Color3 } from "babylonjs/Maths/math.color";
  48606. import { Mesh } from "babylonjs/Meshes/mesh";
  48607. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48608. import { Nullable } from "babylonjs/types";
  48609. /**
  48610. * Class containing static functions to help procedurally build meshes
  48611. */
  48612. export class GroundBuilder {
  48613. /**
  48614. * Creates a ground mesh
  48615. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48616. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48618. * @param name defines the name of the mesh
  48619. * @param options defines the options used to create the mesh
  48620. * @param scene defines the hosting scene
  48621. * @returns the ground mesh
  48622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48623. */
  48624. static CreateGround(name: string, options: {
  48625. width?: number;
  48626. height?: number;
  48627. subdivisions?: number;
  48628. subdivisionsX?: number;
  48629. subdivisionsY?: number;
  48630. updatable?: boolean;
  48631. }, scene: any): Mesh;
  48632. /**
  48633. * Creates a tiled ground mesh
  48634. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48635. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48636. * * 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
  48637. * * 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
  48638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48639. * @param name defines the name of the mesh
  48640. * @param options defines the options used to create the mesh
  48641. * @param scene defines the hosting scene
  48642. * @returns the tiled ground mesh
  48643. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48644. */
  48645. static CreateTiledGround(name: string, options: {
  48646. xmin: number;
  48647. zmin: number;
  48648. xmax: number;
  48649. zmax: number;
  48650. subdivisions?: {
  48651. w: number;
  48652. h: number;
  48653. };
  48654. precision?: {
  48655. w: number;
  48656. h: number;
  48657. };
  48658. updatable?: boolean;
  48659. }, scene?: Nullable<Scene>): Mesh;
  48660. /**
  48661. * Creates a ground mesh from a height map
  48662. * * The parameter `url` sets the URL of the height map image resource.
  48663. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48664. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48665. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48666. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48667. * * 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.
  48668. * * 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).
  48669. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48671. * @param name defines the name of the mesh
  48672. * @param url defines the url to the height map
  48673. * @param options defines the options used to create the mesh
  48674. * @param scene defines the hosting scene
  48675. * @returns the ground mesh
  48676. * @see https://doc.babylonjs.com/babylon101/height_map
  48677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48678. */
  48679. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48680. width?: number;
  48681. height?: number;
  48682. subdivisions?: number;
  48683. minHeight?: number;
  48684. maxHeight?: number;
  48685. colorFilter?: Color3;
  48686. alphaFilter?: number;
  48687. updatable?: boolean;
  48688. onReady?: (mesh: GroundMesh) => void;
  48689. }, scene?: Nullable<Scene>): GroundMesh;
  48690. }
  48691. }
  48692. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48693. import { Vector4 } from "babylonjs/Maths/math.vector";
  48694. import { Mesh } from "babylonjs/Meshes/mesh";
  48695. /**
  48696. * Class containing static functions to help procedurally build meshes
  48697. */
  48698. export class TorusBuilder {
  48699. /**
  48700. * Creates a torus mesh
  48701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48707. * @param name defines the name of the mesh
  48708. * @param options defines the options used to create the mesh
  48709. * @param scene defines the hosting scene
  48710. * @returns the torus mesh
  48711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48712. */
  48713. static CreateTorus(name: string, options: {
  48714. diameter?: number;
  48715. thickness?: number;
  48716. tessellation?: number;
  48717. updatable?: boolean;
  48718. sideOrientation?: number;
  48719. frontUVs?: Vector4;
  48720. backUVs?: Vector4;
  48721. }, scene: any): Mesh;
  48722. }
  48723. }
  48724. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48725. import { Vector4 } from "babylonjs/Maths/math.vector";
  48726. import { Color4 } from "babylonjs/Maths/math.color";
  48727. import { Mesh } from "babylonjs/Meshes/mesh";
  48728. /**
  48729. * Class containing static functions to help procedurally build meshes
  48730. */
  48731. export class CylinderBuilder {
  48732. /**
  48733. * Creates a cylinder or a cone mesh
  48734. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48735. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48736. * * 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.
  48737. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48738. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48739. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48740. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48741. * * 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).
  48742. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48743. * * 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).
  48744. * * 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
  48745. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48746. * * 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
  48747. * * 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.
  48748. * * If `enclose` is false, a ring surface is one element.
  48749. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48750. * * 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
  48751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48754. * @param name defines the name of the mesh
  48755. * @param options defines the options used to create the mesh
  48756. * @param scene defines the hosting scene
  48757. * @returns the cylinder mesh
  48758. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48759. */
  48760. static CreateCylinder(name: string, options: {
  48761. height?: number;
  48762. diameterTop?: number;
  48763. diameterBottom?: number;
  48764. diameter?: number;
  48765. tessellation?: number;
  48766. subdivisions?: number;
  48767. arc?: number;
  48768. faceColors?: Color4[];
  48769. faceUV?: Vector4[];
  48770. updatable?: boolean;
  48771. hasRings?: boolean;
  48772. enclose?: boolean;
  48773. cap?: number;
  48774. sideOrientation?: number;
  48775. frontUVs?: Vector4;
  48776. backUVs?: Vector4;
  48777. }, scene: any): Mesh;
  48778. }
  48779. }
  48780. declare module "babylonjs/XR/webXRTypes" {
  48781. import { Nullable } from "babylonjs/types";
  48782. import { IDisposable } from "babylonjs/scene";
  48783. /**
  48784. * States of the webXR experience
  48785. */
  48786. export enum WebXRState {
  48787. /**
  48788. * Transitioning to being in XR mode
  48789. */
  48790. ENTERING_XR = 0,
  48791. /**
  48792. * Transitioning to non XR mode
  48793. */
  48794. EXITING_XR = 1,
  48795. /**
  48796. * In XR mode and presenting
  48797. */
  48798. IN_XR = 2,
  48799. /**
  48800. * Not entered XR mode
  48801. */
  48802. NOT_IN_XR = 3
  48803. }
  48804. /**
  48805. * Abstraction of the XR render target
  48806. */
  48807. export interface WebXRRenderTarget extends IDisposable {
  48808. /**
  48809. * xrpresent context of the canvas which can be used to display/mirror xr content
  48810. */
  48811. canvasContext: WebGLRenderingContext;
  48812. /**
  48813. * xr layer for the canvas
  48814. */
  48815. xrLayer: Nullable<XRWebGLLayer>;
  48816. /**
  48817. * Initializes the xr layer for the session
  48818. * @param xrSession xr session
  48819. * @returns a promise that will resolve once the XR Layer has been created
  48820. */
  48821. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48822. }
  48823. }
  48824. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48825. import { Nullable } from "babylonjs/types";
  48826. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48827. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48828. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48829. import { Observable } from "babylonjs/Misc/observable";
  48830. /**
  48831. * COnfiguration object for WebXR output canvas
  48832. */
  48833. export class WebXRManagedOutputCanvasOptions {
  48834. /**
  48835. * An optional canvas in case you wish to create it yourself and provide it here.
  48836. * If not provided, a new canvas will be created
  48837. */
  48838. canvasElement?: HTMLCanvasElement;
  48839. /**
  48840. * Options for this XR Layer output
  48841. */
  48842. canvasOptions?: XRWebGLLayerOptions;
  48843. /**
  48844. * CSS styling for a newly created canvas (if not provided)
  48845. */
  48846. newCanvasCssStyle?: string;
  48847. /**
  48848. * Get the default values of the configuration object
  48849. * @param engine defines the engine to use (can be null)
  48850. * @returns default values of this configuration object
  48851. */
  48852. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48853. }
  48854. /**
  48855. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48856. */
  48857. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48858. private _options;
  48859. private _canvas;
  48860. private _engine;
  48861. private _originalCanvasSize;
  48862. /**
  48863. * Rendering context of the canvas which can be used to display/mirror xr content
  48864. */
  48865. canvasContext: WebGLRenderingContext;
  48866. /**
  48867. * xr layer for the canvas
  48868. */
  48869. xrLayer: Nullable<XRWebGLLayer>;
  48870. /**
  48871. * Obseervers registered here will be triggered when the xr layer was initialized
  48872. */
  48873. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48874. /**
  48875. * Initializes the canvas to be added/removed upon entering/exiting xr
  48876. * @param _xrSessionManager The XR Session manager
  48877. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48878. */
  48879. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48880. /**
  48881. * Disposes of the object
  48882. */
  48883. dispose(): void;
  48884. /**
  48885. * Initializes the xr layer for the session
  48886. * @param xrSession xr session
  48887. * @returns a promise that will resolve once the XR Layer has been created
  48888. */
  48889. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48890. private _addCanvas;
  48891. private _removeCanvas;
  48892. private _setCanvasSize;
  48893. private _setManagedOutputCanvas;
  48894. }
  48895. }
  48896. declare module "babylonjs/XR/webXRSessionManager" {
  48897. import { Observable } from "babylonjs/Misc/observable";
  48898. import { Nullable } from "babylonjs/types";
  48899. import { IDisposable, Scene } from "babylonjs/scene";
  48900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48901. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48902. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48903. /**
  48904. * Manages an XRSession to work with Babylon's engine
  48905. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48906. */
  48907. export class WebXRSessionManager implements IDisposable {
  48908. /** The scene which the session should be created for */
  48909. scene: Scene;
  48910. private _referenceSpace;
  48911. private _rttProvider;
  48912. private _sessionEnded;
  48913. private _xrNavigator;
  48914. private baseLayer;
  48915. /**
  48916. * The base reference space from which the session started. good if you want to reset your
  48917. * reference space
  48918. */
  48919. baseReferenceSpace: XRReferenceSpace;
  48920. /**
  48921. * Current XR frame
  48922. */
  48923. currentFrame: Nullable<XRFrame>;
  48924. /** WebXR timestamp updated every frame */
  48925. currentTimestamp: number;
  48926. /**
  48927. * Used just in case of a failure to initialize an immersive session.
  48928. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48929. */
  48930. defaultHeightCompensation: number;
  48931. /**
  48932. * Fires every time a new xrFrame arrives which can be used to update the camera
  48933. */
  48934. onXRFrameObservable: Observable<XRFrame>;
  48935. /**
  48936. * Fires when the reference space changed
  48937. */
  48938. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48939. /**
  48940. * Fires when the xr session is ended either by the device or manually done
  48941. */
  48942. onXRSessionEnded: Observable<any>;
  48943. /**
  48944. * Fires when the xr session is ended either by the device or manually done
  48945. */
  48946. onXRSessionInit: Observable<XRSession>;
  48947. /**
  48948. * Underlying xr session
  48949. */
  48950. session: XRSession;
  48951. /**
  48952. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48953. * or get the offset the player is currently at.
  48954. */
  48955. viewerReferenceSpace: XRReferenceSpace;
  48956. /**
  48957. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48958. * @param scene The scene which the session should be created for
  48959. */
  48960. constructor(
  48961. /** The scene which the session should be created for */
  48962. scene: Scene);
  48963. /**
  48964. * The current reference space used in this session. This reference space can constantly change!
  48965. * It is mainly used to offset the camera's position.
  48966. */
  48967. get referenceSpace(): XRReferenceSpace;
  48968. /**
  48969. * Set a new reference space and triggers the observable
  48970. */
  48971. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48972. /**
  48973. * Disposes of the session manager
  48974. */
  48975. dispose(): void;
  48976. /**
  48977. * Stops the xrSession and restores the render loop
  48978. * @returns Promise which resolves after it exits XR
  48979. */
  48980. exitXRAsync(): Promise<void>;
  48981. /**
  48982. * Gets the correct render target texture to be rendered this frame for this eye
  48983. * @param eye the eye for which to get the render target
  48984. * @returns the render target for the specified eye
  48985. */
  48986. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48987. /**
  48988. * Creates a WebXRRenderTarget object for the XR session
  48989. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48990. * @param options optional options to provide when creating a new render target
  48991. * @returns a WebXR render target to which the session can render
  48992. */
  48993. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48994. /**
  48995. * Initializes the manager
  48996. * After initialization enterXR can be called to start an XR session
  48997. * @returns Promise which resolves after it is initialized
  48998. */
  48999. initializeAsync(): Promise<void>;
  49000. /**
  49001. * Initializes an xr session
  49002. * @param xrSessionMode mode to initialize
  49003. * @param xrSessionInit defines optional and required values to pass to the session builder
  49004. * @returns a promise which will resolve once the session has been initialized
  49005. */
  49006. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  49007. /**
  49008. * Checks if a session would be supported for the creation options specified
  49009. * @param sessionMode session mode to check if supported eg. immersive-vr
  49010. * @returns A Promise that resolves to true if supported and false if not
  49011. */
  49012. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49013. /**
  49014. * Resets the reference space to the one started the session
  49015. */
  49016. resetReferenceSpace(): void;
  49017. /**
  49018. * Starts rendering to the xr layer
  49019. */
  49020. runXRRenderLoop(): void;
  49021. /**
  49022. * Sets the reference space on the xr session
  49023. * @param referenceSpaceType space to set
  49024. * @returns a promise that will resolve once the reference space has been set
  49025. */
  49026. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  49027. /**
  49028. * Updates the render state of the session
  49029. * @param state state to set
  49030. * @returns a promise that resolves once the render state has been updated
  49031. */
  49032. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  49033. /**
  49034. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  49035. * @param sessionMode defines the session to test
  49036. * @returns a promise with boolean as final value
  49037. */
  49038. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49039. private _createRenderTargetTexture;
  49040. }
  49041. }
  49042. declare module "babylonjs/XR/webXRCamera" {
  49043. import { Vector3 } from "babylonjs/Maths/math.vector";
  49044. import { Scene } from "babylonjs/scene";
  49045. import { Camera } from "babylonjs/Cameras/camera";
  49046. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49047. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49048. import { Observable } from "babylonjs/Misc/observable";
  49049. /**
  49050. * WebXR Camera which holds the views for the xrSession
  49051. * @see https://doc.babylonjs.com/how_to/webxr_camera
  49052. */
  49053. export class WebXRCamera extends FreeCamera {
  49054. private _xrSessionManager;
  49055. private _firstFrame;
  49056. private _referenceQuaternion;
  49057. private _referencedPosition;
  49058. private _xrInvPositionCache;
  49059. private _xrInvQuaternionCache;
  49060. /**
  49061. * Observable raised before camera teleportation
  49062. */
  49063. onBeforeCameraTeleport: Observable<Vector3>;
  49064. /**
  49065. * Observable raised after camera teleportation
  49066. */
  49067. onAfterCameraTeleport: Observable<Vector3>;
  49068. /**
  49069. * Should position compensation execute on first frame.
  49070. * This is used when copying the position from a native (non XR) camera
  49071. */
  49072. compensateOnFirstFrame: boolean;
  49073. /**
  49074. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  49075. * @param name the name of the camera
  49076. * @param scene the scene to add the camera to
  49077. * @param _xrSessionManager a constructed xr session manager
  49078. */
  49079. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  49080. /**
  49081. * Return the user's height, unrelated to the current ground.
  49082. * This will be the y position of this camera, when ground level is 0.
  49083. */
  49084. get realWorldHeight(): number;
  49085. /** @hidden */
  49086. _updateForDualEyeDebugging(): void;
  49087. /**
  49088. * Sets this camera's transformation based on a non-vr camera
  49089. * @param otherCamera the non-vr camera to copy the transformation from
  49090. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  49091. */
  49092. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  49093. /**
  49094. * Gets the current instance class name ("WebXRCamera").
  49095. * @returns the class name
  49096. */
  49097. getClassName(): string;
  49098. private _rotate180;
  49099. private _updateFromXRSession;
  49100. private _updateNumberOfRigCameras;
  49101. private _updateReferenceSpace;
  49102. private _updateReferenceSpaceOffset;
  49103. }
  49104. }
  49105. declare module "babylonjs/XR/webXRFeaturesManager" {
  49106. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49107. import { IDisposable } from "babylonjs/scene";
  49108. /**
  49109. * Defining the interface required for a (webxr) feature
  49110. */
  49111. export interface IWebXRFeature extends IDisposable {
  49112. /**
  49113. * Is this feature attached
  49114. */
  49115. attached: boolean;
  49116. /**
  49117. * Should auto-attach be disabled?
  49118. */
  49119. disableAutoAttach: boolean;
  49120. /**
  49121. * Attach the feature to the session
  49122. * Will usually be called by the features manager
  49123. *
  49124. * @param force should attachment be forced (even when already attached)
  49125. * @returns true if successful.
  49126. */
  49127. attach(force?: boolean): boolean;
  49128. /**
  49129. * Detach the feature from the session
  49130. * Will usually be called by the features manager
  49131. *
  49132. * @returns true if successful.
  49133. */
  49134. detach(): boolean;
  49135. /**
  49136. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49137. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49138. *
  49139. * @returns whether or not the feature is compatible in this environment
  49140. */
  49141. isCompatible(): boolean;
  49142. /**
  49143. * Was this feature disposed;
  49144. */
  49145. isDisposed: boolean;
  49146. /**
  49147. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49148. */
  49149. xrNativeFeatureName?: string;
  49150. /**
  49151. * A list of (Babylon WebXR) features this feature depends on
  49152. */
  49153. dependsOn?: string[];
  49154. }
  49155. /**
  49156. * A list of the currently available features without referencing them
  49157. */
  49158. export class WebXRFeatureName {
  49159. /**
  49160. * The name of the anchor system feature
  49161. */
  49162. static readonly ANCHOR_SYSTEM: string;
  49163. /**
  49164. * The name of the background remover feature
  49165. */
  49166. static readonly BACKGROUND_REMOVER: string;
  49167. /**
  49168. * The name of the hit test feature
  49169. */
  49170. static readonly HIT_TEST: string;
  49171. /**
  49172. * physics impostors for xr controllers feature
  49173. */
  49174. static readonly PHYSICS_CONTROLLERS: string;
  49175. /**
  49176. * The name of the plane detection feature
  49177. */
  49178. static readonly PLANE_DETECTION: string;
  49179. /**
  49180. * The name of the pointer selection feature
  49181. */
  49182. static readonly POINTER_SELECTION: string;
  49183. /**
  49184. * The name of the teleportation feature
  49185. */
  49186. static readonly TELEPORTATION: string;
  49187. /**
  49188. * The name of the feature points feature.
  49189. */
  49190. static readonly FEATURE_POINTS: string;
  49191. /**
  49192. * The name of the hand tracking feature.
  49193. */
  49194. static readonly HAND_TRACKING: string;
  49195. }
  49196. /**
  49197. * Defining the constructor of a feature. Used to register the modules.
  49198. */
  49199. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49200. /**
  49201. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49202. * It is mainly used in AR sessions.
  49203. *
  49204. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49205. */
  49206. export class WebXRFeaturesManager implements IDisposable {
  49207. private _xrSessionManager;
  49208. private static readonly _AvailableFeatures;
  49209. private _features;
  49210. /**
  49211. * constructs a new features manages.
  49212. *
  49213. * @param _xrSessionManager an instance of WebXRSessionManager
  49214. */
  49215. constructor(_xrSessionManager: WebXRSessionManager);
  49216. /**
  49217. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49218. * Mainly used internally.
  49219. *
  49220. * @param featureName the name of the feature to register
  49221. * @param constructorFunction the function used to construct the module
  49222. * @param version the (babylon) version of the module
  49223. * @param stable is that a stable version of this module
  49224. */
  49225. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49226. /**
  49227. * Returns a constructor of a specific feature.
  49228. *
  49229. * @param featureName the name of the feature to construct
  49230. * @param version the version of the feature to load
  49231. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49232. * @param options optional options provided to the module.
  49233. * @returns a function that, when called, will return a new instance of this feature
  49234. */
  49235. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49236. /**
  49237. * Can be used to return the list of features currently registered
  49238. *
  49239. * @returns an Array of available features
  49240. */
  49241. static GetAvailableFeatures(): string[];
  49242. /**
  49243. * Gets the versions available for a specific feature
  49244. * @param featureName the name of the feature
  49245. * @returns an array with the available versions
  49246. */
  49247. static GetAvailableVersions(featureName: string): string[];
  49248. /**
  49249. * Return the latest unstable version of this feature
  49250. * @param featureName the name of the feature to search
  49251. * @returns the version number. if not found will return -1
  49252. */
  49253. static GetLatestVersionOfFeature(featureName: string): number;
  49254. /**
  49255. * Return the latest stable version of this feature
  49256. * @param featureName the name of the feature to search
  49257. * @returns the version number. if not found will return -1
  49258. */
  49259. static GetStableVersionOfFeature(featureName: string): number;
  49260. /**
  49261. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49262. * Can be used during a session to start a feature
  49263. * @param featureName the name of feature to attach
  49264. */
  49265. attachFeature(featureName: string): void;
  49266. /**
  49267. * Can be used inside a session or when the session ends to detach a specific feature
  49268. * @param featureName the name of the feature to detach
  49269. */
  49270. detachFeature(featureName: string): void;
  49271. /**
  49272. * Used to disable an already-enabled feature
  49273. * The feature will be disposed and will be recreated once enabled.
  49274. * @param featureName the feature to disable
  49275. * @returns true if disable was successful
  49276. */
  49277. disableFeature(featureName: string | {
  49278. Name: string;
  49279. }): boolean;
  49280. /**
  49281. * dispose this features manager
  49282. */
  49283. dispose(): void;
  49284. /**
  49285. * 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.
  49286. * 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.
  49287. *
  49288. * @param featureName the name of the feature to load or the class of the feature
  49289. * @param version optional version to load. if not provided the latest version will be enabled
  49290. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49291. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49292. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49293. * @returns a new constructed feature or throws an error if feature not found.
  49294. */
  49295. enableFeature(featureName: string | {
  49296. Name: string;
  49297. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49298. /**
  49299. * get the implementation of an enabled feature.
  49300. * @param featureName the name of the feature to load
  49301. * @returns the feature class, if found
  49302. */
  49303. getEnabledFeature(featureName: string): IWebXRFeature;
  49304. /**
  49305. * Get the list of enabled features
  49306. * @returns an array of enabled features
  49307. */
  49308. getEnabledFeatures(): string[];
  49309. /**
  49310. * This function will exten the session creation configuration object with enabled features.
  49311. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49312. * according to the defined "required" variable, provided during enableFeature call
  49313. * @param xrSessionInit the xr Session init object to extend
  49314. *
  49315. * @returns an extended XRSessionInit object
  49316. */
  49317. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49318. }
  49319. }
  49320. declare module "babylonjs/XR/webXRExperienceHelper" {
  49321. import { Observable } from "babylonjs/Misc/observable";
  49322. import { IDisposable, Scene } from "babylonjs/scene";
  49323. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49324. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49325. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49326. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49327. /**
  49328. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49329. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49330. */
  49331. export class WebXRExperienceHelper implements IDisposable {
  49332. private scene;
  49333. private _nonVRCamera;
  49334. private _originalSceneAutoClear;
  49335. private _supported;
  49336. /**
  49337. * Camera used to render xr content
  49338. */
  49339. camera: WebXRCamera;
  49340. /** A features manager for this xr session */
  49341. featuresManager: WebXRFeaturesManager;
  49342. /**
  49343. * Observers registered here will be triggered after the camera's initial transformation is set
  49344. * This can be used to set a different ground level or an extra rotation.
  49345. *
  49346. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49347. * to the position set after this observable is done executing.
  49348. */
  49349. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49350. /**
  49351. * Fires when the state of the experience helper has changed
  49352. */
  49353. onStateChangedObservable: Observable<WebXRState>;
  49354. /** Session manager used to keep track of xr session */
  49355. sessionManager: WebXRSessionManager;
  49356. /**
  49357. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49358. */
  49359. state: WebXRState;
  49360. /**
  49361. * Creates a WebXRExperienceHelper
  49362. * @param scene The scene the helper should be created in
  49363. */
  49364. private constructor();
  49365. /**
  49366. * Creates the experience helper
  49367. * @param scene the scene to attach the experience helper to
  49368. * @returns a promise for the experience helper
  49369. */
  49370. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49371. /**
  49372. * Disposes of the experience helper
  49373. */
  49374. dispose(): void;
  49375. /**
  49376. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49377. * @param sessionMode options for the XR session
  49378. * @param referenceSpaceType frame of reference of the XR session
  49379. * @param renderTarget the output canvas that will be used to enter XR mode
  49380. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49381. * @returns promise that resolves after xr mode has entered
  49382. */
  49383. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49384. /**
  49385. * Exits XR mode and returns the scene to its original state
  49386. * @returns promise that resolves after xr mode has exited
  49387. */
  49388. exitXRAsync(): Promise<void>;
  49389. private _nonXRToXRCamera;
  49390. private _setState;
  49391. }
  49392. }
  49393. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49394. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49395. import { Observable } from "babylonjs/Misc/observable";
  49396. import { IDisposable } from "babylonjs/scene";
  49397. /**
  49398. * X-Y values for axes in WebXR
  49399. */
  49400. export interface IWebXRMotionControllerAxesValue {
  49401. /**
  49402. * The value of the x axis
  49403. */
  49404. x: number;
  49405. /**
  49406. * The value of the y-axis
  49407. */
  49408. y: number;
  49409. }
  49410. /**
  49411. * changed / previous values for the values of this component
  49412. */
  49413. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49414. /**
  49415. * current (this frame) value
  49416. */
  49417. current: T;
  49418. /**
  49419. * previous (last change) value
  49420. */
  49421. previous: T;
  49422. }
  49423. /**
  49424. * Represents changes in the component between current frame and last values recorded
  49425. */
  49426. export interface IWebXRMotionControllerComponentChanges {
  49427. /**
  49428. * will be populated with previous and current values if axes changed
  49429. */
  49430. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49431. /**
  49432. * will be populated with previous and current values if pressed changed
  49433. */
  49434. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49435. /**
  49436. * will be populated with previous and current values if touched changed
  49437. */
  49438. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49439. /**
  49440. * will be populated with previous and current values if value changed
  49441. */
  49442. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49443. }
  49444. /**
  49445. * This class represents a single component (for example button or thumbstick) of a motion controller
  49446. */
  49447. export class WebXRControllerComponent implements IDisposable {
  49448. /**
  49449. * the id of this component
  49450. */
  49451. id: string;
  49452. /**
  49453. * the type of the component
  49454. */
  49455. type: MotionControllerComponentType;
  49456. private _buttonIndex;
  49457. private _axesIndices;
  49458. private _axes;
  49459. private _changes;
  49460. private _currentValue;
  49461. private _hasChanges;
  49462. private _pressed;
  49463. private _touched;
  49464. /**
  49465. * button component type
  49466. */
  49467. static BUTTON_TYPE: MotionControllerComponentType;
  49468. /**
  49469. * squeeze component type
  49470. */
  49471. static SQUEEZE_TYPE: MotionControllerComponentType;
  49472. /**
  49473. * Thumbstick component type
  49474. */
  49475. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49476. /**
  49477. * Touchpad component type
  49478. */
  49479. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49480. /**
  49481. * trigger component type
  49482. */
  49483. static TRIGGER_TYPE: MotionControllerComponentType;
  49484. /**
  49485. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49486. * the axes data changes
  49487. */
  49488. onAxisValueChangedObservable: Observable<{
  49489. x: number;
  49490. y: number;
  49491. }>;
  49492. /**
  49493. * Observers registered here will be triggered when the state of a button changes
  49494. * State change is either pressed / touched / value
  49495. */
  49496. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49497. /**
  49498. * Creates a new component for a motion controller.
  49499. * It is created by the motion controller itself
  49500. *
  49501. * @param id the id of this component
  49502. * @param type the type of the component
  49503. * @param _buttonIndex index in the buttons array of the gamepad
  49504. * @param _axesIndices indices of the values in the axes array of the gamepad
  49505. */
  49506. constructor(
  49507. /**
  49508. * the id of this component
  49509. */
  49510. id: string,
  49511. /**
  49512. * the type of the component
  49513. */
  49514. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49515. /**
  49516. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49517. */
  49518. get axes(): IWebXRMotionControllerAxesValue;
  49519. /**
  49520. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49521. */
  49522. get changes(): IWebXRMotionControllerComponentChanges;
  49523. /**
  49524. * Return whether or not the component changed the last frame
  49525. */
  49526. get hasChanges(): boolean;
  49527. /**
  49528. * is the button currently pressed
  49529. */
  49530. get pressed(): boolean;
  49531. /**
  49532. * is the button currently touched
  49533. */
  49534. get touched(): boolean;
  49535. /**
  49536. * Get the current value of this component
  49537. */
  49538. get value(): number;
  49539. /**
  49540. * Dispose this component
  49541. */
  49542. dispose(): void;
  49543. /**
  49544. * Are there axes correlating to this component
  49545. * @return true is axes data is available
  49546. */
  49547. isAxes(): boolean;
  49548. /**
  49549. * Is this component a button (hence - pressable)
  49550. * @returns true if can be pressed
  49551. */
  49552. isButton(): boolean;
  49553. /**
  49554. * update this component using the gamepad object it is in. Called on every frame
  49555. * @param nativeController the native gamepad controller object
  49556. */
  49557. update(nativeController: IMinimalMotionControllerObject): void;
  49558. }
  49559. }
  49560. declare module "babylonjs/Loading/sceneLoader" {
  49561. import { Observable } from "babylonjs/Misc/observable";
  49562. import { Nullable } from "babylonjs/types";
  49563. import { Scene } from "babylonjs/scene";
  49564. import { Engine } from "babylonjs/Engines/engine";
  49565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49566. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49567. import { AssetContainer } from "babylonjs/assetContainer";
  49568. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49569. import { Skeleton } from "babylonjs/Bones/skeleton";
  49570. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49571. import { WebRequest } from "babylonjs/Misc/webRequest";
  49572. /**
  49573. * Interface used to represent data loading progression
  49574. */
  49575. export interface ISceneLoaderProgressEvent {
  49576. /**
  49577. * Defines if data length to load can be evaluated
  49578. */
  49579. readonly lengthComputable: boolean;
  49580. /**
  49581. * Defines the loaded data length
  49582. */
  49583. readonly loaded: number;
  49584. /**
  49585. * Defines the data length to load
  49586. */
  49587. readonly total: number;
  49588. }
  49589. /**
  49590. * Interface used by SceneLoader plugins to define supported file extensions
  49591. */
  49592. export interface ISceneLoaderPluginExtensions {
  49593. /**
  49594. * Defines the list of supported extensions
  49595. */
  49596. [extension: string]: {
  49597. isBinary: boolean;
  49598. };
  49599. }
  49600. /**
  49601. * Interface used by SceneLoader plugin factory
  49602. */
  49603. export interface ISceneLoaderPluginFactory {
  49604. /**
  49605. * Defines the name of the factory
  49606. */
  49607. name: string;
  49608. /**
  49609. * Function called to create a new plugin
  49610. * @return the new plugin
  49611. */
  49612. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49613. /**
  49614. * The callback that returns true if the data can be directly loaded.
  49615. * @param data string containing the file data
  49616. * @returns if the data can be loaded directly
  49617. */
  49618. canDirectLoad?(data: string): boolean;
  49619. }
  49620. /**
  49621. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49622. */
  49623. export interface ISceneLoaderPluginBase {
  49624. /**
  49625. * The friendly name of this plugin.
  49626. */
  49627. name: string;
  49628. /**
  49629. * The file extensions supported by this plugin.
  49630. */
  49631. extensions: string | ISceneLoaderPluginExtensions;
  49632. /**
  49633. * The callback called when loading from a url.
  49634. * @param scene scene loading this url
  49635. * @param url url to load
  49636. * @param onSuccess callback called when the file successfully loads
  49637. * @param onProgress callback called while file is loading (if the server supports this mode)
  49638. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49639. * @param onError callback called when the file fails to load
  49640. * @returns a file request object
  49641. */
  49642. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49643. /**
  49644. * The callback called when loading from a file object.
  49645. * @param scene scene loading this file
  49646. * @param file defines the file to load
  49647. * @param onSuccess defines the callback to call when data is loaded
  49648. * @param onProgress defines the callback to call during loading process
  49649. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49650. * @param onError defines the callback to call when an error occurs
  49651. * @returns a file request object
  49652. */
  49653. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49654. /**
  49655. * The callback that returns true if the data can be directly loaded.
  49656. * @param data string containing the file data
  49657. * @returns if the data can be loaded directly
  49658. */
  49659. canDirectLoad?(data: string): boolean;
  49660. /**
  49661. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49662. * @param scene scene loading this data
  49663. * @param data string containing the data
  49664. * @returns data to pass to the plugin
  49665. */
  49666. directLoad?(scene: Scene, data: string): any;
  49667. /**
  49668. * The callback that allows custom handling of the root url based on the response url.
  49669. * @param rootUrl the original root url
  49670. * @param responseURL the response url if available
  49671. * @returns the new root url
  49672. */
  49673. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49674. }
  49675. /**
  49676. * Interface used to define a SceneLoader plugin
  49677. */
  49678. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49679. /**
  49680. * Import meshes into a scene.
  49681. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49682. * @param scene The scene to import into
  49683. * @param data The data to import
  49684. * @param rootUrl The root url for scene and resources
  49685. * @param meshes The meshes array to import into
  49686. * @param particleSystems The particle systems array to import into
  49687. * @param skeletons The skeletons array to import into
  49688. * @param onError The callback when import fails
  49689. * @returns True if successful or false otherwise
  49690. */
  49691. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49692. /**
  49693. * Load into a scene.
  49694. * @param scene The scene to load into
  49695. * @param data The data to import
  49696. * @param rootUrl The root url for scene and resources
  49697. * @param onError The callback when import fails
  49698. * @returns True if successful or false otherwise
  49699. */
  49700. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49701. /**
  49702. * Load into an asset container.
  49703. * @param scene The scene to load into
  49704. * @param data The data to import
  49705. * @param rootUrl The root url for scene and resources
  49706. * @param onError The callback when import fails
  49707. * @returns The loaded asset container
  49708. */
  49709. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49710. }
  49711. /**
  49712. * Interface used to define an async SceneLoader plugin
  49713. */
  49714. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49715. /**
  49716. * Import meshes into a scene.
  49717. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49718. * @param scene The scene to import into
  49719. * @param data The data to import
  49720. * @param rootUrl The root url for scene and resources
  49721. * @param onProgress The callback when the load progresses
  49722. * @param fileName Defines the name of the file to load
  49723. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49724. */
  49725. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49726. meshes: AbstractMesh[];
  49727. particleSystems: IParticleSystem[];
  49728. skeletons: Skeleton[];
  49729. animationGroups: AnimationGroup[];
  49730. }>;
  49731. /**
  49732. * Load into a scene.
  49733. * @param scene The scene to load into
  49734. * @param data The data to import
  49735. * @param rootUrl The root url for scene and resources
  49736. * @param onProgress The callback when the load progresses
  49737. * @param fileName Defines the name of the file to load
  49738. * @returns Nothing
  49739. */
  49740. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49741. /**
  49742. * Load into an asset container.
  49743. * @param scene The scene to load into
  49744. * @param data The data to import
  49745. * @param rootUrl The root url for scene and resources
  49746. * @param onProgress The callback when the load progresses
  49747. * @param fileName Defines the name of the file to load
  49748. * @returns The loaded asset container
  49749. */
  49750. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49751. }
  49752. /**
  49753. * Mode that determines how to handle old animation groups before loading new ones.
  49754. */
  49755. export enum SceneLoaderAnimationGroupLoadingMode {
  49756. /**
  49757. * Reset all old animations to initial state then dispose them.
  49758. */
  49759. Clean = 0,
  49760. /**
  49761. * Stop all old animations.
  49762. */
  49763. Stop = 1,
  49764. /**
  49765. * Restart old animations from first frame.
  49766. */
  49767. Sync = 2,
  49768. /**
  49769. * Old animations remains untouched.
  49770. */
  49771. NoSync = 3
  49772. }
  49773. /**
  49774. * Defines a plugin registered by the SceneLoader
  49775. */
  49776. interface IRegisteredPlugin {
  49777. /**
  49778. * Defines the plugin to use
  49779. */
  49780. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49781. /**
  49782. * Defines if the plugin supports binary data
  49783. */
  49784. isBinary: boolean;
  49785. }
  49786. /**
  49787. * Class used to load scene from various file formats using registered plugins
  49788. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49789. */
  49790. export class SceneLoader {
  49791. /**
  49792. * No logging while loading
  49793. */
  49794. static readonly NO_LOGGING: number;
  49795. /**
  49796. * Minimal logging while loading
  49797. */
  49798. static readonly MINIMAL_LOGGING: number;
  49799. /**
  49800. * Summary logging while loading
  49801. */
  49802. static readonly SUMMARY_LOGGING: number;
  49803. /**
  49804. * Detailled logging while loading
  49805. */
  49806. static readonly DETAILED_LOGGING: number;
  49807. /**
  49808. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49809. */
  49810. static get ForceFullSceneLoadingForIncremental(): boolean;
  49811. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49812. /**
  49813. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49814. */
  49815. static get ShowLoadingScreen(): boolean;
  49816. static set ShowLoadingScreen(value: boolean);
  49817. /**
  49818. * Defines the current logging level (while loading the scene)
  49819. * @ignorenaming
  49820. */
  49821. static get loggingLevel(): number;
  49822. static set loggingLevel(value: number);
  49823. /**
  49824. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49825. */
  49826. static get CleanBoneMatrixWeights(): boolean;
  49827. static set CleanBoneMatrixWeights(value: boolean);
  49828. /**
  49829. * Event raised when a plugin is used to load a scene
  49830. */
  49831. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49832. private static _registeredPlugins;
  49833. private static _showingLoadingScreen;
  49834. /**
  49835. * Gets the default plugin (used to load Babylon files)
  49836. * @returns the .babylon plugin
  49837. */
  49838. static GetDefaultPlugin(): IRegisteredPlugin;
  49839. private static _GetPluginForExtension;
  49840. private static _GetPluginForDirectLoad;
  49841. private static _GetPluginForFilename;
  49842. private static _GetDirectLoad;
  49843. private static _LoadData;
  49844. private static _GetFileInfo;
  49845. /**
  49846. * Gets a plugin that can load the given extension
  49847. * @param extension defines the extension to load
  49848. * @returns a plugin or null if none works
  49849. */
  49850. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49851. /**
  49852. * Gets a boolean indicating that the given extension can be loaded
  49853. * @param extension defines the extension to load
  49854. * @returns true if the extension is supported
  49855. */
  49856. static IsPluginForExtensionAvailable(extension: string): boolean;
  49857. /**
  49858. * Adds a new plugin to the list of registered plugins
  49859. * @param plugin defines the plugin to add
  49860. */
  49861. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49862. /**
  49863. * Import meshes into a scene
  49864. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49865. * @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)
  49866. * @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)
  49867. * @param scene the instance of BABYLON.Scene to append to
  49868. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49869. * @param onProgress a callback with a progress event for each file being loaded
  49870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49871. * @param pluginExtension the extension used to determine the plugin
  49872. * @returns The loaded plugin
  49873. */
  49874. 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>;
  49875. /**
  49876. * Import meshes into a scene
  49877. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49878. * @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)
  49879. * @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)
  49880. * @param scene the instance of BABYLON.Scene to append to
  49881. * @param onProgress a callback with a progress event for each file being loaded
  49882. * @param pluginExtension the extension used to determine the plugin
  49883. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49884. */
  49885. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49886. meshes: AbstractMesh[];
  49887. particleSystems: IParticleSystem[];
  49888. skeletons: Skeleton[];
  49889. animationGroups: AnimationGroup[];
  49890. }>;
  49891. /**
  49892. * Load a scene
  49893. * @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)
  49894. * @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)
  49895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49896. * @param onSuccess a callback with the scene when import succeeds
  49897. * @param onProgress a callback with a progress event for each file being loaded
  49898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49899. * @param pluginExtension the extension used to determine the plugin
  49900. * @returns The loaded plugin
  49901. */
  49902. 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>;
  49903. /**
  49904. * Load a scene
  49905. * @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)
  49906. * @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)
  49907. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49908. * @param onProgress a callback with a progress event for each file being loaded
  49909. * @param pluginExtension the extension used to determine the plugin
  49910. * @returns The loaded scene
  49911. */
  49912. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49913. /**
  49914. * Append a scene
  49915. * @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)
  49916. * @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)
  49917. * @param scene is the instance of BABYLON.Scene to append to
  49918. * @param onSuccess a callback with the scene when import succeeds
  49919. * @param onProgress a callback with a progress event for each file being loaded
  49920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49921. * @param pluginExtension the extension used to determine the plugin
  49922. * @returns The loaded plugin
  49923. */
  49924. 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>;
  49925. /**
  49926. * Append a scene
  49927. * @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)
  49928. * @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)
  49929. * @param scene is the instance of BABYLON.Scene to append to
  49930. * @param onProgress a callback with a progress event for each file being loaded
  49931. * @param pluginExtension the extension used to determine the plugin
  49932. * @returns The given scene
  49933. */
  49934. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49935. /**
  49936. * Load a scene into an asset container
  49937. * @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)
  49938. * @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)
  49939. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49940. * @param onSuccess a callback with the scene when import succeeds
  49941. * @param onProgress a callback with a progress event for each file being loaded
  49942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49943. * @param pluginExtension the extension used to determine the plugin
  49944. * @returns The loaded plugin
  49945. */
  49946. 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>;
  49947. /**
  49948. * Load a scene into an asset container
  49949. * @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)
  49950. * @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)
  49951. * @param scene is the instance of Scene to append to
  49952. * @param onProgress a callback with a progress event for each file being loaded
  49953. * @param pluginExtension the extension used to determine the plugin
  49954. * @returns The loaded asset container
  49955. */
  49956. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49957. /**
  49958. * Import animations from a file into a scene
  49959. * @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)
  49960. * @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)
  49961. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49962. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49963. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49964. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49965. * @param onSuccess a callback with the scene when import succeeds
  49966. * @param onProgress a callback with a progress event for each file being loaded
  49967. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49968. * @param pluginExtension the extension used to determine the plugin
  49969. */
  49970. 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;
  49971. /**
  49972. * Import animations from a file into a scene
  49973. * @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)
  49974. * @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)
  49975. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49976. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49977. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49978. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49979. * @param onSuccess a callback with the scene when import succeeds
  49980. * @param onProgress a callback with a progress event for each file being loaded
  49981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49982. * @param pluginExtension the extension used to determine the plugin
  49983. * @returns the updated scene with imported animations
  49984. */
  49985. 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>;
  49986. }
  49987. }
  49988. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49989. import { IDisposable, Scene } from "babylonjs/scene";
  49990. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49991. import { Observable } from "babylonjs/Misc/observable";
  49992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49993. import { Nullable } from "babylonjs/types";
  49994. /**
  49995. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49996. */
  49997. export type MotionControllerHandedness = "none" | "left" | "right";
  49998. /**
  49999. * The type of components available in motion controllers.
  50000. * This is not the name of the component.
  50001. */
  50002. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  50003. /**
  50004. * The state of a controller component
  50005. */
  50006. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  50007. /**
  50008. * The schema of motion controller layout.
  50009. * No object will be initialized using this interface
  50010. * This is used just to define the profile.
  50011. */
  50012. export interface IMotionControllerLayout {
  50013. /**
  50014. * Path to load the assets. Usually relative to the base path
  50015. */
  50016. assetPath: string;
  50017. /**
  50018. * Available components (unsorted)
  50019. */
  50020. components: {
  50021. /**
  50022. * A map of component Ids
  50023. */
  50024. [componentId: string]: {
  50025. /**
  50026. * The type of input the component outputs
  50027. */
  50028. type: MotionControllerComponentType;
  50029. /**
  50030. * The indices of this component in the gamepad object
  50031. */
  50032. gamepadIndices: {
  50033. /**
  50034. * Index of button
  50035. */
  50036. button?: number;
  50037. /**
  50038. * If available, index of x-axis
  50039. */
  50040. xAxis?: number;
  50041. /**
  50042. * If available, index of y-axis
  50043. */
  50044. yAxis?: number;
  50045. };
  50046. /**
  50047. * The mesh's root node name
  50048. */
  50049. rootNodeName: string;
  50050. /**
  50051. * Animation definitions for this model
  50052. */
  50053. visualResponses: {
  50054. [stateKey: string]: {
  50055. /**
  50056. * What property will be animated
  50057. */
  50058. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  50059. /**
  50060. * What states influence this visual response
  50061. */
  50062. states: MotionControllerComponentStateType[];
  50063. /**
  50064. * Type of animation - movement or visibility
  50065. */
  50066. valueNodeProperty: "transform" | "visibility";
  50067. /**
  50068. * Base node name to move. Its position will be calculated according to the min and max nodes
  50069. */
  50070. valueNodeName?: string;
  50071. /**
  50072. * Minimum movement node
  50073. */
  50074. minNodeName?: string;
  50075. /**
  50076. * Max movement node
  50077. */
  50078. maxNodeName?: string;
  50079. };
  50080. };
  50081. /**
  50082. * If touch enabled, what is the name of node to display user feedback
  50083. */
  50084. touchPointNodeName?: string;
  50085. };
  50086. };
  50087. /**
  50088. * Is it xr standard mapping or not
  50089. */
  50090. gamepadMapping: "" | "xr-standard";
  50091. /**
  50092. * Base root node of this entire model
  50093. */
  50094. rootNodeName: string;
  50095. /**
  50096. * Defines the main button component id
  50097. */
  50098. selectComponentId: string;
  50099. }
  50100. /**
  50101. * A definition for the layout map in the input profile
  50102. */
  50103. export interface IMotionControllerLayoutMap {
  50104. /**
  50105. * Layouts with handedness type as a key
  50106. */
  50107. [handedness: string]: IMotionControllerLayout;
  50108. }
  50109. /**
  50110. * The XR Input profile schema
  50111. * Profiles can be found here:
  50112. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50113. */
  50114. export interface IMotionControllerProfile {
  50115. /**
  50116. * fallback profiles for this profileId
  50117. */
  50118. fallbackProfileIds: string[];
  50119. /**
  50120. * The layout map, with handedness as key
  50121. */
  50122. layouts: IMotionControllerLayoutMap;
  50123. /**
  50124. * The id of this profile
  50125. * correlates to the profile(s) in the xrInput.profiles array
  50126. */
  50127. profileId: string;
  50128. }
  50129. /**
  50130. * A helper-interface for the 3 meshes needed for controller button animation
  50131. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50132. */
  50133. export interface IMotionControllerButtonMeshMap {
  50134. /**
  50135. * the mesh that defines the pressed value mesh position.
  50136. * This is used to find the max-position of this button
  50137. */
  50138. pressedMesh: AbstractMesh;
  50139. /**
  50140. * the mesh that defines the unpressed value mesh position.
  50141. * This is used to find the min (or initial) position of this button
  50142. */
  50143. unpressedMesh: AbstractMesh;
  50144. /**
  50145. * The mesh that will be changed when value changes
  50146. */
  50147. valueMesh: AbstractMesh;
  50148. }
  50149. /**
  50150. * A helper-interface for the 3 meshes needed for controller axis animation.
  50151. * This will be expanded when touchpad animations are fully supported
  50152. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50153. */
  50154. export interface IMotionControllerMeshMap {
  50155. /**
  50156. * the mesh that defines the maximum value mesh position.
  50157. */
  50158. maxMesh?: AbstractMesh;
  50159. /**
  50160. * the mesh that defines the minimum value mesh position.
  50161. */
  50162. minMesh?: AbstractMesh;
  50163. /**
  50164. * The mesh that will be changed when axis value changes
  50165. */
  50166. valueMesh?: AbstractMesh;
  50167. }
  50168. /**
  50169. * The elements needed for change-detection of the gamepad objects in motion controllers
  50170. */
  50171. export interface IMinimalMotionControllerObject {
  50172. /**
  50173. * Available axes of this controller
  50174. */
  50175. axes: number[];
  50176. /**
  50177. * An array of available buttons
  50178. */
  50179. buttons: Array<{
  50180. /**
  50181. * Value of the button/trigger
  50182. */
  50183. value: number;
  50184. /**
  50185. * If the button/trigger is currently touched
  50186. */
  50187. touched: boolean;
  50188. /**
  50189. * If the button/trigger is currently pressed
  50190. */
  50191. pressed: boolean;
  50192. }>;
  50193. /**
  50194. * EXPERIMENTAL haptic support.
  50195. */
  50196. hapticActuators?: Array<{
  50197. pulse: (value: number, duration: number) => Promise<boolean>;
  50198. }>;
  50199. }
  50200. /**
  50201. * An Abstract Motion controller
  50202. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50203. * Each component has an observable to check for changes in value and state
  50204. */
  50205. export abstract class WebXRAbstractMotionController implements IDisposable {
  50206. protected scene: Scene;
  50207. protected layout: IMotionControllerLayout;
  50208. /**
  50209. * The gamepad object correlating to this controller
  50210. */
  50211. gamepadObject: IMinimalMotionControllerObject;
  50212. /**
  50213. * handedness (left/right/none) of this controller
  50214. */
  50215. handedness: MotionControllerHandedness;
  50216. private _initComponent;
  50217. private _modelReady;
  50218. /**
  50219. * A map of components (WebXRControllerComponent) in this motion controller
  50220. * Components have a ComponentType and can also have both button and axis definitions
  50221. */
  50222. readonly components: {
  50223. [id: string]: WebXRControllerComponent;
  50224. };
  50225. /**
  50226. * Disable the model's animation. Can be set at any time.
  50227. */
  50228. disableAnimation: boolean;
  50229. /**
  50230. * Observers registered here will be triggered when the model of this controller is done loading
  50231. */
  50232. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50233. /**
  50234. * The profile id of this motion controller
  50235. */
  50236. abstract profileId: string;
  50237. /**
  50238. * The root mesh of the model. It is null if the model was not yet initialized
  50239. */
  50240. rootMesh: Nullable<AbstractMesh>;
  50241. /**
  50242. * constructs a new abstract motion controller
  50243. * @param scene the scene to which the model of the controller will be added
  50244. * @param layout The profile layout to load
  50245. * @param gamepadObject The gamepad object correlating to this controller
  50246. * @param handedness handedness (left/right/none) of this controller
  50247. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50248. */
  50249. constructor(scene: Scene, layout: IMotionControllerLayout,
  50250. /**
  50251. * The gamepad object correlating to this controller
  50252. */
  50253. gamepadObject: IMinimalMotionControllerObject,
  50254. /**
  50255. * handedness (left/right/none) of this controller
  50256. */
  50257. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50258. /**
  50259. * Dispose this controller, the model mesh and all its components
  50260. */
  50261. dispose(): void;
  50262. /**
  50263. * Returns all components of specific type
  50264. * @param type the type to search for
  50265. * @return an array of components with this type
  50266. */
  50267. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50268. /**
  50269. * get a component based an its component id as defined in layout.components
  50270. * @param id the id of the component
  50271. * @returns the component correlates to the id or undefined if not found
  50272. */
  50273. getComponent(id: string): WebXRControllerComponent;
  50274. /**
  50275. * Get the list of components available in this motion controller
  50276. * @returns an array of strings correlating to available components
  50277. */
  50278. getComponentIds(): string[];
  50279. /**
  50280. * Get the first component of specific type
  50281. * @param type type of component to find
  50282. * @return a controller component or null if not found
  50283. */
  50284. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50285. /**
  50286. * Get the main (Select) component of this controller as defined in the layout
  50287. * @returns the main component of this controller
  50288. */
  50289. getMainComponent(): WebXRControllerComponent;
  50290. /**
  50291. * Loads the model correlating to this controller
  50292. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50293. * @returns A promise fulfilled with the result of the model loading
  50294. */
  50295. loadModel(): Promise<boolean>;
  50296. /**
  50297. * Update this model using the current XRFrame
  50298. * @param xrFrame the current xr frame to use and update the model
  50299. */
  50300. updateFromXRFrame(xrFrame: XRFrame): void;
  50301. /**
  50302. * Backwards compatibility due to a deeply-integrated typo
  50303. */
  50304. get handness(): XREye;
  50305. /**
  50306. * Pulse (vibrate) this controller
  50307. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50308. * Consecutive calls to this function will cancel the last pulse call
  50309. *
  50310. * @param value the strength of the pulse in 0.0...1.0 range
  50311. * @param duration Duration of the pulse in milliseconds
  50312. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50313. * @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
  50314. */
  50315. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50316. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50317. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50318. /**
  50319. * Moves the axis on the controller mesh based on its current state
  50320. * @param axis the index of the axis
  50321. * @param axisValue the value of the axis which determines the meshes new position
  50322. * @hidden
  50323. */
  50324. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50325. /**
  50326. * Update the model itself with the current frame data
  50327. * @param xrFrame the frame to use for updating the model mesh
  50328. */
  50329. protected updateModel(xrFrame: XRFrame): void;
  50330. /**
  50331. * Get the filename and path for this controller's model
  50332. * @returns a map of filename and path
  50333. */
  50334. protected abstract _getFilenameAndPath(): {
  50335. filename: string;
  50336. path: string;
  50337. };
  50338. /**
  50339. * This function is called before the mesh is loaded. It checks for loading constraints.
  50340. * For example, this function can check if the GLB loader is available
  50341. * If this function returns false, the generic controller will be loaded instead
  50342. * @returns Is the client ready to load the mesh
  50343. */
  50344. protected abstract _getModelLoadingConstraints(): boolean;
  50345. /**
  50346. * This function will be called after the model was successfully loaded and can be used
  50347. * for mesh transformations before it is available for the user
  50348. * @param meshes the loaded meshes
  50349. */
  50350. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50351. /**
  50352. * Set the root mesh for this controller. Important for the WebXR controller class
  50353. * @param meshes the loaded meshes
  50354. */
  50355. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50356. /**
  50357. * A function executed each frame that updates the mesh (if needed)
  50358. * @param xrFrame the current xrFrame
  50359. */
  50360. protected abstract _updateModel(xrFrame: XRFrame): void;
  50361. private _getGenericFilenameAndPath;
  50362. private _getGenericParentMesh;
  50363. }
  50364. }
  50365. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50366. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50368. import { Scene } from "babylonjs/scene";
  50369. /**
  50370. * A generic trigger-only motion controller for WebXR
  50371. */
  50372. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50373. /**
  50374. * Static version of the profile id of this controller
  50375. */
  50376. static ProfileId: string;
  50377. profileId: string;
  50378. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50379. protected _getFilenameAndPath(): {
  50380. filename: string;
  50381. path: string;
  50382. };
  50383. protected _getModelLoadingConstraints(): boolean;
  50384. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50386. protected _updateModel(): void;
  50387. }
  50388. }
  50389. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50390. import { Vector4 } from "babylonjs/Maths/math.vector";
  50391. import { Mesh } from "babylonjs/Meshes/mesh";
  50392. import { Scene } from "babylonjs/scene";
  50393. import { Nullable } from "babylonjs/types";
  50394. /**
  50395. * Class containing static functions to help procedurally build meshes
  50396. */
  50397. export class SphereBuilder {
  50398. /**
  50399. * Creates a sphere mesh
  50400. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50401. * * 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`)
  50402. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50403. * * 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
  50404. * * 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)
  50405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50408. * @param name defines the name of the mesh
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the sphere mesh
  50412. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50413. */
  50414. static CreateSphere(name: string, options: {
  50415. segments?: number;
  50416. diameter?: number;
  50417. diameterX?: number;
  50418. diameterY?: number;
  50419. diameterZ?: number;
  50420. arc?: number;
  50421. slice?: number;
  50422. sideOrientation?: number;
  50423. frontUVs?: Vector4;
  50424. backUVs?: Vector4;
  50425. updatable?: boolean;
  50426. }, scene?: Nullable<Scene>): Mesh;
  50427. }
  50428. }
  50429. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50431. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50432. import { Scene } from "babylonjs/scene";
  50433. /**
  50434. * A profiled motion controller has its profile loaded from an online repository.
  50435. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50436. */
  50437. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50438. private _repositoryUrl;
  50439. private _buttonMeshMapping;
  50440. private _touchDots;
  50441. /**
  50442. * The profile ID of this controller. Will be populated when the controller initializes.
  50443. */
  50444. profileId: string;
  50445. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50446. dispose(): void;
  50447. protected _getFilenameAndPath(): {
  50448. filename: string;
  50449. path: string;
  50450. };
  50451. protected _getModelLoadingConstraints(): boolean;
  50452. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50453. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50454. protected _updateModel(_xrFrame: XRFrame): void;
  50455. }
  50456. }
  50457. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50458. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50459. import { Scene } from "babylonjs/scene";
  50460. /**
  50461. * A construction function type to create a new controller based on an xrInput object
  50462. */
  50463. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50464. /**
  50465. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50466. *
  50467. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50468. * it should be replaced with auto-loaded controllers.
  50469. *
  50470. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50471. */
  50472. export class WebXRMotionControllerManager {
  50473. private static _AvailableControllers;
  50474. private static _Fallbacks;
  50475. private static _ProfileLoadingPromises;
  50476. private static _ProfilesList;
  50477. /**
  50478. * The base URL of the online controller repository. Can be changed at any time.
  50479. */
  50480. static BaseRepositoryUrl: string;
  50481. /**
  50482. * Which repository gets priority - local or online
  50483. */
  50484. static PrioritizeOnlineRepository: boolean;
  50485. /**
  50486. * Use the online repository, or use only locally-defined controllers
  50487. */
  50488. static UseOnlineRepository: boolean;
  50489. /**
  50490. * Clear the cache used for profile loading and reload when requested again
  50491. */
  50492. static ClearProfilesCache(): void;
  50493. /**
  50494. * Register the default fallbacks.
  50495. * This function is called automatically when this file is imported.
  50496. */
  50497. static DefaultFallbacks(): void;
  50498. /**
  50499. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50500. * @param profileId the profile to which a fallback needs to be found
  50501. * @return an array with corresponding fallback profiles
  50502. */
  50503. static FindFallbackWithProfileId(profileId: string): string[];
  50504. /**
  50505. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50506. * The order of search:
  50507. *
  50508. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50509. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50510. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50511. * 4) return the generic trigger controller if none were found
  50512. *
  50513. * @param xrInput the xrInput to which a new controller is initialized
  50514. * @param scene the scene to which the model will be added
  50515. * @param forceProfile force a certain profile for this controller
  50516. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50517. */
  50518. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50519. /**
  50520. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50521. *
  50522. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50523. *
  50524. * @param type the profile type to register
  50525. * @param constructFunction the function to be called when loading this profile
  50526. */
  50527. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50528. /**
  50529. * Register a fallback to a specific profile.
  50530. * @param profileId the profileId that will receive the fallbacks
  50531. * @param fallbacks A list of fallback profiles
  50532. */
  50533. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50534. /**
  50535. * Will update the list of profiles available in the repository
  50536. * @return a promise that resolves to a map of profiles available online
  50537. */
  50538. static UpdateProfilesList(): Promise<{
  50539. [profile: string]: string;
  50540. }>;
  50541. private static _LoadProfileFromRepository;
  50542. private static _LoadProfilesFromAvailableControllers;
  50543. }
  50544. }
  50545. declare module "babylonjs/XR/webXRInputSource" {
  50546. import { Observable } from "babylonjs/Misc/observable";
  50547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50548. import { Ray } from "babylonjs/Culling/ray";
  50549. import { Scene } from "babylonjs/scene";
  50550. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50551. /**
  50552. * Configuration options for the WebXR controller creation
  50553. */
  50554. export interface IWebXRControllerOptions {
  50555. /**
  50556. * Should the controller mesh be animated when a user interacts with it
  50557. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50558. */
  50559. disableMotionControllerAnimation?: boolean;
  50560. /**
  50561. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50562. */
  50563. doNotLoadControllerMesh?: boolean;
  50564. /**
  50565. * Force a specific controller type for this controller.
  50566. * This can be used when creating your own profile or when testing different controllers
  50567. */
  50568. forceControllerProfile?: string;
  50569. /**
  50570. * Defines a rendering group ID for meshes that will be loaded.
  50571. * This is for the default controllers only.
  50572. */
  50573. renderingGroupId?: number;
  50574. }
  50575. /**
  50576. * Represents an XR controller
  50577. */
  50578. export class WebXRInputSource {
  50579. private _scene;
  50580. /** The underlying input source for the controller */
  50581. inputSource: XRInputSource;
  50582. private _options;
  50583. private _tmpVector;
  50584. private _uniqueId;
  50585. private _disposed;
  50586. /**
  50587. * 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
  50588. */
  50589. grip?: AbstractMesh;
  50590. /**
  50591. * If available, this is the gamepad object related to this controller.
  50592. * Using this object it is possible to get click events and trackpad changes of the
  50593. * webxr controller that is currently being used.
  50594. */
  50595. motionController?: WebXRAbstractMotionController;
  50596. /**
  50597. * Event that fires when the controller is removed/disposed.
  50598. * The object provided as event data is this controller, after associated assets were disposed.
  50599. * uniqueId is still available.
  50600. */
  50601. onDisposeObservable: Observable<WebXRInputSource>;
  50602. /**
  50603. * Will be triggered when the mesh associated with the motion controller is done loading.
  50604. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50605. * A shortened version of controller -> motion controller -> on mesh loaded.
  50606. */
  50607. onMeshLoadedObservable: Observable<AbstractMesh>;
  50608. /**
  50609. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50610. */
  50611. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50612. /**
  50613. * Pointer which can be used to select objects or attach a visible laser to
  50614. */
  50615. pointer: AbstractMesh;
  50616. /**
  50617. * Creates the input source object
  50618. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50619. * @param _scene the scene which the controller should be associated to
  50620. * @param inputSource the underlying input source for the controller
  50621. * @param _options options for this controller creation
  50622. */
  50623. constructor(_scene: Scene,
  50624. /** The underlying input source for the controller */
  50625. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50626. /**
  50627. * Get this controllers unique id
  50628. */
  50629. get uniqueId(): string;
  50630. /**
  50631. * Disposes of the object
  50632. */
  50633. dispose(): void;
  50634. /**
  50635. * Gets a world space ray coming from the pointer or grip
  50636. * @param result the resulting ray
  50637. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50638. */
  50639. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50640. /**
  50641. * Updates the controller pose based on the given XRFrame
  50642. * @param xrFrame xr frame to update the pose with
  50643. * @param referenceSpace reference space to use
  50644. */
  50645. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50646. }
  50647. }
  50648. declare module "babylonjs/XR/webXRInput" {
  50649. import { Observable } from "babylonjs/Misc/observable";
  50650. import { IDisposable } from "babylonjs/scene";
  50651. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50652. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50653. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50654. /**
  50655. * The schema for initialization options of the XR Input class
  50656. */
  50657. export interface IWebXRInputOptions {
  50658. /**
  50659. * If set to true no model will be automatically loaded
  50660. */
  50661. doNotLoadControllerMeshes?: boolean;
  50662. /**
  50663. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50664. * If not found, the xr input profile data will be used.
  50665. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50666. */
  50667. forceInputProfile?: string;
  50668. /**
  50669. * Do not send a request to the controller repository to load the profile.
  50670. *
  50671. * Instead, use the controllers available in babylon itself.
  50672. */
  50673. disableOnlineControllerRepository?: boolean;
  50674. /**
  50675. * A custom URL for the controllers repository
  50676. */
  50677. customControllersRepositoryURL?: string;
  50678. /**
  50679. * Should the controller model's components not move according to the user input
  50680. */
  50681. disableControllerAnimation?: boolean;
  50682. /**
  50683. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50684. */
  50685. controllerOptions?: IWebXRControllerOptions;
  50686. }
  50687. /**
  50688. * XR input used to track XR inputs such as controllers/rays
  50689. */
  50690. export class WebXRInput implements IDisposable {
  50691. /**
  50692. * the xr session manager for this session
  50693. */
  50694. xrSessionManager: WebXRSessionManager;
  50695. /**
  50696. * the WebXR camera for this session. Mainly used for teleportation
  50697. */
  50698. xrCamera: WebXRCamera;
  50699. private readonly options;
  50700. /**
  50701. * XR controllers being tracked
  50702. */
  50703. controllers: Array<WebXRInputSource>;
  50704. private _frameObserver;
  50705. private _sessionEndedObserver;
  50706. private _sessionInitObserver;
  50707. /**
  50708. * Event when a controller has been connected/added
  50709. */
  50710. onControllerAddedObservable: Observable<WebXRInputSource>;
  50711. /**
  50712. * Event when a controller has been removed/disconnected
  50713. */
  50714. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50715. /**
  50716. * Initializes the WebXRInput
  50717. * @param xrSessionManager the xr session manager for this session
  50718. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50719. * @param options = initialization options for this xr input
  50720. */
  50721. constructor(
  50722. /**
  50723. * the xr session manager for this session
  50724. */
  50725. xrSessionManager: WebXRSessionManager,
  50726. /**
  50727. * the WebXR camera for this session. Mainly used for teleportation
  50728. */
  50729. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50730. private _onInputSourcesChange;
  50731. private _addAndRemoveControllers;
  50732. /**
  50733. * Disposes of the object
  50734. */
  50735. dispose(): void;
  50736. }
  50737. }
  50738. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50739. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50740. import { Observable, EventState } from "babylonjs/Misc/observable";
  50741. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50742. /**
  50743. * This is the base class for all WebXR features.
  50744. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50745. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50746. */
  50747. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50748. protected _xrSessionManager: WebXRSessionManager;
  50749. private _attached;
  50750. private _removeOnDetach;
  50751. /**
  50752. * Is this feature disposed?
  50753. */
  50754. isDisposed: boolean;
  50755. /**
  50756. * Should auto-attach be disabled?
  50757. */
  50758. disableAutoAttach: boolean;
  50759. /**
  50760. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50761. */
  50762. xrNativeFeatureName: string;
  50763. /**
  50764. * Construct a new (abstract) WebXR feature
  50765. * @param _xrSessionManager the xr session manager for this feature
  50766. */
  50767. constructor(_xrSessionManager: WebXRSessionManager);
  50768. /**
  50769. * Is this feature attached
  50770. */
  50771. get attached(): boolean;
  50772. /**
  50773. * attach this feature
  50774. *
  50775. * @param force should attachment be forced (even when already attached)
  50776. * @returns true if successful, false is failed or already attached
  50777. */
  50778. attach(force?: boolean): boolean;
  50779. /**
  50780. * detach this feature.
  50781. *
  50782. * @returns true if successful, false if failed or already detached
  50783. */
  50784. detach(): boolean;
  50785. /**
  50786. * Dispose this feature and all of the resources attached
  50787. */
  50788. dispose(): void;
  50789. /**
  50790. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50791. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50792. *
  50793. * @returns whether or not the feature is compatible in this environment
  50794. */
  50795. isCompatible(): boolean;
  50796. /**
  50797. * This is used to register callbacks that will automatically be removed when detach is called.
  50798. * @param observable the observable to which the observer will be attached
  50799. * @param callback the callback to register
  50800. */
  50801. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50802. /**
  50803. * Code in this function will be executed on each xrFrame received from the browser.
  50804. * This function will not execute after the feature is detached.
  50805. * @param _xrFrame the current frame
  50806. */
  50807. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50808. }
  50809. }
  50810. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50811. import { IDisposable, Scene } from "babylonjs/scene";
  50812. import { Nullable } from "babylonjs/types";
  50813. import { Observable } from "babylonjs/Misc/observable";
  50814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50815. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50816. import { Camera } from "babylonjs/Cameras/camera";
  50817. /**
  50818. * Renders a layer on top of an existing scene
  50819. */
  50820. export class UtilityLayerRenderer implements IDisposable {
  50821. /** the original scene that will be rendered on top of */
  50822. originalScene: Scene;
  50823. private _pointerCaptures;
  50824. private _lastPointerEvents;
  50825. private static _DefaultUtilityLayer;
  50826. private static _DefaultKeepDepthUtilityLayer;
  50827. private _sharedGizmoLight;
  50828. private _renderCamera;
  50829. /**
  50830. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50831. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50832. * @returns the camera that is used when rendering the utility layer
  50833. */
  50834. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50835. /**
  50836. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50837. * @param cam the camera that should be used when rendering the utility layer
  50838. */
  50839. setRenderCamera(cam: Nullable<Camera>): void;
  50840. /**
  50841. * @hidden
  50842. * Light which used by gizmos to get light shading
  50843. */
  50844. _getSharedGizmoLight(): HemisphericLight;
  50845. /**
  50846. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50847. */
  50848. pickUtilitySceneFirst: boolean;
  50849. /**
  50850. * 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)
  50851. */
  50852. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50853. /**
  50854. * 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)
  50855. */
  50856. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50857. /**
  50858. * The scene that is rendered on top of the original scene
  50859. */
  50860. utilityLayerScene: Scene;
  50861. /**
  50862. * If the utility layer should automatically be rendered on top of existing scene
  50863. */
  50864. shouldRender: boolean;
  50865. /**
  50866. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50867. */
  50868. onlyCheckPointerDownEvents: boolean;
  50869. /**
  50870. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50871. */
  50872. processAllEvents: boolean;
  50873. /**
  50874. * Observable raised when the pointer move from the utility layer scene to the main scene
  50875. */
  50876. onPointerOutObservable: Observable<number>;
  50877. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50878. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50879. private _afterRenderObserver;
  50880. private _sceneDisposeObserver;
  50881. private _originalPointerObserver;
  50882. /**
  50883. * Instantiates a UtilityLayerRenderer
  50884. * @param originalScene the original scene that will be rendered on top of
  50885. * @param handleEvents boolean indicating if the utility layer should handle events
  50886. */
  50887. constructor(
  50888. /** the original scene that will be rendered on top of */
  50889. originalScene: Scene, handleEvents?: boolean);
  50890. private _notifyObservers;
  50891. /**
  50892. * Renders the utility layers scene on top of the original scene
  50893. */
  50894. render(): void;
  50895. /**
  50896. * Disposes of the renderer
  50897. */
  50898. dispose(): void;
  50899. private _updateCamera;
  50900. }
  50901. }
  50902. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50903. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50905. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50906. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50907. import { Scene } from "babylonjs/scene";
  50908. import { Nullable } from "babylonjs/types";
  50909. import { Color3 } from "babylonjs/Maths/math.color";
  50910. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50911. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50912. /**
  50913. * Options interface for the pointer selection module
  50914. */
  50915. export interface IWebXRControllerPointerSelectionOptions {
  50916. /**
  50917. * if provided, this scene will be used to render meshes.
  50918. */
  50919. customUtilityLayerScene?: Scene;
  50920. /**
  50921. * 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)
  50922. * If not disabled, the last picked point will be used to execute a pointer up event
  50923. * If disabled, pointer up event will be triggered right after the pointer down event.
  50924. * Used in screen and gaze target ray mode only
  50925. */
  50926. disablePointerUpOnTouchOut: boolean;
  50927. /**
  50928. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50929. */
  50930. forceGazeMode: boolean;
  50931. /**
  50932. * 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
  50933. * to start a new countdown to the pointer down event.
  50934. * Defaults to 1.
  50935. */
  50936. gazeModePointerMovedFactor?: number;
  50937. /**
  50938. * Different button type to use instead of the main component
  50939. */
  50940. overrideButtonId?: string;
  50941. /**
  50942. * use this rendering group id for the meshes (optional)
  50943. */
  50944. renderingGroupId?: number;
  50945. /**
  50946. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50947. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50948. * 3000 means 3 seconds between pointing at something and selecting it
  50949. */
  50950. timeToSelect?: number;
  50951. /**
  50952. * Should meshes created here be added to a utility layer or the main scene
  50953. */
  50954. useUtilityLayer?: boolean;
  50955. /**
  50956. * Optional WebXR camera to be used for gaze selection
  50957. */
  50958. gazeCamera?: WebXRCamera;
  50959. /**
  50960. * the xr input to use with this pointer selection
  50961. */
  50962. xrInput: WebXRInput;
  50963. }
  50964. /**
  50965. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50966. */
  50967. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50968. private readonly _options;
  50969. private static _idCounter;
  50970. private _attachController;
  50971. private _controllers;
  50972. private _scene;
  50973. private _tmpVectorForPickCompare;
  50974. /**
  50975. * The module's name
  50976. */
  50977. static readonly Name: string;
  50978. /**
  50979. * The (Babylon) version of this module.
  50980. * This is an integer representing the implementation version.
  50981. * This number does not correspond to the WebXR specs version
  50982. */
  50983. static readonly Version: number;
  50984. /**
  50985. * Disable lighting on the laser pointer (so it will always be visible)
  50986. */
  50987. disablePointerLighting: boolean;
  50988. /**
  50989. * Disable lighting on the selection mesh (so it will always be visible)
  50990. */
  50991. disableSelectionMeshLighting: boolean;
  50992. /**
  50993. * Should the laser pointer be displayed
  50994. */
  50995. displayLaserPointer: boolean;
  50996. /**
  50997. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50998. */
  50999. displaySelectionMesh: boolean;
  51000. /**
  51001. * This color will be set to the laser pointer when selection is triggered
  51002. */
  51003. laserPointerPickedColor: Color3;
  51004. /**
  51005. * Default color of the laser pointer
  51006. */
  51007. laserPointerDefaultColor: Color3;
  51008. /**
  51009. * default color of the selection ring
  51010. */
  51011. selectionMeshDefaultColor: Color3;
  51012. /**
  51013. * This color will be applied to the selection ring when selection is triggered
  51014. */
  51015. selectionMeshPickedColor: Color3;
  51016. /**
  51017. * Optional filter to be used for ray selection. This predicate shares behavior with
  51018. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51019. */
  51020. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51021. /**
  51022. * constructs a new background remover module
  51023. * @param _xrSessionManager the session manager for this module
  51024. * @param _options read-only options to be used in this module
  51025. */
  51026. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51027. /**
  51028. * attach this feature
  51029. * Will usually be called by the features manager
  51030. *
  51031. * @returns true if successful.
  51032. */
  51033. attach(): boolean;
  51034. /**
  51035. * detach this feature.
  51036. * Will usually be called by the features manager
  51037. *
  51038. * @returns true if successful.
  51039. */
  51040. detach(): boolean;
  51041. /**
  51042. * Will get the mesh under a specific pointer.
  51043. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  51044. * @param controllerId the controllerId to check
  51045. * @returns The mesh under pointer or null if no mesh is under the pointer
  51046. */
  51047. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  51048. /**
  51049. * Get the xr controller that correlates to the pointer id in the pointer event
  51050. *
  51051. * @param id the pointer id to search for
  51052. * @returns the controller that correlates to this id or null if not found
  51053. */
  51054. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  51055. protected _onXRFrame(_xrFrame: XRFrame): void;
  51056. private _attachGazeMode;
  51057. private _attachScreenRayMode;
  51058. private _attachTrackedPointerRayMode;
  51059. private _convertNormalToDirectionOfRay;
  51060. private _detachController;
  51061. private _generateNewMeshPair;
  51062. private _pickingMoved;
  51063. private _updatePointerDistance;
  51064. /** @hidden */
  51065. get lasterPointerDefaultColor(): Color3;
  51066. }
  51067. }
  51068. declare module "babylonjs/XR/webXREnterExitUI" {
  51069. import { Nullable } from "babylonjs/types";
  51070. import { Observable } from "babylonjs/Misc/observable";
  51071. import { IDisposable, Scene } from "babylonjs/scene";
  51072. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51073. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51074. /**
  51075. * Button which can be used to enter a different mode of XR
  51076. */
  51077. export class WebXREnterExitUIButton {
  51078. /** button element */
  51079. element: HTMLElement;
  51080. /** XR initialization options for the button */
  51081. sessionMode: XRSessionMode;
  51082. /** Reference space type */
  51083. referenceSpaceType: XRReferenceSpaceType;
  51084. /**
  51085. * Creates a WebXREnterExitUIButton
  51086. * @param element button element
  51087. * @param sessionMode XR initialization session mode
  51088. * @param referenceSpaceType the type of reference space to be used
  51089. */
  51090. constructor(
  51091. /** button element */
  51092. element: HTMLElement,
  51093. /** XR initialization options for the button */
  51094. sessionMode: XRSessionMode,
  51095. /** Reference space type */
  51096. referenceSpaceType: XRReferenceSpaceType);
  51097. /**
  51098. * Extendable function which can be used to update the button's visuals when the state changes
  51099. * @param activeButton the current active button in the UI
  51100. */
  51101. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51102. }
  51103. /**
  51104. * Options to create the webXR UI
  51105. */
  51106. export class WebXREnterExitUIOptions {
  51107. /**
  51108. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51109. */
  51110. customButtons?: Array<WebXREnterExitUIButton>;
  51111. /**
  51112. * A reference space type to use when creating the default button.
  51113. * Default is local-floor
  51114. */
  51115. referenceSpaceType?: XRReferenceSpaceType;
  51116. /**
  51117. * Context to enter xr with
  51118. */
  51119. renderTarget?: Nullable<WebXRRenderTarget>;
  51120. /**
  51121. * A session mode to use when creating the default button.
  51122. * Default is immersive-vr
  51123. */
  51124. sessionMode?: XRSessionMode;
  51125. /**
  51126. * A list of optional features to init the session with
  51127. */
  51128. optionalFeatures?: string[];
  51129. /**
  51130. * A list of optional features to init the session with
  51131. */
  51132. requiredFeatures?: string[];
  51133. }
  51134. /**
  51135. * UI to allow the user to enter/exit XR mode
  51136. */
  51137. export class WebXREnterExitUI implements IDisposable {
  51138. private scene;
  51139. /** version of the options passed to this UI */
  51140. options: WebXREnterExitUIOptions;
  51141. private _activeButton;
  51142. private _buttons;
  51143. /**
  51144. * The HTML Div Element to which buttons are added.
  51145. */
  51146. readonly overlay: HTMLDivElement;
  51147. /**
  51148. * Fired every time the active button is changed.
  51149. *
  51150. * When xr is entered via a button that launches xr that button will be the callback parameter
  51151. *
  51152. * When exiting xr the callback parameter will be null)
  51153. */
  51154. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51155. /**
  51156. *
  51157. * @param scene babylon scene object to use
  51158. * @param options (read-only) version of the options passed to this UI
  51159. */
  51160. private constructor();
  51161. /**
  51162. * Creates UI to allow the user to enter/exit XR mode
  51163. * @param scene the scene to add the ui to
  51164. * @param helper the xr experience helper to enter/exit xr with
  51165. * @param options options to configure the UI
  51166. * @returns the created ui
  51167. */
  51168. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51169. /**
  51170. * Disposes of the XR UI component
  51171. */
  51172. dispose(): void;
  51173. private _updateButtons;
  51174. }
  51175. }
  51176. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51177. import { Vector3 } from "babylonjs/Maths/math.vector";
  51178. import { Color4 } from "babylonjs/Maths/math.color";
  51179. import { Nullable } from "babylonjs/types";
  51180. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51181. import { Scene } from "babylonjs/scene";
  51182. /**
  51183. * Class containing static functions to help procedurally build meshes
  51184. */
  51185. export class LinesBuilder {
  51186. /**
  51187. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51188. * * 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
  51189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51190. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51191. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51192. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51193. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51194. * * 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
  51195. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51198. * @param name defines the name of the new line system
  51199. * @param options defines the options used to create the line system
  51200. * @param scene defines the hosting scene
  51201. * @returns a new line system mesh
  51202. */
  51203. static CreateLineSystem(name: string, options: {
  51204. lines: Vector3[][];
  51205. updatable?: boolean;
  51206. instance?: Nullable<LinesMesh>;
  51207. colors?: Nullable<Color4[][]>;
  51208. useVertexAlpha?: boolean;
  51209. }, scene: Nullable<Scene>): LinesMesh;
  51210. /**
  51211. * Creates a line mesh
  51212. * 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
  51213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51214. * * The parameter `points` is an array successive Vector3
  51215. * * 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
  51216. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51218. * * When updating an instance, remember that only point positions can change, not the number of points
  51219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51221. * @param name defines the name of the new line system
  51222. * @param options defines the options used to create the line system
  51223. * @param scene defines the hosting scene
  51224. * @returns a new line mesh
  51225. */
  51226. static CreateLines(name: string, options: {
  51227. points: Vector3[];
  51228. updatable?: boolean;
  51229. instance?: Nullable<LinesMesh>;
  51230. colors?: Color4[];
  51231. useVertexAlpha?: boolean;
  51232. }, scene?: Nullable<Scene>): LinesMesh;
  51233. /**
  51234. * Creates a dashed line mesh
  51235. * * 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
  51236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51237. * * The parameter `points` is an array successive Vector3
  51238. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51239. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51240. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51241. * * 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
  51242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51243. * * When updating an instance, remember that only point positions can change, not the number of points
  51244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51245. * @param name defines the name of the mesh
  51246. * @param options defines the options used to create the mesh
  51247. * @param scene defines the hosting scene
  51248. * @returns the dashed line mesh
  51249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51250. */
  51251. static CreateDashedLines(name: string, options: {
  51252. points: Vector3[];
  51253. dashSize?: number;
  51254. gapSize?: number;
  51255. dashNb?: number;
  51256. updatable?: boolean;
  51257. instance?: LinesMesh;
  51258. useVertexAlpha?: boolean;
  51259. }, scene?: Nullable<Scene>): LinesMesh;
  51260. }
  51261. }
  51262. declare module "babylonjs/Misc/timer" {
  51263. import { Observable, Observer } from "babylonjs/Misc/observable";
  51264. import { Nullable } from "babylonjs/types";
  51265. import { IDisposable } from "babylonjs/scene";
  51266. /**
  51267. * Construction options for a timer
  51268. */
  51269. export interface ITimerOptions<T> {
  51270. /**
  51271. * Time-to-end
  51272. */
  51273. timeout: number;
  51274. /**
  51275. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51276. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51277. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51278. */
  51279. contextObservable: Observable<T>;
  51280. /**
  51281. * Optional parameters when adding an observer to the observable
  51282. */
  51283. observableParameters?: {
  51284. mask?: number;
  51285. insertFirst?: boolean;
  51286. scope?: any;
  51287. };
  51288. /**
  51289. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51290. */
  51291. breakCondition?: (data?: ITimerData<T>) => boolean;
  51292. /**
  51293. * Will be triggered when the time condition has met
  51294. */
  51295. onEnded?: (data: ITimerData<any>) => void;
  51296. /**
  51297. * Will be triggered when the break condition has met (prematurely ended)
  51298. */
  51299. onAborted?: (data: ITimerData<any>) => void;
  51300. /**
  51301. * Optional function to execute on each tick (or count)
  51302. */
  51303. onTick?: (data: ITimerData<any>) => void;
  51304. }
  51305. /**
  51306. * An interface defining the data sent by the timer
  51307. */
  51308. export interface ITimerData<T> {
  51309. /**
  51310. * When did it start
  51311. */
  51312. startTime: number;
  51313. /**
  51314. * Time now
  51315. */
  51316. currentTime: number;
  51317. /**
  51318. * Time passed since started
  51319. */
  51320. deltaTime: number;
  51321. /**
  51322. * How much is completed, in [0.0...1.0].
  51323. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51324. */
  51325. completeRate: number;
  51326. /**
  51327. * What the registered observable sent in the last count
  51328. */
  51329. payload: T;
  51330. }
  51331. /**
  51332. * The current state of the timer
  51333. */
  51334. export enum TimerState {
  51335. /**
  51336. * Timer initialized, not yet started
  51337. */
  51338. INIT = 0,
  51339. /**
  51340. * Timer started and counting
  51341. */
  51342. STARTED = 1,
  51343. /**
  51344. * Timer ended (whether aborted or time reached)
  51345. */
  51346. ENDED = 2
  51347. }
  51348. /**
  51349. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51350. *
  51351. * @param options options with which to initialize this timer
  51352. */
  51353. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51354. /**
  51355. * An advanced implementation of a timer class
  51356. */
  51357. export class AdvancedTimer<T = any> implements IDisposable {
  51358. /**
  51359. * Will notify each time the timer calculates the remaining time
  51360. */
  51361. onEachCountObservable: Observable<ITimerData<T>>;
  51362. /**
  51363. * Will trigger when the timer was aborted due to the break condition
  51364. */
  51365. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51366. /**
  51367. * Will trigger when the timer ended successfully
  51368. */
  51369. onTimerEndedObservable: Observable<ITimerData<T>>;
  51370. /**
  51371. * Will trigger when the timer state has changed
  51372. */
  51373. onStateChangedObservable: Observable<TimerState>;
  51374. private _observer;
  51375. private _contextObservable;
  51376. private _observableParameters;
  51377. private _startTime;
  51378. private _timer;
  51379. private _state;
  51380. private _breakCondition;
  51381. private _timeToEnd;
  51382. private _breakOnNextTick;
  51383. /**
  51384. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51385. * @param options construction options for this advanced timer
  51386. */
  51387. constructor(options: ITimerOptions<T>);
  51388. /**
  51389. * set a breaking condition for this timer. Default is to never break during count
  51390. * @param predicate the new break condition. Returns true to break, false otherwise
  51391. */
  51392. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51393. /**
  51394. * Reset ALL associated observables in this advanced timer
  51395. */
  51396. clearObservables(): void;
  51397. /**
  51398. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51399. *
  51400. * @param timeToEnd how much time to measure until timer ended
  51401. */
  51402. start(timeToEnd?: number): void;
  51403. /**
  51404. * Will force a stop on the next tick.
  51405. */
  51406. stop(): void;
  51407. /**
  51408. * Dispose this timer, clearing all resources
  51409. */
  51410. dispose(): void;
  51411. private _setState;
  51412. private _tick;
  51413. private _stop;
  51414. }
  51415. }
  51416. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51417. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51418. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51419. import { Nullable } from "babylonjs/types";
  51420. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51422. import { Vector3 } from "babylonjs/Maths/math.vector";
  51423. import { Material } from "babylonjs/Materials/material";
  51424. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51425. import { Scene } from "babylonjs/scene";
  51426. /**
  51427. * The options container for the teleportation module
  51428. */
  51429. export interface IWebXRTeleportationOptions {
  51430. /**
  51431. * if provided, this scene will be used to render meshes.
  51432. */
  51433. customUtilityLayerScene?: Scene;
  51434. /**
  51435. * Values to configure the default target mesh
  51436. */
  51437. defaultTargetMeshOptions?: {
  51438. /**
  51439. * Fill color of the teleportation area
  51440. */
  51441. teleportationFillColor?: string;
  51442. /**
  51443. * Border color for the teleportation area
  51444. */
  51445. teleportationBorderColor?: string;
  51446. /**
  51447. * Disable the mesh's animation sequence
  51448. */
  51449. disableAnimation?: boolean;
  51450. /**
  51451. * Disable lighting on the material or the ring and arrow
  51452. */
  51453. disableLighting?: boolean;
  51454. /**
  51455. * Override the default material of the torus and arrow
  51456. */
  51457. torusArrowMaterial?: Material;
  51458. };
  51459. /**
  51460. * A list of meshes to use as floor meshes.
  51461. * Meshes can be added and removed after initializing the feature using the
  51462. * addFloorMesh and removeFloorMesh functions
  51463. * If empty, rotation will still work
  51464. */
  51465. floorMeshes?: AbstractMesh[];
  51466. /**
  51467. * use this rendering group id for the meshes (optional)
  51468. */
  51469. renderingGroupId?: number;
  51470. /**
  51471. * Should teleportation move only to snap points
  51472. */
  51473. snapPointsOnly?: boolean;
  51474. /**
  51475. * An array of points to which the teleportation will snap to.
  51476. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51477. */
  51478. snapPositions?: Vector3[];
  51479. /**
  51480. * How close should the teleportation ray be in order to snap to position.
  51481. * Default to 0.8 units (meters)
  51482. */
  51483. snapToPositionRadius?: number;
  51484. /**
  51485. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51486. * If you want to support rotation, make sure your mesh has a direction indicator.
  51487. *
  51488. * When left untouched, the default mesh will be initialized.
  51489. */
  51490. teleportationTargetMesh?: AbstractMesh;
  51491. /**
  51492. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51493. */
  51494. timeToTeleport?: number;
  51495. /**
  51496. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51497. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51498. */
  51499. useMainComponentOnly?: boolean;
  51500. /**
  51501. * Should meshes created here be added to a utility layer or the main scene
  51502. */
  51503. useUtilityLayer?: boolean;
  51504. /**
  51505. * Babylon XR Input class for controller
  51506. */
  51507. xrInput: WebXRInput;
  51508. /**
  51509. * Meshes that the teleportation ray cannot go through
  51510. */
  51511. pickBlockerMeshes?: AbstractMesh[];
  51512. }
  51513. /**
  51514. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51515. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51516. * the input of the attached controllers.
  51517. */
  51518. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51519. private _options;
  51520. private _controllers;
  51521. private _currentTeleportationControllerId;
  51522. private _floorMeshes;
  51523. private _quadraticBezierCurve;
  51524. private _selectionFeature;
  51525. private _snapToPositions;
  51526. private _snappedToPoint;
  51527. private _teleportationRingMaterial?;
  51528. private _tmpRay;
  51529. private _tmpVector;
  51530. private _tmpQuaternion;
  51531. /**
  51532. * The module's name
  51533. */
  51534. static readonly Name: string;
  51535. /**
  51536. * The (Babylon) version of this module.
  51537. * This is an integer representing the implementation version.
  51538. * This number does not correspond to the webxr specs version
  51539. */
  51540. static readonly Version: number;
  51541. /**
  51542. * Is movement backwards enabled
  51543. */
  51544. backwardsMovementEnabled: boolean;
  51545. /**
  51546. * Distance to travel when moving backwards
  51547. */
  51548. backwardsTeleportationDistance: number;
  51549. /**
  51550. * The distance from the user to the inspection point in the direction of the controller
  51551. * A higher number will allow the user to move further
  51552. * defaults to 5 (meters, in xr units)
  51553. */
  51554. parabolicCheckRadius: number;
  51555. /**
  51556. * Should the module support parabolic ray on top of direct ray
  51557. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51558. * Very helpful when moving between floors / different heights
  51559. */
  51560. parabolicRayEnabled: boolean;
  51561. /**
  51562. * How much rotation should be applied when rotating right and left
  51563. */
  51564. rotationAngle: number;
  51565. /**
  51566. * Is rotation enabled when moving forward?
  51567. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51568. */
  51569. rotationEnabled: boolean;
  51570. /**
  51571. * constructs a new anchor system
  51572. * @param _xrSessionManager an instance of WebXRSessionManager
  51573. * @param _options configuration object for this feature
  51574. */
  51575. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51576. /**
  51577. * Get the snapPointsOnly flag
  51578. */
  51579. get snapPointsOnly(): boolean;
  51580. /**
  51581. * Sets the snapPointsOnly flag
  51582. * @param snapToPoints should teleportation be exclusively to snap points
  51583. */
  51584. set snapPointsOnly(snapToPoints: boolean);
  51585. /**
  51586. * Add a new mesh to the floor meshes array
  51587. * @param mesh the mesh to use as floor mesh
  51588. */
  51589. addFloorMesh(mesh: AbstractMesh): void;
  51590. /**
  51591. * Add a new snap-to point to fix teleportation to this position
  51592. * @param newSnapPoint The new Snap-To point
  51593. */
  51594. addSnapPoint(newSnapPoint: Vector3): void;
  51595. attach(): boolean;
  51596. detach(): boolean;
  51597. dispose(): void;
  51598. /**
  51599. * Remove a mesh from the floor meshes array
  51600. * @param mesh the mesh to remove
  51601. */
  51602. removeFloorMesh(mesh: AbstractMesh): void;
  51603. /**
  51604. * Remove a mesh from the floor meshes array using its name
  51605. * @param name the mesh name to remove
  51606. */
  51607. removeFloorMeshByName(name: string): void;
  51608. /**
  51609. * 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
  51610. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51611. * @returns was the point found and removed or not
  51612. */
  51613. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51614. /**
  51615. * This function sets a selection feature that will be disabled when
  51616. * the forward ray is shown and will be reattached when hidden.
  51617. * This is used to remove the selection rays when moving.
  51618. * @param selectionFeature the feature to disable when forward movement is enabled
  51619. */
  51620. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51621. protected _onXRFrame(_xrFrame: XRFrame): void;
  51622. private _attachController;
  51623. private _createDefaultTargetMesh;
  51624. private _detachController;
  51625. private _findClosestSnapPointWithRadius;
  51626. private _setTargetMeshPosition;
  51627. private _setTargetMeshVisibility;
  51628. private _showParabolicPath;
  51629. private _teleportForward;
  51630. }
  51631. }
  51632. declare module "babylonjs/XR/webXRDefaultExperience" {
  51633. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51634. import { Scene } from "babylonjs/scene";
  51635. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51636. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51637. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51638. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51640. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51641. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51642. /**
  51643. * Options for the default xr helper
  51644. */
  51645. export class WebXRDefaultExperienceOptions {
  51646. /**
  51647. * Enable or disable default UI to enter XR
  51648. */
  51649. disableDefaultUI?: boolean;
  51650. /**
  51651. * Should teleportation not initialize. defaults to false.
  51652. */
  51653. disableTeleportation?: boolean;
  51654. /**
  51655. * Floor meshes that will be used for teleport
  51656. */
  51657. floorMeshes?: Array<AbstractMesh>;
  51658. /**
  51659. * If set to true, the first frame will not be used to reset position
  51660. * The first frame is mainly used when copying transformation from the old camera
  51661. * Mainly used in AR
  51662. */
  51663. ignoreNativeCameraTransformation?: boolean;
  51664. /**
  51665. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51666. */
  51667. inputOptions?: IWebXRInputOptions;
  51668. /**
  51669. * optional configuration for the output canvas
  51670. */
  51671. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51672. /**
  51673. * optional UI options. This can be used among other to change session mode and reference space type
  51674. */
  51675. uiOptions?: WebXREnterExitUIOptions;
  51676. /**
  51677. * When loading teleportation and pointer select, use stable versions instead of latest.
  51678. */
  51679. useStablePlugins?: boolean;
  51680. /**
  51681. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51682. */
  51683. renderingGroupId?: number;
  51684. /**
  51685. * A list of optional features to init the session with
  51686. * If set to true, all features we support will be added
  51687. */
  51688. optionalFeatures?: boolean | string[];
  51689. }
  51690. /**
  51691. * Default experience which provides a similar setup to the previous webVRExperience
  51692. */
  51693. export class WebXRDefaultExperience {
  51694. /**
  51695. * Base experience
  51696. */
  51697. baseExperience: WebXRExperienceHelper;
  51698. /**
  51699. * Enables ui for entering/exiting xr
  51700. */
  51701. enterExitUI: WebXREnterExitUI;
  51702. /**
  51703. * Input experience extension
  51704. */
  51705. input: WebXRInput;
  51706. /**
  51707. * Enables laser pointer and selection
  51708. */
  51709. pointerSelection: WebXRControllerPointerSelection;
  51710. /**
  51711. * Default target xr should render to
  51712. */
  51713. renderTarget: WebXRRenderTarget;
  51714. /**
  51715. * Enables teleportation
  51716. */
  51717. teleportation: WebXRMotionControllerTeleportation;
  51718. private constructor();
  51719. /**
  51720. * Creates the default xr experience
  51721. * @param scene scene
  51722. * @param options options for basic configuration
  51723. * @returns resulting WebXRDefaultExperience
  51724. */
  51725. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51726. /**
  51727. * DIsposes of the experience helper
  51728. */
  51729. dispose(): void;
  51730. }
  51731. }
  51732. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51733. import { Observable } from "babylonjs/Misc/observable";
  51734. import { Nullable } from "babylonjs/types";
  51735. import { Camera } from "babylonjs/Cameras/camera";
  51736. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51737. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51738. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51739. import { Scene } from "babylonjs/scene";
  51740. import { Vector3 } from "babylonjs/Maths/math.vector";
  51741. import { Color3 } from "babylonjs/Maths/math.color";
  51742. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51744. import { Mesh } from "babylonjs/Meshes/mesh";
  51745. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51746. import { EasingFunction } from "babylonjs/Animations/easing";
  51747. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51748. import "babylonjs/Meshes/Builders/groundBuilder";
  51749. import "babylonjs/Meshes/Builders/torusBuilder";
  51750. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51751. import "babylonjs/Gamepads/gamepadSceneComponent";
  51752. import "babylonjs/Animations/animatable";
  51753. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51754. /**
  51755. * Options to modify the vr teleportation behavior.
  51756. */
  51757. export interface VRTeleportationOptions {
  51758. /**
  51759. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51760. */
  51761. floorMeshName?: string;
  51762. /**
  51763. * A list of meshes to be used as the teleportation floor. (default: empty)
  51764. */
  51765. floorMeshes?: Mesh[];
  51766. /**
  51767. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51768. */
  51769. teleportationMode?: number;
  51770. /**
  51771. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51772. */
  51773. teleportationTime?: number;
  51774. /**
  51775. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51776. */
  51777. teleportationSpeed?: number;
  51778. /**
  51779. * The easing function used in the animation or null for Linear. (default CircleEase)
  51780. */
  51781. easingFunction?: EasingFunction;
  51782. }
  51783. /**
  51784. * Options to modify the vr experience helper's behavior.
  51785. */
  51786. export interface VRExperienceHelperOptions extends WebVROptions {
  51787. /**
  51788. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51789. */
  51790. createDeviceOrientationCamera?: boolean;
  51791. /**
  51792. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51793. */
  51794. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51795. /**
  51796. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51797. */
  51798. laserToggle?: boolean;
  51799. /**
  51800. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51801. */
  51802. floorMeshes?: Mesh[];
  51803. /**
  51804. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51805. */
  51806. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51807. /**
  51808. * Defines if WebXR should be used instead of WebVR (if available)
  51809. */
  51810. useXR?: boolean;
  51811. }
  51812. /**
  51813. * Event containing information after VR has been entered
  51814. */
  51815. export class OnAfterEnteringVRObservableEvent {
  51816. /**
  51817. * If entering vr was successful
  51818. */
  51819. success: boolean;
  51820. }
  51821. /**
  51822. * Helps to quickly add VR support to an existing scene.
  51823. * See https://doc.babylonjs.com/how_to/webvr_helper
  51824. */
  51825. export class VRExperienceHelper {
  51826. /** Options to modify the vr experience helper's behavior. */
  51827. webVROptions: VRExperienceHelperOptions;
  51828. private _scene;
  51829. private _position;
  51830. private _btnVR;
  51831. private _btnVRDisplayed;
  51832. private _webVRsupported;
  51833. private _webVRready;
  51834. private _webVRrequesting;
  51835. private _webVRpresenting;
  51836. private _hasEnteredVR;
  51837. private _fullscreenVRpresenting;
  51838. private _inputElement;
  51839. private _webVRCamera;
  51840. private _vrDeviceOrientationCamera;
  51841. private _deviceOrientationCamera;
  51842. private _existingCamera;
  51843. private _onKeyDown;
  51844. private _onVrDisplayPresentChange;
  51845. private _onVRDisplayChanged;
  51846. private _onVRRequestPresentStart;
  51847. private _onVRRequestPresentComplete;
  51848. /**
  51849. * 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)
  51850. */
  51851. enableGazeEvenWhenNoPointerLock: boolean;
  51852. /**
  51853. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51854. */
  51855. exitVROnDoubleTap: boolean;
  51856. /**
  51857. * Observable raised right before entering VR.
  51858. */
  51859. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51860. /**
  51861. * Observable raised when entering VR has completed.
  51862. */
  51863. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51864. /**
  51865. * Observable raised when exiting VR.
  51866. */
  51867. onExitingVRObservable: Observable<VRExperienceHelper>;
  51868. /**
  51869. * Observable raised when controller mesh is loaded.
  51870. */
  51871. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51872. /** Return this.onEnteringVRObservable
  51873. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51874. */
  51875. get onEnteringVR(): Observable<VRExperienceHelper>;
  51876. /** Return this.onExitingVRObservable
  51877. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51878. */
  51879. get onExitingVR(): Observable<VRExperienceHelper>;
  51880. /** Return this.onControllerMeshLoadedObservable
  51881. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51882. */
  51883. get onControllerMeshLoaded(): Observable<WebVRController>;
  51884. private _rayLength;
  51885. private _useCustomVRButton;
  51886. private _teleportationRequested;
  51887. private _teleportActive;
  51888. private _floorMeshName;
  51889. private _floorMeshesCollection;
  51890. private _teleportationMode;
  51891. private _teleportationTime;
  51892. private _teleportationSpeed;
  51893. private _teleportationEasing;
  51894. private _rotationAllowed;
  51895. private _teleportBackwardsVector;
  51896. private _teleportationTarget;
  51897. private _isDefaultTeleportationTarget;
  51898. private _postProcessMove;
  51899. private _teleportationFillColor;
  51900. private _teleportationBorderColor;
  51901. private _rotationAngle;
  51902. private _haloCenter;
  51903. private _cameraGazer;
  51904. private _padSensibilityUp;
  51905. private _padSensibilityDown;
  51906. private _leftController;
  51907. private _rightController;
  51908. private _gazeColor;
  51909. private _laserColor;
  51910. private _pickedLaserColor;
  51911. private _pickedGazeColor;
  51912. /**
  51913. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51914. */
  51915. onNewMeshSelected: Observable<AbstractMesh>;
  51916. /**
  51917. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51918. * This observable will provide the mesh and the controller used to select the mesh
  51919. */
  51920. onMeshSelectedWithController: Observable<{
  51921. mesh: AbstractMesh;
  51922. controller: WebVRController;
  51923. }>;
  51924. /**
  51925. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51926. */
  51927. onNewMeshPicked: Observable<PickingInfo>;
  51928. private _circleEase;
  51929. /**
  51930. * Observable raised before camera teleportation
  51931. */
  51932. onBeforeCameraTeleport: Observable<Vector3>;
  51933. /**
  51934. * Observable raised after camera teleportation
  51935. */
  51936. onAfterCameraTeleport: Observable<Vector3>;
  51937. /**
  51938. * Observable raised when current selected mesh gets unselected
  51939. */
  51940. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51941. private _raySelectionPredicate;
  51942. /**
  51943. * To be optionaly changed by user to define custom ray selection
  51944. */
  51945. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51946. /**
  51947. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51948. */
  51949. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51950. /**
  51951. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51952. */
  51953. teleportationEnabled: boolean;
  51954. private _defaultHeight;
  51955. private _teleportationInitialized;
  51956. private _interactionsEnabled;
  51957. private _interactionsRequested;
  51958. private _displayGaze;
  51959. private _displayLaserPointer;
  51960. /**
  51961. * The mesh used to display where the user is going to teleport.
  51962. */
  51963. get teleportationTarget(): Mesh;
  51964. /**
  51965. * Sets the mesh to be used to display where the user is going to teleport.
  51966. */
  51967. set teleportationTarget(value: Mesh);
  51968. /**
  51969. * 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
  51970. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51971. * See https://doc.babylonjs.com/resources/baking_transformations
  51972. */
  51973. get gazeTrackerMesh(): Mesh;
  51974. set gazeTrackerMesh(value: Mesh);
  51975. /**
  51976. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51977. */
  51978. updateGazeTrackerScale: boolean;
  51979. /**
  51980. * If the gaze trackers color should be updated when selecting meshes
  51981. */
  51982. updateGazeTrackerColor: boolean;
  51983. /**
  51984. * If the controller laser color should be updated when selecting meshes
  51985. */
  51986. updateControllerLaserColor: boolean;
  51987. /**
  51988. * The gaze tracking mesh corresponding to the left controller
  51989. */
  51990. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51991. /**
  51992. * The gaze tracking mesh corresponding to the right controller
  51993. */
  51994. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51995. /**
  51996. * If the ray of the gaze should be displayed.
  51997. */
  51998. get displayGaze(): boolean;
  51999. /**
  52000. * Sets if the ray of the gaze should be displayed.
  52001. */
  52002. set displayGaze(value: boolean);
  52003. /**
  52004. * If the ray of the LaserPointer should be displayed.
  52005. */
  52006. get displayLaserPointer(): boolean;
  52007. /**
  52008. * Sets if the ray of the LaserPointer should be displayed.
  52009. */
  52010. set displayLaserPointer(value: boolean);
  52011. /**
  52012. * The deviceOrientationCamera used as the camera when not in VR.
  52013. */
  52014. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52015. /**
  52016. * Based on the current WebVR support, returns the current VR camera used.
  52017. */
  52018. get currentVRCamera(): Nullable<Camera>;
  52019. /**
  52020. * The webVRCamera which is used when in VR.
  52021. */
  52022. get webVRCamera(): WebVRFreeCamera;
  52023. /**
  52024. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52025. */
  52026. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52027. /**
  52028. * The html button that is used to trigger entering into VR.
  52029. */
  52030. get vrButton(): Nullable<HTMLButtonElement>;
  52031. private get _teleportationRequestInitiated();
  52032. /**
  52033. * Defines whether or not Pointer lock should be requested when switching to
  52034. * full screen.
  52035. */
  52036. requestPointerLockOnFullScreen: boolean;
  52037. /**
  52038. * If asking to force XR, this will be populated with the default xr experience
  52039. */
  52040. xr: WebXRDefaultExperience;
  52041. /**
  52042. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52043. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52044. */
  52045. xrTestDone: boolean;
  52046. /**
  52047. * Instantiates a VRExperienceHelper.
  52048. * Helps to quickly add VR support to an existing scene.
  52049. * @param scene The scene the VRExperienceHelper belongs to.
  52050. * @param webVROptions Options to modify the vr experience helper's behavior.
  52051. */
  52052. constructor(scene: Scene,
  52053. /** Options to modify the vr experience helper's behavior. */
  52054. webVROptions?: VRExperienceHelperOptions);
  52055. private completeVRInit;
  52056. private _onDefaultMeshLoaded;
  52057. private _onResize;
  52058. private _onFullscreenChange;
  52059. /**
  52060. * Gets a value indicating if we are currently in VR mode.
  52061. */
  52062. get isInVRMode(): boolean;
  52063. private onVrDisplayPresentChange;
  52064. private onVRDisplayChanged;
  52065. private moveButtonToBottomRight;
  52066. private displayVRButton;
  52067. private updateButtonVisibility;
  52068. private _cachedAngularSensibility;
  52069. /**
  52070. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52071. * Otherwise, will use the fullscreen API.
  52072. */
  52073. enterVR(): void;
  52074. /**
  52075. * Attempt to exit VR, or fullscreen.
  52076. */
  52077. exitVR(): void;
  52078. /**
  52079. * The position of the vr experience helper.
  52080. */
  52081. get position(): Vector3;
  52082. /**
  52083. * Sets the position of the vr experience helper.
  52084. */
  52085. set position(value: Vector3);
  52086. /**
  52087. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52088. */
  52089. enableInteractions(): void;
  52090. private get _noControllerIsActive();
  52091. private beforeRender;
  52092. private _isTeleportationFloor;
  52093. /**
  52094. * Adds a floor mesh to be used for teleportation.
  52095. * @param floorMesh the mesh to be used for teleportation.
  52096. */
  52097. addFloorMesh(floorMesh: Mesh): void;
  52098. /**
  52099. * Removes a floor mesh from being used for teleportation.
  52100. * @param floorMesh the mesh to be removed.
  52101. */
  52102. removeFloorMesh(floorMesh: Mesh): void;
  52103. /**
  52104. * Enables interactions and teleportation using the VR controllers and gaze.
  52105. * @param vrTeleportationOptions options to modify teleportation behavior.
  52106. */
  52107. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52108. private _onNewGamepadConnected;
  52109. private _tryEnableInteractionOnController;
  52110. private _onNewGamepadDisconnected;
  52111. private _enableInteractionOnController;
  52112. private _checkTeleportWithRay;
  52113. private _checkRotate;
  52114. private _checkTeleportBackwards;
  52115. private _enableTeleportationOnController;
  52116. private _createTeleportationCircles;
  52117. private _displayTeleportationTarget;
  52118. private _hideTeleportationTarget;
  52119. private _rotateCamera;
  52120. private _moveTeleportationSelectorTo;
  52121. private _workingVector;
  52122. private _workingQuaternion;
  52123. private _workingMatrix;
  52124. /**
  52125. * Time Constant Teleportation Mode
  52126. */
  52127. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52128. /**
  52129. * Speed Constant Teleportation Mode
  52130. */
  52131. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52132. /**
  52133. * Teleports the users feet to the desired location
  52134. * @param location The location where the user's feet should be placed
  52135. */
  52136. teleportCamera(location: Vector3): void;
  52137. private _convertNormalToDirectionOfRay;
  52138. private _castRayAndSelectObject;
  52139. private _notifySelectedMeshUnselected;
  52140. /**
  52141. * Permanently set new colors for the laser pointer
  52142. * @param color the new laser color
  52143. * @param pickedColor the new laser color when picked mesh detected
  52144. */
  52145. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52146. /**
  52147. * Set lighting enabled / disabled on the laser pointer of both controllers
  52148. * @param enabled should the lighting be enabled on the laser pointer
  52149. */
  52150. setLaserLightingState(enabled?: boolean): void;
  52151. /**
  52152. * Permanently set new colors for the gaze pointer
  52153. * @param color the new gaze color
  52154. * @param pickedColor the new gaze color when picked mesh detected
  52155. */
  52156. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52157. /**
  52158. * Sets the color of the laser ray from the vr controllers.
  52159. * @param color new color for the ray.
  52160. */
  52161. changeLaserColor(color: Color3): void;
  52162. /**
  52163. * Sets the color of the ray from the vr headsets gaze.
  52164. * @param color new color for the ray.
  52165. */
  52166. changeGazeColor(color: Color3): void;
  52167. /**
  52168. * Exits VR and disposes of the vr experience helper
  52169. */
  52170. dispose(): void;
  52171. /**
  52172. * Gets the name of the VRExperienceHelper class
  52173. * @returns "VRExperienceHelper"
  52174. */
  52175. getClassName(): string;
  52176. }
  52177. }
  52178. declare module "babylonjs/Cameras/VR/index" {
  52179. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52180. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52181. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52182. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52183. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52184. export * from "babylonjs/Cameras/VR/webVRCamera";
  52185. }
  52186. declare module "babylonjs/Cameras/RigModes/index" {
  52187. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52188. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52189. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52190. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52191. }
  52192. declare module "babylonjs/Cameras/index" {
  52193. export * from "babylonjs/Cameras/Inputs/index";
  52194. export * from "babylonjs/Cameras/cameraInputsManager";
  52195. export * from "babylonjs/Cameras/camera";
  52196. export * from "babylonjs/Cameras/targetCamera";
  52197. export * from "babylonjs/Cameras/freeCamera";
  52198. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52199. export * from "babylonjs/Cameras/touchCamera";
  52200. export * from "babylonjs/Cameras/arcRotateCamera";
  52201. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52202. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52203. export * from "babylonjs/Cameras/flyCamera";
  52204. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52205. export * from "babylonjs/Cameras/followCamera";
  52206. export * from "babylonjs/Cameras/followCameraInputsManager";
  52207. export * from "babylonjs/Cameras/gamepadCamera";
  52208. export * from "babylonjs/Cameras/Stereoscopic/index";
  52209. export * from "babylonjs/Cameras/universalCamera";
  52210. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52211. export * from "babylonjs/Cameras/VR/index";
  52212. export * from "babylonjs/Cameras/RigModes/index";
  52213. }
  52214. declare module "babylonjs/Collisions/index" {
  52215. export * from "babylonjs/Collisions/collider";
  52216. export * from "babylonjs/Collisions/collisionCoordinator";
  52217. export * from "babylonjs/Collisions/pickingInfo";
  52218. export * from "babylonjs/Collisions/intersectionInfo";
  52219. export * from "babylonjs/Collisions/meshCollisionData";
  52220. }
  52221. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52222. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52223. import { Vector3 } from "babylonjs/Maths/math.vector";
  52224. import { Ray } from "babylonjs/Culling/ray";
  52225. import { Plane } from "babylonjs/Maths/math.plane";
  52226. /**
  52227. * Contains an array of blocks representing the octree
  52228. */
  52229. export interface IOctreeContainer<T> {
  52230. /**
  52231. * Blocks within the octree
  52232. */
  52233. blocks: Array<OctreeBlock<T>>;
  52234. }
  52235. /**
  52236. * Class used to store a cell in an octree
  52237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52238. */
  52239. export class OctreeBlock<T> {
  52240. /**
  52241. * Gets the content of the current block
  52242. */
  52243. entries: T[];
  52244. /**
  52245. * Gets the list of block children
  52246. */
  52247. blocks: Array<OctreeBlock<T>>;
  52248. private _depth;
  52249. private _maxDepth;
  52250. private _capacity;
  52251. private _minPoint;
  52252. private _maxPoint;
  52253. private _boundingVectors;
  52254. private _creationFunc;
  52255. /**
  52256. * Creates a new block
  52257. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52258. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52259. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52260. * @param depth defines the current depth of this block in the octree
  52261. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52262. * @param creationFunc defines a callback to call when an element is added to the block
  52263. */
  52264. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52265. /**
  52266. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52267. */
  52268. get capacity(): number;
  52269. /**
  52270. * Gets the minimum vector (in world space) of the block's bounding box
  52271. */
  52272. get minPoint(): Vector3;
  52273. /**
  52274. * Gets the maximum vector (in world space) of the block's bounding box
  52275. */
  52276. get maxPoint(): Vector3;
  52277. /**
  52278. * Add a new element to this block
  52279. * @param entry defines the element to add
  52280. */
  52281. addEntry(entry: T): void;
  52282. /**
  52283. * Remove an element from this block
  52284. * @param entry defines the element to remove
  52285. */
  52286. removeEntry(entry: T): void;
  52287. /**
  52288. * Add an array of elements to this block
  52289. * @param entries defines the array of elements to add
  52290. */
  52291. addEntries(entries: T[]): void;
  52292. /**
  52293. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52294. * @param frustumPlanes defines the frustum planes to test
  52295. * @param selection defines the array to store current content if selection is positive
  52296. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52297. */
  52298. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52299. /**
  52300. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52301. * @param sphereCenter defines the bounding sphere center
  52302. * @param sphereRadius defines the bounding sphere radius
  52303. * @param selection defines the array to store current content if selection is positive
  52304. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52305. */
  52306. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52307. /**
  52308. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52309. * @param ray defines the ray to test with
  52310. * @param selection defines the array to store current content if selection is positive
  52311. */
  52312. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52313. /**
  52314. * Subdivide the content into child blocks (this block will then be empty)
  52315. */
  52316. createInnerBlocks(): void;
  52317. /**
  52318. * @hidden
  52319. */
  52320. 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;
  52321. }
  52322. }
  52323. declare module "babylonjs/Culling/Octrees/octree" {
  52324. import { SmartArray } from "babylonjs/Misc/smartArray";
  52325. import { Vector3 } from "babylonjs/Maths/math.vector";
  52326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52328. import { Ray } from "babylonjs/Culling/ray";
  52329. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52330. import { Plane } from "babylonjs/Maths/math.plane";
  52331. /**
  52332. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52333. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52334. */
  52335. export class Octree<T> {
  52336. /** 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.) */
  52337. maxDepth: number;
  52338. /**
  52339. * Blocks within the octree containing objects
  52340. */
  52341. blocks: Array<OctreeBlock<T>>;
  52342. /**
  52343. * Content stored in the octree
  52344. */
  52345. dynamicContent: T[];
  52346. private _maxBlockCapacity;
  52347. private _selectionContent;
  52348. private _creationFunc;
  52349. /**
  52350. * Creates a octree
  52351. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52352. * @param creationFunc function to be used to instatiate the octree
  52353. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52354. * @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.)
  52355. */
  52356. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52357. /** 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.) */
  52358. maxDepth?: number);
  52359. /**
  52360. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52361. * @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);
  52362. * @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);
  52363. * @param entries meshes to be added to the octree blocks
  52364. */
  52365. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52366. /**
  52367. * Adds a mesh to the octree
  52368. * @param entry Mesh to add to the octree
  52369. */
  52370. addMesh(entry: T): void;
  52371. /**
  52372. * Remove an element from the octree
  52373. * @param entry defines the element to remove
  52374. */
  52375. removeMesh(entry: T): void;
  52376. /**
  52377. * Selects an array of meshes within the frustum
  52378. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52379. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52380. * @returns array of meshes within the frustum
  52381. */
  52382. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52383. /**
  52384. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52385. * @param sphereCenter defines the bounding sphere center
  52386. * @param sphereRadius defines the bounding sphere radius
  52387. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52388. * @returns an array of objects that intersect the sphere
  52389. */
  52390. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52391. /**
  52392. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52393. * @param ray defines the ray to test with
  52394. * @returns array of intersected objects
  52395. */
  52396. intersectsRay(ray: Ray): SmartArray<T>;
  52397. /**
  52398. * Adds a mesh into the octree block if it intersects the block
  52399. */
  52400. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52401. /**
  52402. * Adds a submesh into the octree block if it intersects the block
  52403. */
  52404. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52405. }
  52406. }
  52407. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52408. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52409. import { Scene } from "babylonjs/scene";
  52410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52412. import { Ray } from "babylonjs/Culling/ray";
  52413. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52414. import { Collider } from "babylonjs/Collisions/collider";
  52415. module "babylonjs/scene" {
  52416. interface Scene {
  52417. /**
  52418. * @hidden
  52419. * Backing Filed
  52420. */
  52421. _selectionOctree: Octree<AbstractMesh>;
  52422. /**
  52423. * Gets the octree used to boost mesh selection (picking)
  52424. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52425. */
  52426. selectionOctree: Octree<AbstractMesh>;
  52427. /**
  52428. * Creates or updates the octree used to boost selection (picking)
  52429. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52430. * @param maxCapacity defines the maximum capacity per leaf
  52431. * @param maxDepth defines the maximum depth of the octree
  52432. * @returns an octree of AbstractMesh
  52433. */
  52434. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52435. }
  52436. }
  52437. module "babylonjs/Meshes/abstractMesh" {
  52438. interface AbstractMesh {
  52439. /**
  52440. * @hidden
  52441. * Backing Field
  52442. */
  52443. _submeshesOctree: Octree<SubMesh>;
  52444. /**
  52445. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52446. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52447. * @param maxCapacity defines the maximum size of each block (64 by default)
  52448. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52449. * @returns the new octree
  52450. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52452. */
  52453. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52454. }
  52455. }
  52456. /**
  52457. * Defines the octree scene component responsible to manage any octrees
  52458. * in a given scene.
  52459. */
  52460. export class OctreeSceneComponent {
  52461. /**
  52462. * The component name help to identify the component in the list of scene components.
  52463. */
  52464. readonly name: string;
  52465. /**
  52466. * The scene the component belongs to.
  52467. */
  52468. scene: Scene;
  52469. /**
  52470. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52471. */
  52472. readonly checksIsEnabled: boolean;
  52473. /**
  52474. * Creates a new instance of the component for the given scene
  52475. * @param scene Defines the scene to register the component in
  52476. */
  52477. constructor(scene: Scene);
  52478. /**
  52479. * Registers the component in a given scene
  52480. */
  52481. register(): void;
  52482. /**
  52483. * Return the list of active meshes
  52484. * @returns the list of active meshes
  52485. */
  52486. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52487. /**
  52488. * Return the list of active sub meshes
  52489. * @param mesh The mesh to get the candidates sub meshes from
  52490. * @returns the list of active sub meshes
  52491. */
  52492. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52493. private _tempRay;
  52494. /**
  52495. * Return the list of sub meshes intersecting with a given local ray
  52496. * @param mesh defines the mesh to find the submesh for
  52497. * @param localRay defines the ray in local space
  52498. * @returns the list of intersecting sub meshes
  52499. */
  52500. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52501. /**
  52502. * Return the list of sub meshes colliding with a collider
  52503. * @param mesh defines the mesh to find the submesh for
  52504. * @param collider defines the collider to evaluate the collision against
  52505. * @returns the list of colliding sub meshes
  52506. */
  52507. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52508. /**
  52509. * Rebuilds the elements related to this component in case of
  52510. * context lost for instance.
  52511. */
  52512. rebuild(): void;
  52513. /**
  52514. * Disposes the component and the associated ressources.
  52515. */
  52516. dispose(): void;
  52517. }
  52518. }
  52519. declare module "babylonjs/Culling/Octrees/index" {
  52520. export * from "babylonjs/Culling/Octrees/octree";
  52521. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52522. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52523. }
  52524. declare module "babylonjs/Culling/index" {
  52525. export * from "babylonjs/Culling/boundingBox";
  52526. export * from "babylonjs/Culling/boundingInfo";
  52527. export * from "babylonjs/Culling/boundingSphere";
  52528. export * from "babylonjs/Culling/Octrees/index";
  52529. export * from "babylonjs/Culling/ray";
  52530. }
  52531. declare module "babylonjs/Gizmos/gizmo" {
  52532. import { Nullable } from "babylonjs/types";
  52533. import { IDisposable } from "babylonjs/scene";
  52534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52535. import { Mesh } from "babylonjs/Meshes/mesh";
  52536. import { Node } from "babylonjs/node";
  52537. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52538. /**
  52539. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52540. */
  52541. export class Gizmo implements IDisposable {
  52542. /** The utility layer the gizmo will be added to */
  52543. gizmoLayer: UtilityLayerRenderer;
  52544. /**
  52545. * The root mesh of the gizmo
  52546. */
  52547. _rootMesh: Mesh;
  52548. private _attachedMesh;
  52549. private _attachedNode;
  52550. /**
  52551. * Ratio for the scale of the gizmo (Default: 1)
  52552. */
  52553. protected _scaleRatio: number;
  52554. /**
  52555. * boolean updated by pointermove when a gizmo mesh is hovered
  52556. */
  52557. protected _isHovered: boolean;
  52558. /**
  52559. * Ratio for the scale of the gizmo (Default: 1)
  52560. */
  52561. set scaleRatio(value: number);
  52562. get scaleRatio(): number;
  52563. /**
  52564. * True when the mouse pointer is hovered a gizmo mesh
  52565. */
  52566. get isHovered(): boolean;
  52567. /**
  52568. * If a custom mesh has been set (Default: false)
  52569. */
  52570. protected _customMeshSet: boolean;
  52571. /**
  52572. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52573. * * When set, interactions will be enabled
  52574. */
  52575. get attachedMesh(): Nullable<AbstractMesh>;
  52576. set attachedMesh(value: Nullable<AbstractMesh>);
  52577. /**
  52578. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52579. * * When set, interactions will be enabled
  52580. */
  52581. get attachedNode(): Nullable<Node>;
  52582. set attachedNode(value: Nullable<Node>);
  52583. /**
  52584. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52585. * @param mesh The mesh to replace the default mesh of the gizmo
  52586. */
  52587. setCustomMesh(mesh: Mesh): void;
  52588. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52589. /**
  52590. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52591. */
  52592. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52593. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52594. /**
  52595. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52596. */
  52597. updateGizmoPositionToMatchAttachedMesh: boolean;
  52598. /**
  52599. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52600. */
  52601. updateScale: boolean;
  52602. protected _interactionsEnabled: boolean;
  52603. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52604. private _beforeRenderObserver;
  52605. private _tempQuaternion;
  52606. private _tempVector;
  52607. private _tempVector2;
  52608. private _tempMatrix1;
  52609. private _tempMatrix2;
  52610. private _rightHandtoLeftHandMatrix;
  52611. /**
  52612. * Creates a gizmo
  52613. * @param gizmoLayer The utility layer the gizmo will be added to
  52614. */
  52615. constructor(
  52616. /** The utility layer the gizmo will be added to */
  52617. gizmoLayer?: UtilityLayerRenderer);
  52618. /**
  52619. * Updates the gizmo to match the attached mesh's position/rotation
  52620. */
  52621. protected _update(): void;
  52622. /**
  52623. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52624. * @param value Node, TransformNode or mesh
  52625. */
  52626. protected _matrixChanged(): void;
  52627. /**
  52628. * Disposes of the gizmo
  52629. */
  52630. dispose(): void;
  52631. }
  52632. }
  52633. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52634. import { Observable } from "babylonjs/Misc/observable";
  52635. import { Nullable } from "babylonjs/types";
  52636. import { Vector3 } from "babylonjs/Maths/math.vector";
  52637. import { Color3 } from "babylonjs/Maths/math.color";
  52638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52639. import { Node } from "babylonjs/node";
  52640. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52641. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52642. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52643. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52644. import { Scene } from "babylonjs/scene";
  52645. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52646. /**
  52647. * Single plane drag gizmo
  52648. */
  52649. export class PlaneDragGizmo extends Gizmo {
  52650. /**
  52651. * Drag behavior responsible for the gizmos dragging interactions
  52652. */
  52653. dragBehavior: PointerDragBehavior;
  52654. private _pointerObserver;
  52655. /**
  52656. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52657. */
  52658. snapDistance: number;
  52659. /**
  52660. * Event that fires each time the gizmo snaps to a new location.
  52661. * * snapDistance is the the change in distance
  52662. */
  52663. onSnapObservable: Observable<{
  52664. snapDistance: number;
  52665. }>;
  52666. private _plane;
  52667. private _coloredMaterial;
  52668. private _hoverMaterial;
  52669. private _isEnabled;
  52670. private _parent;
  52671. /** @hidden */
  52672. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52673. /** @hidden */
  52674. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52675. /**
  52676. * Creates a PlaneDragGizmo
  52677. * @param gizmoLayer The utility layer the gizmo will be added to
  52678. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52679. * @param color The color of the gizmo
  52680. */
  52681. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52682. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52683. /**
  52684. * If the gizmo is enabled
  52685. */
  52686. set isEnabled(value: boolean);
  52687. get isEnabled(): boolean;
  52688. /**
  52689. * Disposes of the gizmo
  52690. */
  52691. dispose(): void;
  52692. }
  52693. }
  52694. declare module "babylonjs/Gizmos/positionGizmo" {
  52695. import { Observable } from "babylonjs/Misc/observable";
  52696. import { Nullable } from "babylonjs/types";
  52697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52698. import { Node } from "babylonjs/node";
  52699. import { Mesh } from "babylonjs/Meshes/mesh";
  52700. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52701. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52702. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52703. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52704. /**
  52705. * Gizmo that enables dragging a mesh along 3 axis
  52706. */
  52707. export class PositionGizmo extends Gizmo {
  52708. /**
  52709. * Internal gizmo used for interactions on the x axis
  52710. */
  52711. xGizmo: AxisDragGizmo;
  52712. /**
  52713. * Internal gizmo used for interactions on the y axis
  52714. */
  52715. yGizmo: AxisDragGizmo;
  52716. /**
  52717. * Internal gizmo used for interactions on the z axis
  52718. */
  52719. zGizmo: AxisDragGizmo;
  52720. /**
  52721. * Internal gizmo used for interactions on the yz plane
  52722. */
  52723. xPlaneGizmo: PlaneDragGizmo;
  52724. /**
  52725. * Internal gizmo used for interactions on the xz plane
  52726. */
  52727. yPlaneGizmo: PlaneDragGizmo;
  52728. /**
  52729. * Internal gizmo used for interactions on the xy plane
  52730. */
  52731. zPlaneGizmo: PlaneDragGizmo;
  52732. /**
  52733. * private variables
  52734. */
  52735. private _meshAttached;
  52736. private _nodeAttached;
  52737. private _snapDistance;
  52738. /** Fires an event when any of it's sub gizmos are dragged */
  52739. onDragStartObservable: Observable<unknown>;
  52740. /** Fires an event when any of it's sub gizmos are released from dragging */
  52741. onDragEndObservable: Observable<unknown>;
  52742. /**
  52743. * If set to true, planar drag is enabled
  52744. */
  52745. private _planarGizmoEnabled;
  52746. get attachedMesh(): Nullable<AbstractMesh>;
  52747. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52748. get attachedNode(): Nullable<Node>;
  52749. set attachedNode(node: Nullable<Node>);
  52750. /**
  52751. * True when the mouse pointer is hovering a gizmo mesh
  52752. */
  52753. get isHovered(): boolean;
  52754. /**
  52755. * Creates a PositionGizmo
  52756. * @param gizmoLayer The utility layer the gizmo will be added to
  52757. @param thickness display gizmo axis thickness
  52758. */
  52759. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52760. /**
  52761. * If the planar drag gizmo is enabled
  52762. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52763. */
  52764. set planarGizmoEnabled(value: boolean);
  52765. get planarGizmoEnabled(): boolean;
  52766. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52767. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52768. /**
  52769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52770. */
  52771. set snapDistance(value: number);
  52772. get snapDistance(): number;
  52773. /**
  52774. * Ratio for the scale of the gizmo (Default: 1)
  52775. */
  52776. set scaleRatio(value: number);
  52777. get scaleRatio(): number;
  52778. /**
  52779. * Disposes of the gizmo
  52780. */
  52781. dispose(): void;
  52782. /**
  52783. * CustomMeshes are not supported by this gizmo
  52784. * @param mesh The mesh to replace the default mesh of the gizmo
  52785. */
  52786. setCustomMesh(mesh: Mesh): void;
  52787. }
  52788. }
  52789. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52790. import { Observable } from "babylonjs/Misc/observable";
  52791. import { Nullable } from "babylonjs/types";
  52792. import { Vector3 } from "babylonjs/Maths/math.vector";
  52793. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52794. import { Node } from "babylonjs/node";
  52795. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52796. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52797. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52798. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52799. import { Scene } from "babylonjs/scene";
  52800. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52801. import { Color3 } from "babylonjs/Maths/math.color";
  52802. /**
  52803. * Single axis drag gizmo
  52804. */
  52805. export class AxisDragGizmo extends Gizmo {
  52806. /**
  52807. * Drag behavior responsible for the gizmos dragging interactions
  52808. */
  52809. dragBehavior: PointerDragBehavior;
  52810. private _pointerObserver;
  52811. /**
  52812. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52813. */
  52814. snapDistance: number;
  52815. /**
  52816. * Event that fires each time the gizmo snaps to a new location.
  52817. * * snapDistance is the the change in distance
  52818. */
  52819. onSnapObservable: Observable<{
  52820. snapDistance: number;
  52821. }>;
  52822. private _isEnabled;
  52823. private _parent;
  52824. private _arrow;
  52825. private _coloredMaterial;
  52826. private _hoverMaterial;
  52827. /** @hidden */
  52828. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52829. /** @hidden */
  52830. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52831. /**
  52832. * Creates an AxisDragGizmo
  52833. * @param gizmoLayer The utility layer the gizmo will be added to
  52834. * @param dragAxis The axis which the gizmo will be able to drag on
  52835. * @param color The color of the gizmo
  52836. * @param thickness display gizmo axis thickness
  52837. */
  52838. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52839. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52840. /**
  52841. * If the gizmo is enabled
  52842. */
  52843. set isEnabled(value: boolean);
  52844. get isEnabled(): boolean;
  52845. /**
  52846. * Disposes of the gizmo
  52847. */
  52848. dispose(): void;
  52849. }
  52850. }
  52851. declare module "babylonjs/Debug/axesViewer" {
  52852. import { Vector3 } from "babylonjs/Maths/math.vector";
  52853. import { Nullable } from "babylonjs/types";
  52854. import { Scene } from "babylonjs/scene";
  52855. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52856. /**
  52857. * The Axes viewer will show 3 axes in a specific point in space
  52858. */
  52859. export class AxesViewer {
  52860. private _xAxis;
  52861. private _yAxis;
  52862. private _zAxis;
  52863. private _scaleLinesFactor;
  52864. private _instanced;
  52865. /**
  52866. * Gets the hosting scene
  52867. */
  52868. scene: Nullable<Scene>;
  52869. /**
  52870. * Gets or sets a number used to scale line length
  52871. */
  52872. scaleLines: number;
  52873. /** Gets the node hierarchy used to render x-axis */
  52874. get xAxis(): TransformNode;
  52875. /** Gets the node hierarchy used to render y-axis */
  52876. get yAxis(): TransformNode;
  52877. /** Gets the node hierarchy used to render z-axis */
  52878. get zAxis(): TransformNode;
  52879. /**
  52880. * Creates a new AxesViewer
  52881. * @param scene defines the hosting scene
  52882. * @param scaleLines defines a number used to scale line length (1 by default)
  52883. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52884. * @param xAxis defines the node hierarchy used to render the x-axis
  52885. * @param yAxis defines the node hierarchy used to render the y-axis
  52886. * @param zAxis defines the node hierarchy used to render the z-axis
  52887. */
  52888. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52889. /**
  52890. * Force the viewer to update
  52891. * @param position defines the position of the viewer
  52892. * @param xaxis defines the x axis of the viewer
  52893. * @param yaxis defines the y axis of the viewer
  52894. * @param zaxis defines the z axis of the viewer
  52895. */
  52896. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52897. /**
  52898. * Creates an instance of this axes viewer.
  52899. * @returns a new axes viewer with instanced meshes
  52900. */
  52901. createInstance(): AxesViewer;
  52902. /** Releases resources */
  52903. dispose(): void;
  52904. private static _SetRenderingGroupId;
  52905. }
  52906. }
  52907. declare module "babylonjs/Debug/boneAxesViewer" {
  52908. import { Nullable } from "babylonjs/types";
  52909. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52910. import { Vector3 } from "babylonjs/Maths/math.vector";
  52911. import { Mesh } from "babylonjs/Meshes/mesh";
  52912. import { Bone } from "babylonjs/Bones/bone";
  52913. import { Scene } from "babylonjs/scene";
  52914. /**
  52915. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52916. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52917. */
  52918. export class BoneAxesViewer extends AxesViewer {
  52919. /**
  52920. * Gets or sets the target mesh where to display the axes viewer
  52921. */
  52922. mesh: Nullable<Mesh>;
  52923. /**
  52924. * Gets or sets the target bone where to display the axes viewer
  52925. */
  52926. bone: Nullable<Bone>;
  52927. /** Gets current position */
  52928. pos: Vector3;
  52929. /** Gets direction of X axis */
  52930. xaxis: Vector3;
  52931. /** Gets direction of Y axis */
  52932. yaxis: Vector3;
  52933. /** Gets direction of Z axis */
  52934. zaxis: Vector3;
  52935. /**
  52936. * Creates a new BoneAxesViewer
  52937. * @param scene defines the hosting scene
  52938. * @param bone defines the target bone
  52939. * @param mesh defines the target mesh
  52940. * @param scaleLines defines a scaling factor for line length (1 by default)
  52941. */
  52942. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52943. /**
  52944. * Force the viewer to update
  52945. */
  52946. update(): void;
  52947. /** Releases resources */
  52948. dispose(): void;
  52949. }
  52950. }
  52951. declare module "babylonjs/Debug/debugLayer" {
  52952. import { Scene } from "babylonjs/scene";
  52953. /**
  52954. * Interface used to define scene explorer extensibility option
  52955. */
  52956. export interface IExplorerExtensibilityOption {
  52957. /**
  52958. * Define the option label
  52959. */
  52960. label: string;
  52961. /**
  52962. * Defines the action to execute on click
  52963. */
  52964. action: (entity: any) => void;
  52965. }
  52966. /**
  52967. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52968. */
  52969. export interface IExplorerExtensibilityGroup {
  52970. /**
  52971. * Defines a predicate to test if a given type mut be extended
  52972. */
  52973. predicate: (entity: any) => boolean;
  52974. /**
  52975. * Gets the list of options added to a type
  52976. */
  52977. entries: IExplorerExtensibilityOption[];
  52978. }
  52979. /**
  52980. * Interface used to define the options to use to create the Inspector
  52981. */
  52982. export interface IInspectorOptions {
  52983. /**
  52984. * Display in overlay mode (default: false)
  52985. */
  52986. overlay?: boolean;
  52987. /**
  52988. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52989. */
  52990. globalRoot?: HTMLElement;
  52991. /**
  52992. * Display the Scene explorer
  52993. */
  52994. showExplorer?: boolean;
  52995. /**
  52996. * Display the property inspector
  52997. */
  52998. showInspector?: boolean;
  52999. /**
  53000. * Display in embed mode (both panes on the right)
  53001. */
  53002. embedMode?: boolean;
  53003. /**
  53004. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53005. */
  53006. handleResize?: boolean;
  53007. /**
  53008. * Allow the panes to popup (default: true)
  53009. */
  53010. enablePopup?: boolean;
  53011. /**
  53012. * Allow the panes to be closed by users (default: true)
  53013. */
  53014. enableClose?: boolean;
  53015. /**
  53016. * Optional list of extensibility entries
  53017. */
  53018. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53019. /**
  53020. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53021. */
  53022. inspectorURL?: string;
  53023. /**
  53024. * Optional initial tab (default to DebugLayerTab.Properties)
  53025. */
  53026. initialTab?: DebugLayerTab;
  53027. }
  53028. module "babylonjs/scene" {
  53029. interface Scene {
  53030. /**
  53031. * @hidden
  53032. * Backing field
  53033. */
  53034. _debugLayer: DebugLayer;
  53035. /**
  53036. * Gets the debug layer (aka Inspector) associated with the scene
  53037. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53038. */
  53039. debugLayer: DebugLayer;
  53040. }
  53041. }
  53042. /**
  53043. * Enum of inspector action tab
  53044. */
  53045. export enum DebugLayerTab {
  53046. /**
  53047. * Properties tag (default)
  53048. */
  53049. Properties = 0,
  53050. /**
  53051. * Debug tab
  53052. */
  53053. Debug = 1,
  53054. /**
  53055. * Statistics tab
  53056. */
  53057. Statistics = 2,
  53058. /**
  53059. * Tools tab
  53060. */
  53061. Tools = 3,
  53062. /**
  53063. * Settings tab
  53064. */
  53065. Settings = 4
  53066. }
  53067. /**
  53068. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53069. * what is happening in your scene
  53070. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53071. */
  53072. export class DebugLayer {
  53073. /**
  53074. * Define the url to get the inspector script from.
  53075. * By default it uses the babylonjs CDN.
  53076. * @ignoreNaming
  53077. */
  53078. static InspectorURL: string;
  53079. private _scene;
  53080. private BJSINSPECTOR;
  53081. private _onPropertyChangedObservable?;
  53082. /**
  53083. * Observable triggered when a property is changed through the inspector.
  53084. */
  53085. get onPropertyChangedObservable(): any;
  53086. /**
  53087. * Instantiates a new debug layer.
  53088. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53089. * what is happening in your scene
  53090. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53091. * @param scene Defines the scene to inspect
  53092. */
  53093. constructor(scene: Scene);
  53094. /** Creates the inspector window. */
  53095. private _createInspector;
  53096. /**
  53097. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53098. * @param entity defines the entity to select
  53099. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53100. */
  53101. select(entity: any, lineContainerTitles?: string | string[]): void;
  53102. /** Get the inspector from bundle or global */
  53103. private _getGlobalInspector;
  53104. /**
  53105. * Get if the inspector is visible or not.
  53106. * @returns true if visible otherwise, false
  53107. */
  53108. isVisible(): boolean;
  53109. /**
  53110. * Hide the inspector and close its window.
  53111. */
  53112. hide(): void;
  53113. /**
  53114. * Update the scene in the inspector
  53115. */
  53116. setAsActiveScene(): void;
  53117. /**
  53118. * Launch the debugLayer.
  53119. * @param config Define the configuration of the inspector
  53120. * @return a promise fulfilled when the debug layer is visible
  53121. */
  53122. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53123. }
  53124. }
  53125. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53126. import { Nullable } from "babylonjs/types";
  53127. import { Scene } from "babylonjs/scene";
  53128. import { Vector4 } from "babylonjs/Maths/math.vector";
  53129. import { Color4 } from "babylonjs/Maths/math.color";
  53130. import { Mesh } from "babylonjs/Meshes/mesh";
  53131. /**
  53132. * Class containing static functions to help procedurally build meshes
  53133. */
  53134. export class BoxBuilder {
  53135. /**
  53136. * Creates a box mesh
  53137. * * The parameter `size` sets the size (float) of each box side (default 1)
  53138. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53139. * * 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)
  53140. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53144. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53145. * @param name defines the name of the mesh
  53146. * @param options defines the options used to create the mesh
  53147. * @param scene defines the hosting scene
  53148. * @returns the box mesh
  53149. */
  53150. static CreateBox(name: string, options: {
  53151. size?: number;
  53152. width?: number;
  53153. height?: number;
  53154. depth?: number;
  53155. faceUV?: Vector4[];
  53156. faceColors?: Color4[];
  53157. sideOrientation?: number;
  53158. frontUVs?: Vector4;
  53159. backUVs?: Vector4;
  53160. wrap?: boolean;
  53161. topBaseAt?: number;
  53162. bottomBaseAt?: number;
  53163. updatable?: boolean;
  53164. }, scene?: Nullable<Scene>): Mesh;
  53165. }
  53166. }
  53167. declare module "babylonjs/Debug/physicsViewer" {
  53168. import { Nullable } from "babylonjs/types";
  53169. import { Scene } from "babylonjs/scene";
  53170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53171. import { Mesh } from "babylonjs/Meshes/mesh";
  53172. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53174. /**
  53175. * Used to show the physics impostor around the specific mesh
  53176. */
  53177. export class PhysicsViewer {
  53178. /** @hidden */
  53179. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53180. /** @hidden */
  53181. protected _meshes: Array<Nullable<AbstractMesh>>;
  53182. /** @hidden */
  53183. protected _scene: Nullable<Scene>;
  53184. /** @hidden */
  53185. protected _numMeshes: number;
  53186. /** @hidden */
  53187. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53188. private _renderFunction;
  53189. private _utilityLayer;
  53190. private _debugBoxMesh;
  53191. private _debugSphereMesh;
  53192. private _debugCylinderMesh;
  53193. private _debugMaterial;
  53194. private _debugMeshMeshes;
  53195. /**
  53196. * Creates a new PhysicsViewer
  53197. * @param scene defines the hosting scene
  53198. */
  53199. constructor(scene: Scene);
  53200. /** @hidden */
  53201. protected _updateDebugMeshes(): void;
  53202. /**
  53203. * Renders a specified physic impostor
  53204. * @param impostor defines the impostor to render
  53205. * @param targetMesh defines the mesh represented by the impostor
  53206. * @returns the new debug mesh used to render the impostor
  53207. */
  53208. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53209. /**
  53210. * Hides a specified physic impostor
  53211. * @param impostor defines the impostor to hide
  53212. */
  53213. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53214. private _getDebugMaterial;
  53215. private _getDebugBoxMesh;
  53216. private _getDebugSphereMesh;
  53217. private _getDebugCylinderMesh;
  53218. private _getDebugMeshMesh;
  53219. private _getDebugMesh;
  53220. /** Releases all resources */
  53221. dispose(): void;
  53222. }
  53223. }
  53224. declare module "babylonjs/Debug/rayHelper" {
  53225. import { Nullable } from "babylonjs/types";
  53226. import { Ray } from "babylonjs/Culling/ray";
  53227. import { Vector3 } from "babylonjs/Maths/math.vector";
  53228. import { Color3 } from "babylonjs/Maths/math.color";
  53229. import { Scene } from "babylonjs/scene";
  53230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53231. import "babylonjs/Meshes/Builders/linesBuilder";
  53232. /**
  53233. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53234. * in order to better appreciate the issue one might have.
  53235. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53236. */
  53237. export class RayHelper {
  53238. /**
  53239. * Defines the ray we are currently tryin to visualize.
  53240. */
  53241. ray: Nullable<Ray>;
  53242. private _renderPoints;
  53243. private _renderLine;
  53244. private _renderFunction;
  53245. private _scene;
  53246. private _onAfterRenderObserver;
  53247. private _onAfterStepObserver;
  53248. private _attachedToMesh;
  53249. private _meshSpaceDirection;
  53250. private _meshSpaceOrigin;
  53251. /**
  53252. * Helper function to create a colored helper in a scene in one line.
  53253. * @param ray Defines the ray we are currently tryin to visualize
  53254. * @param scene Defines the scene the ray is used in
  53255. * @param color Defines the color we want to see the ray in
  53256. * @returns The newly created ray helper.
  53257. */
  53258. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53259. /**
  53260. * Instantiate a new ray helper.
  53261. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53262. * in order to better appreciate the issue one might have.
  53263. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53264. * @param ray Defines the ray we are currently tryin to visualize
  53265. */
  53266. constructor(ray: Ray);
  53267. /**
  53268. * Shows the ray we are willing to debug.
  53269. * @param scene Defines the scene the ray needs to be rendered in
  53270. * @param color Defines the color the ray needs to be rendered in
  53271. */
  53272. show(scene: Scene, color?: Color3): void;
  53273. /**
  53274. * Hides the ray we are debugging.
  53275. */
  53276. hide(): void;
  53277. private _render;
  53278. /**
  53279. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53280. * @param mesh Defines the mesh we want the helper attached to
  53281. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53282. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53283. * @param length Defines the length of the ray
  53284. */
  53285. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53286. /**
  53287. * Detach the ray helper from the mesh it has previously been attached to.
  53288. */
  53289. detachFromMesh(): void;
  53290. private _updateToMesh;
  53291. /**
  53292. * Dispose the helper and release its associated resources.
  53293. */
  53294. dispose(): void;
  53295. }
  53296. }
  53297. declare module "babylonjs/Debug/ISkeletonViewer" {
  53298. import { Skeleton } from "babylonjs/Bones/skeleton";
  53299. import { Color3 } from "babylonjs/Maths/math.color";
  53300. /**
  53301. * Defines the options associated with the creation of a SkeletonViewer.
  53302. */
  53303. export interface ISkeletonViewerOptions {
  53304. /** Should the system pause animations before building the Viewer? */
  53305. pauseAnimations: boolean;
  53306. /** Should the system return the skeleton to rest before building? */
  53307. returnToRest: boolean;
  53308. /** public Display Mode of the Viewer */
  53309. displayMode: number;
  53310. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53311. displayOptions: ISkeletonViewerDisplayOptions;
  53312. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53313. computeBonesUsingShaders: boolean;
  53314. /** Flag ignore non weighted bones */
  53315. useAllBones: boolean;
  53316. }
  53317. /**
  53318. * Defines how to display the various bone meshes for the viewer.
  53319. */
  53320. export interface ISkeletonViewerDisplayOptions {
  53321. /** How far down to start tapering the bone spurs */
  53322. midStep?: number;
  53323. /** How big is the midStep? */
  53324. midStepFactor?: number;
  53325. /** Base for the Sphere Size */
  53326. sphereBaseSize?: number;
  53327. /** The ratio of the sphere to the longest bone in units */
  53328. sphereScaleUnit?: number;
  53329. /** Ratio for the Sphere Size */
  53330. sphereFactor?: number;
  53331. /** Whether a spur should attach its far end to the child bone position */
  53332. spurFollowsChild?: boolean;
  53333. /** Whether to show local axes or not */
  53334. showLocalAxes?: boolean;
  53335. /** Length of each local axis */
  53336. localAxesSize?: number;
  53337. }
  53338. /**
  53339. * Defines the constructor options for the BoneWeight Shader.
  53340. */
  53341. export interface IBoneWeightShaderOptions {
  53342. /** Skeleton to Map */
  53343. skeleton: Skeleton;
  53344. /** Colors for Uninfluenced bones */
  53345. colorBase?: Color3;
  53346. /** Colors for 0.0-0.25 Weight bones */
  53347. colorZero?: Color3;
  53348. /** Color for 0.25-0.5 Weight Influence */
  53349. colorQuarter?: Color3;
  53350. /** Color for 0.5-0.75 Weight Influence */
  53351. colorHalf?: Color3;
  53352. /** Color for 0.75-1 Weight Influence */
  53353. colorFull?: Color3;
  53354. /** Color for Zero Weight Influence */
  53355. targetBoneIndex?: number;
  53356. }
  53357. /**
  53358. * Simple structure of the gradient steps for the Color Map.
  53359. */
  53360. export interface ISkeletonMapShaderColorMapKnot {
  53361. /** Color of the Knot */
  53362. color: Color3;
  53363. /** Location of the Knot */
  53364. location: number;
  53365. }
  53366. /**
  53367. * Defines the constructor options for the SkeletonMap Shader.
  53368. */
  53369. export interface ISkeletonMapShaderOptions {
  53370. /** Skeleton to Map */
  53371. skeleton: Skeleton;
  53372. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53373. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53374. }
  53375. }
  53376. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53377. import { Nullable } from "babylonjs/types";
  53378. import { Scene } from "babylonjs/scene";
  53379. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53380. import { Color4 } from "babylonjs/Maths/math.color";
  53381. import { Mesh } from "babylonjs/Meshes/mesh";
  53382. /**
  53383. * Class containing static functions to help procedurally build meshes
  53384. */
  53385. export class RibbonBuilder {
  53386. /**
  53387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53391. * * 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
  53392. * * 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
  53393. * * 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
  53394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53397. * * 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
  53398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53399. * * 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
  53400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53402. * @param name defines the name of the mesh
  53403. * @param options defines the options used to create the mesh
  53404. * @param scene defines the hosting scene
  53405. * @returns the ribbon mesh
  53406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53408. */
  53409. static CreateRibbon(name: string, options: {
  53410. pathArray: Vector3[][];
  53411. closeArray?: boolean;
  53412. closePath?: boolean;
  53413. offset?: number;
  53414. updatable?: boolean;
  53415. sideOrientation?: number;
  53416. frontUVs?: Vector4;
  53417. backUVs?: Vector4;
  53418. instance?: Mesh;
  53419. invertUV?: boolean;
  53420. uvs?: Vector2[];
  53421. colors?: Color4[];
  53422. }, scene?: Nullable<Scene>): Mesh;
  53423. }
  53424. }
  53425. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53426. import { Nullable } from "babylonjs/types";
  53427. import { Scene } from "babylonjs/scene";
  53428. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53429. import { Mesh } from "babylonjs/Meshes/mesh";
  53430. /**
  53431. * Class containing static functions to help procedurally build meshes
  53432. */
  53433. export class ShapeBuilder {
  53434. /**
  53435. * 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.
  53436. * * 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.
  53437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53438. * * 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.
  53439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53440. * * 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
  53441. * * 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
  53442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53447. * @param name defines the name of the mesh
  53448. * @param options defines the options used to create the mesh
  53449. * @param scene defines the hosting scene
  53450. * @returns the extruded shape mesh
  53451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53453. */
  53454. static ExtrudeShape(name: string, options: {
  53455. shape: Vector3[];
  53456. path: Vector3[];
  53457. scale?: number;
  53458. rotation?: number;
  53459. cap?: number;
  53460. updatable?: boolean;
  53461. sideOrientation?: number;
  53462. frontUVs?: Vector4;
  53463. backUVs?: Vector4;
  53464. instance?: Mesh;
  53465. invertUV?: boolean;
  53466. }, scene?: Nullable<Scene>): Mesh;
  53467. /**
  53468. * Creates an custom extruded shape mesh.
  53469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53470. * * 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.
  53471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53472. * * 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
  53473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53474. * * 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
  53475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53478. * * 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
  53479. * * 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
  53480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53485. * @param name defines the name of the mesh
  53486. * @param options defines the options used to create the mesh
  53487. * @param scene defines the hosting scene
  53488. * @returns the custom extruded shape mesh
  53489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53492. */
  53493. static ExtrudeShapeCustom(name: string, options: {
  53494. shape: Vector3[];
  53495. path: Vector3[];
  53496. scaleFunction?: any;
  53497. rotationFunction?: any;
  53498. ribbonCloseArray?: boolean;
  53499. ribbonClosePath?: boolean;
  53500. cap?: number;
  53501. updatable?: boolean;
  53502. sideOrientation?: number;
  53503. frontUVs?: Vector4;
  53504. backUVs?: Vector4;
  53505. instance?: Mesh;
  53506. invertUV?: boolean;
  53507. }, scene?: Nullable<Scene>): Mesh;
  53508. private static _ExtrudeShapeGeneric;
  53509. }
  53510. }
  53511. declare module "babylonjs/Debug/skeletonViewer" {
  53512. import { Color3 } from "babylonjs/Maths/math.color";
  53513. import { Scene } from "babylonjs/scene";
  53514. import { Nullable } from "babylonjs/types";
  53515. import { Skeleton } from "babylonjs/Bones/skeleton";
  53516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53517. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53519. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53520. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53521. /**
  53522. * Class used to render a debug view of a given skeleton
  53523. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53524. */
  53525. export class SkeletonViewer {
  53526. /** defines the skeleton to render */
  53527. skeleton: Skeleton;
  53528. /** defines the mesh attached to the skeleton */
  53529. mesh: AbstractMesh;
  53530. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53531. autoUpdateBonesMatrices: boolean;
  53532. /** defines the rendering group id to use with the viewer */
  53533. renderingGroupId: number;
  53534. /** is the options for the viewer */
  53535. options: Partial<ISkeletonViewerOptions>;
  53536. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53537. static readonly DISPLAY_LINES: number;
  53538. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53539. static readonly DISPLAY_SPHERES: number;
  53540. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53541. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53542. /** public static method to create a BoneWeight Shader
  53543. * @param options The constructor options
  53544. * @param scene The scene that the shader is scoped to
  53545. * @returns The created ShaderMaterial
  53546. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53547. */
  53548. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53549. /** public static method to create a BoneWeight Shader
  53550. * @param options The constructor options
  53551. * @param scene The scene that the shader is scoped to
  53552. * @returns The created ShaderMaterial
  53553. */
  53554. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53555. /** private static method to create a BoneWeight Shader
  53556. * @param size The size of the buffer to create (usually the bone count)
  53557. * @param colorMap The gradient data to generate
  53558. * @param scene The scene that the shader is scoped to
  53559. * @returns an Array of floats from the color gradient values
  53560. */
  53561. private static _CreateBoneMapColorBuffer;
  53562. /** If SkeletonViewer scene scope. */
  53563. private _scene;
  53564. /** Gets or sets the color used to render the skeleton */
  53565. color: Color3;
  53566. /** Array of the points of the skeleton fo the line view. */
  53567. private _debugLines;
  53568. /** The SkeletonViewers Mesh. */
  53569. private _debugMesh;
  53570. /** The local axes Meshes. */
  53571. private _localAxes;
  53572. /** If SkeletonViewer is enabled. */
  53573. private _isEnabled;
  53574. /** If SkeletonViewer is ready. */
  53575. private _ready;
  53576. /** SkeletonViewer render observable. */
  53577. private _obs;
  53578. /** The Utility Layer to render the gizmos in. */
  53579. private _utilityLayer;
  53580. private _boneIndices;
  53581. /** Gets the Scene. */
  53582. get scene(): Scene;
  53583. /** Gets the utilityLayer. */
  53584. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53585. /** Checks Ready Status. */
  53586. get isReady(): Boolean;
  53587. /** Sets Ready Status. */
  53588. set ready(value: boolean);
  53589. /** Gets the debugMesh */
  53590. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53591. /** Sets the debugMesh */
  53592. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53593. /** Gets the displayMode */
  53594. get displayMode(): number;
  53595. /** Sets the displayMode */
  53596. set displayMode(value: number);
  53597. /**
  53598. * Creates a new SkeletonViewer
  53599. * @param skeleton defines the skeleton to render
  53600. * @param mesh defines the mesh attached to the skeleton
  53601. * @param scene defines the hosting scene
  53602. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53603. * @param renderingGroupId defines the rendering group id to use with the viewer
  53604. * @param options All of the extra constructor options for the SkeletonViewer
  53605. */
  53606. constructor(
  53607. /** defines the skeleton to render */
  53608. skeleton: Skeleton,
  53609. /** defines the mesh attached to the skeleton */
  53610. mesh: AbstractMesh,
  53611. /** The Scene scope*/
  53612. scene: Scene,
  53613. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53614. autoUpdateBonesMatrices?: boolean,
  53615. /** defines the rendering group id to use with the viewer */
  53616. renderingGroupId?: number,
  53617. /** is the options for the viewer */
  53618. options?: Partial<ISkeletonViewerOptions>);
  53619. /** The Dynamic bindings for the update functions */
  53620. private _bindObs;
  53621. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53622. update(): void;
  53623. /** Gets or sets a boolean indicating if the viewer is enabled */
  53624. set isEnabled(value: boolean);
  53625. get isEnabled(): boolean;
  53626. private _getBonePosition;
  53627. private _getLinesForBonesWithLength;
  53628. private _getLinesForBonesNoLength;
  53629. /** function to revert the mesh and scene back to the initial state. */
  53630. private _revert;
  53631. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53632. private _getAbsoluteBindPoseToRef;
  53633. /** function to build and bind sphere joint points and spur bone representations. */
  53634. private _buildSpheresAndSpurs;
  53635. private _buildLocalAxes;
  53636. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53637. private _displayLinesUpdate;
  53638. /** Changes the displayMode of the skeleton viewer
  53639. * @param mode The displayMode numerical value
  53640. */
  53641. changeDisplayMode(mode: number): void;
  53642. /** Sets a display option of the skeleton viewer
  53643. *
  53644. * | Option | Type | Default | Description |
  53645. * | ---------------- | ------- | ------- | ----------- |
  53646. * | 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`. |
  53647. * | 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`. |
  53648. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53649. * | 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`. |
  53650. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  53651. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53652. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53653. *
  53654. * @param option String of the option name
  53655. * @param value The numerical option value
  53656. */
  53657. changeDisplayOptions(option: string, value: number): void;
  53658. /** Release associated resources */
  53659. dispose(): void;
  53660. }
  53661. }
  53662. declare module "babylonjs/Debug/index" {
  53663. export * from "babylonjs/Debug/axesViewer";
  53664. export * from "babylonjs/Debug/boneAxesViewer";
  53665. export * from "babylonjs/Debug/debugLayer";
  53666. export * from "babylonjs/Debug/physicsViewer";
  53667. export * from "babylonjs/Debug/rayHelper";
  53668. export * from "babylonjs/Debug/skeletonViewer";
  53669. export * from "babylonjs/Debug/ISkeletonViewer";
  53670. }
  53671. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53672. /**
  53673. * Enum for Device Types
  53674. */
  53675. export enum DeviceType {
  53676. /** Generic */
  53677. Generic = 0,
  53678. /** Keyboard */
  53679. Keyboard = 1,
  53680. /** Mouse */
  53681. Mouse = 2,
  53682. /** Touch Pointers */
  53683. Touch = 3,
  53684. /** PS4 Dual Shock */
  53685. DualShock = 4,
  53686. /** Xbox */
  53687. Xbox = 5,
  53688. /** Switch Controller */
  53689. Switch = 6
  53690. }
  53691. /**
  53692. * Enum for All Pointers (Touch/Mouse)
  53693. */
  53694. export enum PointerInput {
  53695. /** Horizontal Axis */
  53696. Horizontal = 0,
  53697. /** Vertical Axis */
  53698. Vertical = 1,
  53699. /** Left Click or Touch */
  53700. LeftClick = 2,
  53701. /** Middle Click */
  53702. MiddleClick = 3,
  53703. /** Right Click */
  53704. RightClick = 4,
  53705. /** Browser Back */
  53706. BrowserBack = 5,
  53707. /** Browser Forward */
  53708. BrowserForward = 6
  53709. }
  53710. /**
  53711. * Enum for Dual Shock Gamepad
  53712. */
  53713. export enum DualShockInput {
  53714. /** Cross */
  53715. Cross = 0,
  53716. /** Circle */
  53717. Circle = 1,
  53718. /** Square */
  53719. Square = 2,
  53720. /** Triangle */
  53721. Triangle = 3,
  53722. /** L1 */
  53723. L1 = 4,
  53724. /** R1 */
  53725. R1 = 5,
  53726. /** L2 */
  53727. L2 = 6,
  53728. /** R2 */
  53729. R2 = 7,
  53730. /** Share */
  53731. Share = 8,
  53732. /** Options */
  53733. Options = 9,
  53734. /** L3 */
  53735. L3 = 10,
  53736. /** R3 */
  53737. R3 = 11,
  53738. /** DPadUp */
  53739. DPadUp = 12,
  53740. /** DPadDown */
  53741. DPadDown = 13,
  53742. /** DPadLeft */
  53743. DPadLeft = 14,
  53744. /** DRight */
  53745. DPadRight = 15,
  53746. /** Home */
  53747. Home = 16,
  53748. /** TouchPad */
  53749. TouchPad = 17,
  53750. /** LStickXAxis */
  53751. LStickXAxis = 18,
  53752. /** LStickYAxis */
  53753. LStickYAxis = 19,
  53754. /** RStickXAxis */
  53755. RStickXAxis = 20,
  53756. /** RStickYAxis */
  53757. RStickYAxis = 21
  53758. }
  53759. /**
  53760. * Enum for Xbox Gamepad
  53761. */
  53762. export enum XboxInput {
  53763. /** A */
  53764. A = 0,
  53765. /** B */
  53766. B = 1,
  53767. /** X */
  53768. X = 2,
  53769. /** Y */
  53770. Y = 3,
  53771. /** LB */
  53772. LB = 4,
  53773. /** RB */
  53774. RB = 5,
  53775. /** LT */
  53776. LT = 6,
  53777. /** RT */
  53778. RT = 7,
  53779. /** Back */
  53780. Back = 8,
  53781. /** Start */
  53782. Start = 9,
  53783. /** LS */
  53784. LS = 10,
  53785. /** RS */
  53786. RS = 11,
  53787. /** DPadUp */
  53788. DPadUp = 12,
  53789. /** DPadDown */
  53790. DPadDown = 13,
  53791. /** DPadLeft */
  53792. DPadLeft = 14,
  53793. /** DRight */
  53794. DPadRight = 15,
  53795. /** Home */
  53796. Home = 16,
  53797. /** LStickXAxis */
  53798. LStickXAxis = 17,
  53799. /** LStickYAxis */
  53800. LStickYAxis = 18,
  53801. /** RStickXAxis */
  53802. RStickXAxis = 19,
  53803. /** RStickYAxis */
  53804. RStickYAxis = 20
  53805. }
  53806. /**
  53807. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53808. */
  53809. export enum SwitchInput {
  53810. /** B */
  53811. B = 0,
  53812. /** A */
  53813. A = 1,
  53814. /** Y */
  53815. Y = 2,
  53816. /** X */
  53817. X = 3,
  53818. /** L */
  53819. L = 4,
  53820. /** R */
  53821. R = 5,
  53822. /** ZL */
  53823. ZL = 6,
  53824. /** ZR */
  53825. ZR = 7,
  53826. /** Minus */
  53827. Minus = 8,
  53828. /** Plus */
  53829. Plus = 9,
  53830. /** LS */
  53831. LS = 10,
  53832. /** RS */
  53833. RS = 11,
  53834. /** DPadUp */
  53835. DPadUp = 12,
  53836. /** DPadDown */
  53837. DPadDown = 13,
  53838. /** DPadLeft */
  53839. DPadLeft = 14,
  53840. /** DRight */
  53841. DPadRight = 15,
  53842. /** Home */
  53843. Home = 16,
  53844. /** Capture */
  53845. Capture = 17,
  53846. /** LStickXAxis */
  53847. LStickXAxis = 18,
  53848. /** LStickYAxis */
  53849. LStickYAxis = 19,
  53850. /** RStickXAxis */
  53851. RStickXAxis = 20,
  53852. /** RStickYAxis */
  53853. RStickYAxis = 21
  53854. }
  53855. }
  53856. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53857. import { Engine } from "babylonjs/Engines/engine";
  53858. import { IDisposable } from "babylonjs/scene";
  53859. import { Nullable } from "babylonjs/types";
  53860. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53861. /**
  53862. * This class will take all inputs from Keyboard, Pointer, and
  53863. * any Gamepads and provide a polling system that all devices
  53864. * will use. This class assumes that there will only be one
  53865. * pointer device and one keyboard.
  53866. */
  53867. export class DeviceInputSystem implements IDisposable {
  53868. /**
  53869. * Callback to be triggered when a device is connected
  53870. */
  53871. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53872. /**
  53873. * Callback to be triggered when a device is disconnected
  53874. */
  53875. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53876. /**
  53877. * Callback to be triggered when event driven input is updated
  53878. */
  53879. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53880. private _inputs;
  53881. private _gamepads;
  53882. private _keyboardActive;
  53883. private _pointerActive;
  53884. private _elementToAttachTo;
  53885. private _keyboardDownEvent;
  53886. private _keyboardUpEvent;
  53887. private _pointerMoveEvent;
  53888. private _pointerDownEvent;
  53889. private _pointerUpEvent;
  53890. private _gamepadConnectedEvent;
  53891. private _gamepadDisconnectedEvent;
  53892. private static _MAX_KEYCODES;
  53893. private static _MAX_POINTER_INPUTS;
  53894. private constructor();
  53895. /**
  53896. * Creates a new DeviceInputSystem instance
  53897. * @param engine Engine to pull input element from
  53898. * @returns The new instance
  53899. */
  53900. static Create(engine: Engine): DeviceInputSystem;
  53901. /**
  53902. * Checks for current device input value, given an id and input index
  53903. * @param deviceName Id of connected device
  53904. * @param inputIndex Index of device input
  53905. * @returns Current value of input
  53906. */
  53907. /**
  53908. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53909. * @param deviceType Enum specifiying device type
  53910. * @param deviceSlot "Slot" or index that device is referenced in
  53911. * @param inputIndex Id of input to be checked
  53912. * @returns Current value of input
  53913. */
  53914. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53915. /**
  53916. * Dispose of all the eventlisteners
  53917. */
  53918. dispose(): void;
  53919. /**
  53920. * Add device and inputs to device array
  53921. * @param deviceType Enum specifiying device type
  53922. * @param deviceSlot "Slot" or index that device is referenced in
  53923. * @param numberOfInputs Number of input entries to create for given device
  53924. */
  53925. private _registerDevice;
  53926. /**
  53927. * Given a specific device name, remove that device from the device map
  53928. * @param deviceType Enum specifiying device type
  53929. * @param deviceSlot "Slot" or index that device is referenced in
  53930. */
  53931. private _unregisterDevice;
  53932. /**
  53933. * Handle all actions that come from keyboard interaction
  53934. */
  53935. private _handleKeyActions;
  53936. /**
  53937. * Handle all actions that come from pointer interaction
  53938. */
  53939. private _handlePointerActions;
  53940. /**
  53941. * Handle all actions that come from gamepad interaction
  53942. */
  53943. private _handleGamepadActions;
  53944. /**
  53945. * Update all non-event based devices with each frame
  53946. * @param deviceType Enum specifiying device type
  53947. * @param deviceSlot "Slot" or index that device is referenced in
  53948. * @param inputIndex Id of input to be checked
  53949. */
  53950. private _updateDevice;
  53951. /**
  53952. * Gets DeviceType from the device name
  53953. * @param deviceName Name of Device from DeviceInputSystem
  53954. * @returns DeviceType enum value
  53955. */
  53956. private _getGamepadDeviceType;
  53957. }
  53958. }
  53959. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53960. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53961. /**
  53962. * Type to handle enforcement of inputs
  53963. */
  53964. 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;
  53965. }
  53966. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53967. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53968. import { Engine } from "babylonjs/Engines/engine";
  53969. import { IDisposable } from "babylonjs/scene";
  53970. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53971. import { Nullable } from "babylonjs/types";
  53972. import { Observable } from "babylonjs/Misc/observable";
  53973. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53974. /**
  53975. * Class that handles all input for a specific device
  53976. */
  53977. export class DeviceSource<T extends DeviceType> {
  53978. /** Type of device */
  53979. readonly deviceType: DeviceType;
  53980. /** "Slot" or index that device is referenced in */
  53981. readonly deviceSlot: number;
  53982. /**
  53983. * Observable to handle device input changes per device
  53984. */
  53985. readonly onInputChangedObservable: Observable<{
  53986. inputIndex: DeviceInput<T>;
  53987. previousState: Nullable<number>;
  53988. currentState: Nullable<number>;
  53989. }>;
  53990. private readonly _deviceInputSystem;
  53991. /**
  53992. * Default Constructor
  53993. * @param deviceInputSystem Reference to DeviceInputSystem
  53994. * @param deviceType Type of device
  53995. * @param deviceSlot "Slot" or index that device is referenced in
  53996. */
  53997. constructor(deviceInputSystem: DeviceInputSystem,
  53998. /** Type of device */
  53999. deviceType: DeviceType,
  54000. /** "Slot" or index that device is referenced in */
  54001. deviceSlot?: number);
  54002. /**
  54003. * Get input for specific input
  54004. * @param inputIndex index of specific input on device
  54005. * @returns Input value from DeviceInputSystem
  54006. */
  54007. getInput(inputIndex: DeviceInput<T>): number;
  54008. }
  54009. /**
  54010. * Class to keep track of devices
  54011. */
  54012. export class DeviceSourceManager implements IDisposable {
  54013. /**
  54014. * Observable to be triggered when before a device is connected
  54015. */
  54016. readonly onBeforeDeviceConnectedObservable: Observable<{
  54017. deviceType: DeviceType;
  54018. deviceSlot: number;
  54019. }>;
  54020. /**
  54021. * Observable to be triggered when before a device is disconnected
  54022. */
  54023. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54024. deviceType: DeviceType;
  54025. deviceSlot: number;
  54026. }>;
  54027. /**
  54028. * Observable to be triggered when after a device is connected
  54029. */
  54030. readonly onAfterDeviceConnectedObservable: Observable<{
  54031. deviceType: DeviceType;
  54032. deviceSlot: number;
  54033. }>;
  54034. /**
  54035. * Observable to be triggered when after a device is disconnected
  54036. */
  54037. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54038. deviceType: DeviceType;
  54039. deviceSlot: number;
  54040. }>;
  54041. private readonly _devices;
  54042. private readonly _firstDevice;
  54043. private readonly _deviceInputSystem;
  54044. /**
  54045. * Default Constructor
  54046. * @param engine engine to pull input element from
  54047. */
  54048. constructor(engine: Engine);
  54049. /**
  54050. * Gets a DeviceSource, given a type and slot
  54051. * @param deviceType Enum specifying device type
  54052. * @param deviceSlot "Slot" or index that device is referenced in
  54053. * @returns DeviceSource object
  54054. */
  54055. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54056. /**
  54057. * Gets an array of DeviceSource objects for a given device type
  54058. * @param deviceType Enum specifying device type
  54059. * @returns Array of DeviceSource objects
  54060. */
  54061. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54062. /**
  54063. * Dispose of DeviceInputSystem and other parts
  54064. */
  54065. dispose(): void;
  54066. /**
  54067. * Function to add device name to device list
  54068. * @param deviceType Enum specifying device type
  54069. * @param deviceSlot "Slot" or index that device is referenced in
  54070. */
  54071. private _addDevice;
  54072. /**
  54073. * Function to remove device name to device list
  54074. * @param deviceType Enum specifying device type
  54075. * @param deviceSlot "Slot" or index that device is referenced in
  54076. */
  54077. private _removeDevice;
  54078. /**
  54079. * Updates array storing first connected device of each type
  54080. * @param type Type of Device
  54081. */
  54082. private _updateFirstDevices;
  54083. }
  54084. }
  54085. declare module "babylonjs/DeviceInput/index" {
  54086. export * from "babylonjs/DeviceInput/deviceInputSystem";
  54087. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  54088. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  54089. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54090. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54091. }
  54092. declare module "babylonjs/Engines/nullEngine" {
  54093. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  54094. import { Engine } from "babylonjs/Engines/engine";
  54095. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54096. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54098. import { Effect } from "babylonjs/Materials/effect";
  54099. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54100. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54101. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  54102. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54103. /**
  54104. * Options to create the null engine
  54105. */
  54106. export class NullEngineOptions {
  54107. /**
  54108. * Render width (Default: 512)
  54109. */
  54110. renderWidth: number;
  54111. /**
  54112. * Render height (Default: 256)
  54113. */
  54114. renderHeight: number;
  54115. /**
  54116. * Texture size (Default: 512)
  54117. */
  54118. textureSize: number;
  54119. /**
  54120. * If delta time between frames should be constant
  54121. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54122. */
  54123. deterministicLockstep: boolean;
  54124. /**
  54125. * Maximum about of steps between frames (Default: 4)
  54126. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54127. */
  54128. lockstepMaxSteps: number;
  54129. /**
  54130. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54131. */
  54132. useHighPrecisionMatrix?: boolean;
  54133. }
  54134. /**
  54135. * The null engine class provides support for headless version of babylon.js.
  54136. * This can be used in server side scenario or for testing purposes
  54137. */
  54138. export class NullEngine extends Engine {
  54139. private _options;
  54140. /**
  54141. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54143. * @returns true if engine is in deterministic lock step mode
  54144. */
  54145. isDeterministicLockStep(): boolean;
  54146. /**
  54147. * Gets the max steps when engine is running in deterministic lock step
  54148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54149. * @returns the max steps
  54150. */
  54151. getLockstepMaxSteps(): number;
  54152. /**
  54153. * Gets the current hardware scaling level.
  54154. * By default the hardware scaling level is computed from the window device ratio.
  54155. * 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.
  54156. * @returns a number indicating the current hardware scaling level
  54157. */
  54158. getHardwareScalingLevel(): number;
  54159. constructor(options?: NullEngineOptions);
  54160. /**
  54161. * Creates a vertex buffer
  54162. * @param vertices the data for the vertex buffer
  54163. * @returns the new WebGL static buffer
  54164. */
  54165. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54166. /**
  54167. * Creates a new index buffer
  54168. * @param indices defines the content of the index buffer
  54169. * @param updatable defines if the index buffer must be updatable
  54170. * @returns a new webGL buffer
  54171. */
  54172. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54173. /**
  54174. * Clear the current render buffer or the current render target (if any is set up)
  54175. * @param color defines the color to use
  54176. * @param backBuffer defines if the back buffer must be cleared
  54177. * @param depth defines if the depth buffer must be cleared
  54178. * @param stencil defines if the stencil buffer must be cleared
  54179. */
  54180. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54181. /**
  54182. * Gets the current render width
  54183. * @param useScreen defines if screen size must be used (or the current render target if any)
  54184. * @returns a number defining the current render width
  54185. */
  54186. getRenderWidth(useScreen?: boolean): number;
  54187. /**
  54188. * Gets the current render height
  54189. * @param useScreen defines if screen size must be used (or the current render target if any)
  54190. * @returns a number defining the current render height
  54191. */
  54192. getRenderHeight(useScreen?: boolean): number;
  54193. /**
  54194. * Set the WebGL's viewport
  54195. * @param viewport defines the viewport element to be used
  54196. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54197. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54198. */
  54199. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54200. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54201. /**
  54202. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54203. * @param pipelineContext defines the pipeline context to use
  54204. * @param uniformsNames defines the list of uniform names
  54205. * @returns an array of webGL uniform locations
  54206. */
  54207. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54208. /**
  54209. * Gets the lsit of active attributes for a given webGL program
  54210. * @param pipelineContext defines the pipeline context to use
  54211. * @param attributesNames defines the list of attribute names to get
  54212. * @returns an array of indices indicating the offset of each attribute
  54213. */
  54214. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54215. /**
  54216. * Binds an effect to the webGL context
  54217. * @param effect defines the effect to bind
  54218. */
  54219. bindSamplers(effect: Effect): void;
  54220. /**
  54221. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54222. * @param effect defines the effect to activate
  54223. */
  54224. enableEffect(effect: Effect): void;
  54225. /**
  54226. * Set various states to the webGL context
  54227. * @param culling defines backface culling state
  54228. * @param zOffset defines the value to apply to zOffset (0 by default)
  54229. * @param force defines if states must be applied even if cache is up to date
  54230. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54231. */
  54232. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54233. /**
  54234. * Set the value of an uniform to an array of int32
  54235. * @param uniform defines the webGL uniform location where to store the value
  54236. * @param array defines the array of int32 to store
  54237. * @returns true if value was set
  54238. */
  54239. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54240. /**
  54241. * Set the value of an uniform to an array of int32 (stored as vec2)
  54242. * @param uniform defines the webGL uniform location where to store the value
  54243. * @param array defines the array of int32 to store
  54244. * @returns true if value was set
  54245. */
  54246. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54247. /**
  54248. * Set the value of an uniform to an array of int32 (stored as vec3)
  54249. * @param uniform defines the webGL uniform location where to store the value
  54250. * @param array defines the array of int32 to store
  54251. * @returns true if value was set
  54252. */
  54253. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54254. /**
  54255. * Set the value of an uniform to an array of int32 (stored as vec4)
  54256. * @param uniform defines the webGL uniform location where to store the value
  54257. * @param array defines the array of int32 to store
  54258. * @returns true if value was set
  54259. */
  54260. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54261. /**
  54262. * Set the value of an uniform to an array of float32
  54263. * @param uniform defines the webGL uniform location where to store the value
  54264. * @param array defines the array of float32 to store
  54265. * @returns true if value was set
  54266. */
  54267. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54268. /**
  54269. * Set the value of an uniform to an array of float32 (stored as vec2)
  54270. * @param uniform defines the webGL uniform location where to store the value
  54271. * @param array defines the array of float32 to store
  54272. * @returns true if value was set
  54273. */
  54274. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54275. /**
  54276. * Set the value of an uniform to an array of float32 (stored as vec3)
  54277. * @param uniform defines the webGL uniform location where to store the value
  54278. * @param array defines the array of float32 to store
  54279. * @returns true if value was set
  54280. */
  54281. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54282. /**
  54283. * Set the value of an uniform to an array of float32 (stored as vec4)
  54284. * @param uniform defines the webGL uniform location where to store the value
  54285. * @param array defines the array of float32 to store
  54286. * @returns true if value was set
  54287. */
  54288. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54289. /**
  54290. * Set the value of an uniform to an array of number
  54291. * @param uniform defines the webGL uniform location where to store the value
  54292. * @param array defines the array of number to store
  54293. * @returns true if value was set
  54294. */
  54295. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54296. /**
  54297. * Set the value of an uniform to an array of number (stored as vec2)
  54298. * @param uniform defines the webGL uniform location where to store the value
  54299. * @param array defines the array of number to store
  54300. * @returns true if value was set
  54301. */
  54302. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54303. /**
  54304. * Set the value of an uniform to an array of number (stored as vec3)
  54305. * @param uniform defines the webGL uniform location where to store the value
  54306. * @param array defines the array of number to store
  54307. * @returns true if value was set
  54308. */
  54309. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54310. /**
  54311. * Set the value of an uniform to an array of number (stored as vec4)
  54312. * @param uniform defines the webGL uniform location where to store the value
  54313. * @param array defines the array of number to store
  54314. * @returns true if value was set
  54315. */
  54316. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54317. /**
  54318. * Set the value of an uniform to an array of float32 (stored as matrices)
  54319. * @param uniform defines the webGL uniform location where to store the value
  54320. * @param matrices defines the array of float32 to store
  54321. * @returns true if value was set
  54322. */
  54323. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54324. /**
  54325. * Set the value of an uniform to a matrix (3x3)
  54326. * @param uniform defines the webGL uniform location where to store the value
  54327. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54328. * @returns true if value was set
  54329. */
  54330. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54331. /**
  54332. * Set the value of an uniform to a matrix (2x2)
  54333. * @param uniform defines the webGL uniform location where to store the value
  54334. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54335. * @returns true if value was set
  54336. */
  54337. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54338. /**
  54339. * Set the value of an uniform to a number (float)
  54340. * @param uniform defines the webGL uniform location where to store the value
  54341. * @param value defines the float number to store
  54342. * @returns true if value was set
  54343. */
  54344. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54345. /**
  54346. * Set the value of an uniform to a vec2
  54347. * @param uniform defines the webGL uniform location where to store the value
  54348. * @param x defines the 1st component of the value
  54349. * @param y defines the 2nd component of the value
  54350. * @returns true if value was set
  54351. */
  54352. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54353. /**
  54354. * Set the value of an uniform to a vec3
  54355. * @param uniform defines the webGL uniform location where to store the value
  54356. * @param x defines the 1st component of the value
  54357. * @param y defines the 2nd component of the value
  54358. * @param z defines the 3rd component of the value
  54359. * @returns true if value was set
  54360. */
  54361. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54362. /**
  54363. * Set the value of an uniform to a boolean
  54364. * @param uniform defines the webGL uniform location where to store the value
  54365. * @param bool defines the boolean to store
  54366. * @returns true if value was set
  54367. */
  54368. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54369. /**
  54370. * Set the value of an uniform to a vec4
  54371. * @param uniform defines the webGL uniform location where to store the value
  54372. * @param x defines the 1st component of the value
  54373. * @param y defines the 2nd component of the value
  54374. * @param z defines the 3rd component of the value
  54375. * @param w defines the 4th component of the value
  54376. * @returns true if value was set
  54377. */
  54378. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54379. /**
  54380. * Sets the current alpha mode
  54381. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54382. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54383. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54384. */
  54385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54386. /**
  54387. * Bind webGl buffers directly to the webGL context
  54388. * @param vertexBuffers defines the vertex buffer to bind
  54389. * @param indexBuffer defines the index buffer to bind
  54390. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54391. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54392. * @param effect defines the effect associated with the vertex buffer
  54393. */
  54394. bindBuffers(vertexBuffers: {
  54395. [key: string]: VertexBuffer;
  54396. }, indexBuffer: DataBuffer, effect: Effect): void;
  54397. /**
  54398. * Force the entire cache to be cleared
  54399. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54400. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54401. */
  54402. wipeCaches(bruteForce?: boolean): void;
  54403. /**
  54404. * Send a draw order
  54405. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54406. * @param indexStart defines the starting index
  54407. * @param indexCount defines the number of index to draw
  54408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54409. */
  54410. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54411. /**
  54412. * Draw a list of indexed primitives
  54413. * @param fillMode defines the primitive to use
  54414. * @param indexStart defines the starting index
  54415. * @param indexCount defines the number of index to draw
  54416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54417. */
  54418. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54419. /**
  54420. * Draw a list of unindexed primitives
  54421. * @param fillMode defines the primitive to use
  54422. * @param verticesStart defines the index of first vertex to draw
  54423. * @param verticesCount defines the count of vertices to draw
  54424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54425. */
  54426. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54427. /** @hidden */
  54428. _createTexture(): WebGLTexture;
  54429. /** @hidden */
  54430. _releaseTexture(texture: InternalTexture): void;
  54431. /**
  54432. * Usually called from Texture.ts.
  54433. * Passed information to create a WebGLTexture
  54434. * @param urlArg defines a value which contains one of the following:
  54435. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54436. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54437. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54438. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54439. * @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)
  54440. * @param scene needed for loading to the correct scene
  54441. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54442. * @param onLoad optional callback to be called upon successful completion
  54443. * @param onError optional callback to be called upon failure
  54444. * @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
  54445. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54446. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54447. * @param forcedExtension defines the extension to use to pick the right loader
  54448. * @param mimeType defines an optional mime type
  54449. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54450. */
  54451. 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;
  54452. /**
  54453. * Creates a new render target texture
  54454. * @param size defines the size of the texture
  54455. * @param options defines the options used to create the texture
  54456. * @returns a new render target texture stored in an InternalTexture
  54457. */
  54458. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54459. /**
  54460. * Update the sampling mode of a given texture
  54461. * @param samplingMode defines the required sampling mode
  54462. * @param texture defines the texture to update
  54463. */
  54464. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54465. /**
  54466. * Binds the frame buffer to the specified texture.
  54467. * @param texture The texture to render to or null for the default canvas
  54468. * @param faceIndex The face of the texture to render to in case of cube texture
  54469. * @param requiredWidth The width of the target to render to
  54470. * @param requiredHeight The height of the target to render to
  54471. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54472. * @param lodLevel defines le lod level to bind to the frame buffer
  54473. */
  54474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54475. /**
  54476. * Unbind the current render target texture from the webGL context
  54477. * @param texture defines the render target texture to unbind
  54478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54480. */
  54481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54482. /**
  54483. * Creates a dynamic vertex buffer
  54484. * @param vertices the data for the dynamic vertex buffer
  54485. * @returns the new WebGL dynamic buffer
  54486. */
  54487. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54488. /**
  54489. * Update the content of a dynamic texture
  54490. * @param texture defines the texture to update
  54491. * @param canvas defines the canvas containing the source
  54492. * @param invertY defines if data must be stored with Y axis inverted
  54493. * @param premulAlpha defines if alpha is stored as premultiplied
  54494. * @param format defines the format of the data
  54495. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54496. */
  54497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54498. /**
  54499. * Gets a boolean indicating if all created effects are ready
  54500. * @returns true if all effects are ready
  54501. */
  54502. areAllEffectsReady(): boolean;
  54503. /**
  54504. * @hidden
  54505. * Get the current error code of the webGL context
  54506. * @returns the error code
  54507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54508. */
  54509. getError(): number;
  54510. /** @hidden */
  54511. _getUnpackAlignement(): number;
  54512. /** @hidden */
  54513. _unpackFlipY(value: boolean): void;
  54514. /**
  54515. * Update a dynamic index buffer
  54516. * @param indexBuffer defines the target index buffer
  54517. * @param indices defines the data to update
  54518. * @param offset defines the offset in the target index buffer where update should start
  54519. */
  54520. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54521. /**
  54522. * Updates a dynamic vertex buffer.
  54523. * @param vertexBuffer the vertex buffer to update
  54524. * @param vertices the data used to update the vertex buffer
  54525. * @param byteOffset the byte offset of the data (optional)
  54526. * @param byteLength the byte length of the data (optional)
  54527. */
  54528. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54529. /** @hidden */
  54530. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54531. /** @hidden */
  54532. _bindTexture(channel: number, texture: InternalTexture): void;
  54533. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54534. /**
  54535. * 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
  54536. */
  54537. releaseEffects(): void;
  54538. displayLoadingUI(): void;
  54539. hideLoadingUI(): void;
  54540. /** @hidden */
  54541. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54542. /** @hidden */
  54543. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54544. /** @hidden */
  54545. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54546. /** @hidden */
  54547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54548. }
  54549. }
  54550. declare module "babylonjs/Instrumentation/timeToken" {
  54551. import { Nullable } from "babylonjs/types";
  54552. /**
  54553. * @hidden
  54554. **/
  54555. export class _TimeToken {
  54556. _startTimeQuery: Nullable<WebGLQuery>;
  54557. _endTimeQuery: Nullable<WebGLQuery>;
  54558. _timeElapsedQuery: Nullable<WebGLQuery>;
  54559. _timeElapsedQueryEnded: boolean;
  54560. }
  54561. }
  54562. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54563. import { Nullable, int } from "babylonjs/types";
  54564. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54565. /** @hidden */
  54566. export class _OcclusionDataStorage {
  54567. /** @hidden */
  54568. occlusionInternalRetryCounter: number;
  54569. /** @hidden */
  54570. isOcclusionQueryInProgress: boolean;
  54571. /** @hidden */
  54572. isOccluded: boolean;
  54573. /** @hidden */
  54574. occlusionRetryCount: number;
  54575. /** @hidden */
  54576. occlusionType: number;
  54577. /** @hidden */
  54578. occlusionQueryAlgorithmType: number;
  54579. }
  54580. module "babylonjs/Engines/engine" {
  54581. interface Engine {
  54582. /**
  54583. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54584. * @return the new query
  54585. */
  54586. createQuery(): WebGLQuery;
  54587. /**
  54588. * Delete and release a webGL query
  54589. * @param query defines the query to delete
  54590. * @return the current engine
  54591. */
  54592. deleteQuery(query: WebGLQuery): Engine;
  54593. /**
  54594. * Check if a given query has resolved and got its value
  54595. * @param query defines the query to check
  54596. * @returns true if the query got its value
  54597. */
  54598. isQueryResultAvailable(query: WebGLQuery): boolean;
  54599. /**
  54600. * Gets the value of a given query
  54601. * @param query defines the query to check
  54602. * @returns the value of the query
  54603. */
  54604. getQueryResult(query: WebGLQuery): number;
  54605. /**
  54606. * Initiates an occlusion query
  54607. * @param algorithmType defines the algorithm to use
  54608. * @param query defines the query to use
  54609. * @returns the current engine
  54610. * @see https://doc.babylonjs.com/features/occlusionquery
  54611. */
  54612. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54613. /**
  54614. * Ends an occlusion query
  54615. * @see https://doc.babylonjs.com/features/occlusionquery
  54616. * @param algorithmType defines the algorithm to use
  54617. * @returns the current engine
  54618. */
  54619. endOcclusionQuery(algorithmType: number): Engine;
  54620. /**
  54621. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54622. * Please note that only one query can be issued at a time
  54623. * @returns a time token used to track the time span
  54624. */
  54625. startTimeQuery(): Nullable<_TimeToken>;
  54626. /**
  54627. * Ends a time query
  54628. * @param token defines the token used to measure the time span
  54629. * @returns the time spent (in ns)
  54630. */
  54631. endTimeQuery(token: _TimeToken): int;
  54632. /** @hidden */
  54633. _currentNonTimestampToken: Nullable<_TimeToken>;
  54634. /** @hidden */
  54635. _createTimeQuery(): WebGLQuery;
  54636. /** @hidden */
  54637. _deleteTimeQuery(query: WebGLQuery): void;
  54638. /** @hidden */
  54639. _getGlAlgorithmType(algorithmType: number): number;
  54640. /** @hidden */
  54641. _getTimeQueryResult(query: WebGLQuery): any;
  54642. /** @hidden */
  54643. _getTimeQueryAvailability(query: WebGLQuery): any;
  54644. }
  54645. }
  54646. module "babylonjs/Meshes/abstractMesh" {
  54647. interface AbstractMesh {
  54648. /**
  54649. * Backing filed
  54650. * @hidden
  54651. */
  54652. __occlusionDataStorage: _OcclusionDataStorage;
  54653. /**
  54654. * Access property
  54655. * @hidden
  54656. */
  54657. _occlusionDataStorage: _OcclusionDataStorage;
  54658. /**
  54659. * 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.
  54660. * The default value is -1 which means don't break the query and wait till the result
  54661. * @see https://doc.babylonjs.com/features/occlusionquery
  54662. */
  54663. occlusionRetryCount: number;
  54664. /**
  54665. * 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:
  54666. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54667. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54668. * * 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.
  54669. * @see https://doc.babylonjs.com/features/occlusionquery
  54670. */
  54671. occlusionType: number;
  54672. /**
  54673. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54674. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54675. * * 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.
  54676. * @see https://doc.babylonjs.com/features/occlusionquery
  54677. */
  54678. occlusionQueryAlgorithmType: number;
  54679. /**
  54680. * 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
  54681. * @see https://doc.babylonjs.com/features/occlusionquery
  54682. */
  54683. isOccluded: boolean;
  54684. /**
  54685. * Flag to check the progress status of the query
  54686. * @see https://doc.babylonjs.com/features/occlusionquery
  54687. */
  54688. isOcclusionQueryInProgress: boolean;
  54689. }
  54690. }
  54691. }
  54692. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54693. import { Nullable } from "babylonjs/types";
  54694. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54695. /** @hidden */
  54696. export var _forceTransformFeedbackToBundle: boolean;
  54697. module "babylonjs/Engines/engine" {
  54698. interface Engine {
  54699. /**
  54700. * Creates a webGL transform feedback object
  54701. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54702. * @returns the webGL transform feedback object
  54703. */
  54704. createTransformFeedback(): WebGLTransformFeedback;
  54705. /**
  54706. * Delete a webGL transform feedback object
  54707. * @param value defines the webGL transform feedback object to delete
  54708. */
  54709. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54710. /**
  54711. * Bind a webGL transform feedback object to the webgl context
  54712. * @param value defines the webGL transform feedback object to bind
  54713. */
  54714. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54715. /**
  54716. * Begins a transform feedback operation
  54717. * @param usePoints defines if points or triangles must be used
  54718. */
  54719. beginTransformFeedback(usePoints: boolean): void;
  54720. /**
  54721. * Ends a transform feedback operation
  54722. */
  54723. endTransformFeedback(): void;
  54724. /**
  54725. * Specify the varyings to use with transform feedback
  54726. * @param program defines the associated webGL program
  54727. * @param value defines the list of strings representing the varying names
  54728. */
  54729. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54730. /**
  54731. * Bind a webGL buffer for a transform feedback operation
  54732. * @param value defines the webGL buffer to bind
  54733. */
  54734. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54735. }
  54736. }
  54737. }
  54738. declare module "babylonjs/Engines/Extensions/engine.views" {
  54739. import { Camera } from "babylonjs/Cameras/camera";
  54740. import { Nullable } from "babylonjs/types";
  54741. /**
  54742. * Class used to define an additional view for the engine
  54743. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54744. */
  54745. export class EngineView {
  54746. /** Defines the canvas where to render the view */
  54747. target: HTMLCanvasElement;
  54748. /** Defines an optional camera used to render the view (will use active camera else) */
  54749. camera?: Camera;
  54750. }
  54751. module "babylonjs/Engines/engine" {
  54752. interface Engine {
  54753. /**
  54754. * Gets or sets the HTML element to use for attaching events
  54755. */
  54756. inputElement: Nullable<HTMLElement>;
  54757. /**
  54758. * Gets the current engine view
  54759. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54760. */
  54761. activeView: Nullable<EngineView>;
  54762. /** Gets or sets the list of views */
  54763. views: EngineView[];
  54764. /**
  54765. * Register a new child canvas
  54766. * @param canvas defines the canvas to register
  54767. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54768. * @returns the associated view
  54769. */
  54770. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54771. /**
  54772. * Remove a registered child canvas
  54773. * @param canvas defines the canvas to remove
  54774. * @returns the current engine
  54775. */
  54776. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54777. }
  54778. }
  54779. }
  54780. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54781. import { Nullable } from "babylonjs/types";
  54782. module "babylonjs/Engines/engine" {
  54783. interface Engine {
  54784. /** @hidden */
  54785. _excludedCompressedTextures: string[];
  54786. /** @hidden */
  54787. _textureFormatInUse: string;
  54788. /**
  54789. * Gets the list of texture formats supported
  54790. */
  54791. readonly texturesSupported: Array<string>;
  54792. /**
  54793. * Gets the texture format in use
  54794. */
  54795. readonly textureFormatInUse: Nullable<string>;
  54796. /**
  54797. * Set the compressed texture extensions or file names to skip.
  54798. *
  54799. * @param skippedFiles defines the list of those texture files you want to skip
  54800. * Example: [".dds", ".env", "myfile.png"]
  54801. */
  54802. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54803. /**
  54804. * Set the compressed texture format to use, based on the formats you have, and the formats
  54805. * supported by the hardware / browser.
  54806. *
  54807. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54808. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54809. * to API arguments needed to compressed textures. This puts the burden on the container
  54810. * generator to house the arcane code for determining these for current & future formats.
  54811. *
  54812. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54813. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54814. *
  54815. * Note: The result of this call is not taken into account when a texture is base64.
  54816. *
  54817. * @param formatsAvailable defines the list of those format families you have created
  54818. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54819. *
  54820. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54821. * @returns The extension selected.
  54822. */
  54823. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54824. }
  54825. }
  54826. }
  54827. declare module "babylonjs/Engines/Extensions/index" {
  54828. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54829. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54830. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54831. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54832. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54833. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54834. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54835. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54836. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54837. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54838. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54839. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54840. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54841. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54842. export * from "babylonjs/Engines/Extensions/engine.views";
  54843. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54844. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54845. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54846. }
  54847. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54848. import { Nullable } from "babylonjs/types";
  54849. /**
  54850. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54851. */
  54852. export interface CubeMapInfo {
  54853. /**
  54854. * The pixel array for the front face.
  54855. * This is stored in format, left to right, up to down format.
  54856. */
  54857. front: Nullable<ArrayBufferView>;
  54858. /**
  54859. * The pixel array for the back face.
  54860. * This is stored in format, left to right, up to down format.
  54861. */
  54862. back: Nullable<ArrayBufferView>;
  54863. /**
  54864. * The pixel array for the left face.
  54865. * This is stored in format, left to right, up to down format.
  54866. */
  54867. left: Nullable<ArrayBufferView>;
  54868. /**
  54869. * The pixel array for the right face.
  54870. * This is stored in format, left to right, up to down format.
  54871. */
  54872. right: Nullable<ArrayBufferView>;
  54873. /**
  54874. * The pixel array for the up face.
  54875. * This is stored in format, left to right, up to down format.
  54876. */
  54877. up: Nullable<ArrayBufferView>;
  54878. /**
  54879. * The pixel array for the down face.
  54880. * This is stored in format, left to right, up to down format.
  54881. */
  54882. down: Nullable<ArrayBufferView>;
  54883. /**
  54884. * The size of the cubemap stored.
  54885. *
  54886. * Each faces will be size * size pixels.
  54887. */
  54888. size: number;
  54889. /**
  54890. * The format of the texture.
  54891. *
  54892. * RGBA, RGB.
  54893. */
  54894. format: number;
  54895. /**
  54896. * The type of the texture data.
  54897. *
  54898. * UNSIGNED_INT, FLOAT.
  54899. */
  54900. type: number;
  54901. /**
  54902. * Specifies whether the texture is in gamma space.
  54903. */
  54904. gammaSpace: boolean;
  54905. }
  54906. /**
  54907. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54908. */
  54909. export class PanoramaToCubeMapTools {
  54910. private static FACE_LEFT;
  54911. private static FACE_RIGHT;
  54912. private static FACE_FRONT;
  54913. private static FACE_BACK;
  54914. private static FACE_DOWN;
  54915. private static FACE_UP;
  54916. /**
  54917. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54918. *
  54919. * @param float32Array The source data.
  54920. * @param inputWidth The width of the input panorama.
  54921. * @param inputHeight The height of the input panorama.
  54922. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54923. * @return The cubemap data
  54924. */
  54925. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54926. private static CreateCubemapTexture;
  54927. private static CalcProjectionSpherical;
  54928. }
  54929. }
  54930. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54931. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54933. import { Nullable } from "babylonjs/types";
  54934. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54935. /**
  54936. * Helper class dealing with the extraction of spherical polynomial dataArray
  54937. * from a cube map.
  54938. */
  54939. export class CubeMapToSphericalPolynomialTools {
  54940. private static FileFaces;
  54941. /**
  54942. * Converts a texture to the according Spherical Polynomial data.
  54943. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54944. *
  54945. * @param texture The texture to extract the information from.
  54946. * @return The Spherical Polynomial data.
  54947. */
  54948. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54949. /**
  54950. * Converts a cubemap to the according Spherical Polynomial data.
  54951. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54952. *
  54953. * @param cubeInfo The Cube map to extract the information from.
  54954. * @return The Spherical Polynomial data.
  54955. */
  54956. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54957. }
  54958. }
  54959. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54960. import { Nullable } from "babylonjs/types";
  54961. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54962. module "babylonjs/Materials/Textures/baseTexture" {
  54963. interface BaseTexture {
  54964. /**
  54965. * Get the polynomial representation of the texture data.
  54966. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54967. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54968. */
  54969. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54970. }
  54971. }
  54972. }
  54973. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54974. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54975. /** @hidden */
  54976. export var rgbdEncodePixelShader: {
  54977. name: string;
  54978. shader: string;
  54979. };
  54980. }
  54981. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54983. /** @hidden */
  54984. export var rgbdDecodePixelShader: {
  54985. name: string;
  54986. shader: string;
  54987. };
  54988. }
  54989. declare module "babylonjs/Misc/environmentTextureTools" {
  54990. import { Nullable } from "babylonjs/types";
  54991. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54992. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54994. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54995. import "babylonjs/Engines/Extensions/engine.readTexture";
  54996. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54997. import "babylonjs/Shaders/rgbdEncode.fragment";
  54998. import "babylonjs/Shaders/rgbdDecode.fragment";
  54999. /**
  55000. * Raw texture data and descriptor sufficient for WebGL texture upload
  55001. */
  55002. export interface EnvironmentTextureInfo {
  55003. /**
  55004. * Version of the environment map
  55005. */
  55006. version: number;
  55007. /**
  55008. * Width of image
  55009. */
  55010. width: number;
  55011. /**
  55012. * Irradiance information stored in the file.
  55013. */
  55014. irradiance: any;
  55015. /**
  55016. * Specular information stored in the file.
  55017. */
  55018. specular: any;
  55019. }
  55020. /**
  55021. * Defines One Image in the file. It requires only the position in the file
  55022. * as well as the length.
  55023. */
  55024. interface BufferImageData {
  55025. /**
  55026. * Length of the image data.
  55027. */
  55028. length: number;
  55029. /**
  55030. * Position of the data from the null terminator delimiting the end of the JSON.
  55031. */
  55032. position: number;
  55033. }
  55034. /**
  55035. * Defines the specular data enclosed in the file.
  55036. * This corresponds to the version 1 of the data.
  55037. */
  55038. export interface EnvironmentTextureSpecularInfoV1 {
  55039. /**
  55040. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55041. */
  55042. specularDataPosition?: number;
  55043. /**
  55044. * This contains all the images data needed to reconstruct the cubemap.
  55045. */
  55046. mipmaps: Array<BufferImageData>;
  55047. /**
  55048. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55049. */
  55050. lodGenerationScale: number;
  55051. }
  55052. /**
  55053. * Sets of helpers addressing the serialization and deserialization of environment texture
  55054. * stored in a BabylonJS env file.
  55055. * Those files are usually stored as .env files.
  55056. */
  55057. export class EnvironmentTextureTools {
  55058. /**
  55059. * Magic number identifying the env file.
  55060. */
  55061. private static _MagicBytes;
  55062. /**
  55063. * Gets the environment info from an env file.
  55064. * @param data The array buffer containing the .env bytes.
  55065. * @returns the environment file info (the json header) if successfully parsed.
  55066. */
  55067. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55068. /**
  55069. * Creates an environment texture from a loaded cube texture.
  55070. * @param texture defines the cube texture to convert in env file
  55071. * @return a promise containing the environment data if succesfull.
  55072. */
  55073. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55074. /**
  55075. * Creates a JSON representation of the spherical data.
  55076. * @param texture defines the texture containing the polynomials
  55077. * @return the JSON representation of the spherical info
  55078. */
  55079. private static _CreateEnvTextureIrradiance;
  55080. /**
  55081. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55082. * @param data the image data
  55083. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55084. * @return the views described by info providing access to the underlying buffer
  55085. */
  55086. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55087. /**
  55088. * Uploads the texture info contained in the env file to the GPU.
  55089. * @param texture defines the internal texture to upload to
  55090. * @param data defines the data to load
  55091. * @param info defines the texture info retrieved through the GetEnvInfo method
  55092. * @returns a promise
  55093. */
  55094. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55095. private static _OnImageReadyAsync;
  55096. /**
  55097. * Uploads the levels of image data to the GPU.
  55098. * @param texture defines the internal texture to upload to
  55099. * @param imageData defines the array buffer views of image data [mipmap][face]
  55100. * @returns a promise
  55101. */
  55102. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55103. /**
  55104. * Uploads spherical polynomials information to the texture.
  55105. * @param texture defines the texture we are trying to upload the information to
  55106. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55107. */
  55108. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55109. /** @hidden */
  55110. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55111. }
  55112. }
  55113. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  55114. /**
  55115. * Class used to inline functions in shader code
  55116. */
  55117. export class ShaderCodeInliner {
  55118. private static readonly _RegexpFindFunctionNameAndType;
  55119. private _sourceCode;
  55120. private _functionDescr;
  55121. private _numMaxIterations;
  55122. /** Gets or sets the token used to mark the functions to inline */
  55123. inlineToken: string;
  55124. /** Gets or sets the debug mode */
  55125. debug: boolean;
  55126. /** Gets the code after the inlining process */
  55127. get code(): string;
  55128. /**
  55129. * Initializes the inliner
  55130. * @param sourceCode shader code source to inline
  55131. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55132. */
  55133. constructor(sourceCode: string, numMaxIterations?: number);
  55134. /**
  55135. * Start the processing of the shader code
  55136. */
  55137. processCode(): void;
  55138. private _collectFunctions;
  55139. private _processInlining;
  55140. private _extractBetweenMarkers;
  55141. private _skipWhitespaces;
  55142. private _removeComments;
  55143. private _replaceFunctionCallsByCode;
  55144. private _findBackward;
  55145. private _escapeRegExp;
  55146. private _replaceNames;
  55147. }
  55148. }
  55149. declare module "babylonjs/Engines/nativeEngine" {
  55150. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55151. import { Engine } from "babylonjs/Engines/engine";
  55152. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55155. import { Effect } from "babylonjs/Materials/effect";
  55156. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55157. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55158. import { IColor4Like } from "babylonjs/Maths/math.like";
  55159. import { Scene } from "babylonjs/scene";
  55160. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55161. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55162. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55163. /**
  55164. * Container for accessors for natively-stored mesh data buffers.
  55165. */
  55166. class NativeDataBuffer extends DataBuffer {
  55167. /**
  55168. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55169. */
  55170. nativeIndexBuffer?: any;
  55171. /**
  55172. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55173. */
  55174. nativeVertexBuffer?: any;
  55175. }
  55176. /** @hidden */
  55177. class NativeTexture extends InternalTexture {
  55178. getInternalTexture(): InternalTexture;
  55179. getViewCount(): number;
  55180. }
  55181. /** @hidden */
  55182. export class NativeEngine extends Engine {
  55183. private readonly _native;
  55184. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55185. private readonly INVALID_HANDLE;
  55186. private _boundBuffersVertexArray;
  55187. private _currentDepthTest;
  55188. getHardwareScalingLevel(): number;
  55189. constructor();
  55190. dispose(): void;
  55191. /**
  55192. * Can be used to override the current requestAnimationFrame requester.
  55193. * @hidden
  55194. */
  55195. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55196. /**
  55197. * Override default engine behavior.
  55198. * @param color
  55199. * @param backBuffer
  55200. * @param depth
  55201. * @param stencil
  55202. */
  55203. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55204. /**
  55205. * Gets host document
  55206. * @returns the host document object
  55207. */
  55208. getHostDocument(): Nullable<Document>;
  55209. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55210. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55211. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55212. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55213. [key: string]: VertexBuffer;
  55214. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55215. bindBuffers(vertexBuffers: {
  55216. [key: string]: VertexBuffer;
  55217. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55218. recordVertexArrayObject(vertexBuffers: {
  55219. [key: string]: VertexBuffer;
  55220. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55221. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55222. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55223. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55224. /**
  55225. * Draw a list of indexed primitives
  55226. * @param fillMode defines the primitive to use
  55227. * @param indexStart defines the starting index
  55228. * @param indexCount defines the number of index to draw
  55229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55230. */
  55231. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55232. /**
  55233. * Draw a list of unindexed primitives
  55234. * @param fillMode defines the primitive to use
  55235. * @param verticesStart defines the index of first vertex to draw
  55236. * @param verticesCount defines the count of vertices to draw
  55237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55238. */
  55239. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55240. createPipelineContext(): IPipelineContext;
  55241. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55242. /** @hidden */
  55243. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55244. /** @hidden */
  55245. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55246. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55247. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55248. protected _setProgram(program: WebGLProgram): void;
  55249. _releaseEffect(effect: Effect): void;
  55250. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55251. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55252. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55253. bindSamplers(effect: Effect): void;
  55254. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55255. getRenderWidth(useScreen?: boolean): number;
  55256. getRenderHeight(useScreen?: boolean): number;
  55257. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55259. /**
  55260. * Set the z offset to apply to current rendering
  55261. * @param value defines the offset to apply
  55262. */
  55263. setZOffset(value: number): void;
  55264. /**
  55265. * Gets the current value of the zOffset
  55266. * @returns the current zOffset state
  55267. */
  55268. getZOffset(): number;
  55269. /**
  55270. * Enable or disable depth buffering
  55271. * @param enable defines the state to set
  55272. */
  55273. setDepthBuffer(enable: boolean): void;
  55274. /**
  55275. * Gets a boolean indicating if depth writing is enabled
  55276. * @returns the current depth writing state
  55277. */
  55278. getDepthWrite(): boolean;
  55279. setDepthFunctionToGreater(): void;
  55280. setDepthFunctionToGreaterOrEqual(): void;
  55281. setDepthFunctionToLess(): void;
  55282. setDepthFunctionToLessOrEqual(): void;
  55283. /**
  55284. * Enable or disable depth writing
  55285. * @param enable defines the state to set
  55286. */
  55287. setDepthWrite(enable: boolean): void;
  55288. /**
  55289. * Enable or disable color writing
  55290. * @param enable defines the state to set
  55291. */
  55292. setColorWrite(enable: boolean): void;
  55293. /**
  55294. * Gets a boolean indicating if color writing is enabled
  55295. * @returns the current color writing state
  55296. */
  55297. getColorWrite(): boolean;
  55298. /**
  55299. * Sets alpha constants used by some alpha blending modes
  55300. * @param r defines the red component
  55301. * @param g defines the green component
  55302. * @param b defines the blue component
  55303. * @param a defines the alpha component
  55304. */
  55305. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55306. /**
  55307. * Sets the current alpha mode
  55308. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55309. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55310. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55311. */
  55312. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55313. /**
  55314. * Gets the current alpha mode
  55315. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55316. * @returns the current alpha mode
  55317. */
  55318. getAlphaMode(): number;
  55319. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55320. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55321. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55322. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55323. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55324. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55325. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55326. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55327. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55328. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55329. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55330. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55331. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55332. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55333. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55335. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55336. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55337. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55338. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55339. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55340. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55341. wipeCaches(bruteForce?: boolean): void;
  55342. _createTexture(): WebGLTexture;
  55343. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55344. /**
  55345. * Usually called from Texture.ts.
  55346. * Passed information to create a WebGLTexture
  55347. * @param url defines a value which contains one of the following:
  55348. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55349. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55350. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55351. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55352. * @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)
  55353. * @param scene needed for loading to the correct scene
  55354. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55355. * @param onLoad optional callback to be called upon successful completion
  55356. * @param onError optional callback to be called upon failure
  55357. * @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
  55358. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55359. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55360. * @param forcedExtension defines the extension to use to pick the right loader
  55361. * @param mimeType defines an optional mime type
  55362. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55363. */
  55364. 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;
  55365. /**
  55366. * Creates a cube texture
  55367. * @param rootUrl defines the url where the files to load is located
  55368. * @param scene defines the current scene
  55369. * @param files defines the list of files to load (1 per face)
  55370. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55371. * @param onLoad defines an optional callback raised when the texture is loaded
  55372. * @param onError defines an optional callback raised if there is an issue to load the texture
  55373. * @param format defines the format of the data
  55374. * @param forcedExtension defines the extension to use to pick the right loader
  55375. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55378. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55379. * @returns the cube texture as an InternalTexture
  55380. */
  55381. 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;
  55382. private _getSamplingFilter;
  55383. private static _GetNativeTextureFormat;
  55384. createRenderTargetTexture(size: number | {
  55385. width: number;
  55386. height: number;
  55387. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55388. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55389. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55390. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55391. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55392. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55393. /**
  55394. * Updates a dynamic vertex buffer.
  55395. * @param vertexBuffer the vertex buffer to update
  55396. * @param data the data used to update the vertex buffer
  55397. * @param byteOffset the byte offset of the data (optional)
  55398. * @param byteLength the byte length of the data (optional)
  55399. */
  55400. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55401. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55402. private _updateAnisotropicLevel;
  55403. private _getAddressMode;
  55404. /** @hidden */
  55405. _bindTexture(channel: number, texture: InternalTexture): void;
  55406. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55407. releaseEffects(): void;
  55408. /** @hidden */
  55409. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55410. /** @hidden */
  55411. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55412. /** @hidden */
  55413. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55414. /** @hidden */
  55415. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55416. }
  55417. }
  55418. declare module "babylonjs/Engines/index" {
  55419. export * from "babylonjs/Engines/constants";
  55420. export * from "babylonjs/Engines/engineCapabilities";
  55421. export * from "babylonjs/Engines/instancingAttributeInfo";
  55422. export * from "babylonjs/Engines/thinEngine";
  55423. export * from "babylonjs/Engines/engine";
  55424. export * from "babylonjs/Engines/engineStore";
  55425. export * from "babylonjs/Engines/nullEngine";
  55426. export * from "babylonjs/Engines/Extensions/index";
  55427. export * from "babylonjs/Engines/IPipelineContext";
  55428. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55429. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55430. export * from "babylonjs/Engines/nativeEngine";
  55431. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55432. export * from "babylonjs/Engines/performanceConfigurator";
  55433. }
  55434. declare module "babylonjs/Events/clipboardEvents" {
  55435. /**
  55436. * Gather the list of clipboard event types as constants.
  55437. */
  55438. export class ClipboardEventTypes {
  55439. /**
  55440. * The clipboard event is fired when a copy command is active (pressed).
  55441. */
  55442. static readonly COPY: number;
  55443. /**
  55444. * The clipboard event is fired when a cut command is active (pressed).
  55445. */
  55446. static readonly CUT: number;
  55447. /**
  55448. * The clipboard event is fired when a paste command is active (pressed).
  55449. */
  55450. static readonly PASTE: number;
  55451. }
  55452. /**
  55453. * This class is used to store clipboard related info for the onClipboardObservable event.
  55454. */
  55455. export class ClipboardInfo {
  55456. /**
  55457. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55458. */
  55459. type: number;
  55460. /**
  55461. * Defines the related dom event
  55462. */
  55463. event: ClipboardEvent;
  55464. /**
  55465. *Creates an instance of ClipboardInfo.
  55466. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55467. * @param event Defines the related dom event
  55468. */
  55469. constructor(
  55470. /**
  55471. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55472. */
  55473. type: number,
  55474. /**
  55475. * Defines the related dom event
  55476. */
  55477. event: ClipboardEvent);
  55478. /**
  55479. * Get the clipboard event's type from the keycode.
  55480. * @param keyCode Defines the keyCode for the current keyboard event.
  55481. * @return {number}
  55482. */
  55483. static GetTypeFromCharacter(keyCode: number): number;
  55484. }
  55485. }
  55486. declare module "babylonjs/Events/index" {
  55487. export * from "babylonjs/Events/keyboardEvents";
  55488. export * from "babylonjs/Events/pointerEvents";
  55489. export * from "babylonjs/Events/clipboardEvents";
  55490. }
  55491. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55492. import { Scene } from "babylonjs/scene";
  55493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55494. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55495. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55496. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55497. /**
  55498. * Google Daydream controller
  55499. */
  55500. export class DaydreamController extends WebVRController {
  55501. /**
  55502. * Base Url for the controller model.
  55503. */
  55504. static MODEL_BASE_URL: string;
  55505. /**
  55506. * File name for the controller model.
  55507. */
  55508. static MODEL_FILENAME: string;
  55509. /**
  55510. * Gamepad Id prefix used to identify Daydream Controller.
  55511. */
  55512. static readonly GAMEPAD_ID_PREFIX: string;
  55513. /**
  55514. * Creates a new DaydreamController from a gamepad
  55515. * @param vrGamepad the gamepad that the controller should be created from
  55516. */
  55517. constructor(vrGamepad: any);
  55518. /**
  55519. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55520. * @param scene scene in which to add meshes
  55521. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55522. */
  55523. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55524. /**
  55525. * Called once for each button that changed state since the last frame
  55526. * @param buttonIdx Which button index changed
  55527. * @param state New state of the button
  55528. * @param changes Which properties on the state changed since last frame
  55529. */
  55530. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55531. }
  55532. }
  55533. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55534. import { Scene } from "babylonjs/scene";
  55535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55536. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55537. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55538. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55539. /**
  55540. * Gear VR Controller
  55541. */
  55542. export class GearVRController extends WebVRController {
  55543. /**
  55544. * Base Url for the controller model.
  55545. */
  55546. static MODEL_BASE_URL: string;
  55547. /**
  55548. * File name for the controller model.
  55549. */
  55550. static MODEL_FILENAME: string;
  55551. /**
  55552. * Gamepad Id prefix used to identify this controller.
  55553. */
  55554. static readonly GAMEPAD_ID_PREFIX: string;
  55555. private readonly _buttonIndexToObservableNameMap;
  55556. /**
  55557. * Creates a new GearVRController from a gamepad
  55558. * @param vrGamepad the gamepad that the controller should be created from
  55559. */
  55560. constructor(vrGamepad: any);
  55561. /**
  55562. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55563. * @param scene scene in which to add meshes
  55564. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55565. */
  55566. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55567. /**
  55568. * Called once for each button that changed state since the last frame
  55569. * @param buttonIdx Which button index changed
  55570. * @param state New state of the button
  55571. * @param changes Which properties on the state changed since last frame
  55572. */
  55573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55574. }
  55575. }
  55576. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55577. import { Scene } from "babylonjs/scene";
  55578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55579. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55580. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55581. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55582. /**
  55583. * Generic Controller
  55584. */
  55585. export class GenericController extends WebVRController {
  55586. /**
  55587. * Base Url for the controller model.
  55588. */
  55589. static readonly MODEL_BASE_URL: string;
  55590. /**
  55591. * File name for the controller model.
  55592. */
  55593. static readonly MODEL_FILENAME: string;
  55594. /**
  55595. * Creates a new GenericController from a gamepad
  55596. * @param vrGamepad the gamepad that the controller should be created from
  55597. */
  55598. constructor(vrGamepad: any);
  55599. /**
  55600. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55601. * @param scene scene in which to add meshes
  55602. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55603. */
  55604. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55605. /**
  55606. * Called once for each button that changed state since the last frame
  55607. * @param buttonIdx Which button index changed
  55608. * @param state New state of the button
  55609. * @param changes Which properties on the state changed since last frame
  55610. */
  55611. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55612. }
  55613. }
  55614. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55615. import { Observable } from "babylonjs/Misc/observable";
  55616. import { Scene } from "babylonjs/scene";
  55617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55618. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55619. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55620. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55621. /**
  55622. * Oculus Touch Controller
  55623. */
  55624. export class OculusTouchController extends WebVRController {
  55625. /**
  55626. * Base Url for the controller model.
  55627. */
  55628. static MODEL_BASE_URL: string;
  55629. /**
  55630. * File name for the left controller model.
  55631. */
  55632. static MODEL_LEFT_FILENAME: string;
  55633. /**
  55634. * File name for the right controller model.
  55635. */
  55636. static MODEL_RIGHT_FILENAME: string;
  55637. /**
  55638. * Base Url for the Quest controller model.
  55639. */
  55640. static QUEST_MODEL_BASE_URL: string;
  55641. /**
  55642. * @hidden
  55643. * If the controllers are running on a device that needs the updated Quest controller models
  55644. */
  55645. static _IsQuest: boolean;
  55646. /**
  55647. * Fired when the secondary trigger on this controller is modified
  55648. */
  55649. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55650. /**
  55651. * Fired when the thumb rest on this controller is modified
  55652. */
  55653. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55654. /**
  55655. * Creates a new OculusTouchController from a gamepad
  55656. * @param vrGamepad the gamepad that the controller should be created from
  55657. */
  55658. constructor(vrGamepad: any);
  55659. /**
  55660. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55661. * @param scene scene in which to add meshes
  55662. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55663. */
  55664. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55665. /**
  55666. * Fired when the A button on this controller is modified
  55667. */
  55668. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55669. /**
  55670. * Fired when the B button on this controller is modified
  55671. */
  55672. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55673. /**
  55674. * Fired when the X button on this controller is modified
  55675. */
  55676. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55677. /**
  55678. * Fired when the Y button on this controller is modified
  55679. */
  55680. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55681. /**
  55682. * Called once for each button that changed state since the last frame
  55683. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55684. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55685. * 2) secondary trigger (same)
  55686. * 3) A (right) X (left), touch, pressed = value
  55687. * 4) B / Y
  55688. * 5) thumb rest
  55689. * @param buttonIdx Which button index changed
  55690. * @param state New state of the button
  55691. * @param changes Which properties on the state changed since last frame
  55692. */
  55693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55694. }
  55695. }
  55696. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55697. import { Scene } from "babylonjs/scene";
  55698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55699. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55700. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55701. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55702. import { Observable } from "babylonjs/Misc/observable";
  55703. /**
  55704. * Vive Controller
  55705. */
  55706. export class ViveController extends WebVRController {
  55707. /**
  55708. * Base Url for the controller model.
  55709. */
  55710. static MODEL_BASE_URL: string;
  55711. /**
  55712. * File name for the controller model.
  55713. */
  55714. static MODEL_FILENAME: string;
  55715. /**
  55716. * Creates a new ViveController from a gamepad
  55717. * @param vrGamepad the gamepad that the controller should be created from
  55718. */
  55719. constructor(vrGamepad: any);
  55720. /**
  55721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55722. * @param scene scene in which to add meshes
  55723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55724. */
  55725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55726. /**
  55727. * Fired when the left button on this controller is modified
  55728. */
  55729. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55730. /**
  55731. * Fired when the right button on this controller is modified
  55732. */
  55733. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55734. /**
  55735. * Fired when the menu button on this controller is modified
  55736. */
  55737. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55738. /**
  55739. * Called once for each button that changed state since the last frame
  55740. * Vive mapping:
  55741. * 0: touchpad
  55742. * 1: trigger
  55743. * 2: left AND right buttons
  55744. * 3: menu button
  55745. * @param buttonIdx Which button index changed
  55746. * @param state New state of the button
  55747. * @param changes Which properties on the state changed since last frame
  55748. */
  55749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55750. }
  55751. }
  55752. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55753. import { Observable } from "babylonjs/Misc/observable";
  55754. import { Scene } from "babylonjs/scene";
  55755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55756. import { Ray } from "babylonjs/Culling/ray";
  55757. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55758. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55759. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55760. /**
  55761. * Defines the WindowsMotionController object that the state of the windows motion controller
  55762. */
  55763. export class WindowsMotionController extends WebVRController {
  55764. /**
  55765. * The base url used to load the left and right controller models
  55766. */
  55767. static MODEL_BASE_URL: string;
  55768. /**
  55769. * The name of the left controller model file
  55770. */
  55771. static MODEL_LEFT_FILENAME: string;
  55772. /**
  55773. * The name of the right controller model file
  55774. */
  55775. static MODEL_RIGHT_FILENAME: string;
  55776. /**
  55777. * The controller name prefix for this controller type
  55778. */
  55779. static readonly GAMEPAD_ID_PREFIX: string;
  55780. /**
  55781. * The controller id pattern for this controller type
  55782. */
  55783. private static readonly GAMEPAD_ID_PATTERN;
  55784. private _loadedMeshInfo;
  55785. protected readonly _mapping: {
  55786. buttons: string[];
  55787. buttonMeshNames: {
  55788. trigger: string;
  55789. menu: string;
  55790. grip: string;
  55791. thumbstick: string;
  55792. trackpad: string;
  55793. };
  55794. buttonObservableNames: {
  55795. trigger: string;
  55796. menu: string;
  55797. grip: string;
  55798. thumbstick: string;
  55799. trackpad: string;
  55800. };
  55801. axisMeshNames: string[];
  55802. pointingPoseMeshName: string;
  55803. };
  55804. /**
  55805. * Fired when the trackpad on this controller is clicked
  55806. */
  55807. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55808. /**
  55809. * Fired when the trackpad on this controller is modified
  55810. */
  55811. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55812. /**
  55813. * The current x and y values of this controller's trackpad
  55814. */
  55815. trackpad: StickValues;
  55816. /**
  55817. * Creates a new WindowsMotionController from a gamepad
  55818. * @param vrGamepad the gamepad that the controller should be created from
  55819. */
  55820. constructor(vrGamepad: any);
  55821. /**
  55822. * Fired when the trigger on this controller is modified
  55823. */
  55824. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55825. /**
  55826. * Fired when the menu button on this controller is modified
  55827. */
  55828. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55829. /**
  55830. * Fired when the grip button on this controller is modified
  55831. */
  55832. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55833. /**
  55834. * Fired when the thumbstick button on this controller is modified
  55835. */
  55836. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55837. /**
  55838. * Fired when the touchpad button on this controller is modified
  55839. */
  55840. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55841. /**
  55842. * Fired when the touchpad values on this controller are modified
  55843. */
  55844. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55845. protected _updateTrackpad(): void;
  55846. /**
  55847. * Called once per frame by the engine.
  55848. */
  55849. update(): void;
  55850. /**
  55851. * Called once for each button that changed state since the last frame
  55852. * @param buttonIdx Which button index changed
  55853. * @param state New state of the button
  55854. * @param changes Which properties on the state changed since last frame
  55855. */
  55856. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55857. /**
  55858. * Moves the buttons on the controller mesh based on their current state
  55859. * @param buttonName the name of the button to move
  55860. * @param buttonValue the value of the button which determines the buttons new position
  55861. */
  55862. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55863. /**
  55864. * Moves the axis on the controller mesh based on its current state
  55865. * @param axis the index of the axis
  55866. * @param axisValue the value of the axis which determines the meshes new position
  55867. * @hidden
  55868. */
  55869. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55870. /**
  55871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55872. * @param scene scene in which to add meshes
  55873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55874. */
  55875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55876. /**
  55877. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55878. * can be transformed by button presses and axes values, based on this._mapping.
  55879. *
  55880. * @param scene scene in which the meshes exist
  55881. * @param meshes list of meshes that make up the controller model to process
  55882. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55883. */
  55884. private processModel;
  55885. private createMeshInfo;
  55886. /**
  55887. * Gets the ray of the controller in the direction the controller is pointing
  55888. * @param length the length the resulting ray should be
  55889. * @returns a ray in the direction the controller is pointing
  55890. */
  55891. getForwardRay(length?: number): Ray;
  55892. /**
  55893. * Disposes of the controller
  55894. */
  55895. dispose(): void;
  55896. }
  55897. /**
  55898. * This class represents a new windows motion controller in XR.
  55899. */
  55900. export class XRWindowsMotionController extends WindowsMotionController {
  55901. /**
  55902. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55903. */
  55904. protected readonly _mapping: {
  55905. buttons: string[];
  55906. buttonMeshNames: {
  55907. trigger: string;
  55908. menu: string;
  55909. grip: string;
  55910. thumbstick: string;
  55911. trackpad: string;
  55912. };
  55913. buttonObservableNames: {
  55914. trigger: string;
  55915. menu: string;
  55916. grip: string;
  55917. thumbstick: string;
  55918. trackpad: string;
  55919. };
  55920. axisMeshNames: string[];
  55921. pointingPoseMeshName: string;
  55922. };
  55923. /**
  55924. * Construct a new XR-Based windows motion controller
  55925. *
  55926. * @param gamepadInfo the gamepad object from the browser
  55927. */
  55928. constructor(gamepadInfo: any);
  55929. /**
  55930. * holds the thumbstick values (X,Y)
  55931. */
  55932. thumbstickValues: StickValues;
  55933. /**
  55934. * Fired when the thumbstick on this controller is clicked
  55935. */
  55936. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55937. /**
  55938. * Fired when the thumbstick on this controller is modified
  55939. */
  55940. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55941. /**
  55942. * Fired when the touchpad button on this controller is modified
  55943. */
  55944. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55945. /**
  55946. * Fired when the touchpad values on this controller are modified
  55947. */
  55948. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55949. /**
  55950. * Fired when the thumbstick button on this controller is modified
  55951. * here to prevent breaking changes
  55952. */
  55953. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55954. /**
  55955. * updating the thumbstick(!) and not the trackpad.
  55956. * This is named this way due to the difference between WebVR and XR and to avoid
  55957. * changing the parent class.
  55958. */
  55959. protected _updateTrackpad(): void;
  55960. /**
  55961. * Disposes the class with joy
  55962. */
  55963. dispose(): void;
  55964. }
  55965. }
  55966. declare module "babylonjs/Gamepads/Controllers/index" {
  55967. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55968. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55969. export * from "babylonjs/Gamepads/Controllers/genericController";
  55970. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55971. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55972. export * from "babylonjs/Gamepads/Controllers/viveController";
  55973. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55974. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55975. }
  55976. declare module "babylonjs/Gamepads/index" {
  55977. export * from "babylonjs/Gamepads/Controllers/index";
  55978. export * from "babylonjs/Gamepads/gamepad";
  55979. export * from "babylonjs/Gamepads/gamepadManager";
  55980. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55981. export * from "babylonjs/Gamepads/xboxGamepad";
  55982. export * from "babylonjs/Gamepads/dualShockGamepad";
  55983. }
  55984. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55985. import { Scene } from "babylonjs/scene";
  55986. import { Vector4 } from "babylonjs/Maths/math.vector";
  55987. import { Color4 } from "babylonjs/Maths/math.color";
  55988. import { Mesh } from "babylonjs/Meshes/mesh";
  55989. import { Nullable } from "babylonjs/types";
  55990. /**
  55991. * Class containing static functions to help procedurally build meshes
  55992. */
  55993. export class PolyhedronBuilder {
  55994. /**
  55995. * Creates a polyhedron mesh
  55996. * * 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
  55997. * * The parameter `size` (positive float, default 1) sets the polygon size
  55998. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55999. * * 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`
  56000. * * 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
  56001. * * 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)`)
  56002. * * 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
  56003. * * 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
  56004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56007. * @param name defines the name of the mesh
  56008. * @param options defines the options used to create the mesh
  56009. * @param scene defines the hosting scene
  56010. * @returns the polyhedron mesh
  56011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56012. */
  56013. static CreatePolyhedron(name: string, options: {
  56014. type?: number;
  56015. size?: number;
  56016. sizeX?: number;
  56017. sizeY?: number;
  56018. sizeZ?: number;
  56019. custom?: any;
  56020. faceUV?: Vector4[];
  56021. faceColors?: Color4[];
  56022. flat?: boolean;
  56023. updatable?: boolean;
  56024. sideOrientation?: number;
  56025. frontUVs?: Vector4;
  56026. backUVs?: Vector4;
  56027. }, scene?: Nullable<Scene>): Mesh;
  56028. }
  56029. }
  56030. declare module "babylonjs/Gizmos/scaleGizmo" {
  56031. import { Observable } from "babylonjs/Misc/observable";
  56032. import { Nullable } from "babylonjs/types";
  56033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56034. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56035. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56036. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56037. import { Node } from "babylonjs/node";
  56038. /**
  56039. * Gizmo that enables scaling a mesh along 3 axis
  56040. */
  56041. export class ScaleGizmo extends Gizmo {
  56042. /**
  56043. * Internal gizmo used for interactions on the x axis
  56044. */
  56045. xGizmo: AxisScaleGizmo;
  56046. /**
  56047. * Internal gizmo used for interactions on the y axis
  56048. */
  56049. yGizmo: AxisScaleGizmo;
  56050. /**
  56051. * Internal gizmo used for interactions on the z axis
  56052. */
  56053. zGizmo: AxisScaleGizmo;
  56054. /**
  56055. * Internal gizmo used to scale all axis equally
  56056. */
  56057. uniformScaleGizmo: AxisScaleGizmo;
  56058. private _meshAttached;
  56059. private _nodeAttached;
  56060. private _snapDistance;
  56061. private _uniformScalingMesh;
  56062. private _octahedron;
  56063. private _sensitivity;
  56064. /** Fires an event when any of it's sub gizmos are dragged */
  56065. onDragStartObservable: Observable<unknown>;
  56066. /** Fires an event when any of it's sub gizmos are released from dragging */
  56067. onDragEndObservable: Observable<unknown>;
  56068. get attachedMesh(): Nullable<AbstractMesh>;
  56069. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56070. get attachedNode(): Nullable<Node>;
  56071. set attachedNode(node: Nullable<Node>);
  56072. /**
  56073. * True when the mouse pointer is hovering a gizmo mesh
  56074. */
  56075. get isHovered(): boolean;
  56076. /**
  56077. * Creates a ScaleGizmo
  56078. * @param gizmoLayer The utility layer the gizmo will be added to
  56079. * @param thickness display gizmo axis thickness
  56080. */
  56081. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56082. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56083. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56084. /**
  56085. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56086. */
  56087. set snapDistance(value: number);
  56088. get snapDistance(): number;
  56089. /**
  56090. * Ratio for the scale of the gizmo (Default: 1)
  56091. */
  56092. set scaleRatio(value: number);
  56093. get scaleRatio(): number;
  56094. /**
  56095. * Sensitivity factor for dragging (Default: 1)
  56096. */
  56097. set sensitivity(value: number);
  56098. get sensitivity(): number;
  56099. /**
  56100. * Disposes of the gizmo
  56101. */
  56102. dispose(): void;
  56103. }
  56104. }
  56105. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56106. import { Observable } from "babylonjs/Misc/observable";
  56107. import { Nullable } from "babylonjs/types";
  56108. import { Vector3 } from "babylonjs/Maths/math.vector";
  56109. import { Node } from "babylonjs/node";
  56110. import { Mesh } from "babylonjs/Meshes/mesh";
  56111. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56112. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56113. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56114. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56115. import { Color3 } from "babylonjs/Maths/math.color";
  56116. /**
  56117. * Single axis scale gizmo
  56118. */
  56119. export class AxisScaleGizmo extends Gizmo {
  56120. /**
  56121. * Drag behavior responsible for the gizmos dragging interactions
  56122. */
  56123. dragBehavior: PointerDragBehavior;
  56124. private _pointerObserver;
  56125. /**
  56126. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56127. */
  56128. snapDistance: number;
  56129. /**
  56130. * Event that fires each time the gizmo snaps to a new location.
  56131. * * snapDistance is the the change in distance
  56132. */
  56133. onSnapObservable: Observable<{
  56134. snapDistance: number;
  56135. }>;
  56136. /**
  56137. * If the scaling operation should be done on all axis (default: false)
  56138. */
  56139. uniformScaling: boolean;
  56140. /**
  56141. * Custom sensitivity value for the drag strength
  56142. */
  56143. sensitivity: number;
  56144. private _isEnabled;
  56145. private _parent;
  56146. private _arrow;
  56147. private _coloredMaterial;
  56148. private _hoverMaterial;
  56149. /**
  56150. * Creates an AxisScaleGizmo
  56151. * @param gizmoLayer The utility layer the gizmo will be added to
  56152. * @param dragAxis The axis which the gizmo will be able to scale on
  56153. * @param color The color of the gizmo
  56154. * @param thickness display gizmo axis thickness
  56155. */
  56156. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56157. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56158. /**
  56159. * If the gizmo is enabled
  56160. */
  56161. set isEnabled(value: boolean);
  56162. get isEnabled(): boolean;
  56163. /**
  56164. * Disposes of the gizmo
  56165. */
  56166. dispose(): void;
  56167. /**
  56168. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56169. * @param mesh The mesh to replace the default mesh of the gizmo
  56170. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56171. */
  56172. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56173. }
  56174. }
  56175. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56176. import { Observable } from "babylonjs/Misc/observable";
  56177. import { Nullable } from "babylonjs/types";
  56178. import { Vector3 } from "babylonjs/Maths/math.vector";
  56179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56180. import { Mesh } from "babylonjs/Meshes/mesh";
  56181. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56182. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56183. import { Color3 } from "babylonjs/Maths/math.color";
  56184. import "babylonjs/Meshes/Builders/boxBuilder";
  56185. /**
  56186. * Bounding box gizmo
  56187. */
  56188. export class BoundingBoxGizmo extends Gizmo {
  56189. private _lineBoundingBox;
  56190. private _rotateSpheresParent;
  56191. private _scaleBoxesParent;
  56192. private _boundingDimensions;
  56193. private _renderObserver;
  56194. private _pointerObserver;
  56195. private _scaleDragSpeed;
  56196. private _tmpQuaternion;
  56197. private _tmpVector;
  56198. private _tmpRotationMatrix;
  56199. /**
  56200. * 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)
  56201. */
  56202. ignoreChildren: boolean;
  56203. /**
  56204. * 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)
  56205. */
  56206. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56207. /**
  56208. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56209. */
  56210. rotationSphereSize: number;
  56211. /**
  56212. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56213. */
  56214. scaleBoxSize: number;
  56215. /**
  56216. * 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)
  56217. */
  56218. fixedDragMeshScreenSize: boolean;
  56219. /**
  56220. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56221. */
  56222. fixedDragMeshScreenSizeDistanceFactor: number;
  56223. /**
  56224. * Fired when a rotation sphere or scale box is dragged
  56225. */
  56226. onDragStartObservable: Observable<{}>;
  56227. /**
  56228. * Fired when a scale box is dragged
  56229. */
  56230. onScaleBoxDragObservable: Observable<{}>;
  56231. /**
  56232. * Fired when a scale box drag is ended
  56233. */
  56234. onScaleBoxDragEndObservable: Observable<{}>;
  56235. /**
  56236. * Fired when a rotation sphere is dragged
  56237. */
  56238. onRotationSphereDragObservable: Observable<{}>;
  56239. /**
  56240. * Fired when a rotation sphere drag is ended
  56241. */
  56242. onRotationSphereDragEndObservable: Observable<{}>;
  56243. /**
  56244. * 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)
  56245. */
  56246. scalePivot: Nullable<Vector3>;
  56247. /**
  56248. * Mesh used as a pivot to rotate the attached node
  56249. */
  56250. private _anchorMesh;
  56251. private _existingMeshScale;
  56252. private _dragMesh;
  56253. private pointerDragBehavior;
  56254. private coloredMaterial;
  56255. private hoverColoredMaterial;
  56256. /**
  56257. * Sets the color of the bounding box gizmo
  56258. * @param color the color to set
  56259. */
  56260. setColor(color: Color3): void;
  56261. /**
  56262. * Creates an BoundingBoxGizmo
  56263. * @param gizmoLayer The utility layer the gizmo will be added to
  56264. * @param color The color of the gizmo
  56265. */
  56266. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56267. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56268. private _selectNode;
  56269. /**
  56270. * Updates the bounding box information for the Gizmo
  56271. */
  56272. updateBoundingBox(): void;
  56273. private _updateRotationSpheres;
  56274. private _updateScaleBoxes;
  56275. /**
  56276. * Enables rotation on the specified axis and disables rotation on the others
  56277. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56278. */
  56279. setEnabledRotationAxis(axis: string): void;
  56280. /**
  56281. * Enables/disables scaling
  56282. * @param enable if scaling should be enabled
  56283. * @param homogeneousScaling defines if scaling should only be homogeneous
  56284. */
  56285. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56286. private _updateDummy;
  56287. /**
  56288. * Enables a pointer drag behavior on the bounding box of the gizmo
  56289. */
  56290. enableDragBehavior(): void;
  56291. /**
  56292. * Disposes of the gizmo
  56293. */
  56294. dispose(): void;
  56295. /**
  56296. * 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)
  56297. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56298. * @returns the bounding box mesh with the passed in mesh as a child
  56299. */
  56300. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56301. /**
  56302. * CustomMeshes are not supported by this gizmo
  56303. * @param mesh The mesh to replace the default mesh of the gizmo
  56304. */
  56305. setCustomMesh(mesh: Mesh): void;
  56306. }
  56307. }
  56308. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56309. import { Observable } from "babylonjs/Misc/observable";
  56310. import { Nullable } from "babylonjs/types";
  56311. import { Vector3 } from "babylonjs/Maths/math.vector";
  56312. import { Color3 } from "babylonjs/Maths/math.color";
  56313. import { Node } from "babylonjs/node";
  56314. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56315. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56316. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56317. import "babylonjs/Meshes/Builders/linesBuilder";
  56318. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56319. /**
  56320. * Single plane rotation gizmo
  56321. */
  56322. export class PlaneRotationGizmo extends Gizmo {
  56323. /**
  56324. * Drag behavior responsible for the gizmos dragging interactions
  56325. */
  56326. dragBehavior: PointerDragBehavior;
  56327. private _pointerObserver;
  56328. /**
  56329. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56330. */
  56331. snapDistance: number;
  56332. /**
  56333. * Event that fires each time the gizmo snaps to a new location.
  56334. * * snapDistance is the the change in distance
  56335. */
  56336. onSnapObservable: Observable<{
  56337. snapDistance: number;
  56338. }>;
  56339. private _isEnabled;
  56340. private _parent;
  56341. /**
  56342. * Creates a PlaneRotationGizmo
  56343. * @param gizmoLayer The utility layer the gizmo will be added to
  56344. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56345. * @param color The color of the gizmo
  56346. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56347. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56348. * @param thickness display gizmo axis thickness
  56349. */
  56350. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56351. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56352. /**
  56353. * If the gizmo is enabled
  56354. */
  56355. set isEnabled(value: boolean);
  56356. get isEnabled(): boolean;
  56357. /**
  56358. * Disposes of the gizmo
  56359. */
  56360. dispose(): void;
  56361. }
  56362. }
  56363. declare module "babylonjs/Gizmos/rotationGizmo" {
  56364. import { Observable } from "babylonjs/Misc/observable";
  56365. import { Nullable } from "babylonjs/types";
  56366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56367. import { Mesh } from "babylonjs/Meshes/mesh";
  56368. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56369. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56370. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56371. import { Node } from "babylonjs/node";
  56372. /**
  56373. * Gizmo that enables rotating a mesh along 3 axis
  56374. */
  56375. export class RotationGizmo extends Gizmo {
  56376. /**
  56377. * Internal gizmo used for interactions on the x axis
  56378. */
  56379. xGizmo: PlaneRotationGizmo;
  56380. /**
  56381. * Internal gizmo used for interactions on the y axis
  56382. */
  56383. yGizmo: PlaneRotationGizmo;
  56384. /**
  56385. * Internal gizmo used for interactions on the z axis
  56386. */
  56387. zGizmo: PlaneRotationGizmo;
  56388. /** Fires an event when any of it's sub gizmos are dragged */
  56389. onDragStartObservable: Observable<unknown>;
  56390. /** Fires an event when any of it's sub gizmos are released from dragging */
  56391. onDragEndObservable: Observable<unknown>;
  56392. private _meshAttached;
  56393. private _nodeAttached;
  56394. get attachedMesh(): Nullable<AbstractMesh>;
  56395. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56396. get attachedNode(): Nullable<Node>;
  56397. set attachedNode(node: Nullable<Node>);
  56398. /**
  56399. * True when the mouse pointer is hovering a gizmo mesh
  56400. */
  56401. get isHovered(): boolean;
  56402. /**
  56403. * Creates a RotationGizmo
  56404. * @param gizmoLayer The utility layer the gizmo will be added to
  56405. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56406. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56407. * @param thickness display gizmo axis thickness
  56408. */
  56409. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56410. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56411. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56412. /**
  56413. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56414. */
  56415. set snapDistance(value: number);
  56416. get snapDistance(): number;
  56417. /**
  56418. * Ratio for the scale of the gizmo (Default: 1)
  56419. */
  56420. set scaleRatio(value: number);
  56421. get scaleRatio(): number;
  56422. /**
  56423. * Disposes of the gizmo
  56424. */
  56425. dispose(): void;
  56426. /**
  56427. * CustomMeshes are not supported by this gizmo
  56428. * @param mesh The mesh to replace the default mesh of the gizmo
  56429. */
  56430. setCustomMesh(mesh: Mesh): void;
  56431. }
  56432. }
  56433. declare module "babylonjs/Gizmos/gizmoManager" {
  56434. import { Observable } from "babylonjs/Misc/observable";
  56435. import { Nullable } from "babylonjs/types";
  56436. import { Scene, IDisposable } from "babylonjs/scene";
  56437. import { Node } from "babylonjs/node";
  56438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56439. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56440. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56441. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56442. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56443. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56444. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56445. /**
  56446. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56447. */
  56448. export class GizmoManager implements IDisposable {
  56449. private scene;
  56450. /**
  56451. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56452. */
  56453. gizmos: {
  56454. positionGizmo: Nullable<PositionGizmo>;
  56455. rotationGizmo: Nullable<RotationGizmo>;
  56456. scaleGizmo: Nullable<ScaleGizmo>;
  56457. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56458. };
  56459. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56460. clearGizmoOnEmptyPointerEvent: boolean;
  56461. /** Fires an event when the manager is attached to a mesh */
  56462. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56463. /** Fires an event when the manager is attached to a node */
  56464. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56465. private _gizmosEnabled;
  56466. private _pointerObserver;
  56467. private _attachedMesh;
  56468. private _attachedNode;
  56469. private _boundingBoxColor;
  56470. private _defaultUtilityLayer;
  56471. private _defaultKeepDepthUtilityLayer;
  56472. private _thickness;
  56473. /**
  56474. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56475. */
  56476. boundingBoxDragBehavior: SixDofDragBehavior;
  56477. /**
  56478. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56479. */
  56480. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56481. /**
  56482. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56483. */
  56484. attachableNodes: Nullable<Array<Node>>;
  56485. /**
  56486. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56487. */
  56488. usePointerToAttachGizmos: boolean;
  56489. /**
  56490. * Utility layer that the bounding box gizmo belongs to
  56491. */
  56492. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56493. /**
  56494. * Utility layer that all gizmos besides bounding box belong to
  56495. */
  56496. get utilityLayer(): UtilityLayerRenderer;
  56497. /**
  56498. * True when the mouse pointer is hovering a gizmo mesh
  56499. */
  56500. get isHovered(): boolean;
  56501. /**
  56502. * Instatiates a gizmo manager
  56503. * @param scene the scene to overlay the gizmos on top of
  56504. * @param thickness display gizmo axis thickness
  56505. */
  56506. constructor(scene: Scene, thickness?: number);
  56507. /**
  56508. * Attaches a set of gizmos to the specified mesh
  56509. * @param mesh The mesh the gizmo's should be attached to
  56510. */
  56511. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56512. /**
  56513. * Attaches a set of gizmos to the specified node
  56514. * @param node The node the gizmo's should be attached to
  56515. */
  56516. attachToNode(node: Nullable<Node>): void;
  56517. /**
  56518. * If the position gizmo is enabled
  56519. */
  56520. set positionGizmoEnabled(value: boolean);
  56521. get positionGizmoEnabled(): boolean;
  56522. /**
  56523. * If the rotation gizmo is enabled
  56524. */
  56525. set rotationGizmoEnabled(value: boolean);
  56526. get rotationGizmoEnabled(): boolean;
  56527. /**
  56528. * If the scale gizmo is enabled
  56529. */
  56530. set scaleGizmoEnabled(value: boolean);
  56531. get scaleGizmoEnabled(): boolean;
  56532. /**
  56533. * If the boundingBox gizmo is enabled
  56534. */
  56535. set boundingBoxGizmoEnabled(value: boolean);
  56536. get boundingBoxGizmoEnabled(): boolean;
  56537. /**
  56538. * Disposes of the gizmo manager
  56539. */
  56540. dispose(): void;
  56541. }
  56542. }
  56543. declare module "babylonjs/Lights/directionalLight" {
  56544. import { Camera } from "babylonjs/Cameras/camera";
  56545. import { Scene } from "babylonjs/scene";
  56546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56548. import { Light } from "babylonjs/Lights/light";
  56549. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56550. import { Effect } from "babylonjs/Materials/effect";
  56551. /**
  56552. * A directional light is defined by a direction (what a surprise!).
  56553. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56554. * 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.
  56555. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56556. */
  56557. export class DirectionalLight extends ShadowLight {
  56558. private _shadowFrustumSize;
  56559. /**
  56560. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56561. */
  56562. get shadowFrustumSize(): number;
  56563. /**
  56564. * Specifies a fix frustum size for the shadow generation.
  56565. */
  56566. set shadowFrustumSize(value: number);
  56567. private _shadowOrthoScale;
  56568. /**
  56569. * Gets the shadow projection scale against the optimal computed one.
  56570. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56571. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56572. */
  56573. get shadowOrthoScale(): number;
  56574. /**
  56575. * Sets the shadow projection scale against the optimal computed one.
  56576. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56577. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56578. */
  56579. set shadowOrthoScale(value: number);
  56580. /**
  56581. * Automatically compute the projection matrix to best fit (including all the casters)
  56582. * on each frame.
  56583. */
  56584. autoUpdateExtends: boolean;
  56585. /**
  56586. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56587. * on each frame. autoUpdateExtends must be set to true for this to work
  56588. */
  56589. autoCalcShadowZBounds: boolean;
  56590. private _orthoLeft;
  56591. private _orthoRight;
  56592. private _orthoTop;
  56593. private _orthoBottom;
  56594. /**
  56595. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56596. * The directional light is emitted from everywhere in the given direction.
  56597. * It can cast shadows.
  56598. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56599. * @param name The friendly name of the light
  56600. * @param direction The direction of the light
  56601. * @param scene The scene the light belongs to
  56602. */
  56603. constructor(name: string, direction: Vector3, scene: Scene);
  56604. /**
  56605. * Returns the string "DirectionalLight".
  56606. * @return The class name
  56607. */
  56608. getClassName(): string;
  56609. /**
  56610. * Returns the integer 1.
  56611. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56612. */
  56613. getTypeID(): number;
  56614. /**
  56615. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56616. * Returns the DirectionalLight Shadow projection matrix.
  56617. */
  56618. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56619. /**
  56620. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56621. * Returns the DirectionalLight Shadow projection matrix.
  56622. */
  56623. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56624. /**
  56625. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56626. * Returns the DirectionalLight Shadow projection matrix.
  56627. */
  56628. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56629. protected _buildUniformLayout(): void;
  56630. /**
  56631. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56632. * @param effect The effect to update
  56633. * @param lightIndex The index of the light in the effect to update
  56634. * @returns The directional light
  56635. */
  56636. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56637. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56638. /**
  56639. * Gets the minZ used for shadow according to both the scene and the light.
  56640. *
  56641. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56642. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56643. * @param activeCamera The camera we are returning the min for
  56644. * @returns the depth min z
  56645. */
  56646. getDepthMinZ(activeCamera: Camera): number;
  56647. /**
  56648. * Gets the maxZ used for shadow according to both the scene and the light.
  56649. *
  56650. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56651. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56652. * @param activeCamera The camera we are returning the max for
  56653. * @returns the depth max z
  56654. */
  56655. getDepthMaxZ(activeCamera: Camera): number;
  56656. /**
  56657. * Prepares the list of defines specific to the light type.
  56658. * @param defines the list of defines
  56659. * @param lightIndex defines the index of the light for the effect
  56660. */
  56661. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56662. }
  56663. }
  56664. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56665. import { Mesh } from "babylonjs/Meshes/mesh";
  56666. /**
  56667. * Class containing static functions to help procedurally build meshes
  56668. */
  56669. export class HemisphereBuilder {
  56670. /**
  56671. * Creates a hemisphere mesh
  56672. * @param name defines the name of the mesh
  56673. * @param options defines the options used to create the mesh
  56674. * @param scene defines the hosting scene
  56675. * @returns the hemisphere mesh
  56676. */
  56677. static CreateHemisphere(name: string, options: {
  56678. segments?: number;
  56679. diameter?: number;
  56680. sideOrientation?: number;
  56681. }, scene: any): Mesh;
  56682. }
  56683. }
  56684. declare module "babylonjs/Lights/spotLight" {
  56685. import { Nullable } from "babylonjs/types";
  56686. import { Scene } from "babylonjs/scene";
  56687. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56689. import { Effect } from "babylonjs/Materials/effect";
  56690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56691. import { Light } from "babylonjs/Lights/light";
  56692. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56693. /**
  56694. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56695. * These values define a cone of light starting from the position, emitting toward the direction.
  56696. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56697. * and the exponent defines the speed of the decay of the light with distance (reach).
  56698. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56699. */
  56700. export class SpotLight extends ShadowLight {
  56701. private _angle;
  56702. private _innerAngle;
  56703. private _cosHalfAngle;
  56704. private _lightAngleScale;
  56705. private _lightAngleOffset;
  56706. /**
  56707. * Gets the cone angle of the spot light in Radians.
  56708. */
  56709. get angle(): number;
  56710. /**
  56711. * Sets the cone angle of the spot light in Radians.
  56712. */
  56713. set angle(value: number);
  56714. /**
  56715. * Only used in gltf falloff mode, this defines the angle where
  56716. * the directional falloff will start before cutting at angle which could be seen
  56717. * as outer angle.
  56718. */
  56719. get innerAngle(): number;
  56720. /**
  56721. * Only used in gltf falloff mode, this defines the angle where
  56722. * the directional falloff will start before cutting at angle which could be seen
  56723. * as outer angle.
  56724. */
  56725. set innerAngle(value: number);
  56726. private _shadowAngleScale;
  56727. /**
  56728. * Allows scaling the angle of the light for shadow generation only.
  56729. */
  56730. get shadowAngleScale(): number;
  56731. /**
  56732. * Allows scaling the angle of the light for shadow generation only.
  56733. */
  56734. set shadowAngleScale(value: number);
  56735. /**
  56736. * The light decay speed with the distance from the emission spot.
  56737. */
  56738. exponent: number;
  56739. private _projectionTextureMatrix;
  56740. /**
  56741. * Allows reading the projecton texture
  56742. */
  56743. get projectionTextureMatrix(): Matrix;
  56744. protected _projectionTextureLightNear: number;
  56745. /**
  56746. * Gets the near clip of the Spotlight for texture projection.
  56747. */
  56748. get projectionTextureLightNear(): number;
  56749. /**
  56750. * Sets the near clip of the Spotlight for texture projection.
  56751. */
  56752. set projectionTextureLightNear(value: number);
  56753. protected _projectionTextureLightFar: number;
  56754. /**
  56755. * Gets the far clip of the Spotlight for texture projection.
  56756. */
  56757. get projectionTextureLightFar(): number;
  56758. /**
  56759. * Sets the far clip of the Spotlight for texture projection.
  56760. */
  56761. set projectionTextureLightFar(value: number);
  56762. protected _projectionTextureUpDirection: Vector3;
  56763. /**
  56764. * Gets the Up vector of the Spotlight for texture projection.
  56765. */
  56766. get projectionTextureUpDirection(): Vector3;
  56767. /**
  56768. * Sets the Up vector of the Spotlight for texture projection.
  56769. */
  56770. set projectionTextureUpDirection(value: Vector3);
  56771. private _projectionTexture;
  56772. /**
  56773. * Gets the projection texture of the light.
  56774. */
  56775. get projectionTexture(): Nullable<BaseTexture>;
  56776. /**
  56777. * Sets the projection texture of the light.
  56778. */
  56779. set projectionTexture(value: Nullable<BaseTexture>);
  56780. private _projectionTextureViewLightDirty;
  56781. private _projectionTextureProjectionLightDirty;
  56782. private _projectionTextureDirty;
  56783. private _projectionTextureViewTargetVector;
  56784. private _projectionTextureViewLightMatrix;
  56785. private _projectionTextureProjectionLightMatrix;
  56786. private _projectionTextureScalingMatrix;
  56787. /**
  56788. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56789. * It can cast shadows.
  56790. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56791. * @param name The light friendly name
  56792. * @param position The position of the spot light in the scene
  56793. * @param direction The direction of the light in the scene
  56794. * @param angle The cone angle of the light in Radians
  56795. * @param exponent The light decay speed with the distance from the emission spot
  56796. * @param scene The scene the lights belongs to
  56797. */
  56798. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56799. /**
  56800. * Returns the string "SpotLight".
  56801. * @returns the class name
  56802. */
  56803. getClassName(): string;
  56804. /**
  56805. * Returns the integer 2.
  56806. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56807. */
  56808. getTypeID(): number;
  56809. /**
  56810. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56811. */
  56812. protected _setDirection(value: Vector3): void;
  56813. /**
  56814. * Overrides the position setter to recompute the projection texture view light Matrix.
  56815. */
  56816. protected _setPosition(value: Vector3): void;
  56817. /**
  56818. * 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.
  56819. * Returns the SpotLight.
  56820. */
  56821. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56822. protected _computeProjectionTextureViewLightMatrix(): void;
  56823. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56824. /**
  56825. * Main function for light texture projection matrix computing.
  56826. */
  56827. protected _computeProjectionTextureMatrix(): void;
  56828. protected _buildUniformLayout(): void;
  56829. private _computeAngleValues;
  56830. /**
  56831. * Sets the passed Effect "effect" with the Light textures.
  56832. * @param effect The effect to update
  56833. * @param lightIndex The index of the light in the effect to update
  56834. * @returns The light
  56835. */
  56836. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56837. /**
  56838. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56839. * @param effect The effect to update
  56840. * @param lightIndex The index of the light in the effect to update
  56841. * @returns The spot light
  56842. */
  56843. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56844. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56845. /**
  56846. * Disposes the light and the associated resources.
  56847. */
  56848. dispose(): void;
  56849. /**
  56850. * Prepares the list of defines specific to the light type.
  56851. * @param defines the list of defines
  56852. * @param lightIndex defines the index of the light for the effect
  56853. */
  56854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56855. }
  56856. }
  56857. declare module "babylonjs/Gizmos/lightGizmo" {
  56858. import { Nullable } from "babylonjs/types";
  56859. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56860. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56861. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56862. import { Light } from "babylonjs/Lights/light";
  56863. import { Observable } from "babylonjs/Misc/observable";
  56864. /**
  56865. * Gizmo that enables viewing a light
  56866. */
  56867. export class LightGizmo extends Gizmo {
  56868. private _lightMesh;
  56869. private _material;
  56870. private _cachedPosition;
  56871. private _cachedForward;
  56872. private _attachedMeshParent;
  56873. private _pointerObserver;
  56874. /**
  56875. * Event that fires each time the gizmo is clicked
  56876. */
  56877. onClickedObservable: Observable<Light>;
  56878. /**
  56879. * Creates a LightGizmo
  56880. * @param gizmoLayer The utility layer the gizmo will be added to
  56881. */
  56882. constructor(gizmoLayer?: UtilityLayerRenderer);
  56883. private _light;
  56884. /**
  56885. * The light that the gizmo is attached to
  56886. */
  56887. set light(light: Nullable<Light>);
  56888. get light(): Nullable<Light>;
  56889. /**
  56890. * Gets the material used to render the light gizmo
  56891. */
  56892. get material(): StandardMaterial;
  56893. /**
  56894. * @hidden
  56895. * Updates the gizmo to match the attached mesh's position/rotation
  56896. */
  56897. protected _update(): void;
  56898. private static _Scale;
  56899. /**
  56900. * Creates the lines for a light mesh
  56901. */
  56902. private static _CreateLightLines;
  56903. /**
  56904. * Disposes of the light gizmo
  56905. */
  56906. dispose(): void;
  56907. private static _CreateHemisphericLightMesh;
  56908. private static _CreatePointLightMesh;
  56909. private static _CreateSpotLightMesh;
  56910. private static _CreateDirectionalLightMesh;
  56911. }
  56912. }
  56913. declare module "babylonjs/Gizmos/cameraGizmo" {
  56914. import { Nullable } from "babylonjs/types";
  56915. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56916. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56917. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56918. import { Camera } from "babylonjs/Cameras/camera";
  56919. import { Observable } from "babylonjs/Misc/observable";
  56920. /**
  56921. * Gizmo that enables viewing a camera
  56922. */
  56923. export class CameraGizmo extends Gizmo {
  56924. private _cameraMesh;
  56925. private _cameraLinesMesh;
  56926. private _material;
  56927. private _pointerObserver;
  56928. /**
  56929. * Event that fires each time the gizmo is clicked
  56930. */
  56931. onClickedObservable: Observable<Camera>;
  56932. /**
  56933. * Creates a CameraGizmo
  56934. * @param gizmoLayer The utility layer the gizmo will be added to
  56935. */
  56936. constructor(gizmoLayer?: UtilityLayerRenderer);
  56937. private _camera;
  56938. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56939. get displayFrustum(): boolean;
  56940. set displayFrustum(value: boolean);
  56941. /**
  56942. * The camera that the gizmo is attached to
  56943. */
  56944. set camera(camera: Nullable<Camera>);
  56945. get camera(): Nullable<Camera>;
  56946. /**
  56947. * Gets the material used to render the camera gizmo
  56948. */
  56949. get material(): StandardMaterial;
  56950. /**
  56951. * @hidden
  56952. * Updates the gizmo to match the attached mesh's position/rotation
  56953. */
  56954. protected _update(): void;
  56955. private static _Scale;
  56956. private _invProjection;
  56957. /**
  56958. * Disposes of the camera gizmo
  56959. */
  56960. dispose(): void;
  56961. private static _CreateCameraMesh;
  56962. private static _CreateCameraFrustum;
  56963. }
  56964. }
  56965. declare module "babylonjs/Gizmos/index" {
  56966. export * from "babylonjs/Gizmos/axisDragGizmo";
  56967. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56968. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56969. export * from "babylonjs/Gizmos/gizmo";
  56970. export * from "babylonjs/Gizmos/gizmoManager";
  56971. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56972. export * from "babylonjs/Gizmos/positionGizmo";
  56973. export * from "babylonjs/Gizmos/rotationGizmo";
  56974. export * from "babylonjs/Gizmos/scaleGizmo";
  56975. export * from "babylonjs/Gizmos/lightGizmo";
  56976. export * from "babylonjs/Gizmos/cameraGizmo";
  56977. export * from "babylonjs/Gizmos/planeDragGizmo";
  56978. }
  56979. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56980. /** @hidden */
  56981. export var backgroundFragmentDeclaration: {
  56982. name: string;
  56983. shader: string;
  56984. };
  56985. }
  56986. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56987. /** @hidden */
  56988. export var backgroundUboDeclaration: {
  56989. name: string;
  56990. shader: string;
  56991. };
  56992. }
  56993. declare module "babylonjs/Shaders/background.fragment" {
  56994. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56995. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56996. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56997. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56998. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56999. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57001. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57002. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57003. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57004. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57005. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57006. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57007. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57008. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57009. /** @hidden */
  57010. export var backgroundPixelShader: {
  57011. name: string;
  57012. shader: string;
  57013. };
  57014. }
  57015. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  57016. /** @hidden */
  57017. export var backgroundVertexDeclaration: {
  57018. name: string;
  57019. shader: string;
  57020. };
  57021. }
  57022. declare module "babylonjs/Shaders/background.vertex" {
  57023. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  57024. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  57025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57026. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57028. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57029. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57030. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57031. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57034. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57035. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57036. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57037. /** @hidden */
  57038. export var backgroundVertexShader: {
  57039. name: string;
  57040. shader: string;
  57041. };
  57042. }
  57043. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  57044. import { Nullable, int, float } from "babylonjs/types";
  57045. import { Scene } from "babylonjs/scene";
  57046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57049. import { Mesh } from "babylonjs/Meshes/mesh";
  57050. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57051. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57052. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57054. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  57055. import { Color3 } from "babylonjs/Maths/math.color";
  57056. import "babylonjs/Shaders/background.fragment";
  57057. import "babylonjs/Shaders/background.vertex";
  57058. /**
  57059. * Background material used to create an efficient environement around your scene.
  57060. */
  57061. export class BackgroundMaterial extends PushMaterial {
  57062. /**
  57063. * Standard reflectance value at parallel view angle.
  57064. */
  57065. static StandardReflectance0: number;
  57066. /**
  57067. * Standard reflectance value at grazing angle.
  57068. */
  57069. static StandardReflectance90: number;
  57070. protected _primaryColor: Color3;
  57071. /**
  57072. * Key light Color (multiply against the environement texture)
  57073. */
  57074. primaryColor: Color3;
  57075. protected __perceptualColor: Nullable<Color3>;
  57076. /**
  57077. * Experimental Internal Use Only.
  57078. *
  57079. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57080. * This acts as a helper to set the primary color to a more "human friendly" value.
  57081. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57082. * output color as close as possible from the chosen value.
  57083. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57084. * part of lighting setup.)
  57085. */
  57086. get _perceptualColor(): Nullable<Color3>;
  57087. set _perceptualColor(value: Nullable<Color3>);
  57088. protected _primaryColorShadowLevel: float;
  57089. /**
  57090. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57091. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57092. */
  57093. get primaryColorShadowLevel(): float;
  57094. set primaryColorShadowLevel(value: float);
  57095. protected _primaryColorHighlightLevel: float;
  57096. /**
  57097. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57098. * The primary color is used at the level chosen to define what the white area would look.
  57099. */
  57100. get primaryColorHighlightLevel(): float;
  57101. set primaryColorHighlightLevel(value: float);
  57102. protected _reflectionTexture: Nullable<BaseTexture>;
  57103. /**
  57104. * Reflection Texture used in the material.
  57105. * Should be author in a specific way for the best result (refer to the documentation).
  57106. */
  57107. reflectionTexture: Nullable<BaseTexture>;
  57108. protected _reflectionBlur: float;
  57109. /**
  57110. * Reflection Texture level of blur.
  57111. *
  57112. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57113. * texture twice.
  57114. */
  57115. reflectionBlur: float;
  57116. protected _diffuseTexture: Nullable<BaseTexture>;
  57117. /**
  57118. * Diffuse Texture used in the material.
  57119. * Should be author in a specific way for the best result (refer to the documentation).
  57120. */
  57121. diffuseTexture: Nullable<BaseTexture>;
  57122. protected _shadowLights: Nullable<IShadowLight[]>;
  57123. /**
  57124. * Specify the list of lights casting shadow on the material.
  57125. * All scene shadow lights will be included if null.
  57126. */
  57127. shadowLights: Nullable<IShadowLight[]>;
  57128. protected _shadowLevel: float;
  57129. /**
  57130. * Helps adjusting the shadow to a softer level if required.
  57131. * 0 means black shadows and 1 means no shadows.
  57132. */
  57133. shadowLevel: float;
  57134. protected _sceneCenter: Vector3;
  57135. /**
  57136. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57137. * It is usually zero but might be interesting to modify according to your setup.
  57138. */
  57139. sceneCenter: Vector3;
  57140. protected _opacityFresnel: boolean;
  57141. /**
  57142. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57143. * This helps ensuring a nice transition when the camera goes under the ground.
  57144. */
  57145. opacityFresnel: boolean;
  57146. protected _reflectionFresnel: boolean;
  57147. /**
  57148. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57149. * This helps adding a mirror texture on the ground.
  57150. */
  57151. reflectionFresnel: boolean;
  57152. protected _reflectionFalloffDistance: number;
  57153. /**
  57154. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57155. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57156. */
  57157. reflectionFalloffDistance: number;
  57158. protected _reflectionAmount: number;
  57159. /**
  57160. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57161. */
  57162. reflectionAmount: number;
  57163. protected _reflectionReflectance0: number;
  57164. /**
  57165. * This specifies the weight of the reflection at grazing angle.
  57166. */
  57167. reflectionReflectance0: number;
  57168. protected _reflectionReflectance90: number;
  57169. /**
  57170. * This specifies the weight of the reflection at a perpendicular point of view.
  57171. */
  57172. reflectionReflectance90: number;
  57173. /**
  57174. * Sets the reflection reflectance fresnel values according to the default standard
  57175. * empirically know to work well :-)
  57176. */
  57177. set reflectionStandardFresnelWeight(value: number);
  57178. protected _useRGBColor: boolean;
  57179. /**
  57180. * Helps to directly use the maps channels instead of their level.
  57181. */
  57182. useRGBColor: boolean;
  57183. protected _enableNoise: boolean;
  57184. /**
  57185. * This helps reducing the banding effect that could occur on the background.
  57186. */
  57187. enableNoise: boolean;
  57188. /**
  57189. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57190. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57191. * Recommended to be keep at 1.0 except for special cases.
  57192. */
  57193. get fovMultiplier(): number;
  57194. set fovMultiplier(value: number);
  57195. private _fovMultiplier;
  57196. /**
  57197. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57198. */
  57199. useEquirectangularFOV: boolean;
  57200. private _maxSimultaneousLights;
  57201. /**
  57202. * Number of Simultaneous lights allowed on the material.
  57203. */
  57204. maxSimultaneousLights: int;
  57205. private _shadowOnly;
  57206. /**
  57207. * Make the material only render shadows
  57208. */
  57209. shadowOnly: boolean;
  57210. /**
  57211. * Default configuration related to image processing available in the Background Material.
  57212. */
  57213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57214. /**
  57215. * Keep track of the image processing observer to allow dispose and replace.
  57216. */
  57217. private _imageProcessingObserver;
  57218. /**
  57219. * Attaches a new image processing configuration to the PBR Material.
  57220. * @param configuration (if null the scene configuration will be use)
  57221. */
  57222. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57223. /**
  57224. * Gets the image processing configuration used either in this material.
  57225. */
  57226. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57227. /**
  57228. * Sets the Default image processing configuration used either in the this material.
  57229. *
  57230. * If sets to null, the scene one is in use.
  57231. */
  57232. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57233. /**
  57234. * Gets wether the color curves effect is enabled.
  57235. */
  57236. get cameraColorCurvesEnabled(): boolean;
  57237. /**
  57238. * Sets wether the color curves effect is enabled.
  57239. */
  57240. set cameraColorCurvesEnabled(value: boolean);
  57241. /**
  57242. * Gets wether the color grading effect is enabled.
  57243. */
  57244. get cameraColorGradingEnabled(): boolean;
  57245. /**
  57246. * Gets wether the color grading effect is enabled.
  57247. */
  57248. set cameraColorGradingEnabled(value: boolean);
  57249. /**
  57250. * Gets wether tonemapping is enabled or not.
  57251. */
  57252. get cameraToneMappingEnabled(): boolean;
  57253. /**
  57254. * Sets wether tonemapping is enabled or not
  57255. */
  57256. set cameraToneMappingEnabled(value: boolean);
  57257. /**
  57258. * The camera exposure used on this material.
  57259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57260. * This corresponds to a photographic exposure.
  57261. */
  57262. get cameraExposure(): float;
  57263. /**
  57264. * The camera exposure used on this material.
  57265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57266. * This corresponds to a photographic exposure.
  57267. */
  57268. set cameraExposure(value: float);
  57269. /**
  57270. * Gets The camera contrast used on this material.
  57271. */
  57272. get cameraContrast(): float;
  57273. /**
  57274. * Sets The camera contrast used on this material.
  57275. */
  57276. set cameraContrast(value: float);
  57277. /**
  57278. * Gets the Color Grading 2D Lookup Texture.
  57279. */
  57280. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57281. /**
  57282. * Sets the Color Grading 2D Lookup Texture.
  57283. */
  57284. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57285. /**
  57286. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57287. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57288. * 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;
  57289. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57290. */
  57291. get cameraColorCurves(): Nullable<ColorCurves>;
  57292. /**
  57293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57295. * 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;
  57296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57297. */
  57298. set cameraColorCurves(value: Nullable<ColorCurves>);
  57299. /**
  57300. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57301. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57302. */
  57303. switchToBGR: boolean;
  57304. private _renderTargets;
  57305. private _reflectionControls;
  57306. private _white;
  57307. private _primaryShadowColor;
  57308. private _primaryHighlightColor;
  57309. /**
  57310. * Instantiates a Background Material in the given scene
  57311. * @param name The friendly name of the material
  57312. * @param scene The scene to add the material to
  57313. */
  57314. constructor(name: string, scene: Scene);
  57315. /**
  57316. * Gets a boolean indicating that current material needs to register RTT
  57317. */
  57318. get hasRenderTargetTextures(): boolean;
  57319. /**
  57320. * The entire material has been created in order to prevent overdraw.
  57321. * @returns false
  57322. */
  57323. needAlphaTesting(): boolean;
  57324. /**
  57325. * The entire material has been created in order to prevent overdraw.
  57326. * @returns true if blending is enable
  57327. */
  57328. needAlphaBlending(): boolean;
  57329. /**
  57330. * Checks wether the material is ready to be rendered for a given mesh.
  57331. * @param mesh The mesh to render
  57332. * @param subMesh The submesh to check against
  57333. * @param useInstances Specify wether or not the material is used with instances
  57334. * @returns true if all the dependencies are ready (Textures, Effects...)
  57335. */
  57336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57337. /**
  57338. * Compute the primary color according to the chosen perceptual color.
  57339. */
  57340. private _computePrimaryColorFromPerceptualColor;
  57341. /**
  57342. * Compute the highlights and shadow colors according to their chosen levels.
  57343. */
  57344. private _computePrimaryColors;
  57345. /**
  57346. * Build the uniform buffer used in the material.
  57347. */
  57348. buildUniformLayout(): void;
  57349. /**
  57350. * Unbind the material.
  57351. */
  57352. unbind(): void;
  57353. /**
  57354. * Bind only the world matrix to the material.
  57355. * @param world The world matrix to bind.
  57356. */
  57357. bindOnlyWorldMatrix(world: Matrix): void;
  57358. /**
  57359. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57360. * @param world The world matrix to bind.
  57361. * @param subMesh The submesh to bind for.
  57362. */
  57363. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57364. /**
  57365. * Checks to see if a texture is used in the material.
  57366. * @param texture - Base texture to use.
  57367. * @returns - Boolean specifying if a texture is used in the material.
  57368. */
  57369. hasTexture(texture: BaseTexture): boolean;
  57370. /**
  57371. * Dispose the material.
  57372. * @param forceDisposeEffect Force disposal of the associated effect.
  57373. * @param forceDisposeTextures Force disposal of the associated textures.
  57374. */
  57375. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57376. /**
  57377. * Clones the material.
  57378. * @param name The cloned name.
  57379. * @returns The cloned material.
  57380. */
  57381. clone(name: string): BackgroundMaterial;
  57382. /**
  57383. * Serializes the current material to its JSON representation.
  57384. * @returns The JSON representation.
  57385. */
  57386. serialize(): any;
  57387. /**
  57388. * Gets the class name of the material
  57389. * @returns "BackgroundMaterial"
  57390. */
  57391. getClassName(): string;
  57392. /**
  57393. * Parse a JSON input to create back a background material.
  57394. * @param source The JSON data to parse
  57395. * @param scene The scene to create the parsed material in
  57396. * @param rootUrl The root url of the assets the material depends upon
  57397. * @returns the instantiated BackgroundMaterial.
  57398. */
  57399. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57400. }
  57401. }
  57402. declare module "babylonjs/Helpers/environmentHelper" {
  57403. import { Observable } from "babylonjs/Misc/observable";
  57404. import { Nullable } from "babylonjs/types";
  57405. import { Scene } from "babylonjs/scene";
  57406. import { Vector3 } from "babylonjs/Maths/math.vector";
  57407. import { Color3 } from "babylonjs/Maths/math.color";
  57408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57409. import { Mesh } from "babylonjs/Meshes/mesh";
  57410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57411. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57412. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57413. import "babylonjs/Meshes/Builders/planeBuilder";
  57414. import "babylonjs/Meshes/Builders/boxBuilder";
  57415. /**
  57416. * Represents the different options available during the creation of
  57417. * a Environment helper.
  57418. *
  57419. * This can control the default ground, skybox and image processing setup of your scene.
  57420. */
  57421. export interface IEnvironmentHelperOptions {
  57422. /**
  57423. * Specifies whether or not to create a ground.
  57424. * True by default.
  57425. */
  57426. createGround: boolean;
  57427. /**
  57428. * Specifies the ground size.
  57429. * 15 by default.
  57430. */
  57431. groundSize: number;
  57432. /**
  57433. * The texture used on the ground for the main color.
  57434. * Comes from the BabylonJS CDN by default.
  57435. *
  57436. * Remarks: Can be either a texture or a url.
  57437. */
  57438. groundTexture: string | BaseTexture;
  57439. /**
  57440. * The color mixed in the ground texture by default.
  57441. * BabylonJS clearColor by default.
  57442. */
  57443. groundColor: Color3;
  57444. /**
  57445. * Specifies the ground opacity.
  57446. * 1 by default.
  57447. */
  57448. groundOpacity: number;
  57449. /**
  57450. * Enables the ground to receive shadows.
  57451. * True by default.
  57452. */
  57453. enableGroundShadow: boolean;
  57454. /**
  57455. * Helps preventing the shadow to be fully black on the ground.
  57456. * 0.5 by default.
  57457. */
  57458. groundShadowLevel: number;
  57459. /**
  57460. * Creates a mirror texture attach to the ground.
  57461. * false by default.
  57462. */
  57463. enableGroundMirror: boolean;
  57464. /**
  57465. * Specifies the ground mirror size ratio.
  57466. * 0.3 by default as the default kernel is 64.
  57467. */
  57468. groundMirrorSizeRatio: number;
  57469. /**
  57470. * Specifies the ground mirror blur kernel size.
  57471. * 64 by default.
  57472. */
  57473. groundMirrorBlurKernel: number;
  57474. /**
  57475. * Specifies the ground mirror visibility amount.
  57476. * 1 by default
  57477. */
  57478. groundMirrorAmount: number;
  57479. /**
  57480. * Specifies the ground mirror reflectance weight.
  57481. * This uses the standard weight of the background material to setup the fresnel effect
  57482. * of the mirror.
  57483. * 1 by default.
  57484. */
  57485. groundMirrorFresnelWeight: number;
  57486. /**
  57487. * Specifies the ground mirror Falloff distance.
  57488. * This can helps reducing the size of the reflection.
  57489. * 0 by Default.
  57490. */
  57491. groundMirrorFallOffDistance: number;
  57492. /**
  57493. * Specifies the ground mirror texture type.
  57494. * Unsigned Int by Default.
  57495. */
  57496. groundMirrorTextureType: number;
  57497. /**
  57498. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57499. * the shown objects.
  57500. */
  57501. groundYBias: number;
  57502. /**
  57503. * Specifies whether or not to create a skybox.
  57504. * True by default.
  57505. */
  57506. createSkybox: boolean;
  57507. /**
  57508. * Specifies the skybox size.
  57509. * 20 by default.
  57510. */
  57511. skyboxSize: number;
  57512. /**
  57513. * The texture used on the skybox for the main color.
  57514. * Comes from the BabylonJS CDN by default.
  57515. *
  57516. * Remarks: Can be either a texture or a url.
  57517. */
  57518. skyboxTexture: string | BaseTexture;
  57519. /**
  57520. * The color mixed in the skybox texture by default.
  57521. * BabylonJS clearColor by default.
  57522. */
  57523. skyboxColor: Color3;
  57524. /**
  57525. * The background rotation around the Y axis of the scene.
  57526. * This helps aligning the key lights of your scene with the background.
  57527. * 0 by default.
  57528. */
  57529. backgroundYRotation: number;
  57530. /**
  57531. * Compute automatically the size of the elements to best fit with the scene.
  57532. */
  57533. sizeAuto: boolean;
  57534. /**
  57535. * Default position of the rootMesh if autoSize is not true.
  57536. */
  57537. rootPosition: Vector3;
  57538. /**
  57539. * Sets up the image processing in the scene.
  57540. * true by default.
  57541. */
  57542. setupImageProcessing: boolean;
  57543. /**
  57544. * The texture used as your environment texture in the scene.
  57545. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57546. *
  57547. * Remarks: Can be either a texture or a url.
  57548. */
  57549. environmentTexture: string | BaseTexture;
  57550. /**
  57551. * The value of the exposure to apply to the scene.
  57552. * 0.6 by default if setupImageProcessing is true.
  57553. */
  57554. cameraExposure: number;
  57555. /**
  57556. * The value of the contrast to apply to the scene.
  57557. * 1.6 by default if setupImageProcessing is true.
  57558. */
  57559. cameraContrast: number;
  57560. /**
  57561. * Specifies whether or not tonemapping should be enabled in the scene.
  57562. * true by default if setupImageProcessing is true.
  57563. */
  57564. toneMappingEnabled: boolean;
  57565. }
  57566. /**
  57567. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57568. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57569. * It also helps with the default setup of your imageProcessing configuration.
  57570. */
  57571. export class EnvironmentHelper {
  57572. /**
  57573. * Default ground texture URL.
  57574. */
  57575. private static _groundTextureCDNUrl;
  57576. /**
  57577. * Default skybox texture URL.
  57578. */
  57579. private static _skyboxTextureCDNUrl;
  57580. /**
  57581. * Default environment texture URL.
  57582. */
  57583. private static _environmentTextureCDNUrl;
  57584. /**
  57585. * Creates the default options for the helper.
  57586. */
  57587. private static _getDefaultOptions;
  57588. private _rootMesh;
  57589. /**
  57590. * Gets the root mesh created by the helper.
  57591. */
  57592. get rootMesh(): Mesh;
  57593. private _skybox;
  57594. /**
  57595. * Gets the skybox created by the helper.
  57596. */
  57597. get skybox(): Nullable<Mesh>;
  57598. private _skyboxTexture;
  57599. /**
  57600. * Gets the skybox texture created by the helper.
  57601. */
  57602. get skyboxTexture(): Nullable<BaseTexture>;
  57603. private _skyboxMaterial;
  57604. /**
  57605. * Gets the skybox material created by the helper.
  57606. */
  57607. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57608. private _ground;
  57609. /**
  57610. * Gets the ground mesh created by the helper.
  57611. */
  57612. get ground(): Nullable<Mesh>;
  57613. private _groundTexture;
  57614. /**
  57615. * Gets the ground texture created by the helper.
  57616. */
  57617. get groundTexture(): Nullable<BaseTexture>;
  57618. private _groundMirror;
  57619. /**
  57620. * Gets the ground mirror created by the helper.
  57621. */
  57622. get groundMirror(): Nullable<MirrorTexture>;
  57623. /**
  57624. * Gets the ground mirror render list to helps pushing the meshes
  57625. * you wish in the ground reflection.
  57626. */
  57627. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57628. private _groundMaterial;
  57629. /**
  57630. * Gets the ground material created by the helper.
  57631. */
  57632. get groundMaterial(): Nullable<BackgroundMaterial>;
  57633. /**
  57634. * Stores the creation options.
  57635. */
  57636. private readonly _scene;
  57637. private _options;
  57638. /**
  57639. * This observable will be notified with any error during the creation of the environment,
  57640. * mainly texture creation errors.
  57641. */
  57642. onErrorObservable: Observable<{
  57643. message?: string;
  57644. exception?: any;
  57645. }>;
  57646. /**
  57647. * constructor
  57648. * @param options Defines the options we want to customize the helper
  57649. * @param scene The scene to add the material to
  57650. */
  57651. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57652. /**
  57653. * Updates the background according to the new options
  57654. * @param options
  57655. */
  57656. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57657. /**
  57658. * Sets the primary color of all the available elements.
  57659. * @param color the main color to affect to the ground and the background
  57660. */
  57661. setMainColor(color: Color3): void;
  57662. /**
  57663. * Setup the image processing according to the specified options.
  57664. */
  57665. private _setupImageProcessing;
  57666. /**
  57667. * Setup the environment texture according to the specified options.
  57668. */
  57669. private _setupEnvironmentTexture;
  57670. /**
  57671. * Setup the background according to the specified options.
  57672. */
  57673. private _setupBackground;
  57674. /**
  57675. * Get the scene sizes according to the setup.
  57676. */
  57677. private _getSceneSize;
  57678. /**
  57679. * Setup the ground according to the specified options.
  57680. */
  57681. private _setupGround;
  57682. /**
  57683. * Setup the ground material according to the specified options.
  57684. */
  57685. private _setupGroundMaterial;
  57686. /**
  57687. * Setup the ground diffuse texture according to the specified options.
  57688. */
  57689. private _setupGroundDiffuseTexture;
  57690. /**
  57691. * Setup the ground mirror texture according to the specified options.
  57692. */
  57693. private _setupGroundMirrorTexture;
  57694. /**
  57695. * Setup the ground to receive the mirror texture.
  57696. */
  57697. private _setupMirrorInGroundMaterial;
  57698. /**
  57699. * Setup the skybox according to the specified options.
  57700. */
  57701. private _setupSkybox;
  57702. /**
  57703. * Setup the skybox material according to the specified options.
  57704. */
  57705. private _setupSkyboxMaterial;
  57706. /**
  57707. * Setup the skybox reflection texture according to the specified options.
  57708. */
  57709. private _setupSkyboxReflectionTexture;
  57710. private _errorHandler;
  57711. /**
  57712. * Dispose all the elements created by the Helper.
  57713. */
  57714. dispose(): void;
  57715. }
  57716. }
  57717. declare module "babylonjs/Helpers/textureDome" {
  57718. import { Scene } from "babylonjs/scene";
  57719. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57720. import { Mesh } from "babylonjs/Meshes/mesh";
  57721. import { Texture } from "babylonjs/Materials/Textures/texture";
  57722. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57723. import "babylonjs/Meshes/Builders/sphereBuilder";
  57724. import { Nullable } from "babylonjs/types";
  57725. import { Observable } from "babylonjs/Misc/observable";
  57726. /**
  57727. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57728. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57729. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57730. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57731. */
  57732. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57733. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57734. /**
  57735. * Define the source as a Monoscopic panoramic 360/180.
  57736. */
  57737. static readonly MODE_MONOSCOPIC: number;
  57738. /**
  57739. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57740. */
  57741. static readonly MODE_TOPBOTTOM: number;
  57742. /**
  57743. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57744. */
  57745. static readonly MODE_SIDEBYSIDE: number;
  57746. private _halfDome;
  57747. protected _useDirectMapping: boolean;
  57748. /**
  57749. * The texture being displayed on the sphere
  57750. */
  57751. protected _texture: T;
  57752. /**
  57753. * Gets the texture being displayed on the sphere
  57754. */
  57755. get texture(): T;
  57756. /**
  57757. * Sets the texture being displayed on the sphere
  57758. */
  57759. set texture(newTexture: T);
  57760. /**
  57761. * The skybox material
  57762. */
  57763. protected _material: BackgroundMaterial;
  57764. /**
  57765. * The surface used for the dome
  57766. */
  57767. protected _mesh: Mesh;
  57768. /**
  57769. * Gets the mesh used for the dome.
  57770. */
  57771. get mesh(): Mesh;
  57772. /**
  57773. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57774. */
  57775. private _halfDomeMask;
  57776. /**
  57777. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57778. * Also see the options.resolution property.
  57779. */
  57780. get fovMultiplier(): number;
  57781. set fovMultiplier(value: number);
  57782. protected _textureMode: number;
  57783. /**
  57784. * Gets or set the current texture mode for the texture. It can be:
  57785. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57786. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57787. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57788. */
  57789. get textureMode(): number;
  57790. /**
  57791. * Sets the current texture mode for the texture. It can be:
  57792. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57793. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57794. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57795. */
  57796. set textureMode(value: number);
  57797. /**
  57798. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57799. */
  57800. get halfDome(): boolean;
  57801. /**
  57802. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57803. */
  57804. set halfDome(enabled: boolean);
  57805. /**
  57806. * Oberserver used in Stereoscopic VR Mode.
  57807. */
  57808. private _onBeforeCameraRenderObserver;
  57809. /**
  57810. * Observable raised when an error occured while loading the 360 image
  57811. */
  57812. onLoadErrorObservable: Observable<string>;
  57813. /**
  57814. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57815. * @param name Element's name, child elements will append suffixes for their own names.
  57816. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57817. * @param options An object containing optional or exposed sub element properties
  57818. */
  57819. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57820. resolution?: number;
  57821. clickToPlay?: boolean;
  57822. autoPlay?: boolean;
  57823. loop?: boolean;
  57824. size?: number;
  57825. poster?: string;
  57826. faceForward?: boolean;
  57827. useDirectMapping?: boolean;
  57828. halfDomeMode?: boolean;
  57829. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57830. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57831. protected _changeTextureMode(value: number): void;
  57832. /**
  57833. * Releases resources associated with this node.
  57834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57836. */
  57837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57838. }
  57839. }
  57840. declare module "babylonjs/Helpers/photoDome" {
  57841. import { Scene } from "babylonjs/scene";
  57842. import { Texture } from "babylonjs/Materials/Textures/texture";
  57843. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57844. /**
  57845. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57846. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57847. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57848. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57849. */
  57850. export class PhotoDome extends TextureDome<Texture> {
  57851. /**
  57852. * Define the image as a Monoscopic panoramic 360 image.
  57853. */
  57854. static readonly MODE_MONOSCOPIC: number;
  57855. /**
  57856. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57857. */
  57858. static readonly MODE_TOPBOTTOM: number;
  57859. /**
  57860. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57861. */
  57862. static readonly MODE_SIDEBYSIDE: number;
  57863. /**
  57864. * Gets or sets the texture being displayed on the sphere
  57865. */
  57866. get photoTexture(): Texture;
  57867. /**
  57868. * sets the texture being displayed on the sphere
  57869. */
  57870. set photoTexture(value: Texture);
  57871. /**
  57872. * Gets the current video mode for the video. It can be:
  57873. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57874. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57875. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57876. */
  57877. get imageMode(): number;
  57878. /**
  57879. * Sets the current video mode for the video. It can be:
  57880. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57881. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57882. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57883. */
  57884. set imageMode(value: number);
  57885. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57886. }
  57887. }
  57888. declare module "babylonjs/Misc/rgbdTextureTools" {
  57889. import "babylonjs/Shaders/rgbdDecode.fragment";
  57890. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57891. import { Texture } from "babylonjs/Materials/Textures/texture";
  57892. /**
  57893. * Class used to host RGBD texture specific utilities
  57894. */
  57895. export class RGBDTextureTools {
  57896. /**
  57897. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57898. * @param texture the texture to expand.
  57899. */
  57900. static ExpandRGBDTexture(texture: Texture): void;
  57901. }
  57902. }
  57903. declare module "babylonjs/Misc/brdfTextureTools" {
  57904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57905. import { Scene } from "babylonjs/scene";
  57906. /**
  57907. * Class used to host texture specific utilities
  57908. */
  57909. export class BRDFTextureTools {
  57910. /**
  57911. * Prevents texture cache collision
  57912. */
  57913. private static _instanceNumber;
  57914. /**
  57915. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57916. * @param scene defines the hosting scene
  57917. * @returns the environment BRDF texture
  57918. */
  57919. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57920. private static _environmentBRDFBase64Texture;
  57921. }
  57922. }
  57923. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57924. import { Nullable } from "babylonjs/types";
  57925. import { Color3 } from "babylonjs/Maths/math.color";
  57926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57927. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57928. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57929. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57930. import { Engine } from "babylonjs/Engines/engine";
  57931. import { Scene } from "babylonjs/scene";
  57932. /**
  57933. * @hidden
  57934. */
  57935. export interface IMaterialClearCoatDefines {
  57936. CLEARCOAT: boolean;
  57937. CLEARCOAT_DEFAULTIOR: boolean;
  57938. CLEARCOAT_TEXTURE: boolean;
  57939. CLEARCOAT_TEXTUREDIRECTUV: number;
  57940. CLEARCOAT_BUMP: boolean;
  57941. CLEARCOAT_BUMPDIRECTUV: number;
  57942. CLEARCOAT_REMAP_F0: boolean;
  57943. CLEARCOAT_TINT: boolean;
  57944. CLEARCOAT_TINT_TEXTURE: boolean;
  57945. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57946. /** @hidden */
  57947. _areTexturesDirty: boolean;
  57948. }
  57949. /**
  57950. * Define the code related to the clear coat parameters of the pbr material.
  57951. */
  57952. export class PBRClearCoatConfiguration {
  57953. /**
  57954. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57955. * The default fits with a polyurethane material.
  57956. */
  57957. private static readonly _DefaultIndexOfRefraction;
  57958. private _isEnabled;
  57959. /**
  57960. * Defines if the clear coat is enabled in the material.
  57961. */
  57962. isEnabled: boolean;
  57963. /**
  57964. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57965. */
  57966. intensity: number;
  57967. /**
  57968. * Defines the clear coat layer roughness.
  57969. */
  57970. roughness: number;
  57971. private _indexOfRefraction;
  57972. /**
  57973. * Defines the index of refraction of the clear coat.
  57974. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57975. * The default fits with a polyurethane material.
  57976. * Changing the default value is more performance intensive.
  57977. */
  57978. indexOfRefraction: number;
  57979. private _texture;
  57980. /**
  57981. * Stores the clear coat values in a texture.
  57982. */
  57983. texture: Nullable<BaseTexture>;
  57984. private _remapF0OnInterfaceChange;
  57985. /**
  57986. * Defines if the F0 value should be remapped to account for the interface change in the material.
  57987. */
  57988. remapF0OnInterfaceChange: boolean;
  57989. private _bumpTexture;
  57990. /**
  57991. * Define the clear coat specific bump texture.
  57992. */
  57993. bumpTexture: Nullable<BaseTexture>;
  57994. private _isTintEnabled;
  57995. /**
  57996. * Defines if the clear coat tint is enabled in the material.
  57997. */
  57998. isTintEnabled: boolean;
  57999. /**
  58000. * Defines the clear coat tint of the material.
  58001. * This is only use if tint is enabled
  58002. */
  58003. tintColor: Color3;
  58004. /**
  58005. * Defines the distance at which the tint color should be found in the
  58006. * clear coat media.
  58007. * This is only use if tint is enabled
  58008. */
  58009. tintColorAtDistance: number;
  58010. /**
  58011. * Defines the clear coat layer thickness.
  58012. * This is only use if tint is enabled
  58013. */
  58014. tintThickness: number;
  58015. private _tintTexture;
  58016. /**
  58017. * Stores the clear tint values in a texture.
  58018. * rgb is tint
  58019. * a is a thickness factor
  58020. */
  58021. tintTexture: Nullable<BaseTexture>;
  58022. /** @hidden */
  58023. private _internalMarkAllSubMeshesAsTexturesDirty;
  58024. /** @hidden */
  58025. _markAllSubMeshesAsTexturesDirty(): void;
  58026. /**
  58027. * Instantiate a new istance of clear coat configuration.
  58028. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58029. */
  58030. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58031. /**
  58032. * Gets wehter the submesh is ready to be used or not.
  58033. * @param defines the list of "defines" to update.
  58034. * @param scene defines the scene the material belongs to.
  58035. * @param engine defines the engine the material belongs to.
  58036. * @param disableBumpMap defines wether the material disables bump or not.
  58037. * @returns - boolean indicating that the submesh is ready or not.
  58038. */
  58039. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  58040. /**
  58041. * Checks to see if a texture is used in the material.
  58042. * @param defines the list of "defines" to update.
  58043. * @param scene defines the scene to the material belongs to.
  58044. */
  58045. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  58046. /**
  58047. * Binds the material data.
  58048. * @param uniformBuffer defines the Uniform buffer to fill in.
  58049. * @param scene defines the scene the material belongs to.
  58050. * @param engine defines the engine the material belongs to.
  58051. * @param disableBumpMap defines wether the material disables bump or not.
  58052. * @param isFrozen defines wether the material is frozen or not.
  58053. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58054. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58055. */
  58056. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  58057. /**
  58058. * Checks to see if a texture is used in the material.
  58059. * @param texture - Base texture to use.
  58060. * @returns - Boolean specifying if a texture is used in the material.
  58061. */
  58062. hasTexture(texture: BaseTexture): boolean;
  58063. /**
  58064. * Returns an array of the actively used textures.
  58065. * @param activeTextures Array of BaseTextures
  58066. */
  58067. getActiveTextures(activeTextures: BaseTexture[]): void;
  58068. /**
  58069. * Returns the animatable textures.
  58070. * @param animatables Array of animatable textures.
  58071. */
  58072. getAnimatables(animatables: IAnimatable[]): void;
  58073. /**
  58074. * Disposes the resources of the material.
  58075. * @param forceDisposeTextures - Forces the disposal of all textures.
  58076. */
  58077. dispose(forceDisposeTextures?: boolean): void;
  58078. /**
  58079. * Get the current class name of the texture useful for serialization or dynamic coding.
  58080. * @returns "PBRClearCoatConfiguration"
  58081. */
  58082. getClassName(): string;
  58083. /**
  58084. * Add fallbacks to the effect fallbacks list.
  58085. * @param defines defines the Base texture to use.
  58086. * @param fallbacks defines the current fallback list.
  58087. * @param currentRank defines the current fallback rank.
  58088. * @returns the new fallback rank.
  58089. */
  58090. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58091. /**
  58092. * Add the required uniforms to the current list.
  58093. * @param uniforms defines the current uniform list.
  58094. */
  58095. static AddUniforms(uniforms: string[]): void;
  58096. /**
  58097. * Add the required samplers to the current list.
  58098. * @param samplers defines the current sampler list.
  58099. */
  58100. static AddSamplers(samplers: string[]): void;
  58101. /**
  58102. * Add the required uniforms to the current buffer.
  58103. * @param uniformBuffer defines the current uniform buffer.
  58104. */
  58105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58106. /**
  58107. * Makes a duplicate of the current configuration into another one.
  58108. * @param clearCoatConfiguration define the config where to copy the info
  58109. */
  58110. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  58111. /**
  58112. * Serializes this clear coat configuration.
  58113. * @returns - An object with the serialized config.
  58114. */
  58115. serialize(): any;
  58116. /**
  58117. * Parses a anisotropy Configuration from a serialized object.
  58118. * @param source - Serialized object.
  58119. * @param scene Defines the scene we are parsing for
  58120. * @param rootUrl Defines the rootUrl to load from
  58121. */
  58122. parse(source: any, scene: Scene, rootUrl: string): void;
  58123. }
  58124. }
  58125. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  58126. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58128. import { Vector2 } from "babylonjs/Maths/math.vector";
  58129. import { Scene } from "babylonjs/scene";
  58130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58131. import { Nullable } from "babylonjs/types";
  58132. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58133. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58134. /**
  58135. * @hidden
  58136. */
  58137. export interface IMaterialAnisotropicDefines {
  58138. ANISOTROPIC: boolean;
  58139. ANISOTROPIC_TEXTURE: boolean;
  58140. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58141. MAINUV1: boolean;
  58142. _areTexturesDirty: boolean;
  58143. _needUVs: boolean;
  58144. }
  58145. /**
  58146. * Define the code related to the anisotropic parameters of the pbr material.
  58147. */
  58148. export class PBRAnisotropicConfiguration {
  58149. private _isEnabled;
  58150. /**
  58151. * Defines if the anisotropy is enabled in the material.
  58152. */
  58153. isEnabled: boolean;
  58154. /**
  58155. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58156. */
  58157. intensity: number;
  58158. /**
  58159. * Defines if the effect is along the tangents, bitangents or in between.
  58160. * By default, the effect is "strectching" the highlights along the tangents.
  58161. */
  58162. direction: Vector2;
  58163. private _texture;
  58164. /**
  58165. * Stores the anisotropy values in a texture.
  58166. * rg is direction (like normal from -1 to 1)
  58167. * b is a intensity
  58168. */
  58169. texture: Nullable<BaseTexture>;
  58170. /** @hidden */
  58171. private _internalMarkAllSubMeshesAsTexturesDirty;
  58172. /** @hidden */
  58173. _markAllSubMeshesAsTexturesDirty(): void;
  58174. /**
  58175. * Instantiate a new istance of anisotropy configuration.
  58176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58177. */
  58178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58179. /**
  58180. * Specifies that the submesh is ready to be used.
  58181. * @param defines the list of "defines" to update.
  58182. * @param scene defines the scene the material belongs to.
  58183. * @returns - boolean indicating that the submesh is ready or not.
  58184. */
  58185. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58186. /**
  58187. * Checks to see if a texture is used in the material.
  58188. * @param defines the list of "defines" to update.
  58189. * @param mesh the mesh we are preparing the defines for.
  58190. * @param scene defines the scene the material belongs to.
  58191. */
  58192. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58193. /**
  58194. * Binds the material data.
  58195. * @param uniformBuffer defines the Uniform buffer to fill in.
  58196. * @param scene defines the scene the material belongs to.
  58197. * @param isFrozen defines wether the material is frozen or not.
  58198. */
  58199. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58200. /**
  58201. * Checks to see if a texture is used in the material.
  58202. * @param texture - Base texture to use.
  58203. * @returns - Boolean specifying if a texture is used in the material.
  58204. */
  58205. hasTexture(texture: BaseTexture): boolean;
  58206. /**
  58207. * Returns an array of the actively used textures.
  58208. * @param activeTextures Array of BaseTextures
  58209. */
  58210. getActiveTextures(activeTextures: BaseTexture[]): void;
  58211. /**
  58212. * Returns the animatable textures.
  58213. * @param animatables Array of animatable textures.
  58214. */
  58215. getAnimatables(animatables: IAnimatable[]): void;
  58216. /**
  58217. * Disposes the resources of the material.
  58218. * @param forceDisposeTextures - Forces the disposal of all textures.
  58219. */
  58220. dispose(forceDisposeTextures?: boolean): void;
  58221. /**
  58222. * Get the current class name of the texture useful for serialization or dynamic coding.
  58223. * @returns "PBRAnisotropicConfiguration"
  58224. */
  58225. getClassName(): string;
  58226. /**
  58227. * Add fallbacks to the effect fallbacks list.
  58228. * @param defines defines the Base texture to use.
  58229. * @param fallbacks defines the current fallback list.
  58230. * @param currentRank defines the current fallback rank.
  58231. * @returns the new fallback rank.
  58232. */
  58233. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58234. /**
  58235. * Add the required uniforms to the current list.
  58236. * @param uniforms defines the current uniform list.
  58237. */
  58238. static AddUniforms(uniforms: string[]): void;
  58239. /**
  58240. * Add the required uniforms to the current buffer.
  58241. * @param uniformBuffer defines the current uniform buffer.
  58242. */
  58243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58244. /**
  58245. * Add the required samplers to the current list.
  58246. * @param samplers defines the current sampler list.
  58247. */
  58248. static AddSamplers(samplers: string[]): void;
  58249. /**
  58250. * Makes a duplicate of the current configuration into another one.
  58251. * @param anisotropicConfiguration define the config where to copy the info
  58252. */
  58253. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58254. /**
  58255. * Serializes this anisotropy configuration.
  58256. * @returns - An object with the serialized config.
  58257. */
  58258. serialize(): any;
  58259. /**
  58260. * Parses a anisotropy Configuration from a serialized object.
  58261. * @param source - Serialized object.
  58262. * @param scene Defines the scene we are parsing for
  58263. * @param rootUrl Defines the rootUrl to load from
  58264. */
  58265. parse(source: any, scene: Scene, rootUrl: string): void;
  58266. }
  58267. }
  58268. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58269. import { Scene } from "babylonjs/scene";
  58270. /**
  58271. * @hidden
  58272. */
  58273. export interface IMaterialBRDFDefines {
  58274. BRDF_V_HEIGHT_CORRELATED: boolean;
  58275. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58276. SPHERICAL_HARMONICS: boolean;
  58277. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58278. /** @hidden */
  58279. _areMiscDirty: boolean;
  58280. }
  58281. /**
  58282. * Define the code related to the BRDF parameters of the pbr material.
  58283. */
  58284. export class PBRBRDFConfiguration {
  58285. /**
  58286. * Default value used for the energy conservation.
  58287. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58288. */
  58289. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58290. /**
  58291. * Default value used for the Smith Visibility Height Correlated mode.
  58292. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58293. */
  58294. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58295. /**
  58296. * Default value used for the IBL diffuse part.
  58297. * This can help switching back to the polynomials mode globally which is a tiny bit
  58298. * less GPU intensive at the drawback of a lower quality.
  58299. */
  58300. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58301. /**
  58302. * Default value used for activating energy conservation for the specular workflow.
  58303. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58304. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58305. */
  58306. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58307. private _useEnergyConservation;
  58308. /**
  58309. * Defines if the material uses energy conservation.
  58310. */
  58311. useEnergyConservation: boolean;
  58312. private _useSmithVisibilityHeightCorrelated;
  58313. /**
  58314. * LEGACY Mode set to false
  58315. * Defines if the material uses height smith correlated visibility term.
  58316. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58317. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58318. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58319. * Not relying on height correlated will also disable energy conservation.
  58320. */
  58321. useSmithVisibilityHeightCorrelated: boolean;
  58322. private _useSphericalHarmonics;
  58323. /**
  58324. * LEGACY Mode set to false
  58325. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58326. * diffuse part of the IBL.
  58327. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58328. * to the ground truth.
  58329. */
  58330. useSphericalHarmonics: boolean;
  58331. private _useSpecularGlossinessInputEnergyConservation;
  58332. /**
  58333. * Defines if the material uses energy conservation, when the specular workflow is active.
  58334. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58335. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58336. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58337. */
  58338. useSpecularGlossinessInputEnergyConservation: boolean;
  58339. /** @hidden */
  58340. private _internalMarkAllSubMeshesAsMiscDirty;
  58341. /** @hidden */
  58342. _markAllSubMeshesAsMiscDirty(): void;
  58343. /**
  58344. * Instantiate a new istance of clear coat configuration.
  58345. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58346. */
  58347. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58348. /**
  58349. * Checks to see if a texture is used in the material.
  58350. * @param defines the list of "defines" to update.
  58351. */
  58352. prepareDefines(defines: IMaterialBRDFDefines): void;
  58353. /**
  58354. * Get the current class name of the texture useful for serialization or dynamic coding.
  58355. * @returns "PBRClearCoatConfiguration"
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * Makes a duplicate of the current configuration into another one.
  58360. * @param brdfConfiguration define the config where to copy the info
  58361. */
  58362. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58363. /**
  58364. * Serializes this BRDF configuration.
  58365. * @returns - An object with the serialized config.
  58366. */
  58367. serialize(): any;
  58368. /**
  58369. * Parses a anisotropy Configuration from a serialized object.
  58370. * @param source - Serialized object.
  58371. * @param scene Defines the scene we are parsing for
  58372. * @param rootUrl Defines the rootUrl to load from
  58373. */
  58374. parse(source: any, scene: Scene, rootUrl: string): void;
  58375. }
  58376. }
  58377. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58379. import { Color3 } from "babylonjs/Maths/math.color";
  58380. import { Scene } from "babylonjs/scene";
  58381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58382. import { Nullable } from "babylonjs/types";
  58383. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58384. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58385. /**
  58386. * @hidden
  58387. */
  58388. export interface IMaterialSheenDefines {
  58389. SHEEN: boolean;
  58390. SHEEN_TEXTURE: boolean;
  58391. SHEEN_TEXTUREDIRECTUV: number;
  58392. SHEEN_LINKWITHALBEDO: boolean;
  58393. SHEEN_ROUGHNESS: boolean;
  58394. SHEEN_ALBEDOSCALING: boolean;
  58395. /** @hidden */
  58396. _areTexturesDirty: boolean;
  58397. }
  58398. /**
  58399. * Define the code related to the Sheen parameters of the pbr material.
  58400. */
  58401. export class PBRSheenConfiguration {
  58402. private _isEnabled;
  58403. /**
  58404. * Defines if the material uses sheen.
  58405. */
  58406. isEnabled: boolean;
  58407. private _linkSheenWithAlbedo;
  58408. /**
  58409. * Defines if the sheen is linked to the sheen color.
  58410. */
  58411. linkSheenWithAlbedo: boolean;
  58412. /**
  58413. * Defines the sheen intensity.
  58414. */
  58415. intensity: number;
  58416. /**
  58417. * Defines the sheen color.
  58418. */
  58419. color: Color3;
  58420. private _texture;
  58421. /**
  58422. * Stores the sheen tint values in a texture.
  58423. * rgb is tint
  58424. * a is a intensity or roughness if roughness has been defined
  58425. */
  58426. texture: Nullable<BaseTexture>;
  58427. private _roughness;
  58428. /**
  58429. * Defines the sheen roughness.
  58430. * It is not taken into account if linkSheenWithAlbedo is true.
  58431. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58432. */
  58433. roughness: Nullable<number>;
  58434. private _albedoScaling;
  58435. /**
  58436. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58437. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58438. * making it easier to setup and tweak the effect
  58439. */
  58440. albedoScaling: boolean;
  58441. /** @hidden */
  58442. private _internalMarkAllSubMeshesAsTexturesDirty;
  58443. /** @hidden */
  58444. _markAllSubMeshesAsTexturesDirty(): void;
  58445. /**
  58446. * Instantiate a new istance of clear coat configuration.
  58447. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58448. */
  58449. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58450. /**
  58451. * Specifies that the submesh is ready to be used.
  58452. * @param defines the list of "defines" to update.
  58453. * @param scene defines the scene the material belongs to.
  58454. * @returns - boolean indicating that the submesh is ready or not.
  58455. */
  58456. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58457. /**
  58458. * Checks to see if a texture is used in the material.
  58459. * @param defines the list of "defines" to update.
  58460. * @param scene defines the scene the material belongs to.
  58461. */
  58462. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58463. /**
  58464. * Binds the material data.
  58465. * @param uniformBuffer defines the Uniform buffer to fill in.
  58466. * @param scene defines the scene the material belongs to.
  58467. * @param isFrozen defines wether the material is frozen or not.
  58468. */
  58469. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58470. /**
  58471. * Checks to see if a texture is used in the material.
  58472. * @param texture - Base texture to use.
  58473. * @returns - Boolean specifying if a texture is used in the material.
  58474. */
  58475. hasTexture(texture: BaseTexture): boolean;
  58476. /**
  58477. * Returns an array of the actively used textures.
  58478. * @param activeTextures Array of BaseTextures
  58479. */
  58480. getActiveTextures(activeTextures: BaseTexture[]): void;
  58481. /**
  58482. * Returns the animatable textures.
  58483. * @param animatables Array of animatable textures.
  58484. */
  58485. getAnimatables(animatables: IAnimatable[]): void;
  58486. /**
  58487. * Disposes the resources of the material.
  58488. * @param forceDisposeTextures - Forces the disposal of all textures.
  58489. */
  58490. dispose(forceDisposeTextures?: boolean): void;
  58491. /**
  58492. * Get the current class name of the texture useful for serialization or dynamic coding.
  58493. * @returns "PBRSheenConfiguration"
  58494. */
  58495. getClassName(): string;
  58496. /**
  58497. * Add fallbacks to the effect fallbacks list.
  58498. * @param defines defines the Base texture to use.
  58499. * @param fallbacks defines the current fallback list.
  58500. * @param currentRank defines the current fallback rank.
  58501. * @returns the new fallback rank.
  58502. */
  58503. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58504. /**
  58505. * Add the required uniforms to the current list.
  58506. * @param uniforms defines the current uniform list.
  58507. */
  58508. static AddUniforms(uniforms: string[]): void;
  58509. /**
  58510. * Add the required uniforms to the current buffer.
  58511. * @param uniformBuffer defines the current uniform buffer.
  58512. */
  58513. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58514. /**
  58515. * Add the required samplers to the current list.
  58516. * @param samplers defines the current sampler list.
  58517. */
  58518. static AddSamplers(samplers: string[]): void;
  58519. /**
  58520. * Makes a duplicate of the current configuration into another one.
  58521. * @param sheenConfiguration define the config where to copy the info
  58522. */
  58523. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58524. /**
  58525. * Serializes this BRDF configuration.
  58526. * @returns - An object with the serialized config.
  58527. */
  58528. serialize(): any;
  58529. /**
  58530. * Parses a anisotropy Configuration from a serialized object.
  58531. * @param source - Serialized object.
  58532. * @param scene Defines the scene we are parsing for
  58533. * @param rootUrl Defines the rootUrl to load from
  58534. */
  58535. parse(source: any, scene: Scene, rootUrl: string): void;
  58536. }
  58537. }
  58538. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58539. import { Nullable } from "babylonjs/types";
  58540. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58541. import { Color3 } from "babylonjs/Maths/math.color";
  58542. import { SmartArray } from "babylonjs/Misc/smartArray";
  58543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58544. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58545. import { Effect } from "babylonjs/Materials/effect";
  58546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58547. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58548. import { Engine } from "babylonjs/Engines/engine";
  58549. import { Scene } from "babylonjs/scene";
  58550. /**
  58551. * @hidden
  58552. */
  58553. export interface IMaterialSubSurfaceDefines {
  58554. SUBSURFACE: boolean;
  58555. SS_REFRACTION: boolean;
  58556. SS_TRANSLUCENCY: boolean;
  58557. SS_SCATTERING: boolean;
  58558. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58559. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58560. SS_REFRACTIONMAP_3D: boolean;
  58561. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58562. SS_LODINREFRACTIONALPHA: boolean;
  58563. SS_GAMMAREFRACTION: boolean;
  58564. SS_RGBDREFRACTION: boolean;
  58565. SS_LINEARSPECULARREFRACTION: boolean;
  58566. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58567. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58568. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58569. /** @hidden */
  58570. _areTexturesDirty: boolean;
  58571. }
  58572. /**
  58573. * Define the code related to the sub surface parameters of the pbr material.
  58574. */
  58575. export class PBRSubSurfaceConfiguration {
  58576. private _isRefractionEnabled;
  58577. /**
  58578. * Defines if the refraction is enabled in the material.
  58579. */
  58580. isRefractionEnabled: boolean;
  58581. private _isTranslucencyEnabled;
  58582. /**
  58583. * Defines if the translucency is enabled in the material.
  58584. */
  58585. isTranslucencyEnabled: boolean;
  58586. private _isScatteringEnabled;
  58587. /**
  58588. * Defines if the sub surface scattering is enabled in the material.
  58589. */
  58590. isScatteringEnabled: boolean;
  58591. private _scatteringDiffusionProfileIndex;
  58592. /**
  58593. * Diffusion profile for subsurface scattering.
  58594. * Useful for better scattering in the skins or foliages.
  58595. */
  58596. get scatteringDiffusionProfile(): Nullable<Color3>;
  58597. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58598. /**
  58599. * Defines the refraction intensity of the material.
  58600. * The refraction when enabled replaces the Diffuse part of the material.
  58601. * The intensity helps transitionning between diffuse and refraction.
  58602. */
  58603. refractionIntensity: number;
  58604. /**
  58605. * Defines the translucency intensity of the material.
  58606. * When translucency has been enabled, this defines how much of the "translucency"
  58607. * is addded to the diffuse part of the material.
  58608. */
  58609. translucencyIntensity: number;
  58610. /**
  58611. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58612. */
  58613. useAlbedoToTintRefraction: boolean;
  58614. private _thicknessTexture;
  58615. /**
  58616. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58617. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58618. * 0 would mean minimumThickness
  58619. * 1 would mean maximumThickness
  58620. * The other channels might be use as a mask to vary the different effects intensity.
  58621. */
  58622. thicknessTexture: Nullable<BaseTexture>;
  58623. private _refractionTexture;
  58624. /**
  58625. * Defines the texture to use for refraction.
  58626. */
  58627. refractionTexture: Nullable<BaseTexture>;
  58628. private _indexOfRefraction;
  58629. /**
  58630. * Index of refraction of the material base layer.
  58631. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58632. *
  58633. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58634. *
  58635. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58636. */
  58637. indexOfRefraction: number;
  58638. private _volumeIndexOfRefraction;
  58639. /**
  58640. * Index of refraction of the material's volume.
  58641. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58642. *
  58643. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58644. * the volume will use the same IOR as the surface.
  58645. */
  58646. get volumeIndexOfRefraction(): number;
  58647. set volumeIndexOfRefraction(value: number);
  58648. private _invertRefractionY;
  58649. /**
  58650. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58651. */
  58652. invertRefractionY: boolean;
  58653. private _linkRefractionWithTransparency;
  58654. /**
  58655. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58656. * Materials half opaque for instance using refraction could benefit from this control.
  58657. */
  58658. linkRefractionWithTransparency: boolean;
  58659. /**
  58660. * Defines the minimum thickness stored in the thickness map.
  58661. * If no thickness map is defined, this value will be used to simulate thickness.
  58662. */
  58663. minimumThickness: number;
  58664. /**
  58665. * Defines the maximum thickness stored in the thickness map.
  58666. */
  58667. maximumThickness: number;
  58668. /**
  58669. * Defines the volume tint of the material.
  58670. * This is used for both translucency and scattering.
  58671. */
  58672. tintColor: Color3;
  58673. /**
  58674. * Defines the distance at which the tint color should be found in the media.
  58675. * This is used for refraction only.
  58676. */
  58677. tintColorAtDistance: number;
  58678. /**
  58679. * Defines how far each channel transmit through the media.
  58680. * It is defined as a color to simplify it selection.
  58681. */
  58682. diffusionDistance: Color3;
  58683. private _useMaskFromThicknessTexture;
  58684. /**
  58685. * Stores the intensity of the different subsurface effects in the thickness texture.
  58686. * * the green channel is the translucency intensity.
  58687. * * the blue channel is the scattering intensity.
  58688. * * the alpha channel is the refraction intensity.
  58689. */
  58690. useMaskFromThicknessTexture: boolean;
  58691. private _scene;
  58692. /** @hidden */
  58693. private _internalMarkAllSubMeshesAsTexturesDirty;
  58694. private _internalMarkScenePrePassDirty;
  58695. /** @hidden */
  58696. _markAllSubMeshesAsTexturesDirty(): void;
  58697. /** @hidden */
  58698. _markScenePrePassDirty(): void;
  58699. /**
  58700. * Instantiate a new istance of sub surface configuration.
  58701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58702. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58703. * @param scene The scene
  58704. */
  58705. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58706. /**
  58707. * Gets wehter the submesh is ready to be used or not.
  58708. * @param defines the list of "defines" to update.
  58709. * @param scene defines the scene the material belongs to.
  58710. * @returns - boolean indicating that the submesh is ready or not.
  58711. */
  58712. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58713. /**
  58714. * Checks to see if a texture is used in the material.
  58715. * @param defines the list of "defines" to update.
  58716. * @param scene defines the scene to the material belongs to.
  58717. */
  58718. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58719. /**
  58720. * Binds the material data.
  58721. * @param uniformBuffer defines the Uniform buffer to fill in.
  58722. * @param scene defines the scene the material belongs to.
  58723. * @param engine defines the engine the material belongs to.
  58724. * @param isFrozen defines whether the material is frozen or not.
  58725. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58726. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58727. */
  58728. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58729. /**
  58730. * Unbinds the material from the mesh.
  58731. * @param activeEffect defines the effect that should be unbound from.
  58732. * @returns true if unbound, otherwise false
  58733. */
  58734. unbind(activeEffect: Effect): boolean;
  58735. /**
  58736. * Returns the texture used for refraction or null if none is used.
  58737. * @param scene defines the scene the material belongs to.
  58738. * @returns - Refraction texture if present. If no refraction texture and refraction
  58739. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58740. */
  58741. private _getRefractionTexture;
  58742. /**
  58743. * Returns true if alpha blending should be disabled.
  58744. */
  58745. get disableAlphaBlending(): boolean;
  58746. /**
  58747. * Fills the list of render target textures.
  58748. * @param renderTargets the list of render targets to update
  58749. */
  58750. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58751. /**
  58752. * Checks to see if a texture is used in the material.
  58753. * @param texture - Base texture to use.
  58754. * @returns - Boolean specifying if a texture is used in the material.
  58755. */
  58756. hasTexture(texture: BaseTexture): boolean;
  58757. /**
  58758. * Gets a boolean indicating that current material needs to register RTT
  58759. * @returns true if this uses a render target otherwise false.
  58760. */
  58761. hasRenderTargetTextures(): boolean;
  58762. /**
  58763. * Returns an array of the actively used textures.
  58764. * @param activeTextures Array of BaseTextures
  58765. */
  58766. getActiveTextures(activeTextures: BaseTexture[]): void;
  58767. /**
  58768. * Returns the animatable textures.
  58769. * @param animatables Array of animatable textures.
  58770. */
  58771. getAnimatables(animatables: IAnimatable[]): void;
  58772. /**
  58773. * Disposes the resources of the material.
  58774. * @param forceDisposeTextures - Forces the disposal of all textures.
  58775. */
  58776. dispose(forceDisposeTextures?: boolean): void;
  58777. /**
  58778. * Get the current class name of the texture useful for serialization or dynamic coding.
  58779. * @returns "PBRSubSurfaceConfiguration"
  58780. */
  58781. getClassName(): string;
  58782. /**
  58783. * Add fallbacks to the effect fallbacks list.
  58784. * @param defines defines the Base texture to use.
  58785. * @param fallbacks defines the current fallback list.
  58786. * @param currentRank defines the current fallback rank.
  58787. * @returns the new fallback rank.
  58788. */
  58789. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58790. /**
  58791. * Add the required uniforms to the current list.
  58792. * @param uniforms defines the current uniform list.
  58793. */
  58794. static AddUniforms(uniforms: string[]): void;
  58795. /**
  58796. * Add the required samplers to the current list.
  58797. * @param samplers defines the current sampler list.
  58798. */
  58799. static AddSamplers(samplers: string[]): void;
  58800. /**
  58801. * Add the required uniforms to the current buffer.
  58802. * @param uniformBuffer defines the current uniform buffer.
  58803. */
  58804. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58805. /**
  58806. * Makes a duplicate of the current configuration into another one.
  58807. * @param configuration define the config where to copy the info
  58808. */
  58809. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58810. /**
  58811. * Serializes this Sub Surface configuration.
  58812. * @returns - An object with the serialized config.
  58813. */
  58814. serialize(): any;
  58815. /**
  58816. * Parses a anisotropy Configuration from a serialized object.
  58817. * @param source - Serialized object.
  58818. * @param scene Defines the scene we are parsing for
  58819. * @param rootUrl Defines the rootUrl to load from
  58820. */
  58821. parse(source: any, scene: Scene, rootUrl: string): void;
  58822. }
  58823. }
  58824. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58825. /** @hidden */
  58826. export var pbrFragmentDeclaration: {
  58827. name: string;
  58828. shader: string;
  58829. };
  58830. }
  58831. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58832. /** @hidden */
  58833. export var pbrUboDeclaration: {
  58834. name: string;
  58835. shader: string;
  58836. };
  58837. }
  58838. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58839. /** @hidden */
  58840. export var pbrFragmentExtraDeclaration: {
  58841. name: string;
  58842. shader: string;
  58843. };
  58844. }
  58845. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58846. /** @hidden */
  58847. export var pbrFragmentSamplersDeclaration: {
  58848. name: string;
  58849. shader: string;
  58850. };
  58851. }
  58852. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58853. /** @hidden */
  58854. export var subSurfaceScatteringFunctions: {
  58855. name: string;
  58856. shader: string;
  58857. };
  58858. }
  58859. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58860. /** @hidden */
  58861. export var importanceSampling: {
  58862. name: string;
  58863. shader: string;
  58864. };
  58865. }
  58866. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58867. /** @hidden */
  58868. export var pbrHelperFunctions: {
  58869. name: string;
  58870. shader: string;
  58871. };
  58872. }
  58873. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58874. /** @hidden */
  58875. export var harmonicsFunctions: {
  58876. name: string;
  58877. shader: string;
  58878. };
  58879. }
  58880. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58881. /** @hidden */
  58882. export var pbrDirectLightingSetupFunctions: {
  58883. name: string;
  58884. shader: string;
  58885. };
  58886. }
  58887. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58888. /** @hidden */
  58889. export var pbrDirectLightingFalloffFunctions: {
  58890. name: string;
  58891. shader: string;
  58892. };
  58893. }
  58894. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58895. /** @hidden */
  58896. export var pbrBRDFFunctions: {
  58897. name: string;
  58898. shader: string;
  58899. };
  58900. }
  58901. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58902. /** @hidden */
  58903. export var hdrFilteringFunctions: {
  58904. name: string;
  58905. shader: string;
  58906. };
  58907. }
  58908. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58909. /** @hidden */
  58910. export var pbrDirectLightingFunctions: {
  58911. name: string;
  58912. shader: string;
  58913. };
  58914. }
  58915. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58916. /** @hidden */
  58917. export var pbrIBLFunctions: {
  58918. name: string;
  58919. shader: string;
  58920. };
  58921. }
  58922. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58923. /** @hidden */
  58924. export var pbrBlockAlbedoOpacity: {
  58925. name: string;
  58926. shader: string;
  58927. };
  58928. }
  58929. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58930. /** @hidden */
  58931. export var pbrBlockReflectivity: {
  58932. name: string;
  58933. shader: string;
  58934. };
  58935. }
  58936. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58937. /** @hidden */
  58938. export var pbrBlockAmbientOcclusion: {
  58939. name: string;
  58940. shader: string;
  58941. };
  58942. }
  58943. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58944. /** @hidden */
  58945. export var pbrBlockAlphaFresnel: {
  58946. name: string;
  58947. shader: string;
  58948. };
  58949. }
  58950. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58951. /** @hidden */
  58952. export var pbrBlockAnisotropic: {
  58953. name: string;
  58954. shader: string;
  58955. };
  58956. }
  58957. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58958. /** @hidden */
  58959. export var pbrBlockReflection: {
  58960. name: string;
  58961. shader: string;
  58962. };
  58963. }
  58964. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58965. /** @hidden */
  58966. export var pbrBlockSheen: {
  58967. name: string;
  58968. shader: string;
  58969. };
  58970. }
  58971. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58972. /** @hidden */
  58973. export var pbrBlockClearcoat: {
  58974. name: string;
  58975. shader: string;
  58976. };
  58977. }
  58978. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58979. /** @hidden */
  58980. export var pbrBlockSubSurface: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58986. /** @hidden */
  58987. export var pbrBlockNormalGeometric: {
  58988. name: string;
  58989. shader: string;
  58990. };
  58991. }
  58992. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58993. /** @hidden */
  58994. export var pbrBlockNormalFinal: {
  58995. name: string;
  58996. shader: string;
  58997. };
  58998. }
  58999. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  59000. /** @hidden */
  59001. export var pbrBlockLightmapInit: {
  59002. name: string;
  59003. shader: string;
  59004. };
  59005. }
  59006. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  59007. /** @hidden */
  59008. export var pbrBlockGeometryInfo: {
  59009. name: string;
  59010. shader: string;
  59011. };
  59012. }
  59013. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  59014. /** @hidden */
  59015. export var pbrBlockReflectance0: {
  59016. name: string;
  59017. shader: string;
  59018. };
  59019. }
  59020. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  59021. /** @hidden */
  59022. export var pbrBlockReflectance: {
  59023. name: string;
  59024. shader: string;
  59025. };
  59026. }
  59027. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  59028. /** @hidden */
  59029. export var pbrBlockDirectLighting: {
  59030. name: string;
  59031. shader: string;
  59032. };
  59033. }
  59034. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  59035. /** @hidden */
  59036. export var pbrBlockFinalLitComponents: {
  59037. name: string;
  59038. shader: string;
  59039. };
  59040. }
  59041. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  59042. /** @hidden */
  59043. export var pbrBlockFinalUnlitComponents: {
  59044. name: string;
  59045. shader: string;
  59046. };
  59047. }
  59048. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  59049. /** @hidden */
  59050. export var pbrBlockFinalColorComposition: {
  59051. name: string;
  59052. shader: string;
  59053. };
  59054. }
  59055. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  59056. /** @hidden */
  59057. export var pbrBlockImageProcessing: {
  59058. name: string;
  59059. shader: string;
  59060. };
  59061. }
  59062. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  59063. /** @hidden */
  59064. export var pbrDebug: {
  59065. name: string;
  59066. shader: string;
  59067. };
  59068. }
  59069. declare module "babylonjs/Shaders/pbr.fragment" {
  59070. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  59071. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  59072. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59073. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  59074. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59075. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59076. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  59077. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59079. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59080. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59081. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59082. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  59083. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  59084. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  59085. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59086. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59087. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59088. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  59089. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  59090. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  59091. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  59092. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  59093. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  59094. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  59095. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59096. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59097. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  59098. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  59099. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  59100. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  59101. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  59102. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  59103. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  59104. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  59105. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  59106. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59107. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  59108. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59109. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  59110. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  59111. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  59112. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  59113. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  59114. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  59115. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  59116. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59117. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  59118. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  59119. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  59120. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59121. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59122. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  59123. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  59124. /** @hidden */
  59125. export var pbrPixelShader: {
  59126. name: string;
  59127. shader: string;
  59128. };
  59129. }
  59130. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  59131. /** @hidden */
  59132. export var pbrVertexDeclaration: {
  59133. name: string;
  59134. shader: string;
  59135. };
  59136. }
  59137. declare module "babylonjs/Shaders/pbr.vertex" {
  59138. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59139. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59141. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59142. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59143. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  59144. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59145. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59147. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59148. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59149. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59150. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59151. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59154. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59155. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59156. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  59157. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59159. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59160. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59161. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59162. /** @hidden */
  59163. export var pbrVertexShader: {
  59164. name: string;
  59165. shader: string;
  59166. };
  59167. }
  59168. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Scene } from "babylonjs/scene";
  59171. import { Matrix } from "babylonjs/Maths/math.vector";
  59172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59174. import { Mesh } from "babylonjs/Meshes/mesh";
  59175. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59176. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59177. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59178. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59179. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59180. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  59181. import { Color3 } from "babylonjs/Maths/math.color";
  59182. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59183. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59185. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59188. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59189. import "babylonjs/Shaders/pbr.fragment";
  59190. import "babylonjs/Shaders/pbr.vertex";
  59191. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59192. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59193. /**
  59194. * Manages the defines for the PBR Material.
  59195. * @hidden
  59196. */
  59197. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59198. PBR: boolean;
  59199. NUM_SAMPLES: string;
  59200. REALTIME_FILTERING: boolean;
  59201. MAINUV1: boolean;
  59202. MAINUV2: boolean;
  59203. UV1: boolean;
  59204. UV2: boolean;
  59205. ALBEDO: boolean;
  59206. GAMMAALBEDO: boolean;
  59207. ALBEDODIRECTUV: number;
  59208. VERTEXCOLOR: boolean;
  59209. DETAIL: boolean;
  59210. DETAILDIRECTUV: number;
  59211. DETAIL_NORMALBLENDMETHOD: number;
  59212. AMBIENT: boolean;
  59213. AMBIENTDIRECTUV: number;
  59214. AMBIENTINGRAYSCALE: boolean;
  59215. OPACITY: boolean;
  59216. VERTEXALPHA: boolean;
  59217. OPACITYDIRECTUV: number;
  59218. OPACITYRGB: boolean;
  59219. ALPHATEST: boolean;
  59220. DEPTHPREPASS: boolean;
  59221. ALPHABLEND: boolean;
  59222. ALPHAFROMALBEDO: boolean;
  59223. ALPHATESTVALUE: string;
  59224. SPECULAROVERALPHA: boolean;
  59225. RADIANCEOVERALPHA: boolean;
  59226. ALPHAFRESNEL: boolean;
  59227. LINEARALPHAFRESNEL: boolean;
  59228. PREMULTIPLYALPHA: boolean;
  59229. EMISSIVE: boolean;
  59230. EMISSIVEDIRECTUV: number;
  59231. REFLECTIVITY: boolean;
  59232. REFLECTIVITYDIRECTUV: number;
  59233. SPECULARTERM: boolean;
  59234. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59235. MICROSURFACEAUTOMATIC: boolean;
  59236. LODBASEDMICROSFURACE: boolean;
  59237. MICROSURFACEMAP: boolean;
  59238. MICROSURFACEMAPDIRECTUV: number;
  59239. METALLICWORKFLOW: boolean;
  59240. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59241. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59242. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59243. AOSTOREINMETALMAPRED: boolean;
  59244. METALLIC_REFLECTANCE: boolean;
  59245. METALLIC_REFLECTANCEDIRECTUV: number;
  59246. ENVIRONMENTBRDF: boolean;
  59247. ENVIRONMENTBRDF_RGBD: boolean;
  59248. NORMAL: boolean;
  59249. TANGENT: boolean;
  59250. BUMP: boolean;
  59251. BUMPDIRECTUV: number;
  59252. OBJECTSPACE_NORMALMAP: boolean;
  59253. PARALLAX: boolean;
  59254. PARALLAXOCCLUSION: boolean;
  59255. NORMALXYSCALE: boolean;
  59256. LIGHTMAP: boolean;
  59257. LIGHTMAPDIRECTUV: number;
  59258. USELIGHTMAPASSHADOWMAP: boolean;
  59259. GAMMALIGHTMAP: boolean;
  59260. RGBDLIGHTMAP: boolean;
  59261. REFLECTION: boolean;
  59262. REFLECTIONMAP_3D: boolean;
  59263. REFLECTIONMAP_SPHERICAL: boolean;
  59264. REFLECTIONMAP_PLANAR: boolean;
  59265. REFLECTIONMAP_CUBIC: boolean;
  59266. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59267. REFLECTIONMAP_PROJECTION: boolean;
  59268. REFLECTIONMAP_SKYBOX: boolean;
  59269. REFLECTIONMAP_EXPLICIT: boolean;
  59270. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59271. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59272. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59273. INVERTCUBICMAP: boolean;
  59274. USESPHERICALFROMREFLECTIONMAP: boolean;
  59275. USEIRRADIANCEMAP: boolean;
  59276. SPHERICAL_HARMONICS: boolean;
  59277. USESPHERICALINVERTEX: boolean;
  59278. REFLECTIONMAP_OPPOSITEZ: boolean;
  59279. LODINREFLECTIONALPHA: boolean;
  59280. GAMMAREFLECTION: boolean;
  59281. RGBDREFLECTION: boolean;
  59282. LINEARSPECULARREFLECTION: boolean;
  59283. RADIANCEOCCLUSION: boolean;
  59284. HORIZONOCCLUSION: boolean;
  59285. INSTANCES: boolean;
  59286. THIN_INSTANCES: boolean;
  59287. PREPASS: boolean;
  59288. PREPASS_IRRADIANCE: boolean;
  59289. PREPASS_IRRADIANCE_INDEX: number;
  59290. PREPASS_ALBEDO: boolean;
  59291. PREPASS_ALBEDO_INDEX: number;
  59292. PREPASS_DEPTHNORMAL: boolean;
  59293. PREPASS_DEPTHNORMAL_INDEX: number;
  59294. PREPASS_POSITION: boolean;
  59295. PREPASS_POSITION_INDEX: number;
  59296. PREPASS_VELOCITY: boolean;
  59297. PREPASS_VELOCITY_INDEX: number;
  59298. PREPASS_REFLECTIVITY: boolean;
  59299. PREPASS_REFLECTIVITY_INDEX: number;
  59300. SCENE_MRT_COUNT: number;
  59301. NUM_BONE_INFLUENCERS: number;
  59302. BonesPerMesh: number;
  59303. BONETEXTURE: boolean;
  59304. BONES_VELOCITY_ENABLED: boolean;
  59305. NONUNIFORMSCALING: boolean;
  59306. MORPHTARGETS: boolean;
  59307. MORPHTARGETS_NORMAL: boolean;
  59308. MORPHTARGETS_TANGENT: boolean;
  59309. MORPHTARGETS_UV: boolean;
  59310. NUM_MORPH_INFLUENCERS: number;
  59311. IMAGEPROCESSING: boolean;
  59312. VIGNETTE: boolean;
  59313. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59314. VIGNETTEBLENDMODEOPAQUE: boolean;
  59315. TONEMAPPING: boolean;
  59316. TONEMAPPING_ACES: boolean;
  59317. CONTRAST: boolean;
  59318. COLORCURVES: boolean;
  59319. COLORGRADING: boolean;
  59320. COLORGRADING3D: boolean;
  59321. SAMPLER3DGREENDEPTH: boolean;
  59322. SAMPLER3DBGRMAP: boolean;
  59323. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59324. EXPOSURE: boolean;
  59325. MULTIVIEW: boolean;
  59326. USEPHYSICALLIGHTFALLOFF: boolean;
  59327. USEGLTFLIGHTFALLOFF: boolean;
  59328. TWOSIDEDLIGHTING: boolean;
  59329. SHADOWFLOAT: boolean;
  59330. CLIPPLANE: boolean;
  59331. CLIPPLANE2: boolean;
  59332. CLIPPLANE3: boolean;
  59333. CLIPPLANE4: boolean;
  59334. CLIPPLANE5: boolean;
  59335. CLIPPLANE6: boolean;
  59336. POINTSIZE: boolean;
  59337. FOG: boolean;
  59338. LOGARITHMICDEPTH: boolean;
  59339. FORCENORMALFORWARD: boolean;
  59340. SPECULARAA: boolean;
  59341. CLEARCOAT: boolean;
  59342. CLEARCOAT_DEFAULTIOR: boolean;
  59343. CLEARCOAT_TEXTURE: boolean;
  59344. CLEARCOAT_TEXTUREDIRECTUV: number;
  59345. CLEARCOAT_BUMP: boolean;
  59346. CLEARCOAT_BUMPDIRECTUV: number;
  59347. CLEARCOAT_REMAP_F0: boolean;
  59348. CLEARCOAT_TINT: boolean;
  59349. CLEARCOAT_TINT_TEXTURE: boolean;
  59350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59351. ANISOTROPIC: boolean;
  59352. ANISOTROPIC_TEXTURE: boolean;
  59353. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59354. BRDF_V_HEIGHT_CORRELATED: boolean;
  59355. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59356. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59357. SHEEN: boolean;
  59358. SHEEN_TEXTURE: boolean;
  59359. SHEEN_TEXTUREDIRECTUV: number;
  59360. SHEEN_LINKWITHALBEDO: boolean;
  59361. SHEEN_ROUGHNESS: boolean;
  59362. SHEEN_ALBEDOSCALING: boolean;
  59363. SUBSURFACE: boolean;
  59364. SS_REFRACTION: boolean;
  59365. SS_TRANSLUCENCY: boolean;
  59366. SS_SCATTERING: boolean;
  59367. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59368. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59369. SS_REFRACTIONMAP_3D: boolean;
  59370. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59371. SS_LODINREFRACTIONALPHA: boolean;
  59372. SS_GAMMAREFRACTION: boolean;
  59373. SS_RGBDREFRACTION: boolean;
  59374. SS_LINEARSPECULARREFRACTION: boolean;
  59375. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59376. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59377. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59378. UNLIT: boolean;
  59379. DEBUGMODE: number;
  59380. /**
  59381. * Initializes the PBR Material defines.
  59382. */
  59383. constructor();
  59384. /**
  59385. * Resets the PBR Material defines.
  59386. */
  59387. reset(): void;
  59388. }
  59389. /**
  59390. * The Physically based material base class of BJS.
  59391. *
  59392. * This offers the main features of a standard PBR material.
  59393. * For more information, please refer to the documentation :
  59394. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59395. */
  59396. export abstract class PBRBaseMaterial extends PushMaterial {
  59397. /**
  59398. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59399. */
  59400. static readonly PBRMATERIAL_OPAQUE: number;
  59401. /**
  59402. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59403. */
  59404. static readonly PBRMATERIAL_ALPHATEST: number;
  59405. /**
  59406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59407. */
  59408. static readonly PBRMATERIAL_ALPHABLEND: number;
  59409. /**
  59410. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59411. * They are also discarded below the alpha cutoff threshold to improve performances.
  59412. */
  59413. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59414. /**
  59415. * Defines the default value of how much AO map is occluding the analytical lights
  59416. * (point spot...).
  59417. */
  59418. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59419. /**
  59420. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59421. */
  59422. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59423. /**
  59424. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59425. * to enhance interoperability with other engines.
  59426. */
  59427. static readonly LIGHTFALLOFF_GLTF: number;
  59428. /**
  59429. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59430. * to enhance interoperability with other materials.
  59431. */
  59432. static readonly LIGHTFALLOFF_STANDARD: number;
  59433. /**
  59434. * Intensity of the direct lights e.g. the four lights available in your scene.
  59435. * This impacts both the direct diffuse and specular highlights.
  59436. */
  59437. protected _directIntensity: number;
  59438. /**
  59439. * Intensity of the emissive part of the material.
  59440. * This helps controlling the emissive effect without modifying the emissive color.
  59441. */
  59442. protected _emissiveIntensity: number;
  59443. /**
  59444. * Intensity of the environment e.g. how much the environment will light the object
  59445. * either through harmonics for rough material or through the refelction for shiny ones.
  59446. */
  59447. protected _environmentIntensity: number;
  59448. /**
  59449. * This is a special control allowing the reduction of the specular highlights coming from the
  59450. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59451. */
  59452. protected _specularIntensity: number;
  59453. /**
  59454. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59455. */
  59456. private _lightingInfos;
  59457. /**
  59458. * Debug Control allowing disabling the bump map on this material.
  59459. */
  59460. protected _disableBumpMap: boolean;
  59461. /**
  59462. * AKA Diffuse Texture in standard nomenclature.
  59463. */
  59464. protected _albedoTexture: Nullable<BaseTexture>;
  59465. /**
  59466. * AKA Occlusion Texture in other nomenclature.
  59467. */
  59468. protected _ambientTexture: Nullable<BaseTexture>;
  59469. /**
  59470. * AKA Occlusion Texture Intensity in other nomenclature.
  59471. */
  59472. protected _ambientTextureStrength: number;
  59473. /**
  59474. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59475. * 1 means it completely occludes it
  59476. * 0 mean it has no impact
  59477. */
  59478. protected _ambientTextureImpactOnAnalyticalLights: number;
  59479. /**
  59480. * Stores the alpha values in a texture.
  59481. */
  59482. protected _opacityTexture: Nullable<BaseTexture>;
  59483. /**
  59484. * Stores the reflection values in a texture.
  59485. */
  59486. protected _reflectionTexture: Nullable<BaseTexture>;
  59487. /**
  59488. * Stores the emissive values in a texture.
  59489. */
  59490. protected _emissiveTexture: Nullable<BaseTexture>;
  59491. /**
  59492. * AKA Specular texture in other nomenclature.
  59493. */
  59494. protected _reflectivityTexture: Nullable<BaseTexture>;
  59495. /**
  59496. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59497. */
  59498. protected _metallicTexture: Nullable<BaseTexture>;
  59499. /**
  59500. * Specifies the metallic scalar of the metallic/roughness workflow.
  59501. * Can also be used to scale the metalness values of the metallic texture.
  59502. */
  59503. protected _metallic: Nullable<number>;
  59504. /**
  59505. * Specifies the roughness scalar of the metallic/roughness workflow.
  59506. * Can also be used to scale the roughness values of the metallic texture.
  59507. */
  59508. protected _roughness: Nullable<number>;
  59509. /**
  59510. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59511. * By default the indexOfrefraction is used to compute F0;
  59512. *
  59513. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59514. *
  59515. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59516. * F90 = metallicReflectanceColor;
  59517. */
  59518. protected _metallicF0Factor: number;
  59519. /**
  59520. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59521. * By default the F90 is always 1;
  59522. *
  59523. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59524. *
  59525. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59526. * F90 = metallicReflectanceColor;
  59527. */
  59528. protected _metallicReflectanceColor: Color3;
  59529. /**
  59530. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59531. * This is multiply against the scalar values defined in the material.
  59532. */
  59533. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59534. /**
  59535. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59537. */
  59538. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59539. /**
  59540. * Stores surface normal data used to displace a mesh in a texture.
  59541. */
  59542. protected _bumpTexture: Nullable<BaseTexture>;
  59543. /**
  59544. * Stores the pre-calculated light information of a mesh in a texture.
  59545. */
  59546. protected _lightmapTexture: Nullable<BaseTexture>;
  59547. /**
  59548. * The color of a material in ambient lighting.
  59549. */
  59550. protected _ambientColor: Color3;
  59551. /**
  59552. * AKA Diffuse Color in other nomenclature.
  59553. */
  59554. protected _albedoColor: Color3;
  59555. /**
  59556. * AKA Specular Color in other nomenclature.
  59557. */
  59558. protected _reflectivityColor: Color3;
  59559. /**
  59560. * The color applied when light is reflected from a material.
  59561. */
  59562. protected _reflectionColor: Color3;
  59563. /**
  59564. * The color applied when light is emitted from a material.
  59565. */
  59566. protected _emissiveColor: Color3;
  59567. /**
  59568. * AKA Glossiness in other nomenclature.
  59569. */
  59570. protected _microSurface: number;
  59571. /**
  59572. * Specifies that the material will use the light map as a show map.
  59573. */
  59574. protected _useLightmapAsShadowmap: boolean;
  59575. /**
  59576. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59577. * makes the reflect vector face the model (under horizon).
  59578. */
  59579. protected _useHorizonOcclusion: boolean;
  59580. /**
  59581. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59582. * too much the area relying on ambient texture to define their ambient occlusion.
  59583. */
  59584. protected _useRadianceOcclusion: boolean;
  59585. /**
  59586. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59587. */
  59588. protected _useAlphaFromAlbedoTexture: boolean;
  59589. /**
  59590. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59591. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59592. */
  59593. protected _useSpecularOverAlpha: boolean;
  59594. /**
  59595. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59596. */
  59597. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59598. /**
  59599. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59600. */
  59601. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59602. /**
  59603. * Specifies if the metallic texture contains the roughness information in its green channel.
  59604. */
  59605. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59606. /**
  59607. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59608. */
  59609. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59610. /**
  59611. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59612. */
  59613. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59614. /**
  59615. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59616. */
  59617. protected _useAmbientInGrayScale: boolean;
  59618. /**
  59619. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59620. * The material will try to infer what glossiness each pixel should be.
  59621. */
  59622. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59623. /**
  59624. * Defines the falloff type used in this material.
  59625. * It by default is Physical.
  59626. */
  59627. protected _lightFalloff: number;
  59628. /**
  59629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59631. */
  59632. protected _useRadianceOverAlpha: boolean;
  59633. /**
  59634. * Allows using an object space normal map (instead of tangent space).
  59635. */
  59636. protected _useObjectSpaceNormalMap: boolean;
  59637. /**
  59638. * Allows using the bump map in parallax mode.
  59639. */
  59640. protected _useParallax: boolean;
  59641. /**
  59642. * Allows using the bump map in parallax occlusion mode.
  59643. */
  59644. protected _useParallaxOcclusion: boolean;
  59645. /**
  59646. * Controls the scale bias of the parallax mode.
  59647. */
  59648. protected _parallaxScaleBias: number;
  59649. /**
  59650. * If sets to true, disables all the lights affecting the material.
  59651. */
  59652. protected _disableLighting: boolean;
  59653. /**
  59654. * Number of Simultaneous lights allowed on the material.
  59655. */
  59656. protected _maxSimultaneousLights: number;
  59657. /**
  59658. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59659. */
  59660. protected _invertNormalMapX: boolean;
  59661. /**
  59662. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59663. */
  59664. protected _invertNormalMapY: boolean;
  59665. /**
  59666. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59667. */
  59668. protected _twoSidedLighting: boolean;
  59669. /**
  59670. * Defines the alpha limits in alpha test mode.
  59671. */
  59672. protected _alphaCutOff: number;
  59673. /**
  59674. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59675. */
  59676. protected _forceAlphaTest: boolean;
  59677. /**
  59678. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59679. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59680. */
  59681. protected _useAlphaFresnel: boolean;
  59682. /**
  59683. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59684. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59685. */
  59686. protected _useLinearAlphaFresnel: boolean;
  59687. /**
  59688. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59689. * from cos thetav and roughness:
  59690. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59691. */
  59692. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59693. /**
  59694. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59695. */
  59696. protected _forceIrradianceInFragment: boolean;
  59697. private _realTimeFiltering;
  59698. /**
  59699. * Enables realtime filtering on the texture.
  59700. */
  59701. get realTimeFiltering(): boolean;
  59702. set realTimeFiltering(b: boolean);
  59703. private _realTimeFilteringQuality;
  59704. /**
  59705. * Quality switch for realtime filtering
  59706. */
  59707. get realTimeFilteringQuality(): number;
  59708. set realTimeFilteringQuality(n: number);
  59709. /**
  59710. * Can this material render to several textures at once
  59711. */
  59712. get canRenderToMRT(): boolean;
  59713. /**
  59714. * Force normal to face away from face.
  59715. */
  59716. protected _forceNormalForward: boolean;
  59717. /**
  59718. * Enables specular anti aliasing in the PBR shader.
  59719. * It will both interacts on the Geometry for analytical and IBL lighting.
  59720. * It also prefilter the roughness map based on the bump values.
  59721. */
  59722. protected _enableSpecularAntiAliasing: boolean;
  59723. /**
  59724. * Default configuration related to image processing available in the PBR Material.
  59725. */
  59726. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59727. /**
  59728. * Keep track of the image processing observer to allow dispose and replace.
  59729. */
  59730. private _imageProcessingObserver;
  59731. /**
  59732. * Attaches a new image processing configuration to the PBR Material.
  59733. * @param configuration
  59734. */
  59735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59736. /**
  59737. * Stores the available render targets.
  59738. */
  59739. private _renderTargets;
  59740. /**
  59741. * Sets the global ambient color for the material used in lighting calculations.
  59742. */
  59743. private _globalAmbientColor;
  59744. /**
  59745. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59746. */
  59747. private _useLogarithmicDepth;
  59748. /**
  59749. * If set to true, no lighting calculations will be applied.
  59750. */
  59751. private _unlit;
  59752. private _debugMode;
  59753. /**
  59754. * @hidden
  59755. * This is reserved for the inspector.
  59756. * Defines the material debug mode.
  59757. * It helps seeing only some components of the material while troubleshooting.
  59758. */
  59759. debugMode: number;
  59760. /**
  59761. * @hidden
  59762. * This is reserved for the inspector.
  59763. * Specify from where on screen the debug mode should start.
  59764. * The value goes from -1 (full screen) to 1 (not visible)
  59765. * It helps with side by side comparison against the final render
  59766. * This defaults to -1
  59767. */
  59768. private debugLimit;
  59769. /**
  59770. * @hidden
  59771. * This is reserved for the inspector.
  59772. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59773. * You can use the factor to better multiply the final value.
  59774. */
  59775. private debugFactor;
  59776. /**
  59777. * Defines the clear coat layer parameters for the material.
  59778. */
  59779. readonly clearCoat: PBRClearCoatConfiguration;
  59780. /**
  59781. * Defines the anisotropic parameters for the material.
  59782. */
  59783. readonly anisotropy: PBRAnisotropicConfiguration;
  59784. /**
  59785. * Defines the BRDF parameters for the material.
  59786. */
  59787. readonly brdf: PBRBRDFConfiguration;
  59788. /**
  59789. * Defines the Sheen parameters for the material.
  59790. */
  59791. readonly sheen: PBRSheenConfiguration;
  59792. /**
  59793. * Defines the SubSurface parameters for the material.
  59794. */
  59795. readonly subSurface: PBRSubSurfaceConfiguration;
  59796. /**
  59797. * Defines additionnal PrePass parameters for the material.
  59798. */
  59799. readonly prePassConfiguration: PrePassConfiguration;
  59800. /**
  59801. * Defines the detail map parameters for the material.
  59802. */
  59803. readonly detailMap: DetailMapConfiguration;
  59804. protected _rebuildInParallel: boolean;
  59805. /**
  59806. * Instantiates a new PBRMaterial instance.
  59807. *
  59808. * @param name The material name
  59809. * @param scene The scene the material will be use in.
  59810. */
  59811. constructor(name: string, scene: Scene);
  59812. /**
  59813. * Gets a boolean indicating that current material needs to register RTT
  59814. */
  59815. get hasRenderTargetTextures(): boolean;
  59816. /**
  59817. * Gets the name of the material class.
  59818. */
  59819. getClassName(): string;
  59820. /**
  59821. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59822. */
  59823. get useLogarithmicDepth(): boolean;
  59824. /**
  59825. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59826. */
  59827. set useLogarithmicDepth(value: boolean);
  59828. /**
  59829. * Returns true if alpha blending should be disabled.
  59830. */
  59831. protected get _disableAlphaBlending(): boolean;
  59832. /**
  59833. * Specifies whether or not this material should be rendered in alpha blend mode.
  59834. */
  59835. needAlphaBlending(): boolean;
  59836. /**
  59837. * Specifies whether or not this material should be rendered in alpha test mode.
  59838. */
  59839. needAlphaTesting(): boolean;
  59840. /**
  59841. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59842. */
  59843. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59844. /**
  59845. * Gets the texture used for the alpha test.
  59846. */
  59847. getAlphaTestTexture(): Nullable<BaseTexture>;
  59848. /**
  59849. * Specifies that the submesh is ready to be used.
  59850. * @param mesh - BJS mesh.
  59851. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59852. * @param useInstances - Specifies that instances should be used.
  59853. * @returns - boolean indicating that the submesh is ready or not.
  59854. */
  59855. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59856. /**
  59857. * Specifies if the material uses metallic roughness workflow.
  59858. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59859. */
  59860. isMetallicWorkflow(): boolean;
  59861. private _prepareEffect;
  59862. private _prepareDefines;
  59863. /**
  59864. * Force shader compilation
  59865. */
  59866. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59867. /**
  59868. * Initializes the uniform buffer layout for the shader.
  59869. */
  59870. buildUniformLayout(): void;
  59871. /**
  59872. * Unbinds the material from the mesh
  59873. */
  59874. unbind(): void;
  59875. /**
  59876. * Binds the submesh data.
  59877. * @param world - The world matrix.
  59878. * @param mesh - The BJS mesh.
  59879. * @param subMesh - A submesh of the BJS mesh.
  59880. */
  59881. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59882. /**
  59883. * Returns the animatable textures.
  59884. * @returns - Array of animatable textures.
  59885. */
  59886. getAnimatables(): IAnimatable[];
  59887. /**
  59888. * Returns the texture used for reflections.
  59889. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59890. */
  59891. private _getReflectionTexture;
  59892. /**
  59893. * Returns an array of the actively used textures.
  59894. * @returns - Array of BaseTextures
  59895. */
  59896. getActiveTextures(): BaseTexture[];
  59897. /**
  59898. * Checks to see if a texture is used in the material.
  59899. * @param texture - Base texture to use.
  59900. * @returns - Boolean specifying if a texture is used in the material.
  59901. */
  59902. hasTexture(texture: BaseTexture): boolean;
  59903. /**
  59904. * Sets the required values to the prepass renderer.
  59905. * @param prePassRenderer defines the prepass renderer to setup
  59906. */
  59907. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59908. /**
  59909. * Disposes the resources of the material.
  59910. * @param forceDisposeEffect - Forces the disposal of effects.
  59911. * @param forceDisposeTextures - Forces the disposal of all textures.
  59912. */
  59913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59914. }
  59915. }
  59916. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59917. import { Nullable } from "babylonjs/types";
  59918. import { Scene } from "babylonjs/scene";
  59919. import { Color3 } from "babylonjs/Maths/math.color";
  59920. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59921. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59923. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59924. /**
  59925. * The Physically based material of BJS.
  59926. *
  59927. * This offers the main features of a standard PBR material.
  59928. * For more information, please refer to the documentation :
  59929. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59930. */
  59931. export class PBRMaterial extends PBRBaseMaterial {
  59932. /**
  59933. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59934. */
  59935. static readonly PBRMATERIAL_OPAQUE: number;
  59936. /**
  59937. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59938. */
  59939. static readonly PBRMATERIAL_ALPHATEST: number;
  59940. /**
  59941. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59942. */
  59943. static readonly PBRMATERIAL_ALPHABLEND: number;
  59944. /**
  59945. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59946. * They are also discarded below the alpha cutoff threshold to improve performances.
  59947. */
  59948. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59949. /**
  59950. * Defines the default value of how much AO map is occluding the analytical lights
  59951. * (point spot...).
  59952. */
  59953. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59954. /**
  59955. * Intensity of the direct lights e.g. the four lights available in your scene.
  59956. * This impacts both the direct diffuse and specular highlights.
  59957. */
  59958. directIntensity: number;
  59959. /**
  59960. * Intensity of the emissive part of the material.
  59961. * This helps controlling the emissive effect without modifying the emissive color.
  59962. */
  59963. emissiveIntensity: number;
  59964. /**
  59965. * Intensity of the environment e.g. how much the environment will light the object
  59966. * either through harmonics for rough material or through the refelction for shiny ones.
  59967. */
  59968. environmentIntensity: number;
  59969. /**
  59970. * This is a special control allowing the reduction of the specular highlights coming from the
  59971. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59972. */
  59973. specularIntensity: number;
  59974. /**
  59975. * Debug Control allowing disabling the bump map on this material.
  59976. */
  59977. disableBumpMap: boolean;
  59978. /**
  59979. * AKA Diffuse Texture in standard nomenclature.
  59980. */
  59981. albedoTexture: BaseTexture;
  59982. /**
  59983. * AKA Occlusion Texture in other nomenclature.
  59984. */
  59985. ambientTexture: BaseTexture;
  59986. /**
  59987. * AKA Occlusion Texture Intensity in other nomenclature.
  59988. */
  59989. ambientTextureStrength: number;
  59990. /**
  59991. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59992. * 1 means it completely occludes it
  59993. * 0 mean it has no impact
  59994. */
  59995. ambientTextureImpactOnAnalyticalLights: number;
  59996. /**
  59997. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59998. */
  59999. opacityTexture: BaseTexture;
  60000. /**
  60001. * Stores the reflection values in a texture.
  60002. */
  60003. reflectionTexture: Nullable<BaseTexture>;
  60004. /**
  60005. * Stores the emissive values in a texture.
  60006. */
  60007. emissiveTexture: BaseTexture;
  60008. /**
  60009. * AKA Specular texture in other nomenclature.
  60010. */
  60011. reflectivityTexture: BaseTexture;
  60012. /**
  60013. * Used to switch from specular/glossiness to metallic/roughness workflow.
  60014. */
  60015. metallicTexture: BaseTexture;
  60016. /**
  60017. * Specifies the metallic scalar of the metallic/roughness workflow.
  60018. * Can also be used to scale the metalness values of the metallic texture.
  60019. */
  60020. metallic: Nullable<number>;
  60021. /**
  60022. * Specifies the roughness scalar of the metallic/roughness workflow.
  60023. * Can also be used to scale the roughness values of the metallic texture.
  60024. */
  60025. roughness: Nullable<number>;
  60026. /**
  60027. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  60028. * By default the indexOfrefraction is used to compute F0;
  60029. *
  60030. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  60031. *
  60032. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  60033. * F90 = metallicReflectanceColor;
  60034. */
  60035. metallicF0Factor: number;
  60036. /**
  60037. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  60038. * By default the F90 is always 1;
  60039. *
  60040. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  60041. *
  60042. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  60043. * F90 = metallicReflectanceColor;
  60044. */
  60045. metallicReflectanceColor: Color3;
  60046. /**
  60047. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  60048. * This is multiply against the scalar values defined in the material.
  60049. */
  60050. metallicReflectanceTexture: Nullable<BaseTexture>;
  60051. /**
  60052. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  60053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  60054. */
  60055. microSurfaceTexture: BaseTexture;
  60056. /**
  60057. * Stores surface normal data used to displace a mesh in a texture.
  60058. */
  60059. bumpTexture: BaseTexture;
  60060. /**
  60061. * Stores the pre-calculated light information of a mesh in a texture.
  60062. */
  60063. lightmapTexture: BaseTexture;
  60064. /**
  60065. * Stores the refracted light information in a texture.
  60066. */
  60067. get refractionTexture(): Nullable<BaseTexture>;
  60068. set refractionTexture(value: Nullable<BaseTexture>);
  60069. /**
  60070. * The color of a material in ambient lighting.
  60071. */
  60072. ambientColor: Color3;
  60073. /**
  60074. * AKA Diffuse Color in other nomenclature.
  60075. */
  60076. albedoColor: Color3;
  60077. /**
  60078. * AKA Specular Color in other nomenclature.
  60079. */
  60080. reflectivityColor: Color3;
  60081. /**
  60082. * The color reflected from the material.
  60083. */
  60084. reflectionColor: Color3;
  60085. /**
  60086. * The color emitted from the material.
  60087. */
  60088. emissiveColor: Color3;
  60089. /**
  60090. * AKA Glossiness in other nomenclature.
  60091. */
  60092. microSurface: number;
  60093. /**
  60094. * Index of refraction of the material base layer.
  60095. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  60096. *
  60097. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  60098. *
  60099. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  60100. */
  60101. get indexOfRefraction(): number;
  60102. set indexOfRefraction(value: number);
  60103. /**
  60104. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60105. */
  60106. get invertRefractionY(): boolean;
  60107. set invertRefractionY(value: boolean);
  60108. /**
  60109. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60110. * Materials half opaque for instance using refraction could benefit from this control.
  60111. */
  60112. get linkRefractionWithTransparency(): boolean;
  60113. set linkRefractionWithTransparency(value: boolean);
  60114. /**
  60115. * If true, the light map contains occlusion information instead of lighting info.
  60116. */
  60117. useLightmapAsShadowmap: boolean;
  60118. /**
  60119. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  60120. */
  60121. useAlphaFromAlbedoTexture: boolean;
  60122. /**
  60123. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  60124. */
  60125. forceAlphaTest: boolean;
  60126. /**
  60127. * Defines the alpha limits in alpha test mode.
  60128. */
  60129. alphaCutOff: number;
  60130. /**
  60131. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  60132. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  60133. */
  60134. useSpecularOverAlpha: boolean;
  60135. /**
  60136. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  60137. */
  60138. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  60139. /**
  60140. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  60141. */
  60142. useRoughnessFromMetallicTextureAlpha: boolean;
  60143. /**
  60144. * Specifies if the metallic texture contains the roughness information in its green channel.
  60145. */
  60146. useRoughnessFromMetallicTextureGreen: boolean;
  60147. /**
  60148. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60149. */
  60150. useMetallnessFromMetallicTextureBlue: boolean;
  60151. /**
  60152. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60153. */
  60154. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60155. /**
  60156. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60157. */
  60158. useAmbientInGrayScale: boolean;
  60159. /**
  60160. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60161. * The material will try to infer what glossiness each pixel should be.
  60162. */
  60163. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60164. /**
  60165. * BJS is using an harcoded light falloff based on a manually sets up range.
  60166. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60167. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60168. */
  60169. get usePhysicalLightFalloff(): boolean;
  60170. /**
  60171. * BJS is using an harcoded light falloff based on a manually sets up range.
  60172. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60173. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60174. */
  60175. set usePhysicalLightFalloff(value: boolean);
  60176. /**
  60177. * In order to support the falloff compatibility with gltf, a special mode has been added
  60178. * to reproduce the gltf light falloff.
  60179. */
  60180. get useGLTFLightFalloff(): boolean;
  60181. /**
  60182. * In order to support the falloff compatibility with gltf, a special mode has been added
  60183. * to reproduce the gltf light falloff.
  60184. */
  60185. set useGLTFLightFalloff(value: boolean);
  60186. /**
  60187. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60188. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60189. */
  60190. useRadianceOverAlpha: boolean;
  60191. /**
  60192. * Allows using an object space normal map (instead of tangent space).
  60193. */
  60194. useObjectSpaceNormalMap: boolean;
  60195. /**
  60196. * Allows using the bump map in parallax mode.
  60197. */
  60198. useParallax: boolean;
  60199. /**
  60200. * Allows using the bump map in parallax occlusion mode.
  60201. */
  60202. useParallaxOcclusion: boolean;
  60203. /**
  60204. * Controls the scale bias of the parallax mode.
  60205. */
  60206. parallaxScaleBias: number;
  60207. /**
  60208. * If sets to true, disables all the lights affecting the material.
  60209. */
  60210. disableLighting: boolean;
  60211. /**
  60212. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60213. */
  60214. forceIrradianceInFragment: boolean;
  60215. /**
  60216. * Number of Simultaneous lights allowed on the material.
  60217. */
  60218. maxSimultaneousLights: number;
  60219. /**
  60220. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60221. */
  60222. invertNormalMapX: boolean;
  60223. /**
  60224. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60225. */
  60226. invertNormalMapY: boolean;
  60227. /**
  60228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60229. */
  60230. twoSidedLighting: boolean;
  60231. /**
  60232. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60233. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60234. */
  60235. useAlphaFresnel: boolean;
  60236. /**
  60237. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60238. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60239. */
  60240. useLinearAlphaFresnel: boolean;
  60241. /**
  60242. * Let user defines the brdf lookup texture used for IBL.
  60243. * A default 8bit version is embedded but you could point at :
  60244. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60245. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60246. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60247. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60248. */
  60249. environmentBRDFTexture: Nullable<BaseTexture>;
  60250. /**
  60251. * Force normal to face away from face.
  60252. */
  60253. forceNormalForward: boolean;
  60254. /**
  60255. * Enables specular anti aliasing in the PBR shader.
  60256. * It will both interacts on the Geometry for analytical and IBL lighting.
  60257. * It also prefilter the roughness map based on the bump values.
  60258. */
  60259. enableSpecularAntiAliasing: boolean;
  60260. /**
  60261. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60262. * makes the reflect vector face the model (under horizon).
  60263. */
  60264. useHorizonOcclusion: boolean;
  60265. /**
  60266. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60267. * too much the area relying on ambient texture to define their ambient occlusion.
  60268. */
  60269. useRadianceOcclusion: boolean;
  60270. /**
  60271. * If set to true, no lighting calculations will be applied.
  60272. */
  60273. unlit: boolean;
  60274. /**
  60275. * Gets the image processing configuration used either in this material.
  60276. */
  60277. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60278. /**
  60279. * Sets the Default image processing configuration used either in the this material.
  60280. *
  60281. * If sets to null, the scene one is in use.
  60282. */
  60283. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60284. /**
  60285. * Gets wether the color curves effect is enabled.
  60286. */
  60287. get cameraColorCurvesEnabled(): boolean;
  60288. /**
  60289. * Sets wether the color curves effect is enabled.
  60290. */
  60291. set cameraColorCurvesEnabled(value: boolean);
  60292. /**
  60293. * Gets wether the color grading effect is enabled.
  60294. */
  60295. get cameraColorGradingEnabled(): boolean;
  60296. /**
  60297. * Gets wether the color grading effect is enabled.
  60298. */
  60299. set cameraColorGradingEnabled(value: boolean);
  60300. /**
  60301. * Gets wether tonemapping is enabled or not.
  60302. */
  60303. get cameraToneMappingEnabled(): boolean;
  60304. /**
  60305. * Sets wether tonemapping is enabled or not
  60306. */
  60307. set cameraToneMappingEnabled(value: boolean);
  60308. /**
  60309. * The camera exposure used on this material.
  60310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60311. * This corresponds to a photographic exposure.
  60312. */
  60313. get cameraExposure(): number;
  60314. /**
  60315. * The camera exposure used on this material.
  60316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60317. * This corresponds to a photographic exposure.
  60318. */
  60319. set cameraExposure(value: number);
  60320. /**
  60321. * Gets The camera contrast used on this material.
  60322. */
  60323. get cameraContrast(): number;
  60324. /**
  60325. * Sets The camera contrast used on this material.
  60326. */
  60327. set cameraContrast(value: number);
  60328. /**
  60329. * Gets the Color Grading 2D Lookup Texture.
  60330. */
  60331. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60332. /**
  60333. * Sets the Color Grading 2D Lookup Texture.
  60334. */
  60335. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60336. /**
  60337. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60338. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60339. * 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;
  60340. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60341. */
  60342. get cameraColorCurves(): Nullable<ColorCurves>;
  60343. /**
  60344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60346. * 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;
  60347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60348. */
  60349. set cameraColorCurves(value: Nullable<ColorCurves>);
  60350. /**
  60351. * Instantiates a new PBRMaterial instance.
  60352. *
  60353. * @param name The material name
  60354. * @param scene The scene the material will be use in.
  60355. */
  60356. constructor(name: string, scene: Scene);
  60357. /**
  60358. * Returns the name of this material class.
  60359. */
  60360. getClassName(): string;
  60361. /**
  60362. * Makes a duplicate of the current material.
  60363. * @param name - name to use for the new material.
  60364. */
  60365. clone(name: string): PBRMaterial;
  60366. /**
  60367. * Serializes this PBR Material.
  60368. * @returns - An object with the serialized material.
  60369. */
  60370. serialize(): any;
  60371. /**
  60372. * Parses a PBR Material from a serialized object.
  60373. * @param source - Serialized object.
  60374. * @param scene - BJS scene instance.
  60375. * @param rootUrl - url for the scene object
  60376. * @returns - PBRMaterial
  60377. */
  60378. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60379. }
  60380. }
  60381. declare module "babylonjs/Misc/dds" {
  60382. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60384. import { Nullable } from "babylonjs/types";
  60385. import { Scene } from "babylonjs/scene";
  60386. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60388. /**
  60389. * Direct draw surface info
  60390. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60391. */
  60392. export interface DDSInfo {
  60393. /**
  60394. * Width of the texture
  60395. */
  60396. width: number;
  60397. /**
  60398. * Width of the texture
  60399. */
  60400. height: number;
  60401. /**
  60402. * Number of Mipmaps for the texture
  60403. * @see https://en.wikipedia.org/wiki/Mipmap
  60404. */
  60405. mipmapCount: number;
  60406. /**
  60407. * If the textures format is a known fourCC format
  60408. * @see https://www.fourcc.org/
  60409. */
  60410. isFourCC: boolean;
  60411. /**
  60412. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60413. */
  60414. isRGB: boolean;
  60415. /**
  60416. * If the texture is a lumincance format
  60417. */
  60418. isLuminance: boolean;
  60419. /**
  60420. * If this is a cube texture
  60421. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60422. */
  60423. isCube: boolean;
  60424. /**
  60425. * If the texture is a compressed format eg. FOURCC_DXT1
  60426. */
  60427. isCompressed: boolean;
  60428. /**
  60429. * The dxgiFormat of the texture
  60430. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60431. */
  60432. dxgiFormat: number;
  60433. /**
  60434. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60435. */
  60436. textureType: number;
  60437. /**
  60438. * Sphericle polynomial created for the dds texture
  60439. */
  60440. sphericalPolynomial?: SphericalPolynomial;
  60441. }
  60442. /**
  60443. * Class used to provide DDS decompression tools
  60444. */
  60445. export class DDSTools {
  60446. /**
  60447. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60448. */
  60449. static StoreLODInAlphaChannel: boolean;
  60450. /**
  60451. * Gets DDS information from an array buffer
  60452. * @param data defines the array buffer view to read data from
  60453. * @returns the DDS information
  60454. */
  60455. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60456. private static _FloatView;
  60457. private static _Int32View;
  60458. private static _ToHalfFloat;
  60459. private static _FromHalfFloat;
  60460. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60461. private static _GetHalfFloatRGBAArrayBuffer;
  60462. private static _GetFloatRGBAArrayBuffer;
  60463. private static _GetFloatAsUIntRGBAArrayBuffer;
  60464. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60465. private static _GetRGBAArrayBuffer;
  60466. private static _ExtractLongWordOrder;
  60467. private static _GetRGBArrayBuffer;
  60468. private static _GetLuminanceArrayBuffer;
  60469. /**
  60470. * Uploads DDS Levels to a Babylon Texture
  60471. * @hidden
  60472. */
  60473. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60474. }
  60475. module "babylonjs/Engines/thinEngine" {
  60476. interface ThinEngine {
  60477. /**
  60478. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60479. * @param rootUrl defines the url where the file to load is located
  60480. * @param scene defines the current scene
  60481. * @param lodScale defines scale to apply to the mip map selection
  60482. * @param lodOffset defines offset to apply to the mip map selection
  60483. * @param onLoad defines an optional callback raised when the texture is loaded
  60484. * @param onError defines an optional callback raised if there is an issue to load the texture
  60485. * @param format defines the format of the data
  60486. * @param forcedExtension defines the extension to use to pick the right loader
  60487. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60488. * @returns the cube texture as an InternalTexture
  60489. */
  60490. 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;
  60491. }
  60492. }
  60493. }
  60494. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60495. import { Nullable } from "babylonjs/types";
  60496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60497. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60498. /**
  60499. * Implementation of the DDS Texture Loader.
  60500. * @hidden
  60501. */
  60502. export class _DDSTextureLoader implements IInternalTextureLoader {
  60503. /**
  60504. * Defines wether the loader supports cascade loading the different faces.
  60505. */
  60506. readonly supportCascades: boolean;
  60507. /**
  60508. * This returns if the loader support the current file information.
  60509. * @param extension defines the file extension of the file being loaded
  60510. * @returns true if the loader can load the specified file
  60511. */
  60512. canLoad(extension: string): boolean;
  60513. /**
  60514. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60515. * @param data contains the texture data
  60516. * @param texture defines the BabylonJS internal texture
  60517. * @param createPolynomials will be true if polynomials have been requested
  60518. * @param onLoad defines the callback to trigger once the texture is ready
  60519. * @param onError defines the callback to trigger in case of error
  60520. */
  60521. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60522. /**
  60523. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60524. * @param data contains the texture data
  60525. * @param texture defines the BabylonJS internal texture
  60526. * @param callback defines the method to call once ready to upload
  60527. */
  60528. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60529. }
  60530. }
  60531. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60532. import { Nullable } from "babylonjs/types";
  60533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60534. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60535. /**
  60536. * Implementation of the ENV Texture Loader.
  60537. * @hidden
  60538. */
  60539. export class _ENVTextureLoader implements IInternalTextureLoader {
  60540. /**
  60541. * Defines wether the loader supports cascade loading the different faces.
  60542. */
  60543. readonly supportCascades: boolean;
  60544. /**
  60545. * This returns if the loader support the current file information.
  60546. * @param extension defines the file extension of the file being loaded
  60547. * @returns true if the loader can load the specified file
  60548. */
  60549. canLoad(extension: string): boolean;
  60550. /**
  60551. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60552. * @param data contains the texture data
  60553. * @param texture defines the BabylonJS internal texture
  60554. * @param createPolynomials will be true if polynomials have been requested
  60555. * @param onLoad defines the callback to trigger once the texture is ready
  60556. * @param onError defines the callback to trigger in case of error
  60557. */
  60558. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60559. /**
  60560. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60561. * @param data contains the texture data
  60562. * @param texture defines the BabylonJS internal texture
  60563. * @param callback defines the method to call once ready to upload
  60564. */
  60565. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60566. }
  60567. }
  60568. declare module "babylonjs/Misc/khronosTextureContainer" {
  60569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60570. /**
  60571. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60572. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60573. */
  60574. export class KhronosTextureContainer {
  60575. /** contents of the KTX container file */
  60576. data: ArrayBufferView;
  60577. private static HEADER_LEN;
  60578. private static COMPRESSED_2D;
  60579. private static COMPRESSED_3D;
  60580. private static TEX_2D;
  60581. private static TEX_3D;
  60582. /**
  60583. * Gets the openGL type
  60584. */
  60585. glType: number;
  60586. /**
  60587. * Gets the openGL type size
  60588. */
  60589. glTypeSize: number;
  60590. /**
  60591. * Gets the openGL format
  60592. */
  60593. glFormat: number;
  60594. /**
  60595. * Gets the openGL internal format
  60596. */
  60597. glInternalFormat: number;
  60598. /**
  60599. * Gets the base internal format
  60600. */
  60601. glBaseInternalFormat: number;
  60602. /**
  60603. * Gets image width in pixel
  60604. */
  60605. pixelWidth: number;
  60606. /**
  60607. * Gets image height in pixel
  60608. */
  60609. pixelHeight: number;
  60610. /**
  60611. * Gets image depth in pixels
  60612. */
  60613. pixelDepth: number;
  60614. /**
  60615. * Gets the number of array elements
  60616. */
  60617. numberOfArrayElements: number;
  60618. /**
  60619. * Gets the number of faces
  60620. */
  60621. numberOfFaces: number;
  60622. /**
  60623. * Gets the number of mipmap levels
  60624. */
  60625. numberOfMipmapLevels: number;
  60626. /**
  60627. * Gets the bytes of key value data
  60628. */
  60629. bytesOfKeyValueData: number;
  60630. /**
  60631. * Gets the load type
  60632. */
  60633. loadType: number;
  60634. /**
  60635. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60636. */
  60637. isInvalid: boolean;
  60638. /**
  60639. * Creates a new KhronosTextureContainer
  60640. * @param data contents of the KTX container file
  60641. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60642. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60643. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60644. */
  60645. constructor(
  60646. /** contents of the KTX container file */
  60647. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60648. /**
  60649. * Uploads KTX content to a Babylon Texture.
  60650. * It is assumed that the texture has already been created & is currently bound
  60651. * @hidden
  60652. */
  60653. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60654. private _upload2DCompressedLevels;
  60655. /**
  60656. * Checks if the given data starts with a KTX file identifier.
  60657. * @param data the data to check
  60658. * @returns true if the data is a KTX file or false otherwise
  60659. */
  60660. static IsValid(data: ArrayBufferView): boolean;
  60661. }
  60662. }
  60663. declare module "babylonjs/Misc/workerPool" {
  60664. import { IDisposable } from "babylonjs/scene";
  60665. /**
  60666. * Helper class to push actions to a pool of workers.
  60667. */
  60668. export class WorkerPool implements IDisposable {
  60669. private _workerInfos;
  60670. private _pendingActions;
  60671. /**
  60672. * Constructor
  60673. * @param workers Array of workers to use for actions
  60674. */
  60675. constructor(workers: Array<Worker>);
  60676. /**
  60677. * Terminates all workers and clears any pending actions.
  60678. */
  60679. dispose(): void;
  60680. /**
  60681. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60682. * pended until a worker has completed its action.
  60683. * @param action The action to perform. Call onComplete when the action is complete.
  60684. */
  60685. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60686. private _execute;
  60687. }
  60688. }
  60689. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60691. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60692. /**
  60693. * Class for loading KTX2 files
  60694. */
  60695. export class KhronosTextureContainer2 {
  60696. private static _WorkerPoolPromise?;
  60697. private static _Initialized;
  60698. private static _Ktx2Decoder;
  60699. /**
  60700. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  60701. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  60702. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  60703. * Urls you can change:
  60704. * URLConfig.jsDecoderModule
  60705. * URLConfig.wasmUASTCToASTC
  60706. * URLConfig.wasmUASTCToBC7
  60707. * URLConfig.jsMSCTranscoder
  60708. * URLConfig.wasmMSCTranscoder
  60709. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  60710. */
  60711. static URLConfig: {
  60712. jsDecoderModule: string;
  60713. wasmUASTCToASTC: null;
  60714. wasmUASTCToBC7: null;
  60715. jsMSCTranscoder: null;
  60716. wasmMSCTranscoder: null;
  60717. };
  60718. /**
  60719. * Default number of workers used to handle data decoding
  60720. */
  60721. static DefaultNumWorkers: number;
  60722. private static GetDefaultNumWorkers;
  60723. private _engine;
  60724. private static _CreateWorkerPool;
  60725. /**
  60726. * Constructor
  60727. * @param engine The engine to use
  60728. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60729. */
  60730. constructor(engine: ThinEngine, numWorkers?: number);
  60731. /** @hidden */
  60732. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60733. /**
  60734. * Stop all async operations and release resources.
  60735. */
  60736. dispose(): void;
  60737. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60738. /**
  60739. * Checks if the given data starts with a KTX2 file identifier.
  60740. * @param data the data to check
  60741. * @returns true if the data is a KTX2 file or false otherwise
  60742. */
  60743. static IsValid(data: ArrayBufferView): boolean;
  60744. }
  60745. }
  60746. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60747. import { Nullable } from "babylonjs/types";
  60748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60749. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60750. /**
  60751. * Implementation of the KTX Texture Loader.
  60752. * @hidden
  60753. */
  60754. export class _KTXTextureLoader implements IInternalTextureLoader {
  60755. /**
  60756. * Defines wether the loader supports cascade loading the different faces.
  60757. */
  60758. readonly supportCascades: boolean;
  60759. /**
  60760. * This returns if the loader support the current file information.
  60761. * @param extension defines the file extension of the file being loaded
  60762. * @param mimeType defines the optional mime type of the file being loaded
  60763. * @returns true if the loader can load the specified file
  60764. */
  60765. canLoad(extension: string, mimeType?: string): boolean;
  60766. /**
  60767. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60768. * @param data contains the texture data
  60769. * @param texture defines the BabylonJS internal texture
  60770. * @param createPolynomials will be true if polynomials have been requested
  60771. * @param onLoad defines the callback to trigger once the texture is ready
  60772. * @param onError defines the callback to trigger in case of error
  60773. */
  60774. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60775. /**
  60776. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60777. * @param data contains the texture data
  60778. * @param texture defines the BabylonJS internal texture
  60779. * @param callback defines the method to call once ready to upload
  60780. */
  60781. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60782. }
  60783. }
  60784. declare module "babylonjs/Helpers/sceneHelpers" {
  60785. import { Nullable } from "babylonjs/types";
  60786. import { Mesh } from "babylonjs/Meshes/mesh";
  60787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60788. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60789. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60790. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60791. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60792. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60793. import "babylonjs/Meshes/Builders/boxBuilder";
  60794. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60795. /** @hidden */
  60796. export var _forceSceneHelpersToBundle: boolean;
  60797. module "babylonjs/scene" {
  60798. interface Scene {
  60799. /**
  60800. * Creates a default light for the scene.
  60801. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60802. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60803. */
  60804. createDefaultLight(replace?: boolean): void;
  60805. /**
  60806. * Creates a default camera for the scene.
  60807. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60808. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60809. * @param replace has default false, when true replaces the active camera in the scene
  60810. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60811. */
  60812. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60813. /**
  60814. * Creates a default camera and a default light.
  60815. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60816. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60817. * @param replace has the default false, when true replaces the active camera/light in the scene
  60818. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60819. */
  60820. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60821. /**
  60822. * Creates a new sky box
  60823. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60824. * @param environmentTexture defines the texture to use as environment texture
  60825. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60826. * @param scale defines the overall scale of the skybox
  60827. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60828. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60829. * @returns a new mesh holding the sky box
  60830. */
  60831. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60832. /**
  60833. * Creates a new environment
  60834. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60835. * @param options defines the options you can use to configure the environment
  60836. * @returns the new EnvironmentHelper
  60837. */
  60838. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60839. /**
  60840. * Creates a new VREXperienceHelper
  60841. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60842. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60843. * @returns a new VREXperienceHelper
  60844. */
  60845. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60846. /**
  60847. * Creates a new WebXRDefaultExperience
  60848. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60849. * @param options experience options
  60850. * @returns a promise for a new WebXRDefaultExperience
  60851. */
  60852. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60853. }
  60854. }
  60855. }
  60856. declare module "babylonjs/Helpers/videoDome" {
  60857. import { Scene } from "babylonjs/scene";
  60858. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60859. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60860. /**
  60861. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60862. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60863. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60864. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60865. */
  60866. export class VideoDome extends TextureDome<VideoTexture> {
  60867. /**
  60868. * Define the video source as a Monoscopic panoramic 360 video.
  60869. */
  60870. static readonly MODE_MONOSCOPIC: number;
  60871. /**
  60872. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60873. */
  60874. static readonly MODE_TOPBOTTOM: number;
  60875. /**
  60876. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60877. */
  60878. static readonly MODE_SIDEBYSIDE: number;
  60879. /**
  60880. * Get the video texture associated with this video dome
  60881. */
  60882. get videoTexture(): VideoTexture;
  60883. /**
  60884. * Get the video mode of this dome
  60885. */
  60886. get videoMode(): number;
  60887. /**
  60888. * Set the video mode of this dome.
  60889. * @see textureMode
  60890. */
  60891. set videoMode(value: number);
  60892. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60893. }
  60894. }
  60895. declare module "babylonjs/Helpers/index" {
  60896. export * from "babylonjs/Helpers/environmentHelper";
  60897. export * from "babylonjs/Helpers/photoDome";
  60898. export * from "babylonjs/Helpers/sceneHelpers";
  60899. export * from "babylonjs/Helpers/videoDome";
  60900. }
  60901. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60902. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60903. import { IDisposable } from "babylonjs/scene";
  60904. import { Engine } from "babylonjs/Engines/engine";
  60905. /**
  60906. * This class can be used to get instrumentation data from a Babylon engine
  60907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60908. */
  60909. export class EngineInstrumentation implements IDisposable {
  60910. /**
  60911. * Define the instrumented engine.
  60912. */
  60913. engine: Engine;
  60914. private _captureGPUFrameTime;
  60915. private _gpuFrameTimeToken;
  60916. private _gpuFrameTime;
  60917. private _captureShaderCompilationTime;
  60918. private _shaderCompilationTime;
  60919. private _onBeginFrameObserver;
  60920. private _onEndFrameObserver;
  60921. private _onBeforeShaderCompilationObserver;
  60922. private _onAfterShaderCompilationObserver;
  60923. /**
  60924. * Gets the perf counter used for GPU frame time
  60925. */
  60926. get gpuFrameTimeCounter(): PerfCounter;
  60927. /**
  60928. * Gets the GPU frame time capture status
  60929. */
  60930. get captureGPUFrameTime(): boolean;
  60931. /**
  60932. * Enable or disable the GPU frame time capture
  60933. */
  60934. set captureGPUFrameTime(value: boolean);
  60935. /**
  60936. * Gets the perf counter used for shader compilation time
  60937. */
  60938. get shaderCompilationTimeCounter(): PerfCounter;
  60939. /**
  60940. * Gets the shader compilation time capture status
  60941. */
  60942. get captureShaderCompilationTime(): boolean;
  60943. /**
  60944. * Enable or disable the shader compilation time capture
  60945. */
  60946. set captureShaderCompilationTime(value: boolean);
  60947. /**
  60948. * Instantiates a new engine instrumentation.
  60949. * This class can be used to get instrumentation data from a Babylon engine
  60950. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60951. * @param engine Defines the engine to instrument
  60952. */
  60953. constructor(
  60954. /**
  60955. * Define the instrumented engine.
  60956. */
  60957. engine: Engine);
  60958. /**
  60959. * Dispose and release associated resources.
  60960. */
  60961. dispose(): void;
  60962. }
  60963. }
  60964. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60965. import { Scene, IDisposable } from "babylonjs/scene";
  60966. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60967. /**
  60968. * This class can be used to get instrumentation data from a Babylon engine
  60969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60970. */
  60971. export class SceneInstrumentation implements IDisposable {
  60972. /**
  60973. * Defines the scene to instrument
  60974. */
  60975. scene: Scene;
  60976. private _captureActiveMeshesEvaluationTime;
  60977. private _activeMeshesEvaluationTime;
  60978. private _captureRenderTargetsRenderTime;
  60979. private _renderTargetsRenderTime;
  60980. private _captureFrameTime;
  60981. private _frameTime;
  60982. private _captureRenderTime;
  60983. private _renderTime;
  60984. private _captureInterFrameTime;
  60985. private _interFrameTime;
  60986. private _captureParticlesRenderTime;
  60987. private _particlesRenderTime;
  60988. private _captureSpritesRenderTime;
  60989. private _spritesRenderTime;
  60990. private _capturePhysicsTime;
  60991. private _physicsTime;
  60992. private _captureAnimationsTime;
  60993. private _animationsTime;
  60994. private _captureCameraRenderTime;
  60995. private _cameraRenderTime;
  60996. private _onBeforeActiveMeshesEvaluationObserver;
  60997. private _onAfterActiveMeshesEvaluationObserver;
  60998. private _onBeforeRenderTargetsRenderObserver;
  60999. private _onAfterRenderTargetsRenderObserver;
  61000. private _onAfterRenderObserver;
  61001. private _onBeforeDrawPhaseObserver;
  61002. private _onAfterDrawPhaseObserver;
  61003. private _onBeforeAnimationsObserver;
  61004. private _onBeforeParticlesRenderingObserver;
  61005. private _onAfterParticlesRenderingObserver;
  61006. private _onBeforeSpritesRenderingObserver;
  61007. private _onAfterSpritesRenderingObserver;
  61008. private _onBeforePhysicsObserver;
  61009. private _onAfterPhysicsObserver;
  61010. private _onAfterAnimationsObserver;
  61011. private _onBeforeCameraRenderObserver;
  61012. private _onAfterCameraRenderObserver;
  61013. /**
  61014. * Gets the perf counter used for active meshes evaluation time
  61015. */
  61016. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61017. /**
  61018. * Gets the active meshes evaluation time capture status
  61019. */
  61020. get captureActiveMeshesEvaluationTime(): boolean;
  61021. /**
  61022. * Enable or disable the active meshes evaluation time capture
  61023. */
  61024. set captureActiveMeshesEvaluationTime(value: boolean);
  61025. /**
  61026. * Gets the perf counter used for render targets render time
  61027. */
  61028. get renderTargetsRenderTimeCounter(): PerfCounter;
  61029. /**
  61030. * Gets the render targets render time capture status
  61031. */
  61032. get captureRenderTargetsRenderTime(): boolean;
  61033. /**
  61034. * Enable or disable the render targets render time capture
  61035. */
  61036. set captureRenderTargetsRenderTime(value: boolean);
  61037. /**
  61038. * Gets the perf counter used for particles render time
  61039. */
  61040. get particlesRenderTimeCounter(): PerfCounter;
  61041. /**
  61042. * Gets the particles render time capture status
  61043. */
  61044. get captureParticlesRenderTime(): boolean;
  61045. /**
  61046. * Enable or disable the particles render time capture
  61047. */
  61048. set captureParticlesRenderTime(value: boolean);
  61049. /**
  61050. * Gets the perf counter used for sprites render time
  61051. */
  61052. get spritesRenderTimeCounter(): PerfCounter;
  61053. /**
  61054. * Gets the sprites render time capture status
  61055. */
  61056. get captureSpritesRenderTime(): boolean;
  61057. /**
  61058. * Enable or disable the sprites render time capture
  61059. */
  61060. set captureSpritesRenderTime(value: boolean);
  61061. /**
  61062. * Gets the perf counter used for physics time
  61063. */
  61064. get physicsTimeCounter(): PerfCounter;
  61065. /**
  61066. * Gets the physics time capture status
  61067. */
  61068. get capturePhysicsTime(): boolean;
  61069. /**
  61070. * Enable or disable the physics time capture
  61071. */
  61072. set capturePhysicsTime(value: boolean);
  61073. /**
  61074. * Gets the perf counter used for animations time
  61075. */
  61076. get animationsTimeCounter(): PerfCounter;
  61077. /**
  61078. * Gets the animations time capture status
  61079. */
  61080. get captureAnimationsTime(): boolean;
  61081. /**
  61082. * Enable or disable the animations time capture
  61083. */
  61084. set captureAnimationsTime(value: boolean);
  61085. /**
  61086. * Gets the perf counter used for frame time capture
  61087. */
  61088. get frameTimeCounter(): PerfCounter;
  61089. /**
  61090. * Gets the frame time capture status
  61091. */
  61092. get captureFrameTime(): boolean;
  61093. /**
  61094. * Enable or disable the frame time capture
  61095. */
  61096. set captureFrameTime(value: boolean);
  61097. /**
  61098. * Gets the perf counter used for inter-frames time capture
  61099. */
  61100. get interFrameTimeCounter(): PerfCounter;
  61101. /**
  61102. * Gets the inter-frames time capture status
  61103. */
  61104. get captureInterFrameTime(): boolean;
  61105. /**
  61106. * Enable or disable the inter-frames time capture
  61107. */
  61108. set captureInterFrameTime(value: boolean);
  61109. /**
  61110. * Gets the perf counter used for render time capture
  61111. */
  61112. get renderTimeCounter(): PerfCounter;
  61113. /**
  61114. * Gets the render time capture status
  61115. */
  61116. get captureRenderTime(): boolean;
  61117. /**
  61118. * Enable or disable the render time capture
  61119. */
  61120. set captureRenderTime(value: boolean);
  61121. /**
  61122. * Gets the perf counter used for camera render time capture
  61123. */
  61124. get cameraRenderTimeCounter(): PerfCounter;
  61125. /**
  61126. * Gets the camera render time capture status
  61127. */
  61128. get captureCameraRenderTime(): boolean;
  61129. /**
  61130. * Enable or disable the camera render time capture
  61131. */
  61132. set captureCameraRenderTime(value: boolean);
  61133. /**
  61134. * Gets the perf counter used for draw calls
  61135. */
  61136. get drawCallsCounter(): PerfCounter;
  61137. /**
  61138. * Instantiates a new scene instrumentation.
  61139. * This class can be used to get instrumentation data from a Babylon engine
  61140. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61141. * @param scene Defines the scene to instrument
  61142. */
  61143. constructor(
  61144. /**
  61145. * Defines the scene to instrument
  61146. */
  61147. scene: Scene);
  61148. /**
  61149. * Dispose and release associated resources.
  61150. */
  61151. dispose(): void;
  61152. }
  61153. }
  61154. declare module "babylonjs/Instrumentation/index" {
  61155. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61156. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61157. export * from "babylonjs/Instrumentation/timeToken";
  61158. }
  61159. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61160. /** @hidden */
  61161. export var glowMapGenerationPixelShader: {
  61162. name: string;
  61163. shader: string;
  61164. };
  61165. }
  61166. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61167. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61169. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61170. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61172. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61173. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61174. /** @hidden */
  61175. export var glowMapGenerationVertexShader: {
  61176. name: string;
  61177. shader: string;
  61178. };
  61179. }
  61180. declare module "babylonjs/Layers/effectLayer" {
  61181. import { Observable } from "babylonjs/Misc/observable";
  61182. import { Nullable } from "babylonjs/types";
  61183. import { Camera } from "babylonjs/Cameras/camera";
  61184. import { Scene } from "babylonjs/scene";
  61185. import { ISize } from "babylonjs/Maths/math.size";
  61186. import { Color4 } from "babylonjs/Maths/math.color";
  61187. import { Engine } from "babylonjs/Engines/engine";
  61188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61190. import { Mesh } from "babylonjs/Meshes/mesh";
  61191. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61193. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61194. import { Effect } from "babylonjs/Materials/effect";
  61195. import { Material } from "babylonjs/Materials/material";
  61196. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61197. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61198. /**
  61199. * Effect layer options. This helps customizing the behaviour
  61200. * of the effect layer.
  61201. */
  61202. export interface IEffectLayerOptions {
  61203. /**
  61204. * Multiplication factor apply to the canvas size to compute the render target size
  61205. * used to generated the objects (the smaller the faster).
  61206. */
  61207. mainTextureRatio: number;
  61208. /**
  61209. * Enforces a fixed size texture to ensure effect stability across devices.
  61210. */
  61211. mainTextureFixedSize?: number;
  61212. /**
  61213. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61214. */
  61215. alphaBlendingMode: number;
  61216. /**
  61217. * The camera attached to the layer.
  61218. */
  61219. camera: Nullable<Camera>;
  61220. /**
  61221. * The rendering group to draw the layer in.
  61222. */
  61223. renderingGroupId: number;
  61224. }
  61225. /**
  61226. * The effect layer Helps adding post process effect blended with the main pass.
  61227. *
  61228. * This can be for instance use to generate glow or higlight effects on the scene.
  61229. *
  61230. * The effect layer class can not be used directly and is intented to inherited from to be
  61231. * customized per effects.
  61232. */
  61233. export abstract class EffectLayer {
  61234. private _vertexBuffers;
  61235. private _indexBuffer;
  61236. private _cachedDefines;
  61237. private _effectLayerMapGenerationEffect;
  61238. private _effectLayerOptions;
  61239. private _mergeEffect;
  61240. protected _scene: Scene;
  61241. protected _engine: Engine;
  61242. protected _maxSize: number;
  61243. protected _mainTextureDesiredSize: ISize;
  61244. protected _mainTexture: RenderTargetTexture;
  61245. protected _shouldRender: boolean;
  61246. protected _postProcesses: PostProcess[];
  61247. protected _textures: BaseTexture[];
  61248. protected _emissiveTextureAndColor: {
  61249. texture: Nullable<BaseTexture>;
  61250. color: Color4;
  61251. };
  61252. /**
  61253. * The name of the layer
  61254. */
  61255. name: string;
  61256. /**
  61257. * The clear color of the texture used to generate the glow map.
  61258. */
  61259. neutralColor: Color4;
  61260. /**
  61261. * Specifies whether the highlight layer is enabled or not.
  61262. */
  61263. isEnabled: boolean;
  61264. /**
  61265. * Gets the camera attached to the layer.
  61266. */
  61267. get camera(): Nullable<Camera>;
  61268. /**
  61269. * Gets the rendering group id the layer should render in.
  61270. */
  61271. get renderingGroupId(): number;
  61272. set renderingGroupId(renderingGroupId: number);
  61273. /**
  61274. * An event triggered when the effect layer has been disposed.
  61275. */
  61276. onDisposeObservable: Observable<EffectLayer>;
  61277. /**
  61278. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61279. */
  61280. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61281. /**
  61282. * An event triggered when the generated texture is being merged in the scene.
  61283. */
  61284. onBeforeComposeObservable: Observable<EffectLayer>;
  61285. /**
  61286. * An event triggered when the mesh is rendered into the effect render target.
  61287. */
  61288. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61289. /**
  61290. * An event triggered after the mesh has been rendered into the effect render target.
  61291. */
  61292. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61293. /**
  61294. * An event triggered when the generated texture has been merged in the scene.
  61295. */
  61296. onAfterComposeObservable: Observable<EffectLayer>;
  61297. /**
  61298. * An event triggered when the efffect layer changes its size.
  61299. */
  61300. onSizeChangedObservable: Observable<EffectLayer>;
  61301. /** @hidden */
  61302. static _SceneComponentInitialization: (scene: Scene) => void;
  61303. /**
  61304. * Instantiates a new effect Layer and references it in the scene.
  61305. * @param name The name of the layer
  61306. * @param scene The scene to use the layer in
  61307. */
  61308. constructor(
  61309. /** The Friendly of the effect in the scene */
  61310. name: string, scene: Scene);
  61311. /**
  61312. * Get the effect name of the layer.
  61313. * @return The effect name
  61314. */
  61315. abstract getEffectName(): string;
  61316. /**
  61317. * Checks for the readiness of the element composing the layer.
  61318. * @param subMesh the mesh to check for
  61319. * @param useInstances specify whether or not to use instances to render the mesh
  61320. * @return true if ready otherwise, false
  61321. */
  61322. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61323. /**
  61324. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61325. * @returns true if the effect requires stencil during the main canvas render pass.
  61326. */
  61327. abstract needStencil(): boolean;
  61328. /**
  61329. * Create the merge effect. This is the shader use to blit the information back
  61330. * to the main canvas at the end of the scene rendering.
  61331. * @returns The effect containing the shader used to merge the effect on the main canvas
  61332. */
  61333. protected abstract _createMergeEffect(): Effect;
  61334. /**
  61335. * Creates the render target textures and post processes used in the effect layer.
  61336. */
  61337. protected abstract _createTextureAndPostProcesses(): void;
  61338. /**
  61339. * Implementation specific of rendering the generating effect on the main canvas.
  61340. * @param effect The effect used to render through
  61341. */
  61342. protected abstract _internalRender(effect: Effect): void;
  61343. /**
  61344. * Sets the required values for both the emissive texture and and the main color.
  61345. */
  61346. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61347. /**
  61348. * Free any resources and references associated to a mesh.
  61349. * Internal use
  61350. * @param mesh The mesh to free.
  61351. */
  61352. abstract _disposeMesh(mesh: Mesh): void;
  61353. /**
  61354. * Serializes this layer (Glow or Highlight for example)
  61355. * @returns a serialized layer object
  61356. */
  61357. abstract serialize?(): any;
  61358. /**
  61359. * Initializes the effect layer with the required options.
  61360. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61361. */
  61362. protected _init(options: Partial<IEffectLayerOptions>): void;
  61363. /**
  61364. * Generates the index buffer of the full screen quad blending to the main canvas.
  61365. */
  61366. private _generateIndexBuffer;
  61367. /**
  61368. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61369. */
  61370. private _generateVertexBuffer;
  61371. /**
  61372. * Sets the main texture desired size which is the closest power of two
  61373. * of the engine canvas size.
  61374. */
  61375. private _setMainTextureSize;
  61376. /**
  61377. * Creates the main texture for the effect layer.
  61378. */
  61379. protected _createMainTexture(): void;
  61380. /**
  61381. * Adds specific effects defines.
  61382. * @param defines The defines to add specifics to.
  61383. */
  61384. protected _addCustomEffectDefines(defines: string[]): void;
  61385. /**
  61386. * Checks for the readiness of the element composing the layer.
  61387. * @param subMesh the mesh to check for
  61388. * @param useInstances specify whether or not to use instances to render the mesh
  61389. * @param emissiveTexture the associated emissive texture used to generate the glow
  61390. * @return true if ready otherwise, false
  61391. */
  61392. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61393. /**
  61394. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61395. */
  61396. render(): void;
  61397. /**
  61398. * Determine if a given mesh will be used in the current effect.
  61399. * @param mesh mesh to test
  61400. * @returns true if the mesh will be used
  61401. */
  61402. hasMesh(mesh: AbstractMesh): boolean;
  61403. /**
  61404. * Returns true if the layer contains information to display, otherwise false.
  61405. * @returns true if the glow layer should be rendered
  61406. */
  61407. shouldRender(): boolean;
  61408. /**
  61409. * Returns true if the mesh should render, otherwise false.
  61410. * @param mesh The mesh to render
  61411. * @returns true if it should render otherwise false
  61412. */
  61413. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61414. /**
  61415. * Returns true if the mesh can be rendered, otherwise false.
  61416. * @param mesh The mesh to render
  61417. * @param material The material used on the mesh
  61418. * @returns true if it can be rendered otherwise false
  61419. */
  61420. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61421. /**
  61422. * Returns true if the mesh should render, otherwise false.
  61423. * @param mesh The mesh to render
  61424. * @returns true if it should render otherwise false
  61425. */
  61426. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61427. /**
  61428. * Renders the submesh passed in parameter to the generation map.
  61429. */
  61430. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61431. /**
  61432. * Defines whether the current material of the mesh should be use to render the effect.
  61433. * @param mesh defines the current mesh to render
  61434. */
  61435. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61436. /**
  61437. * Rebuild the required buffers.
  61438. * @hidden Internal use only.
  61439. */
  61440. _rebuild(): void;
  61441. /**
  61442. * Dispose only the render target textures and post process.
  61443. */
  61444. private _disposeTextureAndPostProcesses;
  61445. /**
  61446. * Dispose the highlight layer and free resources.
  61447. */
  61448. dispose(): void;
  61449. /**
  61450. * Gets the class name of the effect layer
  61451. * @returns the string with the class name of the effect layer
  61452. */
  61453. getClassName(): string;
  61454. /**
  61455. * Creates an effect layer from parsed effect layer data
  61456. * @param parsedEffectLayer defines effect layer data
  61457. * @param scene defines the current scene
  61458. * @param rootUrl defines the root URL containing the effect layer information
  61459. * @returns a parsed effect Layer
  61460. */
  61461. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61462. }
  61463. }
  61464. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61465. import { Scene } from "babylonjs/scene";
  61466. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61467. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61468. import { AbstractScene } from "babylonjs/abstractScene";
  61469. module "babylonjs/abstractScene" {
  61470. interface AbstractScene {
  61471. /**
  61472. * The list of effect layers (highlights/glow) added to the scene
  61473. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61474. * @see https://doc.babylonjs.com/how_to/glow_layer
  61475. */
  61476. effectLayers: Array<EffectLayer>;
  61477. /**
  61478. * Removes the given effect layer from this scene.
  61479. * @param toRemove defines the effect layer to remove
  61480. * @returns the index of the removed effect layer
  61481. */
  61482. removeEffectLayer(toRemove: EffectLayer): number;
  61483. /**
  61484. * Adds the given effect layer to this scene
  61485. * @param newEffectLayer defines the effect layer to add
  61486. */
  61487. addEffectLayer(newEffectLayer: EffectLayer): void;
  61488. }
  61489. }
  61490. /**
  61491. * Defines the layer scene component responsible to manage any effect layers
  61492. * in a given scene.
  61493. */
  61494. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61495. /**
  61496. * The component name helpfull to identify the component in the list of scene components.
  61497. */
  61498. readonly name: string;
  61499. /**
  61500. * The scene the component belongs to.
  61501. */
  61502. scene: Scene;
  61503. private _engine;
  61504. private _renderEffects;
  61505. private _needStencil;
  61506. private _previousStencilState;
  61507. /**
  61508. * Creates a new instance of the component for the given scene
  61509. * @param scene Defines the scene to register the component in
  61510. */
  61511. constructor(scene: Scene);
  61512. /**
  61513. * Registers the component in a given scene
  61514. */
  61515. register(): void;
  61516. /**
  61517. * Rebuilds the elements related to this component in case of
  61518. * context lost for instance.
  61519. */
  61520. rebuild(): void;
  61521. /**
  61522. * Serializes the component data to the specified json object
  61523. * @param serializationObject The object to serialize to
  61524. */
  61525. serialize(serializationObject: any): void;
  61526. /**
  61527. * Adds all the elements from the container to the scene
  61528. * @param container the container holding the elements
  61529. */
  61530. addFromContainer(container: AbstractScene): void;
  61531. /**
  61532. * Removes all the elements in the container from the scene
  61533. * @param container contains the elements to remove
  61534. * @param dispose if the removed element should be disposed (default: false)
  61535. */
  61536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61537. /**
  61538. * Disposes the component and the associated ressources.
  61539. */
  61540. dispose(): void;
  61541. private _isReadyForMesh;
  61542. private _renderMainTexture;
  61543. private _setStencil;
  61544. private _setStencilBack;
  61545. private _draw;
  61546. private _drawCamera;
  61547. private _drawRenderingGroup;
  61548. }
  61549. }
  61550. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61551. /** @hidden */
  61552. export var glowMapMergePixelShader: {
  61553. name: string;
  61554. shader: string;
  61555. };
  61556. }
  61557. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61558. /** @hidden */
  61559. export var glowMapMergeVertexShader: {
  61560. name: string;
  61561. shader: string;
  61562. };
  61563. }
  61564. declare module "babylonjs/Layers/glowLayer" {
  61565. import { Nullable } from "babylonjs/types";
  61566. import { Camera } from "babylonjs/Cameras/camera";
  61567. import { Scene } from "babylonjs/scene";
  61568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61570. import { Mesh } from "babylonjs/Meshes/mesh";
  61571. import { Texture } from "babylonjs/Materials/Textures/texture";
  61572. import { Effect } from "babylonjs/Materials/effect";
  61573. import { Material } from "babylonjs/Materials/material";
  61574. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61575. import { Color4 } from "babylonjs/Maths/math.color";
  61576. import "babylonjs/Shaders/glowMapMerge.fragment";
  61577. import "babylonjs/Shaders/glowMapMerge.vertex";
  61578. import "babylonjs/Layers/effectLayerSceneComponent";
  61579. module "babylonjs/abstractScene" {
  61580. interface AbstractScene {
  61581. /**
  61582. * Return a the first highlight layer of the scene with a given name.
  61583. * @param name The name of the highlight layer to look for.
  61584. * @return The highlight layer if found otherwise null.
  61585. */
  61586. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61587. }
  61588. }
  61589. /**
  61590. * Glow layer options. This helps customizing the behaviour
  61591. * of the glow layer.
  61592. */
  61593. export interface IGlowLayerOptions {
  61594. /**
  61595. * Multiplication factor apply to the canvas size to compute the render target size
  61596. * used to generated the glowing objects (the smaller the faster).
  61597. */
  61598. mainTextureRatio: number;
  61599. /**
  61600. * Enforces a fixed size texture to ensure resize independant blur.
  61601. */
  61602. mainTextureFixedSize?: number;
  61603. /**
  61604. * How big is the kernel of the blur texture.
  61605. */
  61606. blurKernelSize: number;
  61607. /**
  61608. * The camera attached to the layer.
  61609. */
  61610. camera: Nullable<Camera>;
  61611. /**
  61612. * Enable MSAA by chosing the number of samples.
  61613. */
  61614. mainTextureSamples?: number;
  61615. /**
  61616. * The rendering group to draw the layer in.
  61617. */
  61618. renderingGroupId: number;
  61619. }
  61620. /**
  61621. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61622. *
  61623. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61624. *
  61625. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61626. */
  61627. export class GlowLayer extends EffectLayer {
  61628. /**
  61629. * Effect Name of the layer.
  61630. */
  61631. static readonly EffectName: string;
  61632. /**
  61633. * The default blur kernel size used for the glow.
  61634. */
  61635. static DefaultBlurKernelSize: number;
  61636. /**
  61637. * The default texture size ratio used for the glow.
  61638. */
  61639. static DefaultTextureRatio: number;
  61640. /**
  61641. * Sets the kernel size of the blur.
  61642. */
  61643. set blurKernelSize(value: number);
  61644. /**
  61645. * Gets the kernel size of the blur.
  61646. */
  61647. get blurKernelSize(): number;
  61648. /**
  61649. * Sets the glow intensity.
  61650. */
  61651. set intensity(value: number);
  61652. /**
  61653. * Gets the glow intensity.
  61654. */
  61655. get intensity(): number;
  61656. private _options;
  61657. private _intensity;
  61658. private _horizontalBlurPostprocess1;
  61659. private _verticalBlurPostprocess1;
  61660. private _horizontalBlurPostprocess2;
  61661. private _verticalBlurPostprocess2;
  61662. private _blurTexture1;
  61663. private _blurTexture2;
  61664. private _postProcesses1;
  61665. private _postProcesses2;
  61666. private _includedOnlyMeshes;
  61667. private _excludedMeshes;
  61668. private _meshesUsingTheirOwnMaterials;
  61669. /**
  61670. * Callback used to let the user override the color selection on a per mesh basis
  61671. */
  61672. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61673. /**
  61674. * Callback used to let the user override the texture selection on a per mesh basis
  61675. */
  61676. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61677. /**
  61678. * Instantiates a new glow Layer and references it to the scene.
  61679. * @param name The name of the layer
  61680. * @param scene The scene to use the layer in
  61681. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61682. */
  61683. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61684. /**
  61685. * Get the effect name of the layer.
  61686. * @return The effect name
  61687. */
  61688. getEffectName(): string;
  61689. /**
  61690. * Create the merge effect. This is the shader use to blit the information back
  61691. * to the main canvas at the end of the scene rendering.
  61692. */
  61693. protected _createMergeEffect(): Effect;
  61694. /**
  61695. * Creates the render target textures and post processes used in the glow layer.
  61696. */
  61697. protected _createTextureAndPostProcesses(): void;
  61698. /**
  61699. * Checks for the readiness of the element composing the layer.
  61700. * @param subMesh the mesh to check for
  61701. * @param useInstances specify wether or not to use instances to render the mesh
  61702. * @param emissiveTexture the associated emissive texture used to generate the glow
  61703. * @return true if ready otherwise, false
  61704. */
  61705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61706. /**
  61707. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61708. */
  61709. needStencil(): boolean;
  61710. /**
  61711. * Returns true if the mesh can be rendered, otherwise false.
  61712. * @param mesh The mesh to render
  61713. * @param material The material used on the mesh
  61714. * @returns true if it can be rendered otherwise false
  61715. */
  61716. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61717. /**
  61718. * Implementation specific of rendering the generating effect on the main canvas.
  61719. * @param effect The effect used to render through
  61720. */
  61721. protected _internalRender(effect: Effect): void;
  61722. /**
  61723. * Sets the required values for both the emissive texture and and the main color.
  61724. */
  61725. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61726. /**
  61727. * Returns true if the mesh should render, otherwise false.
  61728. * @param mesh The mesh to render
  61729. * @returns true if it should render otherwise false
  61730. */
  61731. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61732. /**
  61733. * Adds specific effects defines.
  61734. * @param defines The defines to add specifics to.
  61735. */
  61736. protected _addCustomEffectDefines(defines: string[]): void;
  61737. /**
  61738. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61739. * @param mesh The mesh to exclude from the glow layer
  61740. */
  61741. addExcludedMesh(mesh: Mesh): void;
  61742. /**
  61743. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61744. * @param mesh The mesh to remove
  61745. */
  61746. removeExcludedMesh(mesh: Mesh): void;
  61747. /**
  61748. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61749. * @param mesh The mesh to include in the glow layer
  61750. */
  61751. addIncludedOnlyMesh(mesh: Mesh): void;
  61752. /**
  61753. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61754. * @param mesh The mesh to remove
  61755. */
  61756. removeIncludedOnlyMesh(mesh: Mesh): void;
  61757. /**
  61758. * Determine if a given mesh will be used in the glow layer
  61759. * @param mesh The mesh to test
  61760. * @returns true if the mesh will be highlighted by the current glow layer
  61761. */
  61762. hasMesh(mesh: AbstractMesh): boolean;
  61763. /**
  61764. * Defines whether the current material of the mesh should be use to render the effect.
  61765. * @param mesh defines the current mesh to render
  61766. */
  61767. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61768. /**
  61769. * Add a mesh to be rendered through its own material and not with emissive only.
  61770. * @param mesh The mesh for which we need to use its material
  61771. */
  61772. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61773. /**
  61774. * Remove a mesh from being rendered through its own material and not with emissive only.
  61775. * @param mesh The mesh for which we need to not use its material
  61776. */
  61777. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61778. /**
  61779. * Free any resources and references associated to a mesh.
  61780. * Internal use
  61781. * @param mesh The mesh to free.
  61782. * @hidden
  61783. */
  61784. _disposeMesh(mesh: Mesh): void;
  61785. /**
  61786. * Gets the class name of the effect layer
  61787. * @returns the string with the class name of the effect layer
  61788. */
  61789. getClassName(): string;
  61790. /**
  61791. * Serializes this glow layer
  61792. * @returns a serialized glow layer object
  61793. */
  61794. serialize(): any;
  61795. /**
  61796. * Creates a Glow Layer from parsed glow layer data
  61797. * @param parsedGlowLayer defines glow layer data
  61798. * @param scene defines the current scene
  61799. * @param rootUrl defines the root URL containing the glow layer information
  61800. * @returns a parsed Glow Layer
  61801. */
  61802. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61803. }
  61804. }
  61805. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61806. /** @hidden */
  61807. export var glowBlurPostProcessPixelShader: {
  61808. name: string;
  61809. shader: string;
  61810. };
  61811. }
  61812. declare module "babylonjs/Layers/highlightLayer" {
  61813. import { Observable } from "babylonjs/Misc/observable";
  61814. import { Nullable } from "babylonjs/types";
  61815. import { Camera } from "babylonjs/Cameras/camera";
  61816. import { Scene } from "babylonjs/scene";
  61817. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61819. import { Mesh } from "babylonjs/Meshes/mesh";
  61820. import { Effect } from "babylonjs/Materials/effect";
  61821. import { Material } from "babylonjs/Materials/material";
  61822. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61823. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61824. import "babylonjs/Shaders/glowMapMerge.fragment";
  61825. import "babylonjs/Shaders/glowMapMerge.vertex";
  61826. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61827. module "babylonjs/abstractScene" {
  61828. interface AbstractScene {
  61829. /**
  61830. * Return a the first highlight layer of the scene with a given name.
  61831. * @param name The name of the highlight layer to look for.
  61832. * @return The highlight layer if found otherwise null.
  61833. */
  61834. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61835. }
  61836. }
  61837. /**
  61838. * Highlight layer options. This helps customizing the behaviour
  61839. * of the highlight layer.
  61840. */
  61841. export interface IHighlightLayerOptions {
  61842. /**
  61843. * Multiplication factor apply to the canvas size to compute the render target size
  61844. * used to generated the glowing objects (the smaller the faster).
  61845. */
  61846. mainTextureRatio: number;
  61847. /**
  61848. * Enforces a fixed size texture to ensure resize independant blur.
  61849. */
  61850. mainTextureFixedSize?: number;
  61851. /**
  61852. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61853. * of the picture to blur (the smaller the faster).
  61854. */
  61855. blurTextureSizeRatio: number;
  61856. /**
  61857. * How big in texel of the blur texture is the vertical blur.
  61858. */
  61859. blurVerticalSize: number;
  61860. /**
  61861. * How big in texel of the blur texture is the horizontal blur.
  61862. */
  61863. blurHorizontalSize: number;
  61864. /**
  61865. * Alpha blending mode used to apply the blur. Default is combine.
  61866. */
  61867. alphaBlendingMode: number;
  61868. /**
  61869. * The camera attached to the layer.
  61870. */
  61871. camera: Nullable<Camera>;
  61872. /**
  61873. * Should we display highlight as a solid stroke?
  61874. */
  61875. isStroke?: boolean;
  61876. /**
  61877. * The rendering group to draw the layer in.
  61878. */
  61879. renderingGroupId: number;
  61880. }
  61881. /**
  61882. * The highlight layer Helps adding a glow effect around a mesh.
  61883. *
  61884. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61885. * glowy meshes to your scene.
  61886. *
  61887. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61888. */
  61889. export class HighlightLayer extends EffectLayer {
  61890. name: string;
  61891. /**
  61892. * Effect Name of the highlight layer.
  61893. */
  61894. static readonly EffectName: string;
  61895. /**
  61896. * The neutral color used during the preparation of the glow effect.
  61897. * This is black by default as the blend operation is a blend operation.
  61898. */
  61899. static NeutralColor: Color4;
  61900. /**
  61901. * Stencil value used for glowing meshes.
  61902. */
  61903. static GlowingMeshStencilReference: number;
  61904. /**
  61905. * Stencil value used for the other meshes in the scene.
  61906. */
  61907. static NormalMeshStencilReference: number;
  61908. /**
  61909. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61910. */
  61911. innerGlow: boolean;
  61912. /**
  61913. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61914. */
  61915. outerGlow: boolean;
  61916. /**
  61917. * Specifies the horizontal size of the blur.
  61918. */
  61919. set blurHorizontalSize(value: number);
  61920. /**
  61921. * Specifies the vertical size of the blur.
  61922. */
  61923. set blurVerticalSize(value: number);
  61924. /**
  61925. * Gets the horizontal size of the blur.
  61926. */
  61927. get blurHorizontalSize(): number;
  61928. /**
  61929. * Gets the vertical size of the blur.
  61930. */
  61931. get blurVerticalSize(): number;
  61932. /**
  61933. * An event triggered when the highlight layer is being blurred.
  61934. */
  61935. onBeforeBlurObservable: Observable<HighlightLayer>;
  61936. /**
  61937. * An event triggered when the highlight layer has been blurred.
  61938. */
  61939. onAfterBlurObservable: Observable<HighlightLayer>;
  61940. private _instanceGlowingMeshStencilReference;
  61941. private _options;
  61942. private _downSamplePostprocess;
  61943. private _horizontalBlurPostprocess;
  61944. private _verticalBlurPostprocess;
  61945. private _blurTexture;
  61946. private _meshes;
  61947. private _excludedMeshes;
  61948. /**
  61949. * Instantiates a new highlight Layer and references it to the scene..
  61950. * @param name The name of the layer
  61951. * @param scene The scene to use the layer in
  61952. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61953. */
  61954. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61955. /**
  61956. * Get the effect name of the layer.
  61957. * @return The effect name
  61958. */
  61959. getEffectName(): string;
  61960. /**
  61961. * Create the merge effect. This is the shader use to blit the information back
  61962. * to the main canvas at the end of the scene rendering.
  61963. */
  61964. protected _createMergeEffect(): Effect;
  61965. /**
  61966. * Creates the render target textures and post processes used in the highlight layer.
  61967. */
  61968. protected _createTextureAndPostProcesses(): void;
  61969. /**
  61970. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61971. */
  61972. needStencil(): boolean;
  61973. /**
  61974. * Checks for the readiness of the element composing the layer.
  61975. * @param subMesh the mesh to check for
  61976. * @param useInstances specify wether or not to use instances to render the mesh
  61977. * @param emissiveTexture the associated emissive texture used to generate the glow
  61978. * @return true if ready otherwise, false
  61979. */
  61980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61981. /**
  61982. * Implementation specific of rendering the generating effect on the main canvas.
  61983. * @param effect The effect used to render through
  61984. */
  61985. protected _internalRender(effect: Effect): void;
  61986. /**
  61987. * Returns true if the layer contains information to display, otherwise false.
  61988. */
  61989. shouldRender(): boolean;
  61990. /**
  61991. * Returns true if the mesh should render, otherwise false.
  61992. * @param mesh The mesh to render
  61993. * @returns true if it should render otherwise false
  61994. */
  61995. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61996. /**
  61997. * Returns true if the mesh can be rendered, otherwise false.
  61998. * @param mesh The mesh to render
  61999. * @param material The material used on the mesh
  62000. * @returns true if it can be rendered otherwise false
  62001. */
  62002. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62003. /**
  62004. * Adds specific effects defines.
  62005. * @param defines The defines to add specifics to.
  62006. */
  62007. protected _addCustomEffectDefines(defines: string[]): void;
  62008. /**
  62009. * Sets the required values for both the emissive texture and and the main color.
  62010. */
  62011. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62012. /**
  62013. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62014. * @param mesh The mesh to exclude from the highlight layer
  62015. */
  62016. addExcludedMesh(mesh: Mesh): void;
  62017. /**
  62018. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62019. * @param mesh The mesh to highlight
  62020. */
  62021. removeExcludedMesh(mesh: Mesh): void;
  62022. /**
  62023. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62024. * @param mesh mesh to test
  62025. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62026. */
  62027. hasMesh(mesh: AbstractMesh): boolean;
  62028. /**
  62029. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62030. * @param mesh The mesh to highlight
  62031. * @param color The color of the highlight
  62032. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62033. */
  62034. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62035. /**
  62036. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62037. * @param mesh The mesh to highlight
  62038. */
  62039. removeMesh(mesh: Mesh): void;
  62040. /**
  62041. * Remove all the meshes currently referenced in the highlight layer
  62042. */
  62043. removeAllMeshes(): void;
  62044. /**
  62045. * Force the stencil to the normal expected value for none glowing parts
  62046. */
  62047. private _defaultStencilReference;
  62048. /**
  62049. * Free any resources and references associated to a mesh.
  62050. * Internal use
  62051. * @param mesh The mesh to free.
  62052. * @hidden
  62053. */
  62054. _disposeMesh(mesh: Mesh): void;
  62055. /**
  62056. * Dispose the highlight layer and free resources.
  62057. */
  62058. dispose(): void;
  62059. /**
  62060. * Gets the class name of the effect layer
  62061. * @returns the string with the class name of the effect layer
  62062. */
  62063. getClassName(): string;
  62064. /**
  62065. * Serializes this Highlight layer
  62066. * @returns a serialized Highlight layer object
  62067. */
  62068. serialize(): any;
  62069. /**
  62070. * Creates a Highlight layer from parsed Highlight layer data
  62071. * @param parsedHightlightLayer defines the Highlight layer data
  62072. * @param scene defines the current scene
  62073. * @param rootUrl defines the root URL containing the Highlight layer information
  62074. * @returns a parsed Highlight layer
  62075. */
  62076. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62077. }
  62078. }
  62079. declare module "babylonjs/Layers/layerSceneComponent" {
  62080. import { Scene } from "babylonjs/scene";
  62081. import { ISceneComponent } from "babylonjs/sceneComponent";
  62082. import { Layer } from "babylonjs/Layers/layer";
  62083. import { AbstractScene } from "babylonjs/abstractScene";
  62084. module "babylonjs/abstractScene" {
  62085. interface AbstractScene {
  62086. /**
  62087. * The list of layers (background and foreground) of the scene
  62088. */
  62089. layers: Array<Layer>;
  62090. }
  62091. }
  62092. /**
  62093. * Defines the layer scene component responsible to manage any layers
  62094. * in a given scene.
  62095. */
  62096. export class LayerSceneComponent implements ISceneComponent {
  62097. /**
  62098. * The component name helpfull to identify the component in the list of scene components.
  62099. */
  62100. readonly name: string;
  62101. /**
  62102. * The scene the component belongs to.
  62103. */
  62104. scene: Scene;
  62105. private _engine;
  62106. /**
  62107. * Creates a new instance of the component for the given scene
  62108. * @param scene Defines the scene to register the component in
  62109. */
  62110. constructor(scene: Scene);
  62111. /**
  62112. * Registers the component in a given scene
  62113. */
  62114. register(): void;
  62115. /**
  62116. * Rebuilds the elements related to this component in case of
  62117. * context lost for instance.
  62118. */
  62119. rebuild(): void;
  62120. /**
  62121. * Disposes the component and the associated ressources.
  62122. */
  62123. dispose(): void;
  62124. private _draw;
  62125. private _drawCameraPredicate;
  62126. private _drawCameraBackground;
  62127. private _drawCameraForeground;
  62128. private _drawRenderTargetPredicate;
  62129. private _drawRenderTargetBackground;
  62130. private _drawRenderTargetForeground;
  62131. /**
  62132. * Adds all the elements from the container to the scene
  62133. * @param container the container holding the elements
  62134. */
  62135. addFromContainer(container: AbstractScene): void;
  62136. /**
  62137. * Removes all the elements in the container from the scene
  62138. * @param container contains the elements to remove
  62139. * @param dispose if the removed element should be disposed (default: false)
  62140. */
  62141. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62142. }
  62143. }
  62144. declare module "babylonjs/Shaders/layer.fragment" {
  62145. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62146. /** @hidden */
  62147. export var layerPixelShader: {
  62148. name: string;
  62149. shader: string;
  62150. };
  62151. }
  62152. declare module "babylonjs/Shaders/layer.vertex" {
  62153. /** @hidden */
  62154. export var layerVertexShader: {
  62155. name: string;
  62156. shader: string;
  62157. };
  62158. }
  62159. declare module "babylonjs/Layers/layer" {
  62160. import { Observable } from "babylonjs/Misc/observable";
  62161. import { Nullable } from "babylonjs/types";
  62162. import { Scene } from "babylonjs/scene";
  62163. import { Vector2 } from "babylonjs/Maths/math.vector";
  62164. import { Color4 } from "babylonjs/Maths/math.color";
  62165. import { Texture } from "babylonjs/Materials/Textures/texture";
  62166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62167. import "babylonjs/Shaders/layer.fragment";
  62168. import "babylonjs/Shaders/layer.vertex";
  62169. /**
  62170. * This represents a full screen 2d layer.
  62171. * This can be useful to display a picture in the background of your scene for instance.
  62172. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62173. */
  62174. export class Layer {
  62175. /**
  62176. * Define the name of the layer.
  62177. */
  62178. name: string;
  62179. /**
  62180. * Define the texture the layer should display.
  62181. */
  62182. texture: Nullable<Texture>;
  62183. /**
  62184. * Is the layer in background or foreground.
  62185. */
  62186. isBackground: boolean;
  62187. /**
  62188. * Define the color of the layer (instead of texture).
  62189. */
  62190. color: Color4;
  62191. /**
  62192. * Define the scale of the layer in order to zoom in out of the texture.
  62193. */
  62194. scale: Vector2;
  62195. /**
  62196. * Define an offset for the layer in order to shift the texture.
  62197. */
  62198. offset: Vector2;
  62199. /**
  62200. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62201. */
  62202. alphaBlendingMode: number;
  62203. /**
  62204. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62205. * Alpha test will not mix with the background color in case of transparency.
  62206. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62207. */
  62208. alphaTest: boolean;
  62209. /**
  62210. * Define a mask to restrict the layer to only some of the scene cameras.
  62211. */
  62212. layerMask: number;
  62213. /**
  62214. * Define the list of render target the layer is visible into.
  62215. */
  62216. renderTargetTextures: RenderTargetTexture[];
  62217. /**
  62218. * Define if the layer is only used in renderTarget or if it also
  62219. * renders in the main frame buffer of the canvas.
  62220. */
  62221. renderOnlyInRenderTargetTextures: boolean;
  62222. private _scene;
  62223. private _vertexBuffers;
  62224. private _indexBuffer;
  62225. private _effect;
  62226. private _previousDefines;
  62227. /**
  62228. * An event triggered when the layer is disposed.
  62229. */
  62230. onDisposeObservable: Observable<Layer>;
  62231. private _onDisposeObserver;
  62232. /**
  62233. * Back compatibility with callback before the onDisposeObservable existed.
  62234. * The set callback will be triggered when the layer has been disposed.
  62235. */
  62236. set onDispose(callback: () => void);
  62237. /**
  62238. * An event triggered before rendering the scene
  62239. */
  62240. onBeforeRenderObservable: Observable<Layer>;
  62241. private _onBeforeRenderObserver;
  62242. /**
  62243. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62244. * The set callback will be triggered just before rendering the layer.
  62245. */
  62246. set onBeforeRender(callback: () => void);
  62247. /**
  62248. * An event triggered after rendering the scene
  62249. */
  62250. onAfterRenderObservable: Observable<Layer>;
  62251. private _onAfterRenderObserver;
  62252. /**
  62253. * Back compatibility with callback before the onAfterRenderObservable existed.
  62254. * The set callback will be triggered just after rendering the layer.
  62255. */
  62256. set onAfterRender(callback: () => void);
  62257. /**
  62258. * Instantiates a new layer.
  62259. * This represents a full screen 2d layer.
  62260. * This can be useful to display a picture in the background of your scene for instance.
  62261. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62262. * @param name Define the name of the layer in the scene
  62263. * @param imgUrl Define the url of the texture to display in the layer
  62264. * @param scene Define the scene the layer belongs to
  62265. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62266. * @param color Defines a color for the layer
  62267. */
  62268. constructor(
  62269. /**
  62270. * Define the name of the layer.
  62271. */
  62272. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62273. private _createIndexBuffer;
  62274. /** @hidden */
  62275. _rebuild(): void;
  62276. /**
  62277. * Renders the layer in the scene.
  62278. */
  62279. render(): void;
  62280. /**
  62281. * Disposes and releases the associated ressources.
  62282. */
  62283. dispose(): void;
  62284. }
  62285. }
  62286. declare module "babylonjs/Layers/index" {
  62287. export * from "babylonjs/Layers/effectLayer";
  62288. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62289. export * from "babylonjs/Layers/glowLayer";
  62290. export * from "babylonjs/Layers/highlightLayer";
  62291. export * from "babylonjs/Layers/layer";
  62292. export * from "babylonjs/Layers/layerSceneComponent";
  62293. }
  62294. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62295. /** @hidden */
  62296. export var lensFlarePixelShader: {
  62297. name: string;
  62298. shader: string;
  62299. };
  62300. }
  62301. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62302. /** @hidden */
  62303. export var lensFlareVertexShader: {
  62304. name: string;
  62305. shader: string;
  62306. };
  62307. }
  62308. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62309. import { Scene } from "babylonjs/scene";
  62310. import { Vector3 } from "babylonjs/Maths/math.vector";
  62311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62312. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62313. import "babylonjs/Shaders/lensFlare.fragment";
  62314. import "babylonjs/Shaders/lensFlare.vertex";
  62315. import { Viewport } from "babylonjs/Maths/math.viewport";
  62316. /**
  62317. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62318. * It is usually composed of several `lensFlare`.
  62319. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62320. */
  62321. export class LensFlareSystem {
  62322. /**
  62323. * Define the name of the lens flare system
  62324. */
  62325. name: string;
  62326. /**
  62327. * List of lens flares used in this system.
  62328. */
  62329. lensFlares: LensFlare[];
  62330. /**
  62331. * Define a limit from the border the lens flare can be visible.
  62332. */
  62333. borderLimit: number;
  62334. /**
  62335. * Define a viewport border we do not want to see the lens flare in.
  62336. */
  62337. viewportBorder: number;
  62338. /**
  62339. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62340. */
  62341. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62342. /**
  62343. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62344. */
  62345. layerMask: number;
  62346. /**
  62347. * Define the id of the lens flare system in the scene.
  62348. * (equal to name by default)
  62349. */
  62350. id: string;
  62351. private _scene;
  62352. private _emitter;
  62353. private _vertexBuffers;
  62354. private _indexBuffer;
  62355. private _effect;
  62356. private _positionX;
  62357. private _positionY;
  62358. private _isEnabled;
  62359. /** @hidden */
  62360. static _SceneComponentInitialization: (scene: Scene) => void;
  62361. /**
  62362. * Instantiates a lens flare system.
  62363. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62364. * It is usually composed of several `lensFlare`.
  62365. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62366. * @param name Define the name of the lens flare system in the scene
  62367. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62368. * @param scene Define the scene the lens flare system belongs to
  62369. */
  62370. constructor(
  62371. /**
  62372. * Define the name of the lens flare system
  62373. */
  62374. name: string, emitter: any, scene: Scene);
  62375. /**
  62376. * Define if the lens flare system is enabled.
  62377. */
  62378. get isEnabled(): boolean;
  62379. set isEnabled(value: boolean);
  62380. /**
  62381. * Get the scene the effects belongs to.
  62382. * @returns the scene holding the lens flare system
  62383. */
  62384. getScene(): Scene;
  62385. /**
  62386. * Get the emitter of the lens flare system.
  62387. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62388. * @returns the emitter of the lens flare system
  62389. */
  62390. getEmitter(): any;
  62391. /**
  62392. * Set the emitter of the lens flare system.
  62393. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62394. * @param newEmitter Define the new emitter of the system
  62395. */
  62396. setEmitter(newEmitter: any): void;
  62397. /**
  62398. * Get the lens flare system emitter position.
  62399. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62400. * @returns the position
  62401. */
  62402. getEmitterPosition(): Vector3;
  62403. /**
  62404. * @hidden
  62405. */
  62406. computeEffectivePosition(globalViewport: Viewport): boolean;
  62407. /** @hidden */
  62408. _isVisible(): boolean;
  62409. /**
  62410. * @hidden
  62411. */
  62412. render(): boolean;
  62413. /**
  62414. * Dispose and release the lens flare with its associated resources.
  62415. */
  62416. dispose(): void;
  62417. /**
  62418. * Parse a lens flare system from a JSON repressentation
  62419. * @param parsedLensFlareSystem Define the JSON to parse
  62420. * @param scene Define the scene the parsed system should be instantiated in
  62421. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62422. * @returns the parsed system
  62423. */
  62424. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62425. /**
  62426. * Serialize the current Lens Flare System into a JSON representation.
  62427. * @returns the serialized JSON
  62428. */
  62429. serialize(): any;
  62430. }
  62431. }
  62432. declare module "babylonjs/LensFlares/lensFlare" {
  62433. import { Nullable } from "babylonjs/types";
  62434. import { Color3 } from "babylonjs/Maths/math.color";
  62435. import { Texture } from "babylonjs/Materials/Textures/texture";
  62436. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62437. /**
  62438. * This represents one of the lens effect in a `lensFlareSystem`.
  62439. * It controls one of the indiviual texture used in the effect.
  62440. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62441. */
  62442. export class LensFlare {
  62443. /**
  62444. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62445. */
  62446. size: number;
  62447. /**
  62448. * 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.
  62449. */
  62450. position: number;
  62451. /**
  62452. * Define the lens color.
  62453. */
  62454. color: Color3;
  62455. /**
  62456. * Define the lens texture.
  62457. */
  62458. texture: Nullable<Texture>;
  62459. /**
  62460. * Define the alpha mode to render this particular lens.
  62461. */
  62462. alphaMode: number;
  62463. private _system;
  62464. /**
  62465. * Creates a new Lens Flare.
  62466. * This represents one of the lens effect in a `lensFlareSystem`.
  62467. * It controls one of the indiviual texture used in the effect.
  62468. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62469. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62470. * @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.
  62471. * @param color Define the lens color
  62472. * @param imgUrl Define the lens texture url
  62473. * @param system Define the `lensFlareSystem` this flare is part of
  62474. * @returns The newly created Lens Flare
  62475. */
  62476. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62477. /**
  62478. * Instantiates a new Lens Flare.
  62479. * This represents one of the lens effect in a `lensFlareSystem`.
  62480. * It controls one of the indiviual texture used in the effect.
  62481. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62482. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62483. * @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.
  62484. * @param color Define the lens color
  62485. * @param imgUrl Define the lens texture url
  62486. * @param system Define the `lensFlareSystem` this flare is part of
  62487. */
  62488. constructor(
  62489. /**
  62490. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62491. */
  62492. size: number,
  62493. /**
  62494. * 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.
  62495. */
  62496. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62497. /**
  62498. * Dispose and release the lens flare with its associated resources.
  62499. */
  62500. dispose(): void;
  62501. }
  62502. }
  62503. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62504. import { Nullable } from "babylonjs/types";
  62505. import { Scene } from "babylonjs/scene";
  62506. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62507. import { AbstractScene } from "babylonjs/abstractScene";
  62508. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62509. module "babylonjs/abstractScene" {
  62510. interface AbstractScene {
  62511. /**
  62512. * The list of lens flare system added to the scene
  62513. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62514. */
  62515. lensFlareSystems: Array<LensFlareSystem>;
  62516. /**
  62517. * Removes the given lens flare system from this scene.
  62518. * @param toRemove The lens flare system to remove
  62519. * @returns The index of the removed lens flare system
  62520. */
  62521. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62522. /**
  62523. * Adds the given lens flare system to this scene
  62524. * @param newLensFlareSystem The lens flare system to add
  62525. */
  62526. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62527. /**
  62528. * Gets a lens flare system using its name
  62529. * @param name defines the name to look for
  62530. * @returns the lens flare system or null if not found
  62531. */
  62532. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62533. /**
  62534. * Gets a lens flare system using its id
  62535. * @param id defines the id to look for
  62536. * @returns the lens flare system or null if not found
  62537. */
  62538. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62539. }
  62540. }
  62541. /**
  62542. * Defines the lens flare scene component responsible to manage any lens flares
  62543. * in a given scene.
  62544. */
  62545. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62546. /**
  62547. * The component name helpfull to identify the component in the list of scene components.
  62548. */
  62549. readonly name: string;
  62550. /**
  62551. * The scene the component belongs to.
  62552. */
  62553. scene: Scene;
  62554. /**
  62555. * Creates a new instance of the component for the given scene
  62556. * @param scene Defines the scene to register the component in
  62557. */
  62558. constructor(scene: Scene);
  62559. /**
  62560. * Registers the component in a given scene
  62561. */
  62562. register(): void;
  62563. /**
  62564. * Rebuilds the elements related to this component in case of
  62565. * context lost for instance.
  62566. */
  62567. rebuild(): void;
  62568. /**
  62569. * Adds all the elements from the container to the scene
  62570. * @param container the container holding the elements
  62571. */
  62572. addFromContainer(container: AbstractScene): void;
  62573. /**
  62574. * Removes all the elements in the container from the scene
  62575. * @param container contains the elements to remove
  62576. * @param dispose if the removed element should be disposed (default: false)
  62577. */
  62578. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62579. /**
  62580. * Serializes the component data to the specified json object
  62581. * @param serializationObject The object to serialize to
  62582. */
  62583. serialize(serializationObject: any): void;
  62584. /**
  62585. * Disposes the component and the associated ressources.
  62586. */
  62587. dispose(): void;
  62588. private _draw;
  62589. }
  62590. }
  62591. declare module "babylonjs/LensFlares/index" {
  62592. export * from "babylonjs/LensFlares/lensFlare";
  62593. export * from "babylonjs/LensFlares/lensFlareSystem";
  62594. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62595. }
  62596. declare module "babylonjs/Shaders/depth.fragment" {
  62597. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62598. /** @hidden */
  62599. export var depthPixelShader: {
  62600. name: string;
  62601. shader: string;
  62602. };
  62603. }
  62604. declare module "babylonjs/Shaders/depth.vertex" {
  62605. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62608. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62609. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62610. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62611. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62612. /** @hidden */
  62613. export var depthVertexShader: {
  62614. name: string;
  62615. shader: string;
  62616. };
  62617. }
  62618. declare module "babylonjs/Rendering/depthRenderer" {
  62619. import { Nullable } from "babylonjs/types";
  62620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62621. import { Scene } from "babylonjs/scene";
  62622. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62623. import { Camera } from "babylonjs/Cameras/camera";
  62624. import "babylonjs/Shaders/depth.fragment";
  62625. import "babylonjs/Shaders/depth.vertex";
  62626. /**
  62627. * This represents a depth renderer in Babylon.
  62628. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62629. */
  62630. export class DepthRenderer {
  62631. private _scene;
  62632. private _depthMap;
  62633. private _effect;
  62634. private readonly _storeNonLinearDepth;
  62635. private readonly _clearColor;
  62636. /** Get if the depth renderer is using packed depth or not */
  62637. readonly isPacked: boolean;
  62638. private _cachedDefines;
  62639. private _camera;
  62640. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62641. enabled: boolean;
  62642. /**
  62643. * Specifiess that the depth renderer will only be used within
  62644. * the camera it is created for.
  62645. * This can help forcing its rendering during the camera processing.
  62646. */
  62647. useOnlyInActiveCamera: boolean;
  62648. /** @hidden */
  62649. static _SceneComponentInitialization: (scene: Scene) => void;
  62650. /**
  62651. * Instantiates a depth renderer
  62652. * @param scene The scene the renderer belongs to
  62653. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62654. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62655. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62656. */
  62657. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62658. /**
  62659. * Creates the depth rendering effect and checks if the effect is ready.
  62660. * @param subMesh The submesh to be used to render the depth map of
  62661. * @param useInstances If multiple world instances should be used
  62662. * @returns if the depth renderer is ready to render the depth map
  62663. */
  62664. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62665. /**
  62666. * Gets the texture which the depth map will be written to.
  62667. * @returns The depth map texture
  62668. */
  62669. getDepthMap(): RenderTargetTexture;
  62670. /**
  62671. * Disposes of the depth renderer.
  62672. */
  62673. dispose(): void;
  62674. }
  62675. }
  62676. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62677. /** @hidden */
  62678. export var minmaxReduxPixelShader: {
  62679. name: string;
  62680. shader: string;
  62681. };
  62682. }
  62683. declare module "babylonjs/Misc/minMaxReducer" {
  62684. import { Nullable } from "babylonjs/types";
  62685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62686. import { Camera } from "babylonjs/Cameras/camera";
  62687. import { Observer } from "babylonjs/Misc/observable";
  62688. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62689. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62690. import { Observable } from "babylonjs/Misc/observable";
  62691. import "babylonjs/Shaders/minmaxRedux.fragment";
  62692. /**
  62693. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62694. * and maximum values from all values of the texture.
  62695. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62696. * The source values are read from the red channel of the texture.
  62697. */
  62698. export class MinMaxReducer {
  62699. /**
  62700. * Observable triggered when the computation has been performed
  62701. */
  62702. onAfterReductionPerformed: Observable<{
  62703. min: number;
  62704. max: number;
  62705. }>;
  62706. protected _camera: Camera;
  62707. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62708. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62709. protected _postProcessManager: PostProcessManager;
  62710. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62711. protected _forceFullscreenViewport: boolean;
  62712. /**
  62713. * Creates a min/max reducer
  62714. * @param camera The camera to use for the post processes
  62715. */
  62716. constructor(camera: Camera);
  62717. /**
  62718. * Gets the texture used to read the values from.
  62719. */
  62720. get sourceTexture(): Nullable<RenderTargetTexture>;
  62721. /**
  62722. * Sets the source texture to read the values from.
  62723. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62724. * because in such textures '1' value must not be taken into account to compute the maximum
  62725. * as this value is used to clear the texture.
  62726. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62727. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62728. * @param depthRedux Indicates if the texture is a depth texture or not
  62729. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62730. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62731. */
  62732. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62733. /**
  62734. * Defines the refresh rate of the computation.
  62735. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62736. */
  62737. get refreshRate(): number;
  62738. set refreshRate(value: number);
  62739. protected _activated: boolean;
  62740. /**
  62741. * Gets the activation status of the reducer
  62742. */
  62743. get activated(): boolean;
  62744. /**
  62745. * Activates the reduction computation.
  62746. * When activated, the observers registered in onAfterReductionPerformed are
  62747. * called after the compuation is performed
  62748. */
  62749. activate(): void;
  62750. /**
  62751. * Deactivates the reduction computation.
  62752. */
  62753. deactivate(): void;
  62754. /**
  62755. * Disposes the min/max reducer
  62756. * @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.
  62757. */
  62758. dispose(disposeAll?: boolean): void;
  62759. }
  62760. }
  62761. declare module "babylonjs/Misc/depthReducer" {
  62762. import { Nullable } from "babylonjs/types";
  62763. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62764. import { Camera } from "babylonjs/Cameras/camera";
  62765. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62766. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62767. /**
  62768. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62769. */
  62770. export class DepthReducer extends MinMaxReducer {
  62771. private _depthRenderer;
  62772. private _depthRendererId;
  62773. /**
  62774. * Gets the depth renderer used for the computation.
  62775. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62776. */
  62777. get depthRenderer(): Nullable<DepthRenderer>;
  62778. /**
  62779. * Creates a depth reducer
  62780. * @param camera The camera used to render the depth texture
  62781. */
  62782. constructor(camera: Camera);
  62783. /**
  62784. * Sets the depth renderer to use to generate the depth map
  62785. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62786. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62787. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62788. */
  62789. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62790. /** @hidden */
  62791. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62792. /**
  62793. * Activates the reduction computation.
  62794. * When activated, the observers registered in onAfterReductionPerformed are
  62795. * called after the compuation is performed
  62796. */
  62797. activate(): void;
  62798. /**
  62799. * Deactivates the reduction computation.
  62800. */
  62801. deactivate(): void;
  62802. /**
  62803. * Disposes the depth reducer
  62804. * @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.
  62805. */
  62806. dispose(disposeAll?: boolean): void;
  62807. }
  62808. }
  62809. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62810. import { Nullable } from "babylonjs/types";
  62811. import { Scene } from "babylonjs/scene";
  62812. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62813. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62815. import { Effect } from "babylonjs/Materials/effect";
  62816. import "babylonjs/Shaders/shadowMap.fragment";
  62817. import "babylonjs/Shaders/shadowMap.vertex";
  62818. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62819. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62820. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62821. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62822. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62823. /**
  62824. * A CSM implementation allowing casting shadows on large scenes.
  62825. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62826. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62827. */
  62828. export class CascadedShadowGenerator extends ShadowGenerator {
  62829. private static readonly frustumCornersNDCSpace;
  62830. /**
  62831. * Name of the CSM class
  62832. */
  62833. static CLASSNAME: string;
  62834. /**
  62835. * Defines the default number of cascades used by the CSM.
  62836. */
  62837. static readonly DEFAULT_CASCADES_COUNT: number;
  62838. /**
  62839. * Defines the minimum number of cascades used by the CSM.
  62840. */
  62841. static readonly MIN_CASCADES_COUNT: number;
  62842. /**
  62843. * Defines the maximum number of cascades used by the CSM.
  62844. */
  62845. static readonly MAX_CASCADES_COUNT: number;
  62846. protected _validateFilter(filter: number): number;
  62847. /**
  62848. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62849. */
  62850. penumbraDarkness: number;
  62851. private _numCascades;
  62852. /**
  62853. * Gets or set the number of cascades used by the CSM.
  62854. */
  62855. get numCascades(): number;
  62856. set numCascades(value: number);
  62857. /**
  62858. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62859. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62860. */
  62861. stabilizeCascades: boolean;
  62862. private _freezeShadowCastersBoundingInfo;
  62863. private _freezeShadowCastersBoundingInfoObservable;
  62864. /**
  62865. * Enables or disables the shadow casters bounding info computation.
  62866. * If your shadow casters don't move, you can disable this feature.
  62867. * If it is enabled, the bounding box computation is done every frame.
  62868. */
  62869. get freezeShadowCastersBoundingInfo(): boolean;
  62870. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62871. private _scbiMin;
  62872. private _scbiMax;
  62873. protected _computeShadowCastersBoundingInfo(): void;
  62874. protected _shadowCastersBoundingInfo: BoundingInfo;
  62875. /**
  62876. * Gets or sets the shadow casters bounding info.
  62877. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62878. * so that the system won't overwrite the bounds you provide
  62879. */
  62880. get shadowCastersBoundingInfo(): BoundingInfo;
  62881. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62882. protected _breaksAreDirty: boolean;
  62883. protected _minDistance: number;
  62884. protected _maxDistance: number;
  62885. /**
  62886. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62887. *
  62888. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62889. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62890. * @param min minimal distance for the breaks (default to 0.)
  62891. * @param max maximal distance for the breaks (default to 1.)
  62892. */
  62893. setMinMaxDistance(min: number, max: number): void;
  62894. /** Gets the minimal distance used in the cascade break computation */
  62895. get minDistance(): number;
  62896. /** Gets the maximal distance used in the cascade break computation */
  62897. get maxDistance(): number;
  62898. /**
  62899. * Gets the class name of that object
  62900. * @returns "CascadedShadowGenerator"
  62901. */
  62902. getClassName(): string;
  62903. private _cascadeMinExtents;
  62904. private _cascadeMaxExtents;
  62905. /**
  62906. * Gets a cascade minimum extents
  62907. * @param cascadeIndex index of the cascade
  62908. * @returns the minimum cascade extents
  62909. */
  62910. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62911. /**
  62912. * Gets a cascade maximum extents
  62913. * @param cascadeIndex index of the cascade
  62914. * @returns the maximum cascade extents
  62915. */
  62916. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62917. private _cascades;
  62918. private _currentLayer;
  62919. private _viewSpaceFrustumsZ;
  62920. private _viewMatrices;
  62921. private _projectionMatrices;
  62922. private _transformMatrices;
  62923. private _transformMatricesAsArray;
  62924. private _frustumLengths;
  62925. private _lightSizeUVCorrection;
  62926. private _depthCorrection;
  62927. private _frustumCornersWorldSpace;
  62928. private _frustumCenter;
  62929. private _shadowCameraPos;
  62930. private _shadowMaxZ;
  62931. /**
  62932. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62933. * It defaults to camera.maxZ
  62934. */
  62935. get shadowMaxZ(): number;
  62936. /**
  62937. * Sets the shadow max z distance.
  62938. */
  62939. set shadowMaxZ(value: number);
  62940. protected _debug: boolean;
  62941. /**
  62942. * Gets or sets the debug flag.
  62943. * When enabled, the cascades are materialized by different colors on the screen.
  62944. */
  62945. get debug(): boolean;
  62946. set debug(dbg: boolean);
  62947. private _depthClamp;
  62948. /**
  62949. * Gets or sets the depth clamping value.
  62950. *
  62951. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62952. * to account for the shadow casters far away.
  62953. *
  62954. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62955. */
  62956. get depthClamp(): boolean;
  62957. set depthClamp(value: boolean);
  62958. private _cascadeBlendPercentage;
  62959. /**
  62960. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62961. * It defaults to 0.1 (10% blending).
  62962. */
  62963. get cascadeBlendPercentage(): number;
  62964. set cascadeBlendPercentage(value: number);
  62965. private _lambda;
  62966. /**
  62967. * Gets or set the lambda parameter.
  62968. * This parameter is used to split the camera frustum and create the cascades.
  62969. * 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.
  62970. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62971. */
  62972. get lambda(): number;
  62973. set lambda(value: number);
  62974. /**
  62975. * Gets the view matrix corresponding to a given cascade
  62976. * @param cascadeNum cascade to retrieve the view matrix from
  62977. * @returns the cascade view matrix
  62978. */
  62979. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62980. /**
  62981. * Gets the projection matrix corresponding to a given cascade
  62982. * @param cascadeNum cascade to retrieve the projection matrix from
  62983. * @returns the cascade projection matrix
  62984. */
  62985. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62986. /**
  62987. * Gets the transformation matrix corresponding to a given cascade
  62988. * @param cascadeNum cascade to retrieve the transformation matrix from
  62989. * @returns the cascade transformation matrix
  62990. */
  62991. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62992. private _depthRenderer;
  62993. /**
  62994. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62995. *
  62996. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62997. *
  62998. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62999. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63000. * @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
  63001. */
  63002. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63003. private _depthReducer;
  63004. private _autoCalcDepthBounds;
  63005. /**
  63006. * Gets or sets the autoCalcDepthBounds property.
  63007. *
  63008. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63009. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63010. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63011. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63012. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63013. */
  63014. get autoCalcDepthBounds(): boolean;
  63015. set autoCalcDepthBounds(value: boolean);
  63016. /**
  63017. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63018. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63019. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63020. * for setting the refresh rate on the renderer yourself!
  63021. */
  63022. get autoCalcDepthBoundsRefreshRate(): number;
  63023. set autoCalcDepthBoundsRefreshRate(value: number);
  63024. /**
  63025. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63026. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63027. * you change the camera near/far planes!
  63028. */
  63029. splitFrustum(): void;
  63030. private _splitFrustum;
  63031. private _computeMatrices;
  63032. private _computeFrustumInWorldSpace;
  63033. private _computeCascadeFrustum;
  63034. /**
  63035. * Support test.
  63036. */
  63037. static get IsSupported(): boolean;
  63038. /** @hidden */
  63039. static _SceneComponentInitialization: (scene: Scene) => void;
  63040. /**
  63041. * Creates a Cascaded Shadow Generator object.
  63042. * A ShadowGenerator is the required tool to use the shadows.
  63043. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63044. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63045. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63046. * @param light The directional light object generating the shadows.
  63047. * @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.
  63048. */
  63049. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63050. protected _initializeGenerator(): void;
  63051. protected _createTargetRenderTexture(): void;
  63052. protected _initializeShadowMap(): void;
  63053. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63054. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63055. /**
  63056. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63057. * @param defines Defines of the material we want to update
  63058. * @param lightIndex Index of the light in the enabled light list of the material
  63059. */
  63060. prepareDefines(defines: any, lightIndex: number): void;
  63061. /**
  63062. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63063. * defined in the generator but impacting the effect).
  63064. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63065. * @param effect The effect we are binfing the information for
  63066. */
  63067. bindShadowLight(lightIndex: string, effect: Effect): void;
  63068. /**
  63069. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63070. * (eq to view projection * shadow projection matrices)
  63071. * @returns The transform matrix used to create the shadow map
  63072. */
  63073. getTransformMatrix(): Matrix;
  63074. /**
  63075. * Disposes the ShadowGenerator.
  63076. * Returns nothing.
  63077. */
  63078. dispose(): void;
  63079. /**
  63080. * Serializes the shadow generator setup to a json object.
  63081. * @returns The serialized JSON object
  63082. */
  63083. serialize(): any;
  63084. /**
  63085. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63086. * @param parsedShadowGenerator The JSON object to parse
  63087. * @param scene The scene to create the shadow map for
  63088. * @returns The parsed shadow generator
  63089. */
  63090. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63091. }
  63092. }
  63093. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63094. import { Scene } from "babylonjs/scene";
  63095. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63096. import { AbstractScene } from "babylonjs/abstractScene";
  63097. /**
  63098. * Defines the shadow generator component responsible to manage any shadow generators
  63099. * in a given scene.
  63100. */
  63101. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63102. /**
  63103. * The component name helpfull to identify the component in the list of scene components.
  63104. */
  63105. readonly name: string;
  63106. /**
  63107. * The scene the component belongs to.
  63108. */
  63109. scene: Scene;
  63110. /**
  63111. * Creates a new instance of the component for the given scene
  63112. * @param scene Defines the scene to register the component in
  63113. */
  63114. constructor(scene: Scene);
  63115. /**
  63116. * Registers the component in a given scene
  63117. */
  63118. register(): void;
  63119. /**
  63120. * Rebuilds the elements related to this component in case of
  63121. * context lost for instance.
  63122. */
  63123. rebuild(): void;
  63124. /**
  63125. * Serializes the component data to the specified json object
  63126. * @param serializationObject The object to serialize to
  63127. */
  63128. serialize(serializationObject: any): void;
  63129. /**
  63130. * Adds all the elements from the container to the scene
  63131. * @param container the container holding the elements
  63132. */
  63133. addFromContainer(container: AbstractScene): void;
  63134. /**
  63135. * Removes all the elements in the container from the scene
  63136. * @param container contains the elements to remove
  63137. * @param dispose if the removed element should be disposed (default: false)
  63138. */
  63139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63140. /**
  63141. * Rebuilds the elements related to this component in case of
  63142. * context lost for instance.
  63143. */
  63144. dispose(): void;
  63145. private _gatherRenderTargets;
  63146. }
  63147. }
  63148. declare module "babylonjs/Lights/Shadows/index" {
  63149. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63150. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63151. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63152. }
  63153. declare module "babylonjs/Lights/pointLight" {
  63154. import { Scene } from "babylonjs/scene";
  63155. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63157. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63158. import { Effect } from "babylonjs/Materials/effect";
  63159. /**
  63160. * A point light is a light defined by an unique point in world space.
  63161. * The light is emitted in every direction from this point.
  63162. * A good example of a point light is a standard light bulb.
  63163. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63164. */
  63165. export class PointLight extends ShadowLight {
  63166. private _shadowAngle;
  63167. /**
  63168. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63169. * This specifies what angle the shadow will use to be created.
  63170. *
  63171. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63172. */
  63173. get shadowAngle(): number;
  63174. /**
  63175. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63176. * This specifies what angle the shadow will use to be created.
  63177. *
  63178. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63179. */
  63180. set shadowAngle(value: number);
  63181. /**
  63182. * Gets the direction if it has been set.
  63183. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63184. */
  63185. get direction(): Vector3;
  63186. /**
  63187. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63188. */
  63189. set direction(value: Vector3);
  63190. /**
  63191. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63192. * A PointLight emits the light in every direction.
  63193. * It can cast shadows.
  63194. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63195. * ```javascript
  63196. * var pointLight = new PointLight("pl", camera.position, scene);
  63197. * ```
  63198. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63199. * @param name The light friendly name
  63200. * @param position The position of the point light in the scene
  63201. * @param scene The scene the lights belongs to
  63202. */
  63203. constructor(name: string, position: Vector3, scene: Scene);
  63204. /**
  63205. * Returns the string "PointLight"
  63206. * @returns the class name
  63207. */
  63208. getClassName(): string;
  63209. /**
  63210. * Returns the integer 0.
  63211. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63212. */
  63213. getTypeID(): number;
  63214. /**
  63215. * Specifies wether or not the shadowmap should be a cube texture.
  63216. * @returns true if the shadowmap needs to be a cube texture.
  63217. */
  63218. needCube(): boolean;
  63219. /**
  63220. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63223. */
  63224. getShadowDirection(faceIndex?: number): Vector3;
  63225. /**
  63226. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63227. * - fov = PI / 2
  63228. * - aspect ratio : 1.0
  63229. * - z-near and far equal to the active camera minZ and maxZ.
  63230. * Returns the PointLight.
  63231. */
  63232. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63233. protected _buildUniformLayout(): void;
  63234. /**
  63235. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63236. * @param effect The effect to update
  63237. * @param lightIndex The index of the light in the effect to update
  63238. * @returns The point light
  63239. */
  63240. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63241. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63242. /**
  63243. * Prepares the list of defines specific to the light type.
  63244. * @param defines the list of defines
  63245. * @param lightIndex defines the index of the light for the effect
  63246. */
  63247. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63248. }
  63249. }
  63250. declare module "babylonjs/Lights/index" {
  63251. export * from "babylonjs/Lights/light";
  63252. export * from "babylonjs/Lights/shadowLight";
  63253. export * from "babylonjs/Lights/Shadows/index";
  63254. export * from "babylonjs/Lights/directionalLight";
  63255. export * from "babylonjs/Lights/hemisphericLight";
  63256. export * from "babylonjs/Lights/pointLight";
  63257. export * from "babylonjs/Lights/spotLight";
  63258. }
  63259. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63260. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63261. /**
  63262. * Header information of HDR texture files.
  63263. */
  63264. export interface HDRInfo {
  63265. /**
  63266. * The height of the texture in pixels.
  63267. */
  63268. height: number;
  63269. /**
  63270. * The width of the texture in pixels.
  63271. */
  63272. width: number;
  63273. /**
  63274. * The index of the beginning of the data in the binary file.
  63275. */
  63276. dataPosition: number;
  63277. }
  63278. /**
  63279. * This groups tools to convert HDR texture to native colors array.
  63280. */
  63281. export class HDRTools {
  63282. private static Ldexp;
  63283. private static Rgbe2float;
  63284. private static readStringLine;
  63285. /**
  63286. * Reads header information from an RGBE texture stored in a native array.
  63287. * More information on this format are available here:
  63288. * https://en.wikipedia.org/wiki/RGBE_image_format
  63289. *
  63290. * @param uint8array The binary file stored in native array.
  63291. * @return The header information.
  63292. */
  63293. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63294. /**
  63295. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63296. * This RGBE texture needs to store the information as a panorama.
  63297. *
  63298. * More information on this format are available here:
  63299. * https://en.wikipedia.org/wiki/RGBE_image_format
  63300. *
  63301. * @param buffer The binary file stored in an array buffer.
  63302. * @param size The expected size of the extracted cubemap.
  63303. * @return The Cube Map information.
  63304. */
  63305. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63306. /**
  63307. * Returns the pixels data extracted from an RGBE texture.
  63308. * This pixels will be stored left to right up to down in the R G B order in one array.
  63309. *
  63310. * More information on this format are available here:
  63311. * https://en.wikipedia.org/wiki/RGBE_image_format
  63312. *
  63313. * @param uint8array The binary file stored in an array buffer.
  63314. * @param hdrInfo The header information of the file.
  63315. * @return The pixels data in RGB right to left up to down order.
  63316. */
  63317. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63318. private static RGBE_ReadPixels_RLE;
  63319. private static RGBE_ReadPixels_NOT_RLE;
  63320. }
  63321. }
  63322. declare module "babylonjs/Materials/effectRenderer" {
  63323. import { Nullable } from "babylonjs/types";
  63324. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63326. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63327. import { Viewport } from "babylonjs/Maths/math.viewport";
  63328. import { Observable } from "babylonjs/Misc/observable";
  63329. import { Effect } from "babylonjs/Materials/effect";
  63330. import "babylonjs/Shaders/postprocess.vertex";
  63331. /**
  63332. * Effect Render Options
  63333. */
  63334. export interface IEffectRendererOptions {
  63335. /**
  63336. * Defines the vertices positions.
  63337. */
  63338. positions?: number[];
  63339. /**
  63340. * Defines the indices.
  63341. */
  63342. indices?: number[];
  63343. }
  63344. /**
  63345. * Helper class to render one or more effects.
  63346. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63347. */
  63348. export class EffectRenderer {
  63349. private engine;
  63350. private static _DefaultOptions;
  63351. private _vertexBuffers;
  63352. private _indexBuffer;
  63353. private _fullscreenViewport;
  63354. /**
  63355. * Creates an effect renderer
  63356. * @param engine the engine to use for rendering
  63357. * @param options defines the options of the effect renderer
  63358. */
  63359. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63360. /**
  63361. * Sets the current viewport in normalized coordinates 0-1
  63362. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63363. */
  63364. setViewport(viewport?: Viewport): void;
  63365. /**
  63366. * Binds the embedded attributes buffer to the effect.
  63367. * @param effect Defines the effect to bind the attributes for
  63368. */
  63369. bindBuffers(effect: Effect): void;
  63370. /**
  63371. * Sets the current effect wrapper to use during draw.
  63372. * The effect needs to be ready before calling this api.
  63373. * This also sets the default full screen position attribute.
  63374. * @param effectWrapper Defines the effect to draw with
  63375. */
  63376. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63377. /**
  63378. * Restores engine states
  63379. */
  63380. restoreStates(): void;
  63381. /**
  63382. * Draws a full screen quad.
  63383. */
  63384. draw(): void;
  63385. private isRenderTargetTexture;
  63386. /**
  63387. * renders one or more effects to a specified texture
  63388. * @param effectWrapper the effect to renderer
  63389. * @param outputTexture texture to draw to, if null it will render to the screen.
  63390. */
  63391. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63392. /**
  63393. * Disposes of the effect renderer
  63394. */
  63395. dispose(): void;
  63396. }
  63397. /**
  63398. * Options to create an EffectWrapper
  63399. */
  63400. interface EffectWrapperCreationOptions {
  63401. /**
  63402. * Engine to use to create the effect
  63403. */
  63404. engine: ThinEngine;
  63405. /**
  63406. * Fragment shader for the effect
  63407. */
  63408. fragmentShader: string;
  63409. /**
  63410. * Use the shader store instead of direct source code
  63411. */
  63412. useShaderStore?: boolean;
  63413. /**
  63414. * Vertex shader for the effect
  63415. */
  63416. vertexShader?: string;
  63417. /**
  63418. * Attributes to use in the shader
  63419. */
  63420. attributeNames?: Array<string>;
  63421. /**
  63422. * Uniforms to use in the shader
  63423. */
  63424. uniformNames?: Array<string>;
  63425. /**
  63426. * Texture sampler names to use in the shader
  63427. */
  63428. samplerNames?: Array<string>;
  63429. /**
  63430. * Defines to use in the shader
  63431. */
  63432. defines?: Array<string>;
  63433. /**
  63434. * Callback when effect is compiled
  63435. */
  63436. onCompiled?: Nullable<(effect: Effect) => void>;
  63437. /**
  63438. * The friendly name of the effect displayed in Spector.
  63439. */
  63440. name?: string;
  63441. }
  63442. /**
  63443. * Wraps an effect to be used for rendering
  63444. */
  63445. export class EffectWrapper {
  63446. /**
  63447. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63448. */
  63449. onApplyObservable: Observable<{}>;
  63450. /**
  63451. * The underlying effect
  63452. */
  63453. effect: Effect;
  63454. /**
  63455. * Creates an effect to be renderer
  63456. * @param creationOptions options to create the effect
  63457. */
  63458. constructor(creationOptions: EffectWrapperCreationOptions);
  63459. /**
  63460. * Disposes of the effect wrapper
  63461. */
  63462. dispose(): void;
  63463. }
  63464. }
  63465. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63466. /** @hidden */
  63467. export var hdrFilteringVertexShader: {
  63468. name: string;
  63469. shader: string;
  63470. };
  63471. }
  63472. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63474. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63475. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63476. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63477. /** @hidden */
  63478. export var hdrFilteringPixelShader: {
  63479. name: string;
  63480. shader: string;
  63481. };
  63482. }
  63483. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63485. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63486. import { Nullable } from "babylonjs/types";
  63487. import "babylonjs/Shaders/hdrFiltering.vertex";
  63488. import "babylonjs/Shaders/hdrFiltering.fragment";
  63489. /**
  63490. * Options for texture filtering
  63491. */
  63492. interface IHDRFilteringOptions {
  63493. /**
  63494. * Scales pixel intensity for the input HDR map.
  63495. */
  63496. hdrScale?: number;
  63497. /**
  63498. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63499. */
  63500. quality?: number;
  63501. }
  63502. /**
  63503. * Filters HDR maps to get correct renderings of PBR reflections
  63504. */
  63505. export class HDRFiltering {
  63506. private _engine;
  63507. private _effectRenderer;
  63508. private _effectWrapper;
  63509. private _lodGenerationOffset;
  63510. private _lodGenerationScale;
  63511. /**
  63512. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63513. * you care about baking speed.
  63514. */
  63515. quality: number;
  63516. /**
  63517. * Scales pixel intensity for the input HDR map.
  63518. */
  63519. hdrScale: number;
  63520. /**
  63521. * Instantiates HDR filter for reflection maps
  63522. *
  63523. * @param engine Thin engine
  63524. * @param options Options
  63525. */
  63526. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63527. private _createRenderTarget;
  63528. private _prefilterInternal;
  63529. private _createEffect;
  63530. /**
  63531. * Get a value indicating if the filter is ready to be used
  63532. * @param texture Texture to filter
  63533. * @returns true if the filter is ready
  63534. */
  63535. isReady(texture: BaseTexture): boolean;
  63536. /**
  63537. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63538. * Prefiltering will be invoked at the end of next rendering pass.
  63539. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63540. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63541. * @param texture Texture to filter
  63542. * @param onFinished Callback when filtering is done
  63543. * @return Promise called when prefiltering is done
  63544. */
  63545. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63546. }
  63547. }
  63548. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63549. import { Nullable } from "babylonjs/types";
  63550. import { Scene } from "babylonjs/scene";
  63551. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63553. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63554. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63555. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63556. /**
  63557. * This represents a texture coming from an HDR input.
  63558. *
  63559. * The only supported format is currently panorama picture stored in RGBE format.
  63560. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63561. */
  63562. export class HDRCubeTexture extends BaseTexture {
  63563. private static _facesMapping;
  63564. private _generateHarmonics;
  63565. private _noMipmap;
  63566. private _prefilterOnLoad;
  63567. private _textureMatrix;
  63568. private _size;
  63569. private _onLoad;
  63570. private _onError;
  63571. /**
  63572. * The texture URL.
  63573. */
  63574. url: string;
  63575. protected _isBlocking: boolean;
  63576. /**
  63577. * Sets wether or not the texture is blocking during loading.
  63578. */
  63579. set isBlocking(value: boolean);
  63580. /**
  63581. * Gets wether or not the texture is blocking during loading.
  63582. */
  63583. get isBlocking(): boolean;
  63584. protected _rotationY: number;
  63585. /**
  63586. * Sets texture matrix rotation angle around Y axis in radians.
  63587. */
  63588. set rotationY(value: number);
  63589. /**
  63590. * Gets texture matrix rotation angle around Y axis radians.
  63591. */
  63592. get rotationY(): number;
  63593. /**
  63594. * Gets or sets the center of the bounding box associated with the cube texture
  63595. * It must define where the camera used to render the texture was set
  63596. */
  63597. boundingBoxPosition: Vector3;
  63598. private _boundingBoxSize;
  63599. /**
  63600. * Gets or sets the size of the bounding box associated with the cube texture
  63601. * When defined, the cubemap will switch to local mode
  63602. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63603. * @example https://www.babylonjs-playground.com/#RNASML
  63604. */
  63605. set boundingBoxSize(value: Vector3);
  63606. get boundingBoxSize(): Vector3;
  63607. /**
  63608. * Instantiates an HDRTexture from the following parameters.
  63609. *
  63610. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63611. * @param sceneOrEngine The scene or engine the texture will be used in
  63612. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63613. * @param noMipmap Forces to not generate the mipmap if true
  63614. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63615. * @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)
  63616. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63617. */
  63618. 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>);
  63619. /**
  63620. * Get the current class name of the texture useful for serialization or dynamic coding.
  63621. * @returns "HDRCubeTexture"
  63622. */
  63623. getClassName(): string;
  63624. /**
  63625. * Occurs when the file is raw .hdr file.
  63626. */
  63627. private loadTexture;
  63628. clone(): HDRCubeTexture;
  63629. delayLoad(): void;
  63630. /**
  63631. * Get the texture reflection matrix used to rotate/transform the reflection.
  63632. * @returns the reflection matrix
  63633. */
  63634. getReflectionTextureMatrix(): Matrix;
  63635. /**
  63636. * Set the texture reflection matrix used to rotate/transform the reflection.
  63637. * @param value Define the reflection matrix to set
  63638. */
  63639. setReflectionTextureMatrix(value: Matrix): void;
  63640. /**
  63641. * Parses a JSON representation of an HDR Texture in order to create the texture
  63642. * @param parsedTexture Define the JSON representation
  63643. * @param scene Define the scene the texture should be created in
  63644. * @param rootUrl Define the root url in case we need to load relative dependencies
  63645. * @returns the newly created texture after parsing
  63646. */
  63647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63648. serialize(): any;
  63649. }
  63650. }
  63651. declare module "babylonjs/Physics/physicsEngine" {
  63652. import { Nullable } from "babylonjs/types";
  63653. import { Vector3 } from "babylonjs/Maths/math.vector";
  63654. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63655. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63656. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63657. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63658. /**
  63659. * Class used to control physics engine
  63660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63661. */
  63662. export class PhysicsEngine implements IPhysicsEngine {
  63663. private _physicsPlugin;
  63664. /**
  63665. * Global value used to control the smallest number supported by the simulation
  63666. */
  63667. static Epsilon: number;
  63668. private _impostors;
  63669. private _joints;
  63670. private _subTimeStep;
  63671. /**
  63672. * Gets the gravity vector used by the simulation
  63673. */
  63674. gravity: Vector3;
  63675. /**
  63676. * Factory used to create the default physics plugin.
  63677. * @returns The default physics plugin
  63678. */
  63679. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63680. /**
  63681. * Creates a new Physics Engine
  63682. * @param gravity defines the gravity vector used by the simulation
  63683. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63684. */
  63685. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63686. /**
  63687. * Sets the gravity vector used by the simulation
  63688. * @param gravity defines the gravity vector to use
  63689. */
  63690. setGravity(gravity: Vector3): void;
  63691. /**
  63692. * Set the time step of the physics engine.
  63693. * Default is 1/60.
  63694. * To slow it down, enter 1/600 for example.
  63695. * To speed it up, 1/30
  63696. * @param newTimeStep defines the new timestep to apply to this world.
  63697. */
  63698. setTimeStep(newTimeStep?: number): void;
  63699. /**
  63700. * Get the time step of the physics engine.
  63701. * @returns the current time step
  63702. */
  63703. getTimeStep(): number;
  63704. /**
  63705. * Set the sub time step of the physics engine.
  63706. * Default is 0 meaning there is no sub steps
  63707. * To increase physics resolution precision, set a small value (like 1 ms)
  63708. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63709. */
  63710. setSubTimeStep(subTimeStep?: number): void;
  63711. /**
  63712. * Get the sub time step of the physics engine.
  63713. * @returns the current sub time step
  63714. */
  63715. getSubTimeStep(): number;
  63716. /**
  63717. * Release all resources
  63718. */
  63719. dispose(): void;
  63720. /**
  63721. * Gets the name of the current physics plugin
  63722. * @returns the name of the plugin
  63723. */
  63724. getPhysicsPluginName(): string;
  63725. /**
  63726. * Adding a new impostor for the impostor tracking.
  63727. * This will be done by the impostor itself.
  63728. * @param impostor the impostor to add
  63729. */
  63730. addImpostor(impostor: PhysicsImpostor): void;
  63731. /**
  63732. * Remove an impostor from the engine.
  63733. * This impostor and its mesh will not longer be updated by the physics engine.
  63734. * @param impostor the impostor to remove
  63735. */
  63736. removeImpostor(impostor: PhysicsImpostor): void;
  63737. /**
  63738. * Add a joint to the physics engine
  63739. * @param mainImpostor defines the main impostor to which the joint is added.
  63740. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63741. * @param joint defines the joint that will connect both impostors.
  63742. */
  63743. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63744. /**
  63745. * Removes a joint from the simulation
  63746. * @param mainImpostor defines the impostor used with the joint
  63747. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63748. * @param joint defines the joint to remove
  63749. */
  63750. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63751. /**
  63752. * Called by the scene. No need to call it.
  63753. * @param delta defines the timespam between frames
  63754. */
  63755. _step(delta: number): void;
  63756. /**
  63757. * Gets the current plugin used to run the simulation
  63758. * @returns current plugin
  63759. */
  63760. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63761. /**
  63762. * Gets the list of physic impostors
  63763. * @returns an array of PhysicsImpostor
  63764. */
  63765. getImpostors(): Array<PhysicsImpostor>;
  63766. /**
  63767. * Gets the impostor for a physics enabled object
  63768. * @param object defines the object impersonated by the impostor
  63769. * @returns the PhysicsImpostor or null if not found
  63770. */
  63771. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63772. /**
  63773. * Gets the impostor for a physics body object
  63774. * @param body defines physics body used by the impostor
  63775. * @returns the PhysicsImpostor or null if not found
  63776. */
  63777. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63778. /**
  63779. * Does a raycast in the physics world
  63780. * @param from when should the ray start?
  63781. * @param to when should the ray end?
  63782. * @returns PhysicsRaycastResult
  63783. */
  63784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63785. }
  63786. }
  63787. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63788. import { Nullable } from "babylonjs/types";
  63789. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63791. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63792. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63793. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63794. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63795. /** @hidden */
  63796. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63797. private _useDeltaForWorldStep;
  63798. world: any;
  63799. name: string;
  63800. private _physicsMaterials;
  63801. private _fixedTimeStep;
  63802. private _cannonRaycastResult;
  63803. private _raycastResult;
  63804. private _physicsBodysToRemoveAfterStep;
  63805. private _firstFrame;
  63806. BJSCANNON: any;
  63807. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63808. setGravity(gravity: Vector3): void;
  63809. setTimeStep(timeStep: number): void;
  63810. getTimeStep(): number;
  63811. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63812. private _removeMarkedPhysicsBodiesFromWorld;
  63813. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63815. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63816. private _processChildMeshes;
  63817. removePhysicsBody(impostor: PhysicsImpostor): void;
  63818. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63819. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63820. private _addMaterial;
  63821. private _checkWithEpsilon;
  63822. private _createShape;
  63823. private _createHeightmap;
  63824. private _minus90X;
  63825. private _plus90X;
  63826. private _tmpPosition;
  63827. private _tmpDeltaPosition;
  63828. private _tmpUnityRotation;
  63829. private _updatePhysicsBodyTransformation;
  63830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63831. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63832. isSupported(): boolean;
  63833. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63834. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63836. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63838. getBodyMass(impostor: PhysicsImpostor): number;
  63839. getBodyFriction(impostor: PhysicsImpostor): number;
  63840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63841. getBodyRestitution(impostor: PhysicsImpostor): number;
  63842. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63843. sleepBody(impostor: PhysicsImpostor): void;
  63844. wakeUpBody(impostor: PhysicsImpostor): void;
  63845. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63846. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63848. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63849. getRadius(impostor: PhysicsImpostor): number;
  63850. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63851. dispose(): void;
  63852. private _extendNamespace;
  63853. /**
  63854. * Does a raycast in the physics world
  63855. * @param from when should the ray start?
  63856. * @param to when should the ray end?
  63857. * @returns PhysicsRaycastResult
  63858. */
  63859. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63860. }
  63861. }
  63862. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63863. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63864. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63865. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63867. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63868. import { Nullable } from "babylonjs/types";
  63869. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63870. /** @hidden */
  63871. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63872. private _useDeltaForWorldStep;
  63873. world: any;
  63874. name: string;
  63875. BJSOIMO: any;
  63876. private _raycastResult;
  63877. private _fixedTimeStep;
  63878. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63879. setGravity(gravity: Vector3): void;
  63880. setTimeStep(timeStep: number): void;
  63881. getTimeStep(): number;
  63882. private _tmpImpostorsArray;
  63883. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63884. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63885. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63886. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63887. private _tmpPositionVector;
  63888. removePhysicsBody(impostor: PhysicsImpostor): void;
  63889. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63890. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63891. isSupported(): boolean;
  63892. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63893. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63899. getBodyMass(impostor: PhysicsImpostor): number;
  63900. getBodyFriction(impostor: PhysicsImpostor): number;
  63901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63902. getBodyRestitution(impostor: PhysicsImpostor): number;
  63903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63904. sleepBody(impostor: PhysicsImpostor): void;
  63905. wakeUpBody(impostor: PhysicsImpostor): void;
  63906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63907. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63910. getRadius(impostor: PhysicsImpostor): number;
  63911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63912. dispose(): void;
  63913. /**
  63914. * Does a raycast in the physics world
  63915. * @param from when should the ray start?
  63916. * @param to when should the ray end?
  63917. * @returns PhysicsRaycastResult
  63918. */
  63919. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63920. }
  63921. }
  63922. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63923. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63924. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63925. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63926. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63927. import { Nullable } from "babylonjs/types";
  63928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63929. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63930. /**
  63931. * AmmoJS Physics plugin
  63932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63933. * @see https://github.com/kripken/ammo.js/
  63934. */
  63935. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63936. private _useDeltaForWorldStep;
  63937. /**
  63938. * Reference to the Ammo library
  63939. */
  63940. bjsAMMO: any;
  63941. /**
  63942. * Created ammoJS world which physics bodies are added to
  63943. */
  63944. world: any;
  63945. /**
  63946. * Name of the plugin
  63947. */
  63948. name: string;
  63949. private _timeStep;
  63950. private _fixedTimeStep;
  63951. private _maxSteps;
  63952. private _tmpQuaternion;
  63953. private _tmpAmmoTransform;
  63954. private _tmpAmmoQuaternion;
  63955. private _tmpAmmoConcreteContactResultCallback;
  63956. private _collisionConfiguration;
  63957. private _dispatcher;
  63958. private _overlappingPairCache;
  63959. private _solver;
  63960. private _softBodySolver;
  63961. private _tmpAmmoVectorA;
  63962. private _tmpAmmoVectorB;
  63963. private _tmpAmmoVectorC;
  63964. private _tmpAmmoVectorD;
  63965. private _tmpContactCallbackResult;
  63966. private _tmpAmmoVectorRCA;
  63967. private _tmpAmmoVectorRCB;
  63968. private _raycastResult;
  63969. private static readonly DISABLE_COLLISION_FLAG;
  63970. private static readonly KINEMATIC_FLAG;
  63971. private static readonly DISABLE_DEACTIVATION_FLAG;
  63972. /**
  63973. * Initializes the ammoJS plugin
  63974. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63975. * @param ammoInjection can be used to inject your own ammo reference
  63976. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63977. */
  63978. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63979. /**
  63980. * Sets the gravity of the physics world (m/(s^2))
  63981. * @param gravity Gravity to set
  63982. */
  63983. setGravity(gravity: Vector3): void;
  63984. /**
  63985. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63986. * @param timeStep timestep to use in seconds
  63987. */
  63988. setTimeStep(timeStep: number): void;
  63989. /**
  63990. * 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)
  63991. * @param fixedTimeStep fixedTimeStep to use in seconds
  63992. */
  63993. setFixedTimeStep(fixedTimeStep: number): void;
  63994. /**
  63995. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63996. * @param maxSteps the maximum number of steps by the physics engine per frame
  63997. */
  63998. setMaxSteps(maxSteps: number): void;
  63999. /**
  64000. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64001. * @returns the current timestep in seconds
  64002. */
  64003. getTimeStep(): number;
  64004. /**
  64005. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64006. */
  64007. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64008. private _isImpostorInContact;
  64009. private _isImpostorPairInContact;
  64010. private _stepSimulation;
  64011. /**
  64012. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64013. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64014. * After the step the babylon meshes are set to the position of the physics imposters
  64015. * @param delta amount of time to step forward
  64016. * @param impostors array of imposters to update before/after the step
  64017. */
  64018. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64019. /**
  64020. * Update babylon mesh to match physics world object
  64021. * @param impostor imposter to match
  64022. */
  64023. private _afterSoftStep;
  64024. /**
  64025. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64026. * @param impostor imposter to match
  64027. */
  64028. private _ropeStep;
  64029. /**
  64030. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64031. * @param impostor imposter to match
  64032. */
  64033. private _softbodyOrClothStep;
  64034. private _tmpMatrix;
  64035. /**
  64036. * Applies an impulse on the imposter
  64037. * @param impostor imposter to apply impulse to
  64038. * @param force amount of force to be applied to the imposter
  64039. * @param contactPoint the location to apply the impulse on the imposter
  64040. */
  64041. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64042. /**
  64043. * Applies a force on the imposter
  64044. * @param impostor imposter to apply force
  64045. * @param force amount of force to be applied to the imposter
  64046. * @param contactPoint the location to apply the force on the imposter
  64047. */
  64048. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64049. /**
  64050. * Creates a physics body using the plugin
  64051. * @param impostor the imposter to create the physics body on
  64052. */
  64053. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64054. /**
  64055. * Removes the physics body from the imposter and disposes of the body's memory
  64056. * @param impostor imposter to remove the physics body from
  64057. */
  64058. removePhysicsBody(impostor: PhysicsImpostor): void;
  64059. /**
  64060. * Generates a joint
  64061. * @param impostorJoint the imposter joint to create the joint with
  64062. */
  64063. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64064. /**
  64065. * Removes a joint
  64066. * @param impostorJoint the imposter joint to remove the joint from
  64067. */
  64068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64069. private _addMeshVerts;
  64070. /**
  64071. * Initialise the soft body vertices to match its object's (mesh) vertices
  64072. * Softbody vertices (nodes) are in world space and to match this
  64073. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64074. * @param impostor to create the softbody for
  64075. */
  64076. private _softVertexData;
  64077. /**
  64078. * Create an impostor's soft body
  64079. * @param impostor to create the softbody for
  64080. */
  64081. private _createSoftbody;
  64082. /**
  64083. * Create cloth for an impostor
  64084. * @param impostor to create the softbody for
  64085. */
  64086. private _createCloth;
  64087. /**
  64088. * Create rope for an impostor
  64089. * @param impostor to create the softbody for
  64090. */
  64091. private _createRope;
  64092. /**
  64093. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64094. * @param impostor to create the custom physics shape for
  64095. */
  64096. private _createCustom;
  64097. private _addHullVerts;
  64098. private _createShape;
  64099. /**
  64100. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64101. * @param impostor imposter containing the physics body and babylon object
  64102. */
  64103. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64104. /**
  64105. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64106. * @param impostor imposter containing the physics body and babylon object
  64107. * @param newPosition new position
  64108. * @param newRotation new rotation
  64109. */
  64110. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64111. /**
  64112. * If this plugin is supported
  64113. * @returns true if its supported
  64114. */
  64115. isSupported(): boolean;
  64116. /**
  64117. * Sets the linear velocity of the physics body
  64118. * @param impostor imposter to set the velocity on
  64119. * @param velocity velocity to set
  64120. */
  64121. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64122. /**
  64123. * Sets the angular velocity of the physics body
  64124. * @param impostor imposter to set the velocity on
  64125. * @param velocity velocity to set
  64126. */
  64127. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64128. /**
  64129. * gets the linear velocity
  64130. * @param impostor imposter to get linear velocity from
  64131. * @returns linear velocity
  64132. */
  64133. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64134. /**
  64135. * gets the angular velocity
  64136. * @param impostor imposter to get angular velocity from
  64137. * @returns angular velocity
  64138. */
  64139. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64140. /**
  64141. * Sets the mass of physics body
  64142. * @param impostor imposter to set the mass on
  64143. * @param mass mass to set
  64144. */
  64145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64146. /**
  64147. * Gets the mass of the physics body
  64148. * @param impostor imposter to get the mass from
  64149. * @returns mass
  64150. */
  64151. getBodyMass(impostor: PhysicsImpostor): number;
  64152. /**
  64153. * Gets friction of the impostor
  64154. * @param impostor impostor to get friction from
  64155. * @returns friction value
  64156. */
  64157. getBodyFriction(impostor: PhysicsImpostor): number;
  64158. /**
  64159. * Sets friction of the impostor
  64160. * @param impostor impostor to set friction on
  64161. * @param friction friction value
  64162. */
  64163. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64164. /**
  64165. * Gets restitution of the impostor
  64166. * @param impostor impostor to get restitution from
  64167. * @returns restitution value
  64168. */
  64169. getBodyRestitution(impostor: PhysicsImpostor): number;
  64170. /**
  64171. * Sets resitution of the impostor
  64172. * @param impostor impostor to set resitution on
  64173. * @param restitution resitution value
  64174. */
  64175. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64176. /**
  64177. * Gets pressure inside the impostor
  64178. * @param impostor impostor to get pressure from
  64179. * @returns pressure value
  64180. */
  64181. getBodyPressure(impostor: PhysicsImpostor): number;
  64182. /**
  64183. * Sets pressure inside a soft body impostor
  64184. * Cloth and rope must remain 0 pressure
  64185. * @param impostor impostor to set pressure on
  64186. * @param pressure pressure value
  64187. */
  64188. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64189. /**
  64190. * Gets stiffness of the impostor
  64191. * @param impostor impostor to get stiffness from
  64192. * @returns pressure value
  64193. */
  64194. getBodyStiffness(impostor: PhysicsImpostor): number;
  64195. /**
  64196. * Sets stiffness of the impostor
  64197. * @param impostor impostor to set stiffness on
  64198. * @param stiffness stiffness value from 0 to 1
  64199. */
  64200. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64201. /**
  64202. * Gets velocityIterations of the impostor
  64203. * @param impostor impostor to get velocity iterations from
  64204. * @returns velocityIterations value
  64205. */
  64206. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64207. /**
  64208. * Sets velocityIterations of the impostor
  64209. * @param impostor impostor to set velocity iterations on
  64210. * @param velocityIterations velocityIterations value
  64211. */
  64212. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64213. /**
  64214. * Gets positionIterations of the impostor
  64215. * @param impostor impostor to get position iterations from
  64216. * @returns positionIterations value
  64217. */
  64218. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64219. /**
  64220. * Sets positionIterations of the impostor
  64221. * @param impostor impostor to set position on
  64222. * @param positionIterations positionIterations value
  64223. */
  64224. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64225. /**
  64226. * Append an anchor to a cloth object
  64227. * @param impostor is the cloth impostor to add anchor to
  64228. * @param otherImpostor is the rigid impostor to anchor to
  64229. * @param width ratio across width from 0 to 1
  64230. * @param height ratio up height from 0 to 1
  64231. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64232. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64233. */
  64234. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64235. /**
  64236. * Append an hook to a rope object
  64237. * @param impostor is the rope impostor to add hook to
  64238. * @param otherImpostor is the rigid impostor to hook to
  64239. * @param length ratio along the rope from 0 to 1
  64240. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64241. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64242. */
  64243. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64244. /**
  64245. * Sleeps the physics body and stops it from being active
  64246. * @param impostor impostor to sleep
  64247. */
  64248. sleepBody(impostor: PhysicsImpostor): void;
  64249. /**
  64250. * Activates the physics body
  64251. * @param impostor impostor to activate
  64252. */
  64253. wakeUpBody(impostor: PhysicsImpostor): void;
  64254. /**
  64255. * Updates the distance parameters of the joint
  64256. * @param joint joint to update
  64257. * @param maxDistance maximum distance of the joint
  64258. * @param minDistance minimum distance of the joint
  64259. */
  64260. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64261. /**
  64262. * Sets a motor on the joint
  64263. * @param joint joint to set motor on
  64264. * @param speed speed of the motor
  64265. * @param maxForce maximum force of the motor
  64266. * @param motorIndex index of the motor
  64267. */
  64268. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64269. /**
  64270. * Sets the motors limit
  64271. * @param joint joint to set limit on
  64272. * @param upperLimit upper limit
  64273. * @param lowerLimit lower limit
  64274. */
  64275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64276. /**
  64277. * Syncs the position and rotation of a mesh with the impostor
  64278. * @param mesh mesh to sync
  64279. * @param impostor impostor to update the mesh with
  64280. */
  64281. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64282. /**
  64283. * Gets the radius of the impostor
  64284. * @param impostor impostor to get radius from
  64285. * @returns the radius
  64286. */
  64287. getRadius(impostor: PhysicsImpostor): number;
  64288. /**
  64289. * Gets the box size of the impostor
  64290. * @param impostor impostor to get box size from
  64291. * @param result the resulting box size
  64292. */
  64293. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64294. /**
  64295. * Disposes of the impostor
  64296. */
  64297. dispose(): void;
  64298. /**
  64299. * Does a raycast in the physics world
  64300. * @param from when should the ray start?
  64301. * @param to when should the ray end?
  64302. * @returns PhysicsRaycastResult
  64303. */
  64304. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64305. }
  64306. }
  64307. declare module "babylonjs/Probes/reflectionProbe" {
  64308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64309. import { Vector3 } from "babylonjs/Maths/math.vector";
  64310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64311. import { Nullable } from "babylonjs/types";
  64312. import { Scene } from "babylonjs/scene";
  64313. module "babylonjs/abstractScene" {
  64314. interface AbstractScene {
  64315. /**
  64316. * The list of reflection probes added to the scene
  64317. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64318. */
  64319. reflectionProbes: Array<ReflectionProbe>;
  64320. /**
  64321. * Removes the given reflection probe from this scene.
  64322. * @param toRemove The reflection probe to remove
  64323. * @returns The index of the removed reflection probe
  64324. */
  64325. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64326. /**
  64327. * Adds the given reflection probe to this scene.
  64328. * @param newReflectionProbe The reflection probe to add
  64329. */
  64330. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64331. }
  64332. }
  64333. /**
  64334. * Class used to generate realtime reflection / refraction cube textures
  64335. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64336. */
  64337. export class ReflectionProbe {
  64338. /** defines the name of the probe */
  64339. name: string;
  64340. private _scene;
  64341. private _renderTargetTexture;
  64342. private _projectionMatrix;
  64343. private _viewMatrix;
  64344. private _target;
  64345. private _add;
  64346. private _attachedMesh;
  64347. private _invertYAxis;
  64348. /** Gets or sets probe position (center of the cube map) */
  64349. position: Vector3;
  64350. /**
  64351. * Creates a new reflection probe
  64352. * @param name defines the name of the probe
  64353. * @param size defines the texture resolution (for each face)
  64354. * @param scene defines the hosting scene
  64355. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64356. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64357. */
  64358. constructor(
  64359. /** defines the name of the probe */
  64360. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64361. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64362. get samples(): number;
  64363. set samples(value: number);
  64364. /** Gets or sets the refresh rate to use (on every frame by default) */
  64365. get refreshRate(): number;
  64366. set refreshRate(value: number);
  64367. /**
  64368. * Gets the hosting scene
  64369. * @returns a Scene
  64370. */
  64371. getScene(): Scene;
  64372. /** Gets the internal CubeTexture used to render to */
  64373. get cubeTexture(): RenderTargetTexture;
  64374. /** Gets the list of meshes to render */
  64375. get renderList(): Nullable<AbstractMesh[]>;
  64376. /**
  64377. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64378. * @param mesh defines the mesh to attach to
  64379. */
  64380. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64381. /**
  64382. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64383. * @param renderingGroupId The rendering group id corresponding to its index
  64384. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64385. */
  64386. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64387. /**
  64388. * Clean all associated resources
  64389. */
  64390. dispose(): void;
  64391. /**
  64392. * Converts the reflection probe information to a readable string for debug purpose.
  64393. * @param fullDetails Supports for multiple levels of logging within scene loading
  64394. * @returns the human readable reflection probe info
  64395. */
  64396. toString(fullDetails?: boolean): string;
  64397. /**
  64398. * Get the class name of the relfection probe.
  64399. * @returns "ReflectionProbe"
  64400. */
  64401. getClassName(): string;
  64402. /**
  64403. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64404. * @returns The JSON representation of the texture
  64405. */
  64406. serialize(): any;
  64407. /**
  64408. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64409. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64410. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64411. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64412. * @returns The parsed reflection probe if successful
  64413. */
  64414. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64415. }
  64416. }
  64417. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64418. /** @hidden */
  64419. export var _BabylonLoaderRegistered: boolean;
  64420. /**
  64421. * Helps setting up some configuration for the babylon file loader.
  64422. */
  64423. export class BabylonFileLoaderConfiguration {
  64424. /**
  64425. * The loader does not allow injecting custom physix engine into the plugins.
  64426. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64427. * So you could set this variable to your engine import to make it work.
  64428. */
  64429. static LoaderInjectedPhysicsEngine: any;
  64430. }
  64431. }
  64432. declare module "babylonjs/Loading/Plugins/index" {
  64433. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64434. }
  64435. declare module "babylonjs/Loading/index" {
  64436. export * from "babylonjs/Loading/loadingScreen";
  64437. export * from "babylonjs/Loading/Plugins/index";
  64438. export * from "babylonjs/Loading/sceneLoader";
  64439. export * from "babylonjs/Loading/sceneLoaderFlags";
  64440. }
  64441. declare module "babylonjs/Materials/Background/index" {
  64442. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64443. }
  64444. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64445. import { Scene } from "babylonjs/scene";
  64446. import { Color3 } from "babylonjs/Maths/math.color";
  64447. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64449. /**
  64450. * The Physically based simple base material of BJS.
  64451. *
  64452. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64453. * It is used as the base class for both the specGloss and metalRough conventions.
  64454. */
  64455. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64456. /**
  64457. * Number of Simultaneous lights allowed on the material.
  64458. */
  64459. maxSimultaneousLights: number;
  64460. /**
  64461. * If sets to true, disables all the lights affecting the material.
  64462. */
  64463. disableLighting: boolean;
  64464. /**
  64465. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64466. */
  64467. environmentTexture: BaseTexture;
  64468. /**
  64469. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64470. */
  64471. invertNormalMapX: boolean;
  64472. /**
  64473. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64474. */
  64475. invertNormalMapY: boolean;
  64476. /**
  64477. * Normal map used in the model.
  64478. */
  64479. normalTexture: BaseTexture;
  64480. /**
  64481. * Emissivie color used to self-illuminate the model.
  64482. */
  64483. emissiveColor: Color3;
  64484. /**
  64485. * Emissivie texture used to self-illuminate the model.
  64486. */
  64487. emissiveTexture: BaseTexture;
  64488. /**
  64489. * Occlusion Channel Strenght.
  64490. */
  64491. occlusionStrength: number;
  64492. /**
  64493. * Occlusion Texture of the material (adding extra occlusion effects).
  64494. */
  64495. occlusionTexture: BaseTexture;
  64496. /**
  64497. * Defines the alpha limits in alpha test mode.
  64498. */
  64499. alphaCutOff: number;
  64500. /**
  64501. * Gets the current double sided mode.
  64502. */
  64503. get doubleSided(): boolean;
  64504. /**
  64505. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64506. */
  64507. set doubleSided(value: boolean);
  64508. /**
  64509. * Stores the pre-calculated light information of a mesh in a texture.
  64510. */
  64511. lightmapTexture: BaseTexture;
  64512. /**
  64513. * If true, the light map contains occlusion information instead of lighting info.
  64514. */
  64515. useLightmapAsShadowmap: boolean;
  64516. /**
  64517. * Instantiates a new PBRMaterial instance.
  64518. *
  64519. * @param name The material name
  64520. * @param scene The scene the material will be use in.
  64521. */
  64522. constructor(name: string, scene: Scene);
  64523. getClassName(): string;
  64524. }
  64525. }
  64526. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64527. import { Scene } from "babylonjs/scene";
  64528. import { Color3 } from "babylonjs/Maths/math.color";
  64529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64530. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64531. /**
  64532. * The PBR material of BJS following the metal roughness convention.
  64533. *
  64534. * This fits to the PBR convention in the GLTF definition:
  64535. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64536. */
  64537. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64538. /**
  64539. * The base color has two different interpretations depending on the value of metalness.
  64540. * When the material is a metal, the base color is the specific measured reflectance value
  64541. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64542. * of the material.
  64543. */
  64544. baseColor: Color3;
  64545. /**
  64546. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64547. * well as opacity information in the alpha channel.
  64548. */
  64549. baseTexture: BaseTexture;
  64550. /**
  64551. * Specifies the metallic scalar value of the material.
  64552. * Can also be used to scale the metalness values of the metallic texture.
  64553. */
  64554. metallic: number;
  64555. /**
  64556. * Specifies the roughness scalar value of the material.
  64557. * Can also be used to scale the roughness values of the metallic texture.
  64558. */
  64559. roughness: number;
  64560. /**
  64561. * Texture containing both the metallic value in the B channel and the
  64562. * roughness value in the G channel to keep better precision.
  64563. */
  64564. metallicRoughnessTexture: BaseTexture;
  64565. /**
  64566. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64567. *
  64568. * @param name The material name
  64569. * @param scene The scene the material will be use in.
  64570. */
  64571. constructor(name: string, scene: Scene);
  64572. /**
  64573. * Return the currrent class name of the material.
  64574. */
  64575. getClassName(): string;
  64576. /**
  64577. * Makes a duplicate of the current material.
  64578. * @param name - name to use for the new material.
  64579. */
  64580. clone(name: string): PBRMetallicRoughnessMaterial;
  64581. /**
  64582. * Serialize the material to a parsable JSON object.
  64583. */
  64584. serialize(): any;
  64585. /**
  64586. * Parses a JSON object correponding to the serialize function.
  64587. */
  64588. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64589. }
  64590. }
  64591. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64592. import { Scene } from "babylonjs/scene";
  64593. import { Color3 } from "babylonjs/Maths/math.color";
  64594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64595. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64596. /**
  64597. * The PBR material of BJS following the specular glossiness convention.
  64598. *
  64599. * This fits to the PBR convention in the GLTF definition:
  64600. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64601. */
  64602. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64603. /**
  64604. * Specifies the diffuse color of the material.
  64605. */
  64606. diffuseColor: Color3;
  64607. /**
  64608. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64609. * channel.
  64610. */
  64611. diffuseTexture: BaseTexture;
  64612. /**
  64613. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64614. */
  64615. specularColor: Color3;
  64616. /**
  64617. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64618. */
  64619. glossiness: number;
  64620. /**
  64621. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64622. */
  64623. specularGlossinessTexture: BaseTexture;
  64624. /**
  64625. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64626. *
  64627. * @param name The material name
  64628. * @param scene The scene the material will be use in.
  64629. */
  64630. constructor(name: string, scene: Scene);
  64631. /**
  64632. * Return the currrent class name of the material.
  64633. */
  64634. getClassName(): string;
  64635. /**
  64636. * Makes a duplicate of the current material.
  64637. * @param name - name to use for the new material.
  64638. */
  64639. clone(name: string): PBRSpecularGlossinessMaterial;
  64640. /**
  64641. * Serialize the material to a parsable JSON object.
  64642. */
  64643. serialize(): any;
  64644. /**
  64645. * Parses a JSON object correponding to the serialize function.
  64646. */
  64647. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64648. }
  64649. }
  64650. declare module "babylonjs/Materials/PBR/index" {
  64651. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64652. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64653. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64654. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64655. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64656. }
  64657. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64658. import { Nullable } from "babylonjs/types";
  64659. import { Scene } from "babylonjs/scene";
  64660. import { Matrix } from "babylonjs/Maths/math.vector";
  64661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64662. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64663. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64664. /**
  64665. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64666. * It can help converting any input color in a desired output one. This can then be used to create effects
  64667. * from sepia, black and white to sixties or futuristic rendering...
  64668. *
  64669. * The only supported format is currently 3dl.
  64670. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64671. */
  64672. export class ColorGradingTexture extends BaseTexture {
  64673. /**
  64674. * The texture URL.
  64675. */
  64676. url: string;
  64677. /**
  64678. * Empty line regex stored for GC.
  64679. */
  64680. private static _noneEmptyLineRegex;
  64681. private _textureMatrix;
  64682. private _onLoad;
  64683. /**
  64684. * Instantiates a ColorGradingTexture from the following parameters.
  64685. *
  64686. * @param url The location of the color gradind data (currently only supporting 3dl)
  64687. * @param sceneOrEngine The scene or engine the texture will be used in
  64688. * @param onLoad defines a callback triggered when the texture has been loaded
  64689. */
  64690. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64691. /**
  64692. * Fires the onload event from the constructor if requested.
  64693. */
  64694. private _triggerOnLoad;
  64695. /**
  64696. * Returns the texture matrix used in most of the material.
  64697. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64698. */
  64699. getTextureMatrix(): Matrix;
  64700. /**
  64701. * Occurs when the file being loaded is a .3dl LUT file.
  64702. */
  64703. private load3dlTexture;
  64704. /**
  64705. * Starts the loading process of the texture.
  64706. */
  64707. private loadTexture;
  64708. /**
  64709. * Clones the color gradind texture.
  64710. */
  64711. clone(): ColorGradingTexture;
  64712. /**
  64713. * Called during delayed load for textures.
  64714. */
  64715. delayLoad(): void;
  64716. /**
  64717. * Parses a color grading texture serialized by Babylon.
  64718. * @param parsedTexture The texture information being parsedTexture
  64719. * @param scene The scene to load the texture in
  64720. * @param rootUrl The root url of the data assets to load
  64721. * @return A color gradind texture
  64722. */
  64723. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64724. /**
  64725. * Serializes the LUT texture to json format.
  64726. */
  64727. serialize(): any;
  64728. }
  64729. }
  64730. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64732. import { Scene } from "babylonjs/scene";
  64733. import { Nullable } from "babylonjs/types";
  64734. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64735. /**
  64736. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64737. */
  64738. export class EquiRectangularCubeTexture extends BaseTexture {
  64739. /** The six faces of the cube. */
  64740. private static _FacesMapping;
  64741. private _noMipmap;
  64742. private _onLoad;
  64743. private _onError;
  64744. /** The size of the cubemap. */
  64745. private _size;
  64746. /** The buffer of the image. */
  64747. private _buffer;
  64748. /** The width of the input image. */
  64749. private _width;
  64750. /** The height of the input image. */
  64751. private _height;
  64752. /** The URL to the image. */
  64753. url: string;
  64754. /**
  64755. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64756. * @param url The location of the image
  64757. * @param scene The scene the texture will be used in
  64758. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64759. * @param noMipmap Forces to not generate the mipmap if true
  64760. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64761. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64762. * @param onLoad — defines a callback called when texture is loaded
  64763. * @param onError — defines a callback called if there is an error
  64764. */
  64765. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64766. /**
  64767. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64768. */
  64769. private loadImage;
  64770. /**
  64771. * Convert the image buffer into a cubemap and create a CubeTexture.
  64772. */
  64773. private loadTexture;
  64774. /**
  64775. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64776. * @param buffer The ArrayBuffer that should be converted.
  64777. * @returns The buffer as Float32Array.
  64778. */
  64779. private getFloat32ArrayFromArrayBuffer;
  64780. /**
  64781. * Get the current class name of the texture useful for serialization or dynamic coding.
  64782. * @returns "EquiRectangularCubeTexture"
  64783. */
  64784. getClassName(): string;
  64785. /**
  64786. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64787. * @returns A clone of the current EquiRectangularCubeTexture.
  64788. */
  64789. clone(): EquiRectangularCubeTexture;
  64790. }
  64791. }
  64792. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64793. import { Nullable } from "babylonjs/types";
  64794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64795. import { Matrix } from "babylonjs/Maths/math.vector";
  64796. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64797. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64798. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64799. import { Scene } from "babylonjs/scene";
  64800. /**
  64801. * Defines the options related to the creation of an HtmlElementTexture
  64802. */
  64803. export interface IHtmlElementTextureOptions {
  64804. /**
  64805. * Defines wether mip maps should be created or not.
  64806. */
  64807. generateMipMaps?: boolean;
  64808. /**
  64809. * Defines the sampling mode of the texture.
  64810. */
  64811. samplingMode?: number;
  64812. /**
  64813. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64814. */
  64815. engine: Nullable<ThinEngine>;
  64816. /**
  64817. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64818. */
  64819. scene: Nullable<Scene>;
  64820. }
  64821. /**
  64822. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64823. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64824. * is automatically managed.
  64825. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64826. * in your application.
  64827. *
  64828. * As the update is not automatic, you need to call them manually.
  64829. */
  64830. export class HtmlElementTexture extends BaseTexture {
  64831. /**
  64832. * The texture URL.
  64833. */
  64834. element: HTMLVideoElement | HTMLCanvasElement;
  64835. private static readonly DefaultOptions;
  64836. private _textureMatrix;
  64837. private _isVideo;
  64838. private _generateMipMaps;
  64839. private _samplingMode;
  64840. /**
  64841. * Instantiates a HtmlElementTexture from the following parameters.
  64842. *
  64843. * @param name Defines the name of the texture
  64844. * @param element Defines the video or canvas the texture is filled with
  64845. * @param options Defines the other none mandatory texture creation options
  64846. */
  64847. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64848. private _createInternalTexture;
  64849. /**
  64850. * Returns the texture matrix used in most of the material.
  64851. */
  64852. getTextureMatrix(): Matrix;
  64853. /**
  64854. * Updates the content of the texture.
  64855. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64856. */
  64857. update(invertY?: Nullable<boolean>): void;
  64858. }
  64859. }
  64860. declare module "babylonjs/Misc/tga" {
  64861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64862. /**
  64863. * Based on jsTGALoader - Javascript loader for TGA file
  64864. * By Vincent Thibault
  64865. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64866. */
  64867. export class TGATools {
  64868. private static _TYPE_INDEXED;
  64869. private static _TYPE_RGB;
  64870. private static _TYPE_GREY;
  64871. private static _TYPE_RLE_INDEXED;
  64872. private static _TYPE_RLE_RGB;
  64873. private static _TYPE_RLE_GREY;
  64874. private static _ORIGIN_MASK;
  64875. private static _ORIGIN_SHIFT;
  64876. private static _ORIGIN_BL;
  64877. private static _ORIGIN_BR;
  64878. private static _ORIGIN_UL;
  64879. private static _ORIGIN_UR;
  64880. /**
  64881. * Gets the header of a TGA file
  64882. * @param data defines the TGA data
  64883. * @returns the header
  64884. */
  64885. static GetTGAHeader(data: Uint8Array): any;
  64886. /**
  64887. * Uploads TGA content to a Babylon Texture
  64888. * @hidden
  64889. */
  64890. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64891. /** @hidden */
  64892. 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;
  64893. /** @hidden */
  64894. 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;
  64895. /** @hidden */
  64896. 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;
  64897. /** @hidden */
  64898. 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;
  64899. /** @hidden */
  64900. 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;
  64901. /** @hidden */
  64902. 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;
  64903. }
  64904. }
  64905. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64906. import { Nullable } from "babylonjs/types";
  64907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64908. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64909. /**
  64910. * Implementation of the TGA Texture Loader.
  64911. * @hidden
  64912. */
  64913. export class _TGATextureLoader implements IInternalTextureLoader {
  64914. /**
  64915. * Defines wether the loader supports cascade loading the different faces.
  64916. */
  64917. readonly supportCascades: boolean;
  64918. /**
  64919. * This returns if the loader support the current file information.
  64920. * @param extension defines the file extension of the file being loaded
  64921. * @returns true if the loader can load the specified file
  64922. */
  64923. canLoad(extension: string): boolean;
  64924. /**
  64925. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64926. * @param data contains the texture data
  64927. * @param texture defines the BabylonJS internal texture
  64928. * @param createPolynomials will be true if polynomials have been requested
  64929. * @param onLoad defines the callback to trigger once the texture is ready
  64930. * @param onError defines the callback to trigger in case of error
  64931. */
  64932. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64933. /**
  64934. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64935. * @param data contains the texture data
  64936. * @param texture defines the BabylonJS internal texture
  64937. * @param callback defines the method to call once ready to upload
  64938. */
  64939. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64940. }
  64941. }
  64942. declare module "babylonjs/Misc/basis" {
  64943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64944. /**
  64945. * Info about the .basis files
  64946. */
  64947. class BasisFileInfo {
  64948. /**
  64949. * If the file has alpha
  64950. */
  64951. hasAlpha: boolean;
  64952. /**
  64953. * Info about each image of the basis file
  64954. */
  64955. images: Array<{
  64956. levels: Array<{
  64957. width: number;
  64958. height: number;
  64959. transcodedPixels: ArrayBufferView;
  64960. }>;
  64961. }>;
  64962. }
  64963. /**
  64964. * Result of transcoding a basis file
  64965. */
  64966. class TranscodeResult {
  64967. /**
  64968. * Info about the .basis file
  64969. */
  64970. fileInfo: BasisFileInfo;
  64971. /**
  64972. * Format to use when loading the file
  64973. */
  64974. format: number;
  64975. }
  64976. /**
  64977. * Configuration options for the Basis transcoder
  64978. */
  64979. export class BasisTranscodeConfiguration {
  64980. /**
  64981. * Supported compression formats used to determine the supported output format of the transcoder
  64982. */
  64983. supportedCompressionFormats?: {
  64984. /**
  64985. * etc1 compression format
  64986. */
  64987. etc1?: boolean;
  64988. /**
  64989. * s3tc compression format
  64990. */
  64991. s3tc?: boolean;
  64992. /**
  64993. * pvrtc compression format
  64994. */
  64995. pvrtc?: boolean;
  64996. /**
  64997. * etc2 compression format
  64998. */
  64999. etc2?: boolean;
  65000. };
  65001. /**
  65002. * If mipmap levels should be loaded for transcoded images (Default: true)
  65003. */
  65004. loadMipmapLevels?: boolean;
  65005. /**
  65006. * Index of a single image to load (Default: all images)
  65007. */
  65008. loadSingleImage?: number;
  65009. }
  65010. /**
  65011. * Used to load .Basis files
  65012. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65013. */
  65014. export class BasisTools {
  65015. private static _IgnoreSupportedFormats;
  65016. /**
  65017. * URL to use when loading the basis transcoder
  65018. */
  65019. static JSModuleURL: string;
  65020. /**
  65021. * URL to use when loading the wasm module for the transcoder
  65022. */
  65023. static WasmModuleURL: string;
  65024. /**
  65025. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65026. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65027. * @returns internal format corresponding to the Basis format
  65028. */
  65029. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65030. private static _WorkerPromise;
  65031. private static _Worker;
  65032. private static _actionId;
  65033. private static _CreateWorkerAsync;
  65034. /**
  65035. * Transcodes a loaded image file to compressed pixel data
  65036. * @param data image data to transcode
  65037. * @param config configuration options for the transcoding
  65038. * @returns a promise resulting in the transcoded image
  65039. */
  65040. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65041. /**
  65042. * Loads a texture from the transcode result
  65043. * @param texture texture load to
  65044. * @param transcodeResult the result of transcoding the basis file to load from
  65045. */
  65046. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65047. }
  65048. }
  65049. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65050. import { Nullable } from "babylonjs/types";
  65051. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65052. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65053. /**
  65054. * Loader for .basis file format
  65055. */
  65056. export class _BasisTextureLoader implements IInternalTextureLoader {
  65057. /**
  65058. * Defines whether the loader supports cascade loading the different faces.
  65059. */
  65060. readonly supportCascades: boolean;
  65061. /**
  65062. * This returns if the loader support the current file information.
  65063. * @param extension defines the file extension of the file being loaded
  65064. * @returns true if the loader can load the specified file
  65065. */
  65066. canLoad(extension: string): boolean;
  65067. /**
  65068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65069. * @param data contains the texture data
  65070. * @param texture defines the BabylonJS internal texture
  65071. * @param createPolynomials will be true if polynomials have been requested
  65072. * @param onLoad defines the callback to trigger once the texture is ready
  65073. * @param onError defines the callback to trigger in case of error
  65074. */
  65075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65076. /**
  65077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65078. * @param data contains the texture data
  65079. * @param texture defines the BabylonJS internal texture
  65080. * @param callback defines the method to call once ready to upload
  65081. */
  65082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65083. }
  65084. }
  65085. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65086. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65087. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65088. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65089. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65090. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65091. }
  65092. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65093. import { Vector2 } from "babylonjs/Maths/math.vector";
  65094. /**
  65095. * Defines the basic options interface of a TexturePacker Frame
  65096. */
  65097. export interface ITexturePackerFrame {
  65098. /**
  65099. * The frame ID
  65100. */
  65101. id: number;
  65102. /**
  65103. * The frames Scale
  65104. */
  65105. scale: Vector2;
  65106. /**
  65107. * The Frames offset
  65108. */
  65109. offset: Vector2;
  65110. }
  65111. /**
  65112. * This is a support class for frame Data on texture packer sets.
  65113. */
  65114. export class TexturePackerFrame implements ITexturePackerFrame {
  65115. /**
  65116. * The frame ID
  65117. */
  65118. id: number;
  65119. /**
  65120. * The frames Scale
  65121. */
  65122. scale: Vector2;
  65123. /**
  65124. * The Frames offset
  65125. */
  65126. offset: Vector2;
  65127. /**
  65128. * Initializes a texture package frame.
  65129. * @param id The numerical frame identifier
  65130. * @param scale Scalar Vector2 for UV frame
  65131. * @param offset Vector2 for the frame position in UV units.
  65132. * @returns TexturePackerFrame
  65133. */
  65134. constructor(id: number, scale: Vector2, offset: Vector2);
  65135. }
  65136. }
  65137. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65139. import { Scene } from "babylonjs/scene";
  65140. import { Nullable } from "babylonjs/types";
  65141. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65142. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65143. /**
  65144. * Defines the basic options interface of a TexturePacker
  65145. */
  65146. export interface ITexturePackerOptions {
  65147. /**
  65148. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65149. */
  65150. map?: string[];
  65151. /**
  65152. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65153. */
  65154. uvsIn?: string;
  65155. /**
  65156. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65157. */
  65158. uvsOut?: string;
  65159. /**
  65160. * number representing the layout style. Defaults to LAYOUT_STRIP
  65161. */
  65162. layout?: number;
  65163. /**
  65164. * number of columns if using custom column count layout(2). This defaults to 4.
  65165. */
  65166. colnum?: number;
  65167. /**
  65168. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65169. */
  65170. updateInputMeshes?: boolean;
  65171. /**
  65172. * boolean flag to dispose all the source textures. Defaults to true.
  65173. */
  65174. disposeSources?: boolean;
  65175. /**
  65176. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65177. */
  65178. fillBlanks?: boolean;
  65179. /**
  65180. * string value representing the context fill style color. Defaults to 'black'.
  65181. */
  65182. customFillColor?: string;
  65183. /**
  65184. * Width and Height Value of each Frame in the TexturePacker Sets
  65185. */
  65186. frameSize?: number;
  65187. /**
  65188. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65189. */
  65190. paddingRatio?: number;
  65191. /**
  65192. * Number that declares the fill method for the padding gutter.
  65193. */
  65194. paddingMode?: number;
  65195. /**
  65196. * If in SUBUV_COLOR padding mode what color to use.
  65197. */
  65198. paddingColor?: Color3 | Color4;
  65199. }
  65200. /**
  65201. * Defines the basic interface of a TexturePacker JSON File
  65202. */
  65203. export interface ITexturePackerJSON {
  65204. /**
  65205. * The frame ID
  65206. */
  65207. name: string;
  65208. /**
  65209. * The base64 channel data
  65210. */
  65211. sets: any;
  65212. /**
  65213. * The options of the Packer
  65214. */
  65215. options: ITexturePackerOptions;
  65216. /**
  65217. * The frame data of the Packer
  65218. */
  65219. frames: Array<number>;
  65220. }
  65221. /**
  65222. * This is a support class that generates a series of packed texture sets.
  65223. * @see https://doc.babylonjs.com/babylon101/materials
  65224. */
  65225. export class TexturePacker {
  65226. /** Packer Layout Constant 0 */
  65227. static readonly LAYOUT_STRIP: number;
  65228. /** Packer Layout Constant 1 */
  65229. static readonly LAYOUT_POWER2: number;
  65230. /** Packer Layout Constant 2 */
  65231. static readonly LAYOUT_COLNUM: number;
  65232. /** Packer Layout Constant 0 */
  65233. static readonly SUBUV_WRAP: number;
  65234. /** Packer Layout Constant 1 */
  65235. static readonly SUBUV_EXTEND: number;
  65236. /** Packer Layout Constant 2 */
  65237. static readonly SUBUV_COLOR: number;
  65238. /** The Name of the Texture Package */
  65239. name: string;
  65240. /** The scene scope of the TexturePacker */
  65241. scene: Scene;
  65242. /** The Meshes to target */
  65243. meshes: AbstractMesh[];
  65244. /** Arguments passed with the Constructor */
  65245. options: ITexturePackerOptions;
  65246. /** The promise that is started upon initialization */
  65247. promise: Nullable<Promise<TexturePacker | string>>;
  65248. /** The Container object for the channel sets that are generated */
  65249. sets: object;
  65250. /** The Container array for the frames that are generated */
  65251. frames: TexturePackerFrame[];
  65252. /** The expected number of textures the system is parsing. */
  65253. private _expecting;
  65254. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65255. private _paddingValue;
  65256. /**
  65257. * Initializes a texture package series from an array of meshes or a single mesh.
  65258. * @param name The name of the package
  65259. * @param meshes The target meshes to compose the package from
  65260. * @param options The arguments that texture packer should follow while building.
  65261. * @param scene The scene which the textures are scoped to.
  65262. * @returns TexturePacker
  65263. */
  65264. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65265. /**
  65266. * Starts the package process
  65267. * @param resolve The promises resolution function
  65268. * @returns TexturePacker
  65269. */
  65270. private _createFrames;
  65271. /**
  65272. * Calculates the Size of the Channel Sets
  65273. * @returns Vector2
  65274. */
  65275. private _calculateSize;
  65276. /**
  65277. * Calculates the UV data for the frames.
  65278. * @param baseSize the base frameSize
  65279. * @param padding the base frame padding
  65280. * @param dtSize size of the Dynamic Texture for that channel
  65281. * @param dtUnits is 1/dtSize
  65282. * @param update flag to update the input meshes
  65283. */
  65284. private _calculateMeshUVFrames;
  65285. /**
  65286. * Calculates the frames Offset.
  65287. * @param index of the frame
  65288. * @returns Vector2
  65289. */
  65290. private _getFrameOffset;
  65291. /**
  65292. * Updates a Mesh to the frame data
  65293. * @param mesh that is the target
  65294. * @param frameID or the frame index
  65295. */
  65296. private _updateMeshUV;
  65297. /**
  65298. * Updates a Meshes materials to use the texture packer channels
  65299. * @param m is the mesh to target
  65300. * @param force all channels on the packer to be set.
  65301. */
  65302. private _updateTextureReferences;
  65303. /**
  65304. * Public method to set a Mesh to a frame
  65305. * @param m that is the target
  65306. * @param frameID or the frame index
  65307. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65308. */
  65309. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65310. /**
  65311. * Starts the async promise to compile the texture packer.
  65312. * @returns Promise<void>
  65313. */
  65314. processAsync(): Promise<void>;
  65315. /**
  65316. * Disposes all textures associated with this packer
  65317. */
  65318. dispose(): void;
  65319. /**
  65320. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65321. * @param imageType is the image type to use.
  65322. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65323. */
  65324. download(imageType?: string, quality?: number): void;
  65325. /**
  65326. * Public method to load a texturePacker JSON file.
  65327. * @param data of the JSON file in string format.
  65328. */
  65329. updateFromJSON(data: string): void;
  65330. }
  65331. }
  65332. declare module "babylonjs/Materials/Textures/Packer/index" {
  65333. export * from "babylonjs/Materials/Textures/Packer/packer";
  65334. export * from "babylonjs/Materials/Textures/Packer/frame";
  65335. }
  65336. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65337. import { Scene } from "babylonjs/scene";
  65338. import { Texture } from "babylonjs/Materials/Textures/texture";
  65339. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65340. /**
  65341. * 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.
  65342. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65343. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65344. */
  65345. export class CustomProceduralTexture extends ProceduralTexture {
  65346. private _animate;
  65347. private _time;
  65348. private _config;
  65349. private _texturePath;
  65350. /**
  65351. * Instantiates a new Custom Procedural Texture.
  65352. * 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.
  65353. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65354. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65355. * @param name Define the name of the texture
  65356. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65357. * @param size Define the size of the texture to create
  65358. * @param scene Define the scene the texture belongs to
  65359. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65360. * @param generateMipMaps Define if the texture should creates mip maps or not
  65361. */
  65362. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65363. private _loadJson;
  65364. /**
  65365. * Is the texture ready to be used ? (rendered at least once)
  65366. * @returns true if ready, otherwise, false.
  65367. */
  65368. isReady(): boolean;
  65369. /**
  65370. * Render the texture to its associated render target.
  65371. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65372. */
  65373. render(useCameraPostProcess?: boolean): void;
  65374. /**
  65375. * Update the list of dependant textures samplers in the shader.
  65376. */
  65377. updateTextures(): void;
  65378. /**
  65379. * Update the uniform values of the procedural texture in the shader.
  65380. */
  65381. updateShaderUniforms(): void;
  65382. /**
  65383. * Define if the texture animates or not.
  65384. */
  65385. get animate(): boolean;
  65386. set animate(value: boolean);
  65387. }
  65388. }
  65389. declare module "babylonjs/Shaders/noise.fragment" {
  65390. /** @hidden */
  65391. export var noisePixelShader: {
  65392. name: string;
  65393. shader: string;
  65394. };
  65395. }
  65396. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65397. import { Nullable } from "babylonjs/types";
  65398. import { Scene } from "babylonjs/scene";
  65399. import { Texture } from "babylonjs/Materials/Textures/texture";
  65400. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65401. import "babylonjs/Shaders/noise.fragment";
  65402. /**
  65403. * Class used to generate noise procedural textures
  65404. */
  65405. export class NoiseProceduralTexture extends ProceduralTexture {
  65406. /** Gets or sets the start time (default is 0) */
  65407. time: number;
  65408. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65409. brightness: number;
  65410. /** Defines the number of octaves to process */
  65411. octaves: number;
  65412. /** Defines the level of persistence (0.8 by default) */
  65413. persistence: number;
  65414. /** Gets or sets animation speed factor (default is 1) */
  65415. animationSpeedFactor: number;
  65416. /**
  65417. * Creates a new NoiseProceduralTexture
  65418. * @param name defines the name fo the texture
  65419. * @param size defines the size of the texture (default is 256)
  65420. * @param scene defines the hosting scene
  65421. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65422. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65423. */
  65424. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65425. private _updateShaderUniforms;
  65426. protected _getDefines(): string;
  65427. /** Generate the current state of the procedural texture */
  65428. render(useCameraPostProcess?: boolean): void;
  65429. /**
  65430. * Serializes this noise procedural texture
  65431. * @returns a serialized noise procedural texture object
  65432. */
  65433. serialize(): any;
  65434. /**
  65435. * Clone the texture.
  65436. * @returns the cloned texture
  65437. */
  65438. clone(): NoiseProceduralTexture;
  65439. /**
  65440. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65441. * @param parsedTexture defines parsed texture data
  65442. * @param scene defines the current scene
  65443. * @param rootUrl defines the root URL containing noise procedural texture information
  65444. * @returns a parsed NoiseProceduralTexture
  65445. */
  65446. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65447. }
  65448. }
  65449. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65450. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65451. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65452. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65453. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65454. }
  65455. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65456. import { Nullable } from "babylonjs/types";
  65457. import { Scene } from "babylonjs/scene";
  65458. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65460. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65461. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65462. /**
  65463. * Raw cube texture where the raw buffers are passed in
  65464. */
  65465. export class RawCubeTexture extends CubeTexture {
  65466. /**
  65467. * Creates a cube texture where the raw buffers are passed in.
  65468. * @param scene defines the scene the texture is attached to
  65469. * @param data defines the array of data to use to create each face
  65470. * @param size defines the size of the textures
  65471. * @param format defines the format of the data
  65472. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65473. * @param generateMipMaps defines if the engine should generate the mip levels
  65474. * @param invertY defines if data must be stored with Y axis inverted
  65475. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65476. * @param compression defines the compression used (null by default)
  65477. */
  65478. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65479. /**
  65480. * Updates the raw cube texture.
  65481. * @param data defines the data to store
  65482. * @param format defines the data format
  65483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65484. * @param invertY defines if data must be stored with Y axis inverted
  65485. * @param compression defines the compression used (null by default)
  65486. * @param level defines which level of the texture to update
  65487. */
  65488. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65489. /**
  65490. * Updates a raw cube texture with RGBD encoded data.
  65491. * @param data defines the array of data [mipmap][face] to use to create each face
  65492. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65495. * @returns a promsie that resolves when the operation is complete
  65496. */
  65497. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65498. /**
  65499. * Clones the raw cube texture.
  65500. * @return a new cube texture
  65501. */
  65502. clone(): CubeTexture;
  65503. /** @hidden */
  65504. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65505. }
  65506. }
  65507. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65508. import { Scene } from "babylonjs/scene";
  65509. import { Texture } from "babylonjs/Materials/Textures/texture";
  65510. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65511. /**
  65512. * Class used to store 2D array textures containing user data
  65513. */
  65514. export class RawTexture2DArray extends Texture {
  65515. /** Gets or sets the texture format to use */
  65516. format: number;
  65517. /**
  65518. * Create a new RawTexture2DArray
  65519. * @param data defines the data of the texture
  65520. * @param width defines the width of the texture
  65521. * @param height defines the height of the texture
  65522. * @param depth defines the number of layers of the texture
  65523. * @param format defines the texture format to use
  65524. * @param scene defines the hosting scene
  65525. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65526. * @param invertY defines if texture must be stored with Y axis inverted
  65527. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65528. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65529. */
  65530. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65531. /** Gets or sets the texture format to use */
  65532. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65533. /**
  65534. * Update the texture with new data
  65535. * @param data defines the data to store in the texture
  65536. */
  65537. update(data: ArrayBufferView): void;
  65538. }
  65539. }
  65540. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65541. import { Scene } from "babylonjs/scene";
  65542. import { Texture } from "babylonjs/Materials/Textures/texture";
  65543. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65544. /**
  65545. * Class used to store 3D textures containing user data
  65546. */
  65547. export class RawTexture3D extends Texture {
  65548. /** Gets or sets the texture format to use */
  65549. format: number;
  65550. /**
  65551. * Create a new RawTexture3D
  65552. * @param data defines the data of the texture
  65553. * @param width defines the width of the texture
  65554. * @param height defines the height of the texture
  65555. * @param depth defines the depth of the texture
  65556. * @param format defines the texture format to use
  65557. * @param scene defines the hosting scene
  65558. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65559. * @param invertY defines if texture must be stored with Y axis inverted
  65560. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65562. */
  65563. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65564. /** Gets or sets the texture format to use */
  65565. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65566. /**
  65567. * Update the texture with new data
  65568. * @param data defines the data to store in the texture
  65569. */
  65570. update(data: ArrayBufferView): void;
  65571. }
  65572. }
  65573. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65574. import { Scene } from "babylonjs/scene";
  65575. import { Plane } from "babylonjs/Maths/math.plane";
  65576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65577. /**
  65578. * Creates a refraction texture used by refraction channel of the standard material.
  65579. * It is like a mirror but to see through a material.
  65580. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65581. */
  65582. export class RefractionTexture extends RenderTargetTexture {
  65583. /**
  65584. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65585. * 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.
  65586. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65587. */
  65588. refractionPlane: Plane;
  65589. /**
  65590. * Define how deep under the surface we should see.
  65591. */
  65592. depth: number;
  65593. /**
  65594. * Creates a refraction texture used by refraction channel of the standard material.
  65595. * It is like a mirror but to see through a material.
  65596. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65597. * @param name Define the texture name
  65598. * @param size Define the size of the underlying texture
  65599. * @param scene Define the scene the refraction belongs to
  65600. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65601. */
  65602. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65603. /**
  65604. * Clone the refraction texture.
  65605. * @returns the cloned texture
  65606. */
  65607. clone(): RefractionTexture;
  65608. /**
  65609. * Serialize the texture to a JSON representation you could use in Parse later on
  65610. * @returns the serialized JSON representation
  65611. */
  65612. serialize(): any;
  65613. }
  65614. }
  65615. declare module "babylonjs/Materials/Textures/index" {
  65616. export * from "babylonjs/Materials/Textures/baseTexture";
  65617. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65618. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65619. export * from "babylonjs/Materials/Textures/cubeTexture";
  65620. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65621. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65622. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65623. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65624. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65625. export * from "babylonjs/Materials/Textures/internalTexture";
  65626. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65627. export * from "babylonjs/Materials/Textures/Loaders/index";
  65628. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65629. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65630. export * from "babylonjs/Materials/Textures/Packer/index";
  65631. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65632. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65633. export * from "babylonjs/Materials/Textures/rawTexture";
  65634. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65635. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65636. export * from "babylonjs/Materials/Textures/refractionTexture";
  65637. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65638. export * from "babylonjs/Materials/Textures/texture";
  65639. export * from "babylonjs/Materials/Textures/videoTexture";
  65640. }
  65641. declare module "babylonjs/Materials/Node/Enums/index" {
  65642. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65643. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65644. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65645. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65646. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65647. }
  65648. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65652. import { Mesh } from "babylonjs/Meshes/mesh";
  65653. import { Effect } from "babylonjs/Materials/effect";
  65654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65655. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65656. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65657. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65658. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65659. /**
  65660. * Block used to add support for vertex skinning (bones)
  65661. */
  65662. export class BonesBlock extends NodeMaterialBlock {
  65663. /**
  65664. * Creates a new BonesBlock
  65665. * @param name defines the block name
  65666. */
  65667. constructor(name: string);
  65668. /**
  65669. * Initialize the block and prepare the context for build
  65670. * @param state defines the state that will be used for the build
  65671. */
  65672. initialize(state: NodeMaterialBuildState): void;
  65673. /**
  65674. * Gets the current class name
  65675. * @returns the class name
  65676. */
  65677. getClassName(): string;
  65678. /**
  65679. * Gets the matrix indices input component
  65680. */
  65681. get matricesIndices(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the matrix weights input component
  65684. */
  65685. get matricesWeights(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the extra matrix indices input component
  65688. */
  65689. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the extra matrix weights input component
  65692. */
  65693. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the world input component
  65696. */
  65697. get world(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the output component
  65700. */
  65701. get output(): NodeMaterialConnectionPoint;
  65702. autoConfigure(material: NodeMaterial): void;
  65703. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65706. protected _buildBlock(state: NodeMaterialBuildState): this;
  65707. }
  65708. }
  65709. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65716. /**
  65717. * Block used to add support for instances
  65718. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65719. */
  65720. export class InstancesBlock extends NodeMaterialBlock {
  65721. /**
  65722. * Creates a new InstancesBlock
  65723. * @param name defines the block name
  65724. */
  65725. constructor(name: string);
  65726. /**
  65727. * Gets the current class name
  65728. * @returns the class name
  65729. */
  65730. getClassName(): string;
  65731. /**
  65732. * Gets the first world row input component
  65733. */
  65734. get world0(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the second world row input component
  65737. */
  65738. get world1(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the third world row input component
  65741. */
  65742. get world2(): NodeMaterialConnectionPoint;
  65743. /**
  65744. * Gets the forth world row input component
  65745. */
  65746. get world3(): NodeMaterialConnectionPoint;
  65747. /**
  65748. * Gets the world input component
  65749. */
  65750. get world(): NodeMaterialConnectionPoint;
  65751. /**
  65752. * Gets the output component
  65753. */
  65754. get output(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the isntanceID component
  65757. */
  65758. get instanceID(): NodeMaterialConnectionPoint;
  65759. autoConfigure(material: NodeMaterial): void;
  65760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65761. protected _buildBlock(state: NodeMaterialBuildState): this;
  65762. }
  65763. }
  65764. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65769. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65770. import { Effect } from "babylonjs/Materials/effect";
  65771. import { Mesh } from "babylonjs/Meshes/mesh";
  65772. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65773. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65774. /**
  65775. * Block used to add morph targets support to vertex shader
  65776. */
  65777. export class MorphTargetsBlock extends NodeMaterialBlock {
  65778. private _repeatableContentAnchor;
  65779. /**
  65780. * Create a new MorphTargetsBlock
  65781. * @param name defines the block name
  65782. */
  65783. constructor(name: string);
  65784. /**
  65785. * Gets the current class name
  65786. * @returns the class name
  65787. */
  65788. getClassName(): string;
  65789. /**
  65790. * Gets the position input component
  65791. */
  65792. get position(): NodeMaterialConnectionPoint;
  65793. /**
  65794. * Gets the normal input component
  65795. */
  65796. get normal(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the tangent input component
  65799. */
  65800. get tangent(): NodeMaterialConnectionPoint;
  65801. /**
  65802. * Gets the tangent input component
  65803. */
  65804. get uv(): NodeMaterialConnectionPoint;
  65805. /**
  65806. * Gets the position output component
  65807. */
  65808. get positionOutput(): NodeMaterialConnectionPoint;
  65809. /**
  65810. * Gets the normal output component
  65811. */
  65812. get normalOutput(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the tangent output component
  65815. */
  65816. get tangentOutput(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the tangent output component
  65819. */
  65820. get uvOutput(): NodeMaterialConnectionPoint;
  65821. initialize(state: NodeMaterialBuildState): void;
  65822. autoConfigure(material: NodeMaterial): void;
  65823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65825. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65826. protected _buildBlock(state: NodeMaterialBuildState): this;
  65827. }
  65828. }
  65829. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65833. import { Nullable } from "babylonjs/types";
  65834. import { Scene } from "babylonjs/scene";
  65835. import { Effect } from "babylonjs/Materials/effect";
  65836. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65837. import { Mesh } from "babylonjs/Meshes/mesh";
  65838. import { Light } from "babylonjs/Lights/light";
  65839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65840. /**
  65841. * Block used to get data information from a light
  65842. */
  65843. export class LightInformationBlock extends NodeMaterialBlock {
  65844. private _lightDataUniformName;
  65845. private _lightColorUniformName;
  65846. private _lightTypeDefineName;
  65847. /**
  65848. * Gets or sets the light associated with this block
  65849. */
  65850. light: Nullable<Light>;
  65851. /**
  65852. * Creates a new LightInformationBlock
  65853. * @param name defines the block name
  65854. */
  65855. constructor(name: string);
  65856. /**
  65857. * Gets the current class name
  65858. * @returns the class name
  65859. */
  65860. getClassName(): string;
  65861. /**
  65862. * Gets the world position input component
  65863. */
  65864. get worldPosition(): NodeMaterialConnectionPoint;
  65865. /**
  65866. * Gets the direction output component
  65867. */
  65868. get direction(): NodeMaterialConnectionPoint;
  65869. /**
  65870. * Gets the direction output component
  65871. */
  65872. get color(): NodeMaterialConnectionPoint;
  65873. /**
  65874. * Gets the direction output component
  65875. */
  65876. get intensity(): NodeMaterialConnectionPoint;
  65877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65879. protected _buildBlock(state: NodeMaterialBuildState): this;
  65880. serialize(): any;
  65881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65882. }
  65883. }
  65884. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65885. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65886. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65887. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65888. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65889. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65890. }
  65891. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65896. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65897. import { Effect } from "babylonjs/Materials/effect";
  65898. import { Mesh } from "babylonjs/Meshes/mesh";
  65899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65900. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65901. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65902. /**
  65903. * Block used to add image processing support to fragment shader
  65904. */
  65905. export class ImageProcessingBlock extends NodeMaterialBlock {
  65906. /**
  65907. * Create a new ImageProcessingBlock
  65908. * @param name defines the block name
  65909. */
  65910. constructor(name: string);
  65911. /**
  65912. * Gets the current class name
  65913. * @returns the class name
  65914. */
  65915. getClassName(): string;
  65916. /**
  65917. * Gets the color input component
  65918. */
  65919. get color(): NodeMaterialConnectionPoint;
  65920. /**
  65921. * Gets the output component
  65922. */
  65923. get output(): NodeMaterialConnectionPoint;
  65924. /**
  65925. * Initialize the block and prepare the context for build
  65926. * @param state defines the state that will be used for the build
  65927. */
  65928. initialize(state: NodeMaterialBuildState): void;
  65929. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65932. protected _buildBlock(state: NodeMaterialBuildState): this;
  65933. }
  65934. }
  65935. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65939. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65941. import { Effect } from "babylonjs/Materials/effect";
  65942. import { Mesh } from "babylonjs/Meshes/mesh";
  65943. import { Scene } from "babylonjs/scene";
  65944. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65945. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65946. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65947. /**
  65948. * Block used to pertub normals based on a normal map
  65949. */
  65950. export class PerturbNormalBlock extends NodeMaterialBlock {
  65951. private _tangentSpaceParameterName;
  65952. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65953. invertX: boolean;
  65954. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65955. invertY: boolean;
  65956. /**
  65957. * Create a new PerturbNormalBlock
  65958. * @param name defines the block name
  65959. */
  65960. constructor(name: string);
  65961. /**
  65962. * Gets the current class name
  65963. * @returns the class name
  65964. */
  65965. getClassName(): string;
  65966. /**
  65967. * Gets the world position input component
  65968. */
  65969. get worldPosition(): NodeMaterialConnectionPoint;
  65970. /**
  65971. * Gets the world normal input component
  65972. */
  65973. get worldNormal(): NodeMaterialConnectionPoint;
  65974. /**
  65975. * Gets the world tangent input component
  65976. */
  65977. get worldTangent(): NodeMaterialConnectionPoint;
  65978. /**
  65979. * Gets the uv input component
  65980. */
  65981. get uv(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the normal map color input component
  65984. */
  65985. get normalMapColor(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the strength input component
  65988. */
  65989. get strength(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the output component
  65992. */
  65993. get output(): NodeMaterialConnectionPoint;
  65994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65996. autoConfigure(material: NodeMaterial): void;
  65997. protected _buildBlock(state: NodeMaterialBuildState): this;
  65998. protected _dumpPropertiesCode(): string;
  65999. serialize(): any;
  66000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66001. }
  66002. }
  66003. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66007. /**
  66008. * Block used to discard a pixel if a value is smaller than a cutoff
  66009. */
  66010. export class DiscardBlock extends NodeMaterialBlock {
  66011. /**
  66012. * Create a new DiscardBlock
  66013. * @param name defines the block name
  66014. */
  66015. constructor(name: string);
  66016. /**
  66017. * Gets the current class name
  66018. * @returns the class name
  66019. */
  66020. getClassName(): string;
  66021. /**
  66022. * Gets the color input component
  66023. */
  66024. get value(): NodeMaterialConnectionPoint;
  66025. /**
  66026. * Gets the cutoff input component
  66027. */
  66028. get cutoff(): NodeMaterialConnectionPoint;
  66029. protected _buildBlock(state: NodeMaterialBuildState): this;
  66030. }
  66031. }
  66032. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66036. /**
  66037. * Block used to test if the fragment shader is front facing
  66038. */
  66039. export class FrontFacingBlock extends NodeMaterialBlock {
  66040. /**
  66041. * Creates a new FrontFacingBlock
  66042. * @param name defines the block name
  66043. */
  66044. constructor(name: string);
  66045. /**
  66046. * Gets the current class name
  66047. * @returns the class name
  66048. */
  66049. getClassName(): string;
  66050. /**
  66051. * Gets the output component
  66052. */
  66053. get output(): NodeMaterialConnectionPoint;
  66054. protected _buildBlock(state: NodeMaterialBuildState): this;
  66055. }
  66056. }
  66057. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66061. /**
  66062. * Block used to get the derivative value on x and y of a given input
  66063. */
  66064. export class DerivativeBlock extends NodeMaterialBlock {
  66065. /**
  66066. * Create a new DerivativeBlock
  66067. * @param name defines the block name
  66068. */
  66069. constructor(name: string);
  66070. /**
  66071. * Gets the current class name
  66072. * @returns the class name
  66073. */
  66074. getClassName(): string;
  66075. /**
  66076. * Gets the input component
  66077. */
  66078. get input(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the derivative output on x
  66081. */
  66082. get dx(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the derivative output on y
  66085. */
  66086. get dy(): NodeMaterialConnectionPoint;
  66087. protected _buildBlock(state: NodeMaterialBuildState): this;
  66088. }
  66089. }
  66090. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66094. /**
  66095. * Block used to make gl_FragCoord available
  66096. */
  66097. export class FragCoordBlock extends NodeMaterialBlock {
  66098. /**
  66099. * Creates a new FragCoordBlock
  66100. * @param name defines the block name
  66101. */
  66102. constructor(name: string);
  66103. /**
  66104. * Gets the current class name
  66105. * @returns the class name
  66106. */
  66107. getClassName(): string;
  66108. /**
  66109. * Gets the xy component
  66110. */
  66111. get xy(): NodeMaterialConnectionPoint;
  66112. /**
  66113. * Gets the xyz component
  66114. */
  66115. get xyz(): NodeMaterialConnectionPoint;
  66116. /**
  66117. * Gets the xyzw component
  66118. */
  66119. get xyzw(): NodeMaterialConnectionPoint;
  66120. /**
  66121. * Gets the x component
  66122. */
  66123. get x(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the y component
  66126. */
  66127. get y(): NodeMaterialConnectionPoint;
  66128. /**
  66129. * Gets the z component
  66130. */
  66131. get z(): NodeMaterialConnectionPoint;
  66132. /**
  66133. * Gets the w component
  66134. */
  66135. get output(): NodeMaterialConnectionPoint;
  66136. protected writeOutputs(state: NodeMaterialBuildState): string;
  66137. protected _buildBlock(state: NodeMaterialBuildState): this;
  66138. }
  66139. }
  66140. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66144. import { Effect } from "babylonjs/Materials/effect";
  66145. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66146. import { Mesh } from "babylonjs/Meshes/mesh";
  66147. /**
  66148. * Block used to get the screen sizes
  66149. */
  66150. export class ScreenSizeBlock extends NodeMaterialBlock {
  66151. private _varName;
  66152. private _scene;
  66153. /**
  66154. * Creates a new ScreenSizeBlock
  66155. * @param name defines the block name
  66156. */
  66157. constructor(name: string);
  66158. /**
  66159. * Gets the current class name
  66160. * @returns the class name
  66161. */
  66162. getClassName(): string;
  66163. /**
  66164. * Gets the xy component
  66165. */
  66166. get xy(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the x component
  66169. */
  66170. get x(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the y component
  66173. */
  66174. get y(): NodeMaterialConnectionPoint;
  66175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66176. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66177. protected _buildBlock(state: NodeMaterialBuildState): this;
  66178. }
  66179. }
  66180. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66181. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66182. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66183. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66184. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66185. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66186. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66187. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66188. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66189. }
  66190. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66193. import { Mesh } from "babylonjs/Meshes/mesh";
  66194. import { Effect } from "babylonjs/Materials/effect";
  66195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66197. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66198. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66199. /**
  66200. * Block used to add support for scene fog
  66201. */
  66202. export class FogBlock extends NodeMaterialBlock {
  66203. private _fogDistanceName;
  66204. private _fogParameters;
  66205. /**
  66206. * Create a new FogBlock
  66207. * @param name defines the block name
  66208. */
  66209. constructor(name: string);
  66210. /**
  66211. * Gets the current class name
  66212. * @returns the class name
  66213. */
  66214. getClassName(): string;
  66215. /**
  66216. * Gets the world position input component
  66217. */
  66218. get worldPosition(): NodeMaterialConnectionPoint;
  66219. /**
  66220. * Gets the view input component
  66221. */
  66222. get view(): NodeMaterialConnectionPoint;
  66223. /**
  66224. * Gets the color input component
  66225. */
  66226. get input(): NodeMaterialConnectionPoint;
  66227. /**
  66228. * Gets the fog color input component
  66229. */
  66230. get fogColor(): NodeMaterialConnectionPoint;
  66231. /**
  66232. * Gets the output component
  66233. */
  66234. get output(): NodeMaterialConnectionPoint;
  66235. autoConfigure(material: NodeMaterial): void;
  66236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66238. protected _buildBlock(state: NodeMaterialBuildState): this;
  66239. }
  66240. }
  66241. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66246. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66247. import { Effect } from "babylonjs/Materials/effect";
  66248. import { Mesh } from "babylonjs/Meshes/mesh";
  66249. import { Light } from "babylonjs/Lights/light";
  66250. import { Nullable } from "babylonjs/types";
  66251. import { Scene } from "babylonjs/scene";
  66252. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66253. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66254. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66255. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66256. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66257. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66258. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66259. /**
  66260. * Block used to add light in the fragment shader
  66261. */
  66262. export class LightBlock extends NodeMaterialBlock {
  66263. private _lightId;
  66264. /**
  66265. * Gets or sets the light associated with this block
  66266. */
  66267. light: Nullable<Light>;
  66268. /**
  66269. * Create a new LightBlock
  66270. * @param name defines the block name
  66271. */
  66272. constructor(name: string);
  66273. /**
  66274. * Gets the current class name
  66275. * @returns the class name
  66276. */
  66277. getClassName(): string;
  66278. /**
  66279. * Gets the world position input component
  66280. */
  66281. get worldPosition(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the world normal input component
  66284. */
  66285. get worldNormal(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the camera (or eye) position component
  66288. */
  66289. get cameraPosition(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the glossiness component
  66292. */
  66293. get glossiness(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the glossinness power component
  66296. */
  66297. get glossPower(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the diffuse color component
  66300. */
  66301. get diffuseColor(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the specular color component
  66304. */
  66305. get specularColor(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the diffuse output component
  66308. */
  66309. get diffuseOutput(): NodeMaterialConnectionPoint;
  66310. /**
  66311. * Gets the specular output component
  66312. */
  66313. get specularOutput(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the shadow output component
  66316. */
  66317. get shadow(): NodeMaterialConnectionPoint;
  66318. autoConfigure(material: NodeMaterial): void;
  66319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66320. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66322. private _injectVertexCode;
  66323. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66324. serialize(): any;
  66325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66326. }
  66327. }
  66328. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66331. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66332. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66333. /**
  66334. * Block used to read a reflection texture from a sampler
  66335. */
  66336. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66337. /**
  66338. * Create a new ReflectionTextureBlock
  66339. * @param name defines the block name
  66340. */
  66341. constructor(name: string);
  66342. /**
  66343. * Gets the current class name
  66344. * @returns the class name
  66345. */
  66346. getClassName(): string;
  66347. /**
  66348. * Gets the world position input component
  66349. */
  66350. get position(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the world position input component
  66353. */
  66354. get worldPosition(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the world normal input component
  66357. */
  66358. get worldNormal(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the world input component
  66361. */
  66362. get world(): NodeMaterialConnectionPoint;
  66363. /**
  66364. * Gets the camera (or eye) position component
  66365. */
  66366. get cameraPosition(): NodeMaterialConnectionPoint;
  66367. /**
  66368. * Gets the view input component
  66369. */
  66370. get view(): NodeMaterialConnectionPoint;
  66371. /**
  66372. * Gets the rgb output component
  66373. */
  66374. get rgb(): NodeMaterialConnectionPoint;
  66375. /**
  66376. * Gets the rgba output component
  66377. */
  66378. get rgba(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the r output component
  66381. */
  66382. get r(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the g output component
  66385. */
  66386. get g(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the b output component
  66389. */
  66390. get b(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the a output component
  66393. */
  66394. get a(): NodeMaterialConnectionPoint;
  66395. autoConfigure(material: NodeMaterial): void;
  66396. protected _buildBlock(state: NodeMaterialBuildState): this;
  66397. }
  66398. }
  66399. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66400. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66401. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66402. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66403. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66404. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66405. }
  66406. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66407. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66408. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66409. }
  66410. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66414. /**
  66415. * Block used to add 2 vectors
  66416. */
  66417. export class AddBlock extends NodeMaterialBlock {
  66418. /**
  66419. * Creates a new AddBlock
  66420. * @param name defines the block name
  66421. */
  66422. constructor(name: string);
  66423. /**
  66424. * Gets the current class name
  66425. * @returns the class name
  66426. */
  66427. getClassName(): string;
  66428. /**
  66429. * Gets the left operand input component
  66430. */
  66431. get left(): NodeMaterialConnectionPoint;
  66432. /**
  66433. * Gets the right operand input component
  66434. */
  66435. get right(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the output component
  66438. */
  66439. get output(): NodeMaterialConnectionPoint;
  66440. protected _buildBlock(state: NodeMaterialBuildState): this;
  66441. }
  66442. }
  66443. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66447. /**
  66448. * Block used to scale a vector by a float
  66449. */
  66450. export class ScaleBlock extends NodeMaterialBlock {
  66451. /**
  66452. * Creates a new ScaleBlock
  66453. * @param name defines the block name
  66454. */
  66455. constructor(name: string);
  66456. /**
  66457. * Gets the current class name
  66458. * @returns the class name
  66459. */
  66460. getClassName(): string;
  66461. /**
  66462. * Gets the input component
  66463. */
  66464. get input(): NodeMaterialConnectionPoint;
  66465. /**
  66466. * Gets the factor input component
  66467. */
  66468. get factor(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the output component
  66471. */
  66472. get output(): NodeMaterialConnectionPoint;
  66473. protected _buildBlock(state: NodeMaterialBuildState): this;
  66474. }
  66475. }
  66476. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66480. import { Scene } from "babylonjs/scene";
  66481. /**
  66482. * Block used to clamp a float
  66483. */
  66484. export class ClampBlock extends NodeMaterialBlock {
  66485. /** Gets or sets the minimum range */
  66486. minimum: number;
  66487. /** Gets or sets the maximum range */
  66488. maximum: number;
  66489. /**
  66490. * Creates a new ClampBlock
  66491. * @param name defines the block name
  66492. */
  66493. constructor(name: string);
  66494. /**
  66495. * Gets the current class name
  66496. * @returns the class name
  66497. */
  66498. getClassName(): string;
  66499. /**
  66500. * Gets the value input component
  66501. */
  66502. get value(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the output component
  66505. */
  66506. get output(): NodeMaterialConnectionPoint;
  66507. protected _buildBlock(state: NodeMaterialBuildState): this;
  66508. protected _dumpPropertiesCode(): string;
  66509. serialize(): any;
  66510. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66511. }
  66512. }
  66513. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66517. /**
  66518. * Block used to apply a cross product between 2 vectors
  66519. */
  66520. export class CrossBlock extends NodeMaterialBlock {
  66521. /**
  66522. * Creates a new CrossBlock
  66523. * @param name defines the block name
  66524. */
  66525. constructor(name: string);
  66526. /**
  66527. * Gets the current class name
  66528. * @returns the class name
  66529. */
  66530. getClassName(): string;
  66531. /**
  66532. * Gets the left operand input component
  66533. */
  66534. get left(): NodeMaterialConnectionPoint;
  66535. /**
  66536. * Gets the right operand input component
  66537. */
  66538. get right(): NodeMaterialConnectionPoint;
  66539. /**
  66540. * Gets the output component
  66541. */
  66542. get output(): NodeMaterialConnectionPoint;
  66543. protected _buildBlock(state: NodeMaterialBuildState): this;
  66544. }
  66545. }
  66546. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66550. /**
  66551. * Block used to apply a dot product between 2 vectors
  66552. */
  66553. export class DotBlock extends NodeMaterialBlock {
  66554. /**
  66555. * Creates a new DotBlock
  66556. * @param name defines the block name
  66557. */
  66558. constructor(name: string);
  66559. /**
  66560. * Gets the current class name
  66561. * @returns the class name
  66562. */
  66563. getClassName(): string;
  66564. /**
  66565. * Gets the left operand input component
  66566. */
  66567. get left(): NodeMaterialConnectionPoint;
  66568. /**
  66569. * Gets the right operand input component
  66570. */
  66571. get right(): NodeMaterialConnectionPoint;
  66572. /**
  66573. * Gets the output component
  66574. */
  66575. get output(): NodeMaterialConnectionPoint;
  66576. protected _buildBlock(state: NodeMaterialBuildState): this;
  66577. }
  66578. }
  66579. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66583. /**
  66584. * Block used to normalize a vector
  66585. */
  66586. export class NormalizeBlock extends NodeMaterialBlock {
  66587. /**
  66588. * Creates a new NormalizeBlock
  66589. * @param name defines the block name
  66590. */
  66591. constructor(name: string);
  66592. /**
  66593. * Gets the current class name
  66594. * @returns the class name
  66595. */
  66596. getClassName(): string;
  66597. /**
  66598. * Gets the input component
  66599. */
  66600. get input(): NodeMaterialConnectionPoint;
  66601. /**
  66602. * Gets the output component
  66603. */
  66604. get output(): NodeMaterialConnectionPoint;
  66605. protected _buildBlock(state: NodeMaterialBuildState): this;
  66606. }
  66607. }
  66608. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66612. /**
  66613. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66614. */
  66615. export class ColorMergerBlock extends NodeMaterialBlock {
  66616. /**
  66617. * Create a new ColorMergerBlock
  66618. * @param name defines the block name
  66619. */
  66620. constructor(name: string);
  66621. /**
  66622. * Gets the current class name
  66623. * @returns the class name
  66624. */
  66625. getClassName(): string;
  66626. /**
  66627. * Gets the rgb component (input)
  66628. */
  66629. get rgbIn(): NodeMaterialConnectionPoint;
  66630. /**
  66631. * Gets the r component (input)
  66632. */
  66633. get r(): NodeMaterialConnectionPoint;
  66634. /**
  66635. * Gets the g component (input)
  66636. */
  66637. get g(): NodeMaterialConnectionPoint;
  66638. /**
  66639. * Gets the b component (input)
  66640. */
  66641. get b(): NodeMaterialConnectionPoint;
  66642. /**
  66643. * Gets the a component (input)
  66644. */
  66645. get a(): NodeMaterialConnectionPoint;
  66646. /**
  66647. * Gets the rgba component (output)
  66648. */
  66649. get rgba(): NodeMaterialConnectionPoint;
  66650. /**
  66651. * Gets the rgb component (output)
  66652. */
  66653. get rgbOut(): NodeMaterialConnectionPoint;
  66654. /**
  66655. * Gets the rgb component (output)
  66656. * @deprecated Please use rgbOut instead.
  66657. */
  66658. get rgb(): NodeMaterialConnectionPoint;
  66659. protected _buildBlock(state: NodeMaterialBuildState): this;
  66660. }
  66661. }
  66662. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66666. /**
  66667. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66668. */
  66669. export class VectorSplitterBlock extends NodeMaterialBlock {
  66670. /**
  66671. * Create a new VectorSplitterBlock
  66672. * @param name defines the block name
  66673. */
  66674. constructor(name: string);
  66675. /**
  66676. * Gets the current class name
  66677. * @returns the class name
  66678. */
  66679. getClassName(): string;
  66680. /**
  66681. * Gets the xyzw component (input)
  66682. */
  66683. get xyzw(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the xyz component (input)
  66686. */
  66687. get xyzIn(): NodeMaterialConnectionPoint;
  66688. /**
  66689. * Gets the xy component (input)
  66690. */
  66691. get xyIn(): NodeMaterialConnectionPoint;
  66692. /**
  66693. * Gets the xyz component (output)
  66694. */
  66695. get xyzOut(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the xy component (output)
  66698. */
  66699. get xyOut(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the x component (output)
  66702. */
  66703. get x(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Gets the y component (output)
  66706. */
  66707. get y(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the z component (output)
  66710. */
  66711. get z(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the w component (output)
  66714. */
  66715. get w(): NodeMaterialConnectionPoint;
  66716. protected _inputRename(name: string): string;
  66717. protected _outputRename(name: string): string;
  66718. protected _buildBlock(state: NodeMaterialBuildState): this;
  66719. }
  66720. }
  66721. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66725. /**
  66726. * Block used to lerp between 2 values
  66727. */
  66728. export class LerpBlock extends NodeMaterialBlock {
  66729. /**
  66730. * Creates a new LerpBlock
  66731. * @param name defines the block name
  66732. */
  66733. constructor(name: string);
  66734. /**
  66735. * Gets the current class name
  66736. * @returns the class name
  66737. */
  66738. getClassName(): string;
  66739. /**
  66740. * Gets the left operand input component
  66741. */
  66742. get left(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the right operand input component
  66745. */
  66746. get right(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the gradient operand input component
  66749. */
  66750. get gradient(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the output component
  66753. */
  66754. get output(): NodeMaterialConnectionPoint;
  66755. protected _buildBlock(state: NodeMaterialBuildState): this;
  66756. }
  66757. }
  66758. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66762. /**
  66763. * Block used to divide 2 vectors
  66764. */
  66765. export class DivideBlock extends NodeMaterialBlock {
  66766. /**
  66767. * Creates a new DivideBlock
  66768. * @param name defines the block name
  66769. */
  66770. constructor(name: string);
  66771. /**
  66772. * Gets the current class name
  66773. * @returns the class name
  66774. */
  66775. getClassName(): string;
  66776. /**
  66777. * Gets the left operand input component
  66778. */
  66779. get left(): NodeMaterialConnectionPoint;
  66780. /**
  66781. * Gets the right operand input component
  66782. */
  66783. get right(): NodeMaterialConnectionPoint;
  66784. /**
  66785. * Gets the output component
  66786. */
  66787. get output(): NodeMaterialConnectionPoint;
  66788. protected _buildBlock(state: NodeMaterialBuildState): this;
  66789. }
  66790. }
  66791. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66795. /**
  66796. * Block used to subtract 2 vectors
  66797. */
  66798. export class SubtractBlock extends NodeMaterialBlock {
  66799. /**
  66800. * Creates a new SubtractBlock
  66801. * @param name defines the block name
  66802. */
  66803. constructor(name: string);
  66804. /**
  66805. * Gets the current class name
  66806. * @returns the class name
  66807. */
  66808. getClassName(): string;
  66809. /**
  66810. * Gets the left operand input component
  66811. */
  66812. get left(): NodeMaterialConnectionPoint;
  66813. /**
  66814. * Gets the right operand input component
  66815. */
  66816. get right(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the output component
  66819. */
  66820. get output(): NodeMaterialConnectionPoint;
  66821. protected _buildBlock(state: NodeMaterialBuildState): this;
  66822. }
  66823. }
  66824. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66828. /**
  66829. * Block used to step a value
  66830. */
  66831. export class StepBlock extends NodeMaterialBlock {
  66832. /**
  66833. * Creates a new StepBlock
  66834. * @param name defines the block name
  66835. */
  66836. constructor(name: string);
  66837. /**
  66838. * Gets the current class name
  66839. * @returns the class name
  66840. */
  66841. getClassName(): string;
  66842. /**
  66843. * Gets the value operand input component
  66844. */
  66845. get value(): NodeMaterialConnectionPoint;
  66846. /**
  66847. * Gets the edge operand input component
  66848. */
  66849. get edge(): NodeMaterialConnectionPoint;
  66850. /**
  66851. * Gets the output component
  66852. */
  66853. get output(): NodeMaterialConnectionPoint;
  66854. protected _buildBlock(state: NodeMaterialBuildState): this;
  66855. }
  66856. }
  66857. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66861. /**
  66862. * Block used to get the opposite (1 - x) of a value
  66863. */
  66864. export class OneMinusBlock extends NodeMaterialBlock {
  66865. /**
  66866. * Creates a new OneMinusBlock
  66867. * @param name defines the block name
  66868. */
  66869. constructor(name: string);
  66870. /**
  66871. * Gets the current class name
  66872. * @returns the class name
  66873. */
  66874. getClassName(): string;
  66875. /**
  66876. * Gets the input component
  66877. */
  66878. get input(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the output component
  66881. */
  66882. get output(): NodeMaterialConnectionPoint;
  66883. protected _buildBlock(state: NodeMaterialBuildState): this;
  66884. }
  66885. }
  66886. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66890. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66891. /**
  66892. * Block used to get the view direction
  66893. */
  66894. export class ViewDirectionBlock extends NodeMaterialBlock {
  66895. /**
  66896. * Creates a new ViewDirectionBlock
  66897. * @param name defines the block name
  66898. */
  66899. constructor(name: string);
  66900. /**
  66901. * Gets the current class name
  66902. * @returns the class name
  66903. */
  66904. getClassName(): string;
  66905. /**
  66906. * Gets the world position component
  66907. */
  66908. get worldPosition(): NodeMaterialConnectionPoint;
  66909. /**
  66910. * Gets the camera position component
  66911. */
  66912. get cameraPosition(): NodeMaterialConnectionPoint;
  66913. /**
  66914. * Gets the output component
  66915. */
  66916. get output(): NodeMaterialConnectionPoint;
  66917. autoConfigure(material: NodeMaterial): void;
  66918. protected _buildBlock(state: NodeMaterialBuildState): this;
  66919. }
  66920. }
  66921. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66925. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66926. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66927. /**
  66928. * Block used to compute fresnel value
  66929. */
  66930. export class FresnelBlock extends NodeMaterialBlock {
  66931. /**
  66932. * Create a new FresnelBlock
  66933. * @param name defines the block name
  66934. */
  66935. constructor(name: string);
  66936. /**
  66937. * Gets the current class name
  66938. * @returns the class name
  66939. */
  66940. getClassName(): string;
  66941. /**
  66942. * Gets the world normal input component
  66943. */
  66944. get worldNormal(): NodeMaterialConnectionPoint;
  66945. /**
  66946. * Gets the view direction input component
  66947. */
  66948. get viewDirection(): NodeMaterialConnectionPoint;
  66949. /**
  66950. * Gets the bias input component
  66951. */
  66952. get bias(): NodeMaterialConnectionPoint;
  66953. /**
  66954. * Gets the camera (or eye) position component
  66955. */
  66956. get power(): NodeMaterialConnectionPoint;
  66957. /**
  66958. * Gets the fresnel output component
  66959. */
  66960. get fresnel(): NodeMaterialConnectionPoint;
  66961. autoConfigure(material: NodeMaterial): void;
  66962. protected _buildBlock(state: NodeMaterialBuildState): this;
  66963. }
  66964. }
  66965. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66969. /**
  66970. * Block used to get the max of 2 values
  66971. */
  66972. export class MaxBlock extends NodeMaterialBlock {
  66973. /**
  66974. * Creates a new MaxBlock
  66975. * @param name defines the block name
  66976. */
  66977. constructor(name: string);
  66978. /**
  66979. * Gets the current class name
  66980. * @returns the class name
  66981. */
  66982. getClassName(): string;
  66983. /**
  66984. * Gets the left operand input component
  66985. */
  66986. get left(): NodeMaterialConnectionPoint;
  66987. /**
  66988. * Gets the right operand input component
  66989. */
  66990. get right(): NodeMaterialConnectionPoint;
  66991. /**
  66992. * Gets the output component
  66993. */
  66994. get output(): NodeMaterialConnectionPoint;
  66995. protected _buildBlock(state: NodeMaterialBuildState): this;
  66996. }
  66997. }
  66998. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67002. /**
  67003. * Block used to get the min of 2 values
  67004. */
  67005. export class MinBlock extends NodeMaterialBlock {
  67006. /**
  67007. * Creates a new MinBlock
  67008. * @param name defines the block name
  67009. */
  67010. constructor(name: string);
  67011. /**
  67012. * Gets the current class name
  67013. * @returns the class name
  67014. */
  67015. getClassName(): string;
  67016. /**
  67017. * Gets the left operand input component
  67018. */
  67019. get left(): NodeMaterialConnectionPoint;
  67020. /**
  67021. * Gets the right operand input component
  67022. */
  67023. get right(): NodeMaterialConnectionPoint;
  67024. /**
  67025. * Gets the output component
  67026. */
  67027. get output(): NodeMaterialConnectionPoint;
  67028. protected _buildBlock(state: NodeMaterialBuildState): this;
  67029. }
  67030. }
  67031. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67035. /**
  67036. * Block used to get the distance between 2 values
  67037. */
  67038. export class DistanceBlock extends NodeMaterialBlock {
  67039. /**
  67040. * Creates a new DistanceBlock
  67041. * @param name defines the block name
  67042. */
  67043. constructor(name: string);
  67044. /**
  67045. * Gets the current class name
  67046. * @returns the class name
  67047. */
  67048. getClassName(): string;
  67049. /**
  67050. * Gets the left operand input component
  67051. */
  67052. get left(): NodeMaterialConnectionPoint;
  67053. /**
  67054. * Gets the right operand input component
  67055. */
  67056. get right(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the output component
  67059. */
  67060. get output(): NodeMaterialConnectionPoint;
  67061. protected _buildBlock(state: NodeMaterialBuildState): this;
  67062. }
  67063. }
  67064. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67068. /**
  67069. * Block used to get the length of a vector
  67070. */
  67071. export class LengthBlock extends NodeMaterialBlock {
  67072. /**
  67073. * Creates a new LengthBlock
  67074. * @param name defines the block name
  67075. */
  67076. constructor(name: string);
  67077. /**
  67078. * Gets the current class name
  67079. * @returns the class name
  67080. */
  67081. getClassName(): string;
  67082. /**
  67083. * Gets the value input component
  67084. */
  67085. get value(): NodeMaterialConnectionPoint;
  67086. /**
  67087. * Gets the output component
  67088. */
  67089. get output(): NodeMaterialConnectionPoint;
  67090. protected _buildBlock(state: NodeMaterialBuildState): this;
  67091. }
  67092. }
  67093. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67097. /**
  67098. * Block used to get negative version of a value (i.e. x * -1)
  67099. */
  67100. export class NegateBlock extends NodeMaterialBlock {
  67101. /**
  67102. * Creates a new NegateBlock
  67103. * @param name defines the block name
  67104. */
  67105. constructor(name: string);
  67106. /**
  67107. * Gets the current class name
  67108. * @returns the class name
  67109. */
  67110. getClassName(): string;
  67111. /**
  67112. * Gets the value input component
  67113. */
  67114. get value(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the output component
  67117. */
  67118. get output(): NodeMaterialConnectionPoint;
  67119. protected _buildBlock(state: NodeMaterialBuildState): this;
  67120. }
  67121. }
  67122. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67126. /**
  67127. * Block used to get the value of the first parameter raised to the power of the second
  67128. */
  67129. export class PowBlock extends NodeMaterialBlock {
  67130. /**
  67131. * Creates a new PowBlock
  67132. * @param name defines the block name
  67133. */
  67134. constructor(name: string);
  67135. /**
  67136. * Gets the current class name
  67137. * @returns the class name
  67138. */
  67139. getClassName(): string;
  67140. /**
  67141. * Gets the value operand input component
  67142. */
  67143. get value(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the power operand input component
  67146. */
  67147. get power(): 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/randomNumberBlock" {
  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. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67160. /**
  67161. * Block used to get a random number
  67162. */
  67163. export class RandomNumberBlock extends NodeMaterialBlock {
  67164. /**
  67165. * Creates a new RandomNumberBlock
  67166. * @param name defines the block name
  67167. */
  67168. constructor(name: string);
  67169. /**
  67170. * Gets the current class name
  67171. * @returns the class name
  67172. */
  67173. getClassName(): string;
  67174. /**
  67175. * Gets the seed input component
  67176. */
  67177. get seed(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the output component
  67180. */
  67181. get output(): NodeMaterialConnectionPoint;
  67182. protected _buildBlock(state: NodeMaterialBuildState): this;
  67183. }
  67184. }
  67185. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67189. /**
  67190. * Block used to compute arc tangent of 2 values
  67191. */
  67192. export class ArcTan2Block extends NodeMaterialBlock {
  67193. /**
  67194. * Creates a new ArcTan2Block
  67195. * @param name defines the block name
  67196. */
  67197. constructor(name: string);
  67198. /**
  67199. * Gets the current class name
  67200. * @returns the class name
  67201. */
  67202. getClassName(): string;
  67203. /**
  67204. * Gets the x operand input component
  67205. */
  67206. get x(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the y operand input component
  67209. */
  67210. get y(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the output component
  67213. */
  67214. get output(): NodeMaterialConnectionPoint;
  67215. protected _buildBlock(state: NodeMaterialBuildState): this;
  67216. }
  67217. }
  67218. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67222. /**
  67223. * Block used to smooth step a value
  67224. */
  67225. export class SmoothStepBlock extends NodeMaterialBlock {
  67226. /**
  67227. * Creates a new SmoothStepBlock
  67228. * @param name defines the block name
  67229. */
  67230. constructor(name: string);
  67231. /**
  67232. * Gets the current class name
  67233. * @returns the class name
  67234. */
  67235. getClassName(): string;
  67236. /**
  67237. * Gets the value operand input component
  67238. */
  67239. get value(): NodeMaterialConnectionPoint;
  67240. /**
  67241. * Gets the first edge operand input component
  67242. */
  67243. get edge0(): NodeMaterialConnectionPoint;
  67244. /**
  67245. * Gets the second edge operand input component
  67246. */
  67247. get edge1(): NodeMaterialConnectionPoint;
  67248. /**
  67249. * Gets the output component
  67250. */
  67251. get output(): NodeMaterialConnectionPoint;
  67252. protected _buildBlock(state: NodeMaterialBuildState): this;
  67253. }
  67254. }
  67255. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67259. /**
  67260. * Block used to get the reciprocal (1 / x) of a value
  67261. */
  67262. export class ReciprocalBlock extends NodeMaterialBlock {
  67263. /**
  67264. * Creates a new ReciprocalBlock
  67265. * @param name defines the block name
  67266. */
  67267. constructor(name: string);
  67268. /**
  67269. * Gets the current class name
  67270. * @returns the class name
  67271. */
  67272. getClassName(): string;
  67273. /**
  67274. * Gets the input component
  67275. */
  67276. get input(): NodeMaterialConnectionPoint;
  67277. /**
  67278. * Gets the output component
  67279. */
  67280. get output(): NodeMaterialConnectionPoint;
  67281. protected _buildBlock(state: NodeMaterialBuildState): this;
  67282. }
  67283. }
  67284. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67288. /**
  67289. * Block used to replace a color by another one
  67290. */
  67291. export class ReplaceColorBlock extends NodeMaterialBlock {
  67292. /**
  67293. * Creates a new ReplaceColorBlock
  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 value input component
  67304. */
  67305. get value(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the reference input component
  67308. */
  67309. get reference(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the distance input component
  67312. */
  67313. get distance(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the replacement input component
  67316. */
  67317. get replacement(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the output component
  67320. */
  67321. get output(): NodeMaterialConnectionPoint;
  67322. protected _buildBlock(state: NodeMaterialBuildState): this;
  67323. }
  67324. }
  67325. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67329. /**
  67330. * Block used to posterize a value
  67331. * @see https://en.wikipedia.org/wiki/Posterization
  67332. */
  67333. export class PosterizeBlock extends NodeMaterialBlock {
  67334. /**
  67335. * Creates a new PosterizeBlock
  67336. * @param name defines the block name
  67337. */
  67338. constructor(name: string);
  67339. /**
  67340. * Gets the current class name
  67341. * @returns the class name
  67342. */
  67343. getClassName(): string;
  67344. /**
  67345. * Gets the value input component
  67346. */
  67347. get value(): NodeMaterialConnectionPoint;
  67348. /**
  67349. * Gets the steps input component
  67350. */
  67351. get steps(): NodeMaterialConnectionPoint;
  67352. /**
  67353. * Gets the output component
  67354. */
  67355. get output(): NodeMaterialConnectionPoint;
  67356. protected _buildBlock(state: NodeMaterialBuildState): this;
  67357. }
  67358. }
  67359. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67363. import { Scene } from "babylonjs/scene";
  67364. /**
  67365. * Operations supported by the Wave block
  67366. */
  67367. export enum WaveBlockKind {
  67368. /** SawTooth */
  67369. SawTooth = 0,
  67370. /** Square */
  67371. Square = 1,
  67372. /** Triangle */
  67373. Triangle = 2
  67374. }
  67375. /**
  67376. * Block used to apply wave operation to floats
  67377. */
  67378. export class WaveBlock extends NodeMaterialBlock {
  67379. /**
  67380. * Gets or sets the kibnd of wave to be applied by the block
  67381. */
  67382. kind: WaveBlockKind;
  67383. /**
  67384. * Creates a new WaveBlock
  67385. * @param name defines the block name
  67386. */
  67387. constructor(name: string);
  67388. /**
  67389. * Gets the current class name
  67390. * @returns the class name
  67391. */
  67392. getClassName(): string;
  67393. /**
  67394. * Gets the input component
  67395. */
  67396. get input(): NodeMaterialConnectionPoint;
  67397. /**
  67398. * Gets the output component
  67399. */
  67400. get output(): NodeMaterialConnectionPoint;
  67401. protected _buildBlock(state: NodeMaterialBuildState): this;
  67402. serialize(): any;
  67403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67404. }
  67405. }
  67406. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67410. import { Color3 } from "babylonjs/Maths/math.color";
  67411. import { Scene } from "babylonjs/scene";
  67412. import { Observable } from "babylonjs/Misc/observable";
  67413. /**
  67414. * Class used to store a color step for the GradientBlock
  67415. */
  67416. export class GradientBlockColorStep {
  67417. private _step;
  67418. /**
  67419. * Gets value indicating which step this color is associated with (between 0 and 1)
  67420. */
  67421. get step(): number;
  67422. /**
  67423. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67424. */
  67425. set step(val: number);
  67426. private _color;
  67427. /**
  67428. * Gets the color associated with this step
  67429. */
  67430. get color(): Color3;
  67431. /**
  67432. * Sets the color associated with this step
  67433. */
  67434. set color(val: Color3);
  67435. /**
  67436. * Creates a new GradientBlockColorStep
  67437. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67438. * @param color defines the color associated with this step
  67439. */
  67440. constructor(step: number, color: Color3);
  67441. }
  67442. /**
  67443. * Block used to return a color from a gradient based on an input value between 0 and 1
  67444. */
  67445. export class GradientBlock extends NodeMaterialBlock {
  67446. /**
  67447. * Gets or sets the list of color steps
  67448. */
  67449. colorSteps: GradientBlockColorStep[];
  67450. /** Gets an observable raised when the value is changed */
  67451. onValueChangedObservable: Observable<GradientBlock>;
  67452. /** calls observable when the value is changed*/
  67453. colorStepsUpdated(): void;
  67454. /**
  67455. * Creates a new GradientBlock
  67456. * @param name defines the block name
  67457. */
  67458. constructor(name: string);
  67459. /**
  67460. * Gets the current class name
  67461. * @returns the class name
  67462. */
  67463. getClassName(): string;
  67464. /**
  67465. * Gets the gradient input component
  67466. */
  67467. get gradient(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the output component
  67470. */
  67471. get output(): NodeMaterialConnectionPoint;
  67472. private _writeColorConstant;
  67473. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67474. serialize(): any;
  67475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67476. protected _dumpPropertiesCode(): string;
  67477. }
  67478. }
  67479. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67483. /**
  67484. * Block used to normalize lerp between 2 values
  67485. */
  67486. export class NLerpBlock extends NodeMaterialBlock {
  67487. /**
  67488. * Creates a new NLerpBlock
  67489. * @param name defines the block name
  67490. */
  67491. constructor(name: string);
  67492. /**
  67493. * Gets the current class name
  67494. * @returns the class name
  67495. */
  67496. getClassName(): string;
  67497. /**
  67498. * Gets the left operand input component
  67499. */
  67500. get left(): NodeMaterialConnectionPoint;
  67501. /**
  67502. * Gets the right operand input component
  67503. */
  67504. get right(): NodeMaterialConnectionPoint;
  67505. /**
  67506. * Gets the gradient operand input component
  67507. */
  67508. get gradient(): NodeMaterialConnectionPoint;
  67509. /**
  67510. * Gets the output component
  67511. */
  67512. get output(): NodeMaterialConnectionPoint;
  67513. protected _buildBlock(state: NodeMaterialBuildState): this;
  67514. }
  67515. }
  67516. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67520. import { Scene } from "babylonjs/scene";
  67521. /**
  67522. * block used to Generate a Worley Noise 3D Noise Pattern
  67523. */
  67524. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67525. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67526. manhattanDistance: boolean;
  67527. /**
  67528. * Creates a new WorleyNoise3DBlock
  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 seed input component
  67539. */
  67540. get seed(): NodeMaterialConnectionPoint;
  67541. /**
  67542. * Gets the jitter input component
  67543. */
  67544. get jitter(): NodeMaterialConnectionPoint;
  67545. /**
  67546. * Gets the output component
  67547. */
  67548. get output(): NodeMaterialConnectionPoint;
  67549. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67550. /**
  67551. * Exposes the properties to the UI?
  67552. */
  67553. protected _dumpPropertiesCode(): string;
  67554. /**
  67555. * Exposes the properties to the Seralize?
  67556. */
  67557. serialize(): any;
  67558. /**
  67559. * Exposes the properties to the deseralize?
  67560. */
  67561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67562. }
  67563. }
  67564. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67568. /**
  67569. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67570. */
  67571. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67572. /**
  67573. * Creates a new SimplexPerlin3DBlock
  67574. * @param name defines the block name
  67575. */
  67576. constructor(name: string);
  67577. /**
  67578. * Gets the current class name
  67579. * @returns the class name
  67580. */
  67581. getClassName(): string;
  67582. /**
  67583. * Gets the seed operand input component
  67584. */
  67585. get seed(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the output component
  67588. */
  67589. get output(): NodeMaterialConnectionPoint;
  67590. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67597. /**
  67598. * Block used to blend normals
  67599. */
  67600. export class NormalBlendBlock extends NodeMaterialBlock {
  67601. /**
  67602. * Creates a new NormalBlendBlock
  67603. * @param name defines the block name
  67604. */
  67605. constructor(name: string);
  67606. /**
  67607. * Gets the current class name
  67608. * @returns the class name
  67609. */
  67610. getClassName(): string;
  67611. /**
  67612. * Gets the first input component
  67613. */
  67614. get normalMap0(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the second input component
  67617. */
  67618. get normalMap1(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the output component
  67621. */
  67622. get output(): NodeMaterialConnectionPoint;
  67623. protected _buildBlock(state: NodeMaterialBuildState): this;
  67624. }
  67625. }
  67626. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67630. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67631. /**
  67632. * Block used to rotate a 2d vector by a given angle
  67633. */
  67634. export class Rotate2dBlock extends NodeMaterialBlock {
  67635. /**
  67636. * Creates a new Rotate2dBlock
  67637. * @param name defines the block name
  67638. */
  67639. constructor(name: string);
  67640. /**
  67641. * Gets the current class name
  67642. * @returns the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the input vector
  67647. */
  67648. get input(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the input angle
  67651. */
  67652. get angle(): NodeMaterialConnectionPoint;
  67653. /**
  67654. * Gets the output component
  67655. */
  67656. get output(): NodeMaterialConnectionPoint;
  67657. autoConfigure(material: NodeMaterial): void;
  67658. protected _buildBlock(state: NodeMaterialBuildState): this;
  67659. }
  67660. }
  67661. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67665. /**
  67666. * Block used to get the reflected vector from a direction and a normal
  67667. */
  67668. export class ReflectBlock extends NodeMaterialBlock {
  67669. /**
  67670. * Creates a new ReflectBlock
  67671. * @param name defines the block name
  67672. */
  67673. constructor(name: string);
  67674. /**
  67675. * Gets the current class name
  67676. * @returns the class name
  67677. */
  67678. getClassName(): string;
  67679. /**
  67680. * Gets the incident component
  67681. */
  67682. get incident(): NodeMaterialConnectionPoint;
  67683. /**
  67684. * Gets the normal component
  67685. */
  67686. get normal(): NodeMaterialConnectionPoint;
  67687. /**
  67688. * Gets the output component
  67689. */
  67690. get output(): NodeMaterialConnectionPoint;
  67691. protected _buildBlock(state: NodeMaterialBuildState): this;
  67692. }
  67693. }
  67694. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67698. /**
  67699. * Block used to get the refracted vector from a direction and a normal
  67700. */
  67701. export class RefractBlock extends NodeMaterialBlock {
  67702. /**
  67703. * Creates a new RefractBlock
  67704. * @param name defines the block name
  67705. */
  67706. constructor(name: string);
  67707. /**
  67708. * Gets the current class name
  67709. * @returns the class name
  67710. */
  67711. getClassName(): string;
  67712. /**
  67713. * Gets the incident component
  67714. */
  67715. get incident(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the normal component
  67718. */
  67719. get normal(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the index of refraction component
  67722. */
  67723. get ior(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the output component
  67726. */
  67727. get output(): NodeMaterialConnectionPoint;
  67728. protected _buildBlock(state: NodeMaterialBuildState): this;
  67729. }
  67730. }
  67731. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67735. /**
  67736. * Block used to desaturate a color
  67737. */
  67738. export class DesaturateBlock extends NodeMaterialBlock {
  67739. /**
  67740. * Creates a new DesaturateBlock
  67741. * @param name defines the block name
  67742. */
  67743. constructor(name: string);
  67744. /**
  67745. * Gets the current class name
  67746. * @returns the class name
  67747. */
  67748. getClassName(): string;
  67749. /**
  67750. * Gets the color operand input component
  67751. */
  67752. get color(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the level operand input component
  67755. */
  67756. get level(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the output component
  67759. */
  67760. get output(): NodeMaterialConnectionPoint;
  67761. protected _buildBlock(state: NodeMaterialBuildState): this;
  67762. }
  67763. }
  67764. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67768. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67769. import { Nullable } from "babylonjs/types";
  67770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67771. import { Scene } from "babylonjs/scene";
  67772. /**
  67773. * Block used to implement the ambient occlusion module of the PBR material
  67774. */
  67775. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67776. /**
  67777. * Create a new AmbientOcclusionBlock
  67778. * @param name defines the block name
  67779. */
  67780. constructor(name: string);
  67781. /**
  67782. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67783. */
  67784. useAmbientInGrayScale: boolean;
  67785. /**
  67786. * Initialize the block and prepare the context for build
  67787. * @param state defines the state that will be used for the build
  67788. */
  67789. initialize(state: NodeMaterialBuildState): void;
  67790. /**
  67791. * Gets the current class name
  67792. * @returns the class name
  67793. */
  67794. getClassName(): string;
  67795. /**
  67796. * Gets the texture input component
  67797. */
  67798. get texture(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the texture intensity component
  67801. */
  67802. get intensity(): NodeMaterialConnectionPoint;
  67803. /**
  67804. * Gets the direct light intensity input component
  67805. */
  67806. get directLightIntensity(): NodeMaterialConnectionPoint;
  67807. /**
  67808. * Gets the ambient occlusion object output component
  67809. */
  67810. get ambientOcc(): NodeMaterialConnectionPoint;
  67811. /**
  67812. * Gets the main code of the block (fragment side)
  67813. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67814. * @returns the shader code
  67815. */
  67816. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67818. protected _buildBlock(state: NodeMaterialBuildState): this;
  67819. protected _dumpPropertiesCode(): string;
  67820. serialize(): any;
  67821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67822. }
  67823. }
  67824. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67828. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67830. import { Nullable } from "babylonjs/types";
  67831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67832. import { Mesh } from "babylonjs/Meshes/mesh";
  67833. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67834. import { Effect } from "babylonjs/Materials/effect";
  67835. import { Scene } from "babylonjs/scene";
  67836. /**
  67837. * Block used to implement the reflection module of the PBR material
  67838. */
  67839. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67840. /** @hidden */
  67841. _defineLODReflectionAlpha: string;
  67842. /** @hidden */
  67843. _defineLinearSpecularReflection: string;
  67844. private _vEnvironmentIrradianceName;
  67845. /** @hidden */
  67846. _vReflectionMicrosurfaceInfosName: string;
  67847. /** @hidden */
  67848. _vReflectionInfosName: string;
  67849. /** @hidden */
  67850. _vReflectionFilteringInfoName: string;
  67851. private _scene;
  67852. /**
  67853. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67854. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67855. * It's less burden on the user side in the editor part.
  67856. */
  67857. /** @hidden */
  67858. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67859. /** @hidden */
  67860. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67861. /** @hidden */
  67862. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67863. /**
  67864. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67865. * diffuse part of the IBL.
  67866. */
  67867. useSphericalHarmonics: boolean;
  67868. /**
  67869. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67870. */
  67871. forceIrradianceInFragment: boolean;
  67872. /**
  67873. * Create a new ReflectionBlock
  67874. * @param name defines the block name
  67875. */
  67876. constructor(name: string);
  67877. /**
  67878. * Gets the current class name
  67879. * @returns the class name
  67880. */
  67881. getClassName(): string;
  67882. /**
  67883. * Gets the position input component
  67884. */
  67885. get position(): NodeMaterialConnectionPoint;
  67886. /**
  67887. * Gets the world position input component
  67888. */
  67889. get worldPosition(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the world normal input component
  67892. */
  67893. get worldNormal(): NodeMaterialConnectionPoint;
  67894. /**
  67895. * Gets the world input component
  67896. */
  67897. get world(): NodeMaterialConnectionPoint;
  67898. /**
  67899. * Gets the camera (or eye) position component
  67900. */
  67901. get cameraPosition(): NodeMaterialConnectionPoint;
  67902. /**
  67903. * Gets the view input component
  67904. */
  67905. get view(): NodeMaterialConnectionPoint;
  67906. /**
  67907. * Gets the color input component
  67908. */
  67909. get color(): NodeMaterialConnectionPoint;
  67910. /**
  67911. * Gets the reflection object output component
  67912. */
  67913. get reflection(): NodeMaterialConnectionPoint;
  67914. /**
  67915. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67916. */
  67917. get hasTexture(): boolean;
  67918. /**
  67919. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67920. */
  67921. get reflectionColor(): string;
  67922. protected _getTexture(): Nullable<BaseTexture>;
  67923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67925. /**
  67926. * Gets the code to inject in the vertex shader
  67927. * @param state current state of the node material building
  67928. * @returns the shader code
  67929. */
  67930. handleVertexSide(state: NodeMaterialBuildState): string;
  67931. /**
  67932. * Gets the main code of the block (fragment side)
  67933. * @param state current state of the node material building
  67934. * @param normalVarName name of the existing variable corresponding to the normal
  67935. * @returns the shader code
  67936. */
  67937. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67938. protected _buildBlock(state: NodeMaterialBuildState): this;
  67939. protected _dumpPropertiesCode(): string;
  67940. serialize(): any;
  67941. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67942. }
  67943. }
  67944. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67950. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67951. import { Scene } from "babylonjs/scene";
  67952. import { Nullable } from "babylonjs/types";
  67953. /**
  67954. * Block used to implement the sheen module of the PBR material
  67955. */
  67956. export class SheenBlock extends NodeMaterialBlock {
  67957. /**
  67958. * Create a new SheenBlock
  67959. * @param name defines the block name
  67960. */
  67961. constructor(name: string);
  67962. /**
  67963. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67964. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67965. * making it easier to setup and tweak the effect
  67966. */
  67967. albedoScaling: boolean;
  67968. /**
  67969. * Defines if the sheen is linked to the sheen color.
  67970. */
  67971. linkSheenWithAlbedo: boolean;
  67972. /**
  67973. * Initialize the block and prepare the context for build
  67974. * @param state defines the state that will be used for the build
  67975. */
  67976. initialize(state: NodeMaterialBuildState): void;
  67977. /**
  67978. * Gets the current class name
  67979. * @returns the class name
  67980. */
  67981. getClassName(): string;
  67982. /**
  67983. * Gets the intensity input component
  67984. */
  67985. get intensity(): NodeMaterialConnectionPoint;
  67986. /**
  67987. * Gets the color input component
  67988. */
  67989. get color(): NodeMaterialConnectionPoint;
  67990. /**
  67991. * Gets the roughness input component
  67992. */
  67993. get roughness(): NodeMaterialConnectionPoint;
  67994. /**
  67995. * Gets the sheen object output component
  67996. */
  67997. get sheen(): NodeMaterialConnectionPoint;
  67998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67999. /**
  68000. * Gets the main code of the block (fragment side)
  68001. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68002. * @returns the shader code
  68003. */
  68004. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68005. protected _buildBlock(state: NodeMaterialBuildState): this;
  68006. protected _dumpPropertiesCode(): string;
  68007. serialize(): any;
  68008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68009. }
  68010. }
  68011. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68012. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68017. import { Scene } from "babylonjs/scene";
  68018. import { Nullable } from "babylonjs/types";
  68019. import { Mesh } from "babylonjs/Meshes/mesh";
  68020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68021. import { Effect } from "babylonjs/Materials/effect";
  68022. /**
  68023. * Block used to implement the reflectivity module of the PBR material
  68024. */
  68025. export class ReflectivityBlock extends NodeMaterialBlock {
  68026. private _metallicReflectanceColor;
  68027. private _metallicF0Factor;
  68028. /** @hidden */
  68029. _vMetallicReflectanceFactorsName: string;
  68030. /**
  68031. * The property below is set by the main PBR block prior to calling methods of this class.
  68032. */
  68033. /** @hidden */
  68034. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68035. /**
  68036. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68037. */
  68038. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68039. /**
  68040. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68041. */
  68042. useMetallnessFromMetallicTextureBlue: boolean;
  68043. /**
  68044. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68045. */
  68046. useRoughnessFromMetallicTextureAlpha: boolean;
  68047. /**
  68048. * Specifies if the metallic texture contains the roughness information in its green channel.
  68049. */
  68050. useRoughnessFromMetallicTextureGreen: boolean;
  68051. /**
  68052. * Create a new ReflectivityBlock
  68053. * @param name defines the block name
  68054. */
  68055. constructor(name: string);
  68056. /**
  68057. * Initialize the block and prepare the context for build
  68058. * @param state defines the state that will be used for the build
  68059. */
  68060. initialize(state: NodeMaterialBuildState): void;
  68061. /**
  68062. * Gets the current class name
  68063. * @returns the class name
  68064. */
  68065. getClassName(): string;
  68066. /**
  68067. * Gets the metallic input component
  68068. */
  68069. get metallic(): NodeMaterialConnectionPoint;
  68070. /**
  68071. * Gets the roughness input component
  68072. */
  68073. get roughness(): NodeMaterialConnectionPoint;
  68074. /**
  68075. * Gets the texture input component
  68076. */
  68077. get texture(): NodeMaterialConnectionPoint;
  68078. /**
  68079. * Gets the reflectivity object output component
  68080. */
  68081. get reflectivity(): NodeMaterialConnectionPoint;
  68082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68083. /**
  68084. * Gets the main code of the block (fragment side)
  68085. * @param state current state of the node material building
  68086. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68087. * @returns the shader code
  68088. */
  68089. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68091. protected _buildBlock(state: NodeMaterialBuildState): this;
  68092. protected _dumpPropertiesCode(): string;
  68093. serialize(): any;
  68094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68095. }
  68096. }
  68097. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68103. /**
  68104. * Block used to implement the anisotropy module of the PBR material
  68105. */
  68106. export class AnisotropyBlock extends NodeMaterialBlock {
  68107. /**
  68108. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68109. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68110. * It's less burden on the user side in the editor part.
  68111. */
  68112. /** @hidden */
  68113. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68114. /** @hidden */
  68115. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68116. /**
  68117. * Create a new AnisotropyBlock
  68118. * @param name defines the block name
  68119. */
  68120. constructor(name: string);
  68121. /**
  68122. * Initialize the block and prepare the context for build
  68123. * @param state defines the state that will be used for the build
  68124. */
  68125. initialize(state: NodeMaterialBuildState): void;
  68126. /**
  68127. * Gets the current class name
  68128. * @returns the class name
  68129. */
  68130. getClassName(): string;
  68131. /**
  68132. * Gets the intensity input component
  68133. */
  68134. get intensity(): NodeMaterialConnectionPoint;
  68135. /**
  68136. * Gets the direction input component
  68137. */
  68138. get direction(): NodeMaterialConnectionPoint;
  68139. /**
  68140. * Gets the texture input component
  68141. */
  68142. get texture(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the uv input component
  68145. */
  68146. get uv(): NodeMaterialConnectionPoint;
  68147. /**
  68148. * Gets the worldTangent input component
  68149. */
  68150. get worldTangent(): NodeMaterialConnectionPoint;
  68151. /**
  68152. * Gets the anisotropy object output component
  68153. */
  68154. get anisotropy(): NodeMaterialConnectionPoint;
  68155. private _generateTBNSpace;
  68156. /**
  68157. * Gets the main code of the block (fragment side)
  68158. * @param state current state of the node material building
  68159. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68160. * @returns the shader code
  68161. */
  68162. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68164. protected _buildBlock(state: NodeMaterialBuildState): this;
  68165. }
  68166. }
  68167. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68171. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68173. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68174. import { Nullable } from "babylonjs/types";
  68175. import { Mesh } from "babylonjs/Meshes/mesh";
  68176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68177. import { Effect } from "babylonjs/Materials/effect";
  68178. /**
  68179. * Block used to implement the clear coat module of the PBR material
  68180. */
  68181. export class ClearCoatBlock extends NodeMaterialBlock {
  68182. private _scene;
  68183. /**
  68184. * Create a new ClearCoatBlock
  68185. * @param name defines the block name
  68186. */
  68187. constructor(name: string);
  68188. /**
  68189. * Initialize the block and prepare the context for build
  68190. * @param state defines the state that will be used for the build
  68191. */
  68192. initialize(state: NodeMaterialBuildState): void;
  68193. /**
  68194. * Gets the current class name
  68195. * @returns the class name
  68196. */
  68197. getClassName(): string;
  68198. /**
  68199. * Gets the intensity input component
  68200. */
  68201. get intensity(): NodeMaterialConnectionPoint;
  68202. /**
  68203. * Gets the roughness input component
  68204. */
  68205. get roughness(): NodeMaterialConnectionPoint;
  68206. /**
  68207. * Gets the ior input component
  68208. */
  68209. get ior(): NodeMaterialConnectionPoint;
  68210. /**
  68211. * Gets the texture input component
  68212. */
  68213. get texture(): NodeMaterialConnectionPoint;
  68214. /**
  68215. * Gets the bump texture input component
  68216. */
  68217. get bumpTexture(): NodeMaterialConnectionPoint;
  68218. /**
  68219. * Gets the uv input component
  68220. */
  68221. get uv(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the tint color input component
  68224. */
  68225. get tintColor(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the tint "at distance" input component
  68228. */
  68229. get tintAtDistance(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the tint thickness input component
  68232. */
  68233. get tintThickness(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the world tangent input component
  68236. */
  68237. get worldTangent(): NodeMaterialConnectionPoint;
  68238. /**
  68239. * Gets the clear coat object output component
  68240. */
  68241. get clearcoat(): NodeMaterialConnectionPoint;
  68242. autoConfigure(material: NodeMaterial): void;
  68243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68244. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68245. private _generateTBNSpace;
  68246. /**
  68247. * Gets the main code of the block (fragment side)
  68248. * @param state current state of the node material building
  68249. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68250. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68251. * @param worldPosVarName name of the variable holding the world position
  68252. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68253. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68254. * @param worldNormalVarName name of the variable holding the world normal
  68255. * @returns the shader code
  68256. */
  68257. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68258. protected _buildBlock(state: NodeMaterialBuildState): this;
  68259. }
  68260. }
  68261. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68265. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68267. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68268. import { Nullable } from "babylonjs/types";
  68269. /**
  68270. * Block used to implement the sub surface module of the PBR material
  68271. */
  68272. export class SubSurfaceBlock extends NodeMaterialBlock {
  68273. /**
  68274. * Create a new SubSurfaceBlock
  68275. * @param name defines the block name
  68276. */
  68277. constructor(name: string);
  68278. /**
  68279. * Stores the intensity of the different subsurface effects in the thickness texture.
  68280. * * the green channel is the translucency intensity.
  68281. * * the blue channel is the scattering intensity.
  68282. * * the alpha channel is the refraction intensity.
  68283. */
  68284. useMaskFromThicknessTexture: boolean;
  68285. /**
  68286. * Initialize the block and prepare the context for build
  68287. * @param state defines the state that will be used for the build
  68288. */
  68289. initialize(state: NodeMaterialBuildState): void;
  68290. /**
  68291. * Gets the current class name
  68292. * @returns the class name
  68293. */
  68294. getClassName(): string;
  68295. /**
  68296. * Gets the min thickness input component
  68297. */
  68298. get minThickness(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the max thickness input component
  68301. */
  68302. get maxThickness(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the thickness texture component
  68305. */
  68306. get thicknessTexture(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the tint color input component
  68309. */
  68310. get tintColor(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the translucency intensity input component
  68313. */
  68314. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68315. /**
  68316. * Gets the translucency diffusion distance input component
  68317. */
  68318. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68319. /**
  68320. * Gets the refraction object parameters
  68321. */
  68322. get refraction(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the sub surface object output component
  68325. */
  68326. get subsurface(): NodeMaterialConnectionPoint;
  68327. autoConfigure(material: NodeMaterial): void;
  68328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68329. /**
  68330. * Gets the main code of the block (fragment side)
  68331. * @param state current state of the node material building
  68332. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68333. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68334. * @param worldPosVarName name of the variable holding the world position
  68335. * @returns the shader code
  68336. */
  68337. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68338. protected _buildBlock(state: NodeMaterialBuildState): this;
  68339. }
  68340. }
  68341. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  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 { Light } from "babylonjs/Lights/light";
  68347. import { Nullable } from "babylonjs/types";
  68348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68349. import { Effect } from "babylonjs/Materials/effect";
  68350. import { Mesh } from "babylonjs/Meshes/mesh";
  68351. import { Scene } from "babylonjs/scene";
  68352. /**
  68353. * Block used to implement the PBR metallic/roughness model
  68354. */
  68355. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68356. /**
  68357. * Gets or sets the light associated with this block
  68358. */
  68359. light: Nullable<Light>;
  68360. private _lightId;
  68361. private _scene;
  68362. private _environmentBRDFTexture;
  68363. private _environmentBrdfSamplerName;
  68364. private _vNormalWName;
  68365. private _invertNormalName;
  68366. /**
  68367. * Create a new ReflectionBlock
  68368. * @param name defines the block name
  68369. */
  68370. constructor(name: string);
  68371. /**
  68372. * Intensity of the direct lights e.g. the four lights available in your scene.
  68373. * This impacts both the direct diffuse and specular highlights.
  68374. */
  68375. directIntensity: number;
  68376. /**
  68377. * Intensity of the environment e.g. how much the environment will light the object
  68378. * either through harmonics for rough material or through the refelction for shiny ones.
  68379. */
  68380. environmentIntensity: number;
  68381. /**
  68382. * This is a special control allowing the reduction of the specular highlights coming from the
  68383. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68384. */
  68385. specularIntensity: number;
  68386. /**
  68387. * Defines the falloff type used in this material.
  68388. * It by default is Physical.
  68389. */
  68390. lightFalloff: number;
  68391. /**
  68392. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68393. */
  68394. useAlphaFromAlbedoTexture: boolean;
  68395. /**
  68396. * Specifies that alpha test should be used
  68397. */
  68398. useAlphaTest: boolean;
  68399. /**
  68400. * Defines the alpha limits in alpha test mode.
  68401. */
  68402. alphaTestCutoff: number;
  68403. /**
  68404. * Specifies that alpha blending should be used
  68405. */
  68406. useAlphaBlending: boolean;
  68407. /**
  68408. * Defines if the alpha value should be determined via the rgb values.
  68409. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68410. */
  68411. opacityRGB: boolean;
  68412. /**
  68413. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68414. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68415. */
  68416. useRadianceOverAlpha: boolean;
  68417. /**
  68418. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68419. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68420. */
  68421. useSpecularOverAlpha: boolean;
  68422. /**
  68423. * Enables specular anti aliasing in the PBR shader.
  68424. * It will both interacts on the Geometry for analytical and IBL lighting.
  68425. * It also prefilter the roughness map based on the bump values.
  68426. */
  68427. enableSpecularAntiAliasing: boolean;
  68428. /**
  68429. * Enables realtime filtering on the texture.
  68430. */
  68431. realTimeFiltering: boolean;
  68432. /**
  68433. * Quality switch for realtime filtering
  68434. */
  68435. realTimeFilteringQuality: number;
  68436. /**
  68437. * Defines if the material uses energy conservation.
  68438. */
  68439. useEnergyConservation: boolean;
  68440. /**
  68441. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68442. * too much the area relying on ambient texture to define their ambient occlusion.
  68443. */
  68444. useRadianceOcclusion: boolean;
  68445. /**
  68446. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68447. * makes the reflect vector face the model (under horizon).
  68448. */
  68449. useHorizonOcclusion: boolean;
  68450. /**
  68451. * If set to true, no lighting calculations will be applied.
  68452. */
  68453. unlit: boolean;
  68454. /**
  68455. * Force normal to face away from face.
  68456. */
  68457. forceNormalForward: boolean;
  68458. /**
  68459. * Defines the material debug mode.
  68460. * It helps seeing only some components of the material while troubleshooting.
  68461. */
  68462. debugMode: number;
  68463. /**
  68464. * Specify from where on screen the debug mode should start.
  68465. * The value goes from -1 (full screen) to 1 (not visible)
  68466. * It helps with side by side comparison against the final render
  68467. * This defaults to 0
  68468. */
  68469. debugLimit: number;
  68470. /**
  68471. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68472. * You can use the factor to better multiply the final value.
  68473. */
  68474. debugFactor: number;
  68475. /**
  68476. * Initialize the block and prepare the context for build
  68477. * @param state defines the state that will be used for the build
  68478. */
  68479. initialize(state: NodeMaterialBuildState): void;
  68480. /**
  68481. * Gets the current class name
  68482. * @returns the class name
  68483. */
  68484. getClassName(): string;
  68485. /**
  68486. * Gets the world position input component
  68487. */
  68488. get worldPosition(): NodeMaterialConnectionPoint;
  68489. /**
  68490. * Gets the world normal input component
  68491. */
  68492. get worldNormal(): NodeMaterialConnectionPoint;
  68493. /**
  68494. * Gets the perturbed normal input component
  68495. */
  68496. get perturbedNormal(): NodeMaterialConnectionPoint;
  68497. /**
  68498. * Gets the camera position input component
  68499. */
  68500. get cameraPosition(): NodeMaterialConnectionPoint;
  68501. /**
  68502. * Gets the base color input component
  68503. */
  68504. get baseColor(): NodeMaterialConnectionPoint;
  68505. /**
  68506. * Gets the opacity texture input component
  68507. */
  68508. get opacityTexture(): NodeMaterialConnectionPoint;
  68509. /**
  68510. * Gets the ambient color input component
  68511. */
  68512. get ambientColor(): NodeMaterialConnectionPoint;
  68513. /**
  68514. * Gets the reflectivity object parameters
  68515. */
  68516. get reflectivity(): NodeMaterialConnectionPoint;
  68517. /**
  68518. * Gets the ambient occlusion object parameters
  68519. */
  68520. get ambientOcc(): NodeMaterialConnectionPoint;
  68521. /**
  68522. * Gets the reflection object parameters
  68523. */
  68524. get reflection(): NodeMaterialConnectionPoint;
  68525. /**
  68526. * Gets the sheen object parameters
  68527. */
  68528. get sheen(): NodeMaterialConnectionPoint;
  68529. /**
  68530. * Gets the clear coat object parameters
  68531. */
  68532. get clearcoat(): NodeMaterialConnectionPoint;
  68533. /**
  68534. * Gets the sub surface object parameters
  68535. */
  68536. get subsurface(): NodeMaterialConnectionPoint;
  68537. /**
  68538. * Gets the anisotropy object parameters
  68539. */
  68540. get anisotropy(): NodeMaterialConnectionPoint;
  68541. /**
  68542. * Gets the ambient output component
  68543. */
  68544. get ambient(): NodeMaterialConnectionPoint;
  68545. /**
  68546. * Gets the diffuse output component
  68547. */
  68548. get diffuse(): NodeMaterialConnectionPoint;
  68549. /**
  68550. * Gets the specular output component
  68551. */
  68552. get specular(): NodeMaterialConnectionPoint;
  68553. /**
  68554. * Gets the sheen output component
  68555. */
  68556. get sheenDir(): NodeMaterialConnectionPoint;
  68557. /**
  68558. * Gets the clear coat output component
  68559. */
  68560. get clearcoatDir(): NodeMaterialConnectionPoint;
  68561. /**
  68562. * Gets the indirect diffuse output component
  68563. */
  68564. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68565. /**
  68566. * Gets the indirect specular output component
  68567. */
  68568. get specularIndirect(): NodeMaterialConnectionPoint;
  68569. /**
  68570. * Gets the indirect sheen output component
  68571. */
  68572. get sheenIndirect(): NodeMaterialConnectionPoint;
  68573. /**
  68574. * Gets the indirect clear coat output component
  68575. */
  68576. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68577. /**
  68578. * Gets the refraction output component
  68579. */
  68580. get refraction(): NodeMaterialConnectionPoint;
  68581. /**
  68582. * Gets the global lighting output component
  68583. */
  68584. get lighting(): NodeMaterialConnectionPoint;
  68585. /**
  68586. * Gets the shadow output component
  68587. */
  68588. get shadow(): NodeMaterialConnectionPoint;
  68589. /**
  68590. * Gets the alpha output component
  68591. */
  68592. get alpha(): NodeMaterialConnectionPoint;
  68593. autoConfigure(material: NodeMaterial): void;
  68594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68595. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68597. private _injectVertexCode;
  68598. /**
  68599. * Gets the code corresponding to the albedo/opacity module
  68600. * @returns the shader code
  68601. */
  68602. getAlbedoOpacityCode(): string;
  68603. protected _buildBlock(state: NodeMaterialBuildState): this;
  68604. protected _dumpPropertiesCode(): string;
  68605. serialize(): any;
  68606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68607. }
  68608. }
  68609. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68610. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68611. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68612. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68613. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68614. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68615. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68616. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68617. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68618. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68619. }
  68620. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68621. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68622. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68623. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68624. }
  68625. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68629. /**
  68630. * Block used to compute value of one parameter modulo another
  68631. */
  68632. export class ModBlock extends NodeMaterialBlock {
  68633. /**
  68634. * Creates a new ModBlock
  68635. * @param name defines the block name
  68636. */
  68637. constructor(name: string);
  68638. /**
  68639. * Gets the current class name
  68640. * @returns the class name
  68641. */
  68642. getClassName(): string;
  68643. /**
  68644. * Gets the left operand input component
  68645. */
  68646. get left(): NodeMaterialConnectionPoint;
  68647. /**
  68648. * Gets the right operand input component
  68649. */
  68650. get right(): NodeMaterialConnectionPoint;
  68651. /**
  68652. * Gets the output component
  68653. */
  68654. get output(): NodeMaterialConnectionPoint;
  68655. protected _buildBlock(state: NodeMaterialBuildState): this;
  68656. }
  68657. }
  68658. declare module "babylonjs/Materials/Node/Blocks/index" {
  68659. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68660. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68661. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68662. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68663. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68664. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68665. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68666. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68667. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68668. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68669. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68670. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68671. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68672. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68673. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68674. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68675. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68676. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68677. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68678. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68679. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68680. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68681. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68682. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68683. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68684. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68685. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68686. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68687. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68688. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68689. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68690. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68691. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68692. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68693. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68694. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68695. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68696. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68697. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68698. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68699. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68700. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68701. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68702. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68703. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68704. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68705. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68706. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68707. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68708. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68709. }
  68710. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68711. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68712. }
  68713. declare module "babylonjs/Materials/Node/index" {
  68714. export * from "babylonjs/Materials/Node/Enums/index";
  68715. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68716. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68717. export * from "babylonjs/Materials/Node/nodeMaterial";
  68718. export * from "babylonjs/Materials/Node/Blocks/index";
  68719. export * from "babylonjs/Materials/Node/Optimizers/index";
  68720. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68721. }
  68722. declare module "babylonjs/Materials/index" {
  68723. export * from "babylonjs/Materials/Background/index";
  68724. export * from "babylonjs/Materials/colorCurves";
  68725. export * from "babylonjs/Materials/iEffectFallbacks";
  68726. export * from "babylonjs/Materials/effectFallbacks";
  68727. export * from "babylonjs/Materials/effect";
  68728. export * from "babylonjs/Materials/fresnelParameters";
  68729. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68730. export * from "babylonjs/Materials/material";
  68731. export * from "babylonjs/Materials/materialDefines";
  68732. export * from "babylonjs/Materials/thinMaterialHelper";
  68733. export * from "babylonjs/Materials/materialHelper";
  68734. export * from "babylonjs/Materials/multiMaterial";
  68735. export * from "babylonjs/Materials/PBR/index";
  68736. export * from "babylonjs/Materials/pushMaterial";
  68737. export * from "babylonjs/Materials/shaderMaterial";
  68738. export * from "babylonjs/Materials/standardMaterial";
  68739. export * from "babylonjs/Materials/Textures/index";
  68740. export * from "babylonjs/Materials/uniformBuffer";
  68741. export * from "babylonjs/Materials/materialFlags";
  68742. export * from "babylonjs/Materials/Node/index";
  68743. export * from "babylonjs/Materials/effectRenderer";
  68744. export * from "babylonjs/Materials/shadowDepthWrapper";
  68745. }
  68746. declare module "babylonjs/Maths/index" {
  68747. export * from "babylonjs/Maths/math.scalar";
  68748. export * from "babylonjs/Maths/math";
  68749. export * from "babylonjs/Maths/sphericalPolynomial";
  68750. }
  68751. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68752. import { IDisposable } from "babylonjs/scene";
  68753. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68754. /**
  68755. * Configuration for Draco compression
  68756. */
  68757. export interface IDracoCompressionConfiguration {
  68758. /**
  68759. * Configuration for the decoder.
  68760. */
  68761. decoder: {
  68762. /**
  68763. * The url to the WebAssembly module.
  68764. */
  68765. wasmUrl?: string;
  68766. /**
  68767. * The url to the WebAssembly binary.
  68768. */
  68769. wasmBinaryUrl?: string;
  68770. /**
  68771. * The url to the fallback JavaScript module.
  68772. */
  68773. fallbackUrl?: string;
  68774. };
  68775. }
  68776. /**
  68777. * Draco compression (https://google.github.io/draco/)
  68778. *
  68779. * This class wraps the Draco module.
  68780. *
  68781. * **Encoder**
  68782. *
  68783. * The encoder is not currently implemented.
  68784. *
  68785. * **Decoder**
  68786. *
  68787. * 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.
  68788. *
  68789. * To update the configuration, use the following code:
  68790. * ```javascript
  68791. * DracoCompression.Configuration = {
  68792. * decoder: {
  68793. * wasmUrl: "<url to the WebAssembly library>",
  68794. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68795. * fallbackUrl: "<url to the fallback JavaScript library>",
  68796. * }
  68797. * };
  68798. * ```
  68799. *
  68800. * 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.
  68801. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68802. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68803. *
  68804. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68805. * ```javascript
  68806. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68807. * ```
  68808. *
  68809. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68810. */
  68811. export class DracoCompression implements IDisposable {
  68812. private _workerPoolPromise?;
  68813. private _decoderModulePromise?;
  68814. /**
  68815. * The configuration. Defaults to the following urls:
  68816. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68817. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68818. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68819. */
  68820. static Configuration: IDracoCompressionConfiguration;
  68821. /**
  68822. * Returns true if the decoder configuration is available.
  68823. */
  68824. static get DecoderAvailable(): boolean;
  68825. /**
  68826. * Default number of workers to create when creating the draco compression object.
  68827. */
  68828. static DefaultNumWorkers: number;
  68829. private static GetDefaultNumWorkers;
  68830. private static _Default;
  68831. /**
  68832. * Default instance for the draco compression object.
  68833. */
  68834. static get Default(): DracoCompression;
  68835. /**
  68836. * Constructor
  68837. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68838. */
  68839. constructor(numWorkers?: number);
  68840. /**
  68841. * Stop all async operations and release resources.
  68842. */
  68843. dispose(): void;
  68844. /**
  68845. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68846. * @returns a promise that resolves when ready
  68847. */
  68848. whenReadyAsync(): Promise<void>;
  68849. /**
  68850. * Decode Draco compressed mesh data to vertex data.
  68851. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68852. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68853. * @returns A promise that resolves with the decoded vertex data
  68854. */
  68855. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68856. [kind: string]: number;
  68857. }): Promise<VertexData>;
  68858. }
  68859. }
  68860. declare module "babylonjs/Meshes/Compression/index" {
  68861. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68862. }
  68863. declare module "babylonjs/Meshes/csg" {
  68864. import { Nullable } from "babylonjs/types";
  68865. import { Scene } from "babylonjs/scene";
  68866. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68867. import { Mesh } from "babylonjs/Meshes/mesh";
  68868. import { Material } from "babylonjs/Materials/material";
  68869. /**
  68870. * Class for building Constructive Solid Geometry
  68871. */
  68872. export class CSG {
  68873. private polygons;
  68874. /**
  68875. * The world matrix
  68876. */
  68877. matrix: Matrix;
  68878. /**
  68879. * Stores the position
  68880. */
  68881. position: Vector3;
  68882. /**
  68883. * Stores the rotation
  68884. */
  68885. rotation: Vector3;
  68886. /**
  68887. * Stores the rotation quaternion
  68888. */
  68889. rotationQuaternion: Nullable<Quaternion>;
  68890. /**
  68891. * Stores the scaling vector
  68892. */
  68893. scaling: Vector3;
  68894. /**
  68895. * Convert the Mesh to CSG
  68896. * @param mesh The Mesh to convert to CSG
  68897. * @returns A new CSG from the Mesh
  68898. */
  68899. static FromMesh(mesh: Mesh): CSG;
  68900. /**
  68901. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68902. * @param polygons Polygons used to construct a CSG solid
  68903. */
  68904. private static FromPolygons;
  68905. /**
  68906. * Clones, or makes a deep copy, of the CSG
  68907. * @returns A new CSG
  68908. */
  68909. clone(): CSG;
  68910. /**
  68911. * Unions this CSG with another CSG
  68912. * @param csg The CSG to union against this CSG
  68913. * @returns The unioned CSG
  68914. */
  68915. union(csg: CSG): CSG;
  68916. /**
  68917. * Unions this CSG with another CSG in place
  68918. * @param csg The CSG to union against this CSG
  68919. */
  68920. unionInPlace(csg: CSG): void;
  68921. /**
  68922. * Subtracts this CSG with another CSG
  68923. * @param csg The CSG to subtract against this CSG
  68924. * @returns A new CSG
  68925. */
  68926. subtract(csg: CSG): CSG;
  68927. /**
  68928. * Subtracts this CSG with another CSG in place
  68929. * @param csg The CSG to subtact against this CSG
  68930. */
  68931. subtractInPlace(csg: CSG): void;
  68932. /**
  68933. * Intersect this CSG with another CSG
  68934. * @param csg The CSG to intersect against this CSG
  68935. * @returns A new CSG
  68936. */
  68937. intersect(csg: CSG): CSG;
  68938. /**
  68939. * Intersects this CSG with another CSG in place
  68940. * @param csg The CSG to intersect against this CSG
  68941. */
  68942. intersectInPlace(csg: CSG): void;
  68943. /**
  68944. * Return a new CSG solid with solid and empty space switched. This solid is
  68945. * not modified.
  68946. * @returns A new CSG solid with solid and empty space switched
  68947. */
  68948. inverse(): CSG;
  68949. /**
  68950. * Inverses the CSG in place
  68951. */
  68952. inverseInPlace(): void;
  68953. /**
  68954. * This is used to keep meshes transformations so they can be restored
  68955. * when we build back a Babylon Mesh
  68956. * NB : All CSG operations are performed in world coordinates
  68957. * @param csg The CSG to copy the transform attributes from
  68958. * @returns This CSG
  68959. */
  68960. copyTransformAttributes(csg: CSG): CSG;
  68961. /**
  68962. * Build Raw mesh from CSG
  68963. * Coordinates here are in world space
  68964. * @param name The name of the mesh geometry
  68965. * @param scene The Scene
  68966. * @param keepSubMeshes Specifies if the submeshes should be kept
  68967. * @returns A new Mesh
  68968. */
  68969. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68970. /**
  68971. * Build Mesh from CSG taking material and transforms into account
  68972. * @param name The name of the Mesh
  68973. * @param material The material of the Mesh
  68974. * @param scene The Scene
  68975. * @param keepSubMeshes Specifies if submeshes should be kept
  68976. * @returns The new Mesh
  68977. */
  68978. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68979. }
  68980. }
  68981. declare module "babylonjs/Meshes/trailMesh" {
  68982. import { Mesh } from "babylonjs/Meshes/mesh";
  68983. import { Scene } from "babylonjs/scene";
  68984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68985. /**
  68986. * Class used to create a trail following a mesh
  68987. */
  68988. export class TrailMesh extends Mesh {
  68989. private _generator;
  68990. private _autoStart;
  68991. private _running;
  68992. private _diameter;
  68993. private _length;
  68994. private _sectionPolygonPointsCount;
  68995. private _sectionVectors;
  68996. private _sectionNormalVectors;
  68997. private _beforeRenderObserver;
  68998. /**
  68999. * @constructor
  69000. * @param name The value used by scene.getMeshByName() to do a lookup.
  69001. * @param generator The mesh or transform node to generate a trail.
  69002. * @param scene The scene to add this mesh to.
  69003. * @param diameter Diameter of trailing mesh. Default is 1.
  69004. * @param length Length of trailing mesh. Default is 60.
  69005. * @param autoStart Automatically start trailing mesh. Default true.
  69006. */
  69007. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69008. /**
  69009. * "TrailMesh"
  69010. * @returns "TrailMesh"
  69011. */
  69012. getClassName(): string;
  69013. private _createMesh;
  69014. /**
  69015. * Start trailing mesh.
  69016. */
  69017. start(): void;
  69018. /**
  69019. * Stop trailing mesh.
  69020. */
  69021. stop(): void;
  69022. /**
  69023. * Update trailing mesh geometry.
  69024. */
  69025. update(): void;
  69026. /**
  69027. * Returns a new TrailMesh object.
  69028. * @param name is a string, the name given to the new mesh
  69029. * @param newGenerator use new generator object for cloned trail mesh
  69030. * @returns a new mesh
  69031. */
  69032. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69033. /**
  69034. * Serializes this trail mesh
  69035. * @param serializationObject object to write serialization to
  69036. */
  69037. serialize(serializationObject: any): void;
  69038. /**
  69039. * Parses a serialized trail mesh
  69040. * @param parsedMesh the serialized mesh
  69041. * @param scene the scene to create the trail mesh in
  69042. * @returns the created trail mesh
  69043. */
  69044. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69045. }
  69046. }
  69047. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69048. import { Nullable } from "babylonjs/types";
  69049. import { Scene } from "babylonjs/scene";
  69050. import { Vector4 } from "babylonjs/Maths/math.vector";
  69051. import { Color4 } from "babylonjs/Maths/math.color";
  69052. import { Mesh } from "babylonjs/Meshes/mesh";
  69053. /**
  69054. * Class containing static functions to help procedurally build meshes
  69055. */
  69056. export class TiledBoxBuilder {
  69057. /**
  69058. * Creates a box mesh
  69059. * 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)
  69060. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69064. * @param name defines the name of the mesh
  69065. * @param options defines the options used to create the mesh
  69066. * @param scene defines the hosting scene
  69067. * @returns the box mesh
  69068. */
  69069. static CreateTiledBox(name: string, options: {
  69070. pattern?: number;
  69071. width?: number;
  69072. height?: number;
  69073. depth?: number;
  69074. tileSize?: number;
  69075. tileWidth?: number;
  69076. tileHeight?: number;
  69077. alignHorizontal?: number;
  69078. alignVertical?: number;
  69079. faceUV?: Vector4[];
  69080. faceColors?: Color4[];
  69081. sideOrientation?: number;
  69082. updatable?: boolean;
  69083. }, scene?: Nullable<Scene>): Mesh;
  69084. }
  69085. }
  69086. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69087. import { Vector4 } from "babylonjs/Maths/math.vector";
  69088. import { Mesh } from "babylonjs/Meshes/mesh";
  69089. /**
  69090. * Class containing static functions to help procedurally build meshes
  69091. */
  69092. export class TorusKnotBuilder {
  69093. /**
  69094. * Creates a torus knot mesh
  69095. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69096. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69097. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69098. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69102. * @param name defines the name of the mesh
  69103. * @param options defines the options used to create the mesh
  69104. * @param scene defines the hosting scene
  69105. * @returns the torus knot mesh
  69106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69107. */
  69108. static CreateTorusKnot(name: string, options: {
  69109. radius?: number;
  69110. tube?: number;
  69111. radialSegments?: number;
  69112. tubularSegments?: number;
  69113. p?: number;
  69114. q?: number;
  69115. updatable?: boolean;
  69116. sideOrientation?: number;
  69117. frontUVs?: Vector4;
  69118. backUVs?: Vector4;
  69119. }, scene: any): Mesh;
  69120. }
  69121. }
  69122. declare module "babylonjs/Meshes/polygonMesh" {
  69123. import { Scene } from "babylonjs/scene";
  69124. import { Vector2 } from "babylonjs/Maths/math.vector";
  69125. import { Mesh } from "babylonjs/Meshes/mesh";
  69126. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69127. import { Path2 } from "babylonjs/Maths/math.path";
  69128. /**
  69129. * Polygon
  69130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69131. */
  69132. export class Polygon {
  69133. /**
  69134. * Creates a rectangle
  69135. * @param xmin bottom X coord
  69136. * @param ymin bottom Y coord
  69137. * @param xmax top X coord
  69138. * @param ymax top Y coord
  69139. * @returns points that make the resulting rectation
  69140. */
  69141. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69142. /**
  69143. * Creates a circle
  69144. * @param radius radius of circle
  69145. * @param cx scale in x
  69146. * @param cy scale in y
  69147. * @param numberOfSides number of sides that make up the circle
  69148. * @returns points that make the resulting circle
  69149. */
  69150. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69151. /**
  69152. * Creates a polygon from input string
  69153. * @param input Input polygon data
  69154. * @returns the parsed points
  69155. */
  69156. static Parse(input: string): Vector2[];
  69157. /**
  69158. * Starts building a polygon from x and y coordinates
  69159. * @param x x coordinate
  69160. * @param y y coordinate
  69161. * @returns the started path2
  69162. */
  69163. static StartingAt(x: number, y: number): Path2;
  69164. }
  69165. /**
  69166. * Builds a polygon
  69167. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69168. */
  69169. export class PolygonMeshBuilder {
  69170. private _points;
  69171. private _outlinepoints;
  69172. private _holes;
  69173. private _name;
  69174. private _scene;
  69175. private _epoints;
  69176. private _eholes;
  69177. private _addToepoint;
  69178. /**
  69179. * Babylon reference to the earcut plugin.
  69180. */
  69181. bjsEarcut: any;
  69182. /**
  69183. * Creates a PolygonMeshBuilder
  69184. * @param name name of the builder
  69185. * @param contours Path of the polygon
  69186. * @param scene scene to add to when creating the mesh
  69187. * @param earcutInjection can be used to inject your own earcut reference
  69188. */
  69189. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69190. /**
  69191. * Adds a whole within the polygon
  69192. * @param hole Array of points defining the hole
  69193. * @returns this
  69194. */
  69195. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69196. /**
  69197. * Creates the polygon
  69198. * @param updatable If the mesh should be updatable
  69199. * @param depth The depth of the mesh created
  69200. * @returns the created mesh
  69201. */
  69202. build(updatable?: boolean, depth?: number): Mesh;
  69203. /**
  69204. * Creates the polygon
  69205. * @param depth The depth of the mesh created
  69206. * @returns the created VertexData
  69207. */
  69208. buildVertexData(depth?: number): VertexData;
  69209. /**
  69210. * Adds a side to the polygon
  69211. * @param positions points that make the polygon
  69212. * @param normals normals of the polygon
  69213. * @param uvs uvs of the polygon
  69214. * @param indices indices of the polygon
  69215. * @param bounds bounds of the polygon
  69216. * @param points points of the polygon
  69217. * @param depth depth of the polygon
  69218. * @param flip flip of the polygon
  69219. */
  69220. private addSide;
  69221. }
  69222. }
  69223. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69224. import { Scene } from "babylonjs/scene";
  69225. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69226. import { Color4 } from "babylonjs/Maths/math.color";
  69227. import { Mesh } from "babylonjs/Meshes/mesh";
  69228. import { Nullable } from "babylonjs/types";
  69229. /**
  69230. * Class containing static functions to help procedurally build meshes
  69231. */
  69232. export class PolygonBuilder {
  69233. /**
  69234. * Creates a polygon mesh
  69235. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69236. * * 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
  69237. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69240. * * Remember you can only change the shape positions, not their number when updating a polygon
  69241. * @param name defines the name of the mesh
  69242. * @param options defines the options used to create the mesh
  69243. * @param scene defines the hosting scene
  69244. * @param earcutInjection can be used to inject your own earcut reference
  69245. * @returns the polygon mesh
  69246. */
  69247. static CreatePolygon(name: string, options: {
  69248. shape: Vector3[];
  69249. holes?: Vector3[][];
  69250. depth?: number;
  69251. faceUV?: Vector4[];
  69252. faceColors?: Color4[];
  69253. updatable?: boolean;
  69254. sideOrientation?: number;
  69255. frontUVs?: Vector4;
  69256. backUVs?: Vector4;
  69257. wrap?: boolean;
  69258. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69259. /**
  69260. * Creates an extruded polygon mesh, with depth in the Y direction.
  69261. * * 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)
  69262. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69263. * @param name defines the name of the mesh
  69264. * @param options defines the options used to create the mesh
  69265. * @param scene defines the hosting scene
  69266. * @param earcutInjection can be used to inject your own earcut reference
  69267. * @returns the polygon mesh
  69268. */
  69269. static ExtrudePolygon(name: string, options: {
  69270. shape: Vector3[];
  69271. holes?: Vector3[][];
  69272. depth?: number;
  69273. faceUV?: Vector4[];
  69274. faceColors?: Color4[];
  69275. updatable?: boolean;
  69276. sideOrientation?: number;
  69277. frontUVs?: Vector4;
  69278. backUVs?: Vector4;
  69279. wrap?: boolean;
  69280. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69281. }
  69282. }
  69283. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69284. import { Scene } from "babylonjs/scene";
  69285. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69286. import { Mesh } from "babylonjs/Meshes/mesh";
  69287. import { Nullable } from "babylonjs/types";
  69288. /**
  69289. * Class containing static functions to help procedurally build meshes
  69290. */
  69291. export class LatheBuilder {
  69292. /**
  69293. * Creates lathe mesh.
  69294. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69295. * * 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
  69296. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69297. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69298. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69299. * * 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
  69300. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69301. * * 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
  69302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69306. * @param name defines the name of the mesh
  69307. * @param options defines the options used to create the mesh
  69308. * @param scene defines the hosting scene
  69309. * @returns the lathe mesh
  69310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69311. */
  69312. static CreateLathe(name: string, options: {
  69313. shape: Vector3[];
  69314. radius?: number;
  69315. tessellation?: number;
  69316. clip?: number;
  69317. arc?: number;
  69318. closed?: boolean;
  69319. updatable?: boolean;
  69320. sideOrientation?: number;
  69321. frontUVs?: Vector4;
  69322. backUVs?: Vector4;
  69323. cap?: number;
  69324. invertUV?: boolean;
  69325. }, scene?: Nullable<Scene>): Mesh;
  69326. }
  69327. }
  69328. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69329. import { Nullable } from "babylonjs/types";
  69330. import { Scene } from "babylonjs/scene";
  69331. import { Vector4 } from "babylonjs/Maths/math.vector";
  69332. import { Mesh } from "babylonjs/Meshes/mesh";
  69333. /**
  69334. * Class containing static functions to help procedurally build meshes
  69335. */
  69336. export class TiledPlaneBuilder {
  69337. /**
  69338. * Creates a tiled plane mesh
  69339. * * The parameter `pattern` will, depending on value, do nothing or
  69340. * * * flip (reflect about central vertical) alternate tiles across and up
  69341. * * * flip every tile on alternate rows
  69342. * * * rotate (180 degs) alternate tiles across and up
  69343. * * * rotate every tile on alternate rows
  69344. * * * flip and rotate alternate tiles across and up
  69345. * * * flip and rotate every tile on alternate rows
  69346. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69347. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69350. * * 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)
  69351. * * 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)
  69352. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69353. * @param name defines the name of the mesh
  69354. * @param options defines the options used to create the mesh
  69355. * @param scene defines the hosting scene
  69356. * @returns the box mesh
  69357. */
  69358. static CreateTiledPlane(name: string, options: {
  69359. pattern?: number;
  69360. tileSize?: number;
  69361. tileWidth?: number;
  69362. tileHeight?: number;
  69363. size?: number;
  69364. width?: number;
  69365. height?: number;
  69366. alignHorizontal?: number;
  69367. alignVertical?: number;
  69368. sideOrientation?: number;
  69369. frontUVs?: Vector4;
  69370. backUVs?: Vector4;
  69371. updatable?: boolean;
  69372. }, scene?: Nullable<Scene>): Mesh;
  69373. }
  69374. }
  69375. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69376. import { Nullable } from "babylonjs/types";
  69377. import { Scene } from "babylonjs/scene";
  69378. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69379. import { Mesh } from "babylonjs/Meshes/mesh";
  69380. /**
  69381. * Class containing static functions to help procedurally build meshes
  69382. */
  69383. export class TubeBuilder {
  69384. /**
  69385. * Creates a tube mesh.
  69386. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69387. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69388. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69389. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69390. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69391. * * 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)
  69392. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69393. * * 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
  69394. * * 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
  69395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69397. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69399. * @param name defines the name of the mesh
  69400. * @param options defines the options used to create the mesh
  69401. * @param scene defines the hosting scene
  69402. * @returns the tube mesh
  69403. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69404. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69405. */
  69406. static CreateTube(name: string, options: {
  69407. path: Vector3[];
  69408. radius?: number;
  69409. tessellation?: number;
  69410. radiusFunction?: {
  69411. (i: number, distance: number): number;
  69412. };
  69413. cap?: number;
  69414. arc?: number;
  69415. updatable?: boolean;
  69416. sideOrientation?: number;
  69417. frontUVs?: Vector4;
  69418. backUVs?: Vector4;
  69419. instance?: Mesh;
  69420. invertUV?: boolean;
  69421. }, scene?: Nullable<Scene>): Mesh;
  69422. }
  69423. }
  69424. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69425. import { Scene } from "babylonjs/scene";
  69426. import { Vector4 } from "babylonjs/Maths/math.vector";
  69427. import { Mesh } from "babylonjs/Meshes/mesh";
  69428. import { Nullable } from "babylonjs/types";
  69429. /**
  69430. * Class containing static functions to help procedurally build meshes
  69431. */
  69432. export class IcoSphereBuilder {
  69433. /**
  69434. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69435. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69436. * * 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`)
  69437. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69438. * * 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
  69439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69442. * @param name defines the name of the mesh
  69443. * @param options defines the options used to create the mesh
  69444. * @param scene defines the hosting scene
  69445. * @returns the icosahedron mesh
  69446. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69447. */
  69448. static CreateIcoSphere(name: string, options: {
  69449. radius?: number;
  69450. radiusX?: number;
  69451. radiusY?: number;
  69452. radiusZ?: number;
  69453. flat?: boolean;
  69454. subdivisions?: number;
  69455. sideOrientation?: number;
  69456. frontUVs?: Vector4;
  69457. backUVs?: Vector4;
  69458. updatable?: boolean;
  69459. }, scene?: Nullable<Scene>): Mesh;
  69460. }
  69461. }
  69462. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69463. import { Vector3 } from "babylonjs/Maths/math.vector";
  69464. import { Mesh } from "babylonjs/Meshes/mesh";
  69465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69466. /**
  69467. * Class containing static functions to help procedurally build meshes
  69468. */
  69469. export class DecalBuilder {
  69470. /**
  69471. * Creates a decal mesh.
  69472. * 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
  69473. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69474. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69475. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69476. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69477. * @param name defines the name of the mesh
  69478. * @param sourceMesh defines the mesh where the decal must be applied
  69479. * @param options defines the options used to create the mesh
  69480. * @param scene defines the hosting scene
  69481. * @returns the decal mesh
  69482. * @see https://doc.babylonjs.com/how_to/decals
  69483. */
  69484. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69485. position?: Vector3;
  69486. normal?: Vector3;
  69487. size?: Vector3;
  69488. angle?: number;
  69489. }): Mesh;
  69490. }
  69491. }
  69492. declare module "babylonjs/Meshes/meshBuilder" {
  69493. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69494. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69495. import { Nullable } from "babylonjs/types";
  69496. import { Scene } from "babylonjs/scene";
  69497. import { Mesh } from "babylonjs/Meshes/mesh";
  69498. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69499. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69501. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69502. import { Plane } from "babylonjs/Maths/math.plane";
  69503. /**
  69504. * Class containing static functions to help procedurally build meshes
  69505. */
  69506. export class MeshBuilder {
  69507. /**
  69508. * Creates a box mesh
  69509. * * The parameter `size` sets the size (float) of each box side (default 1)
  69510. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69511. * * 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)
  69512. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69516. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69517. * @param name defines the name of the mesh
  69518. * @param options defines the options used to create the mesh
  69519. * @param scene defines the hosting scene
  69520. * @returns the box mesh
  69521. */
  69522. static CreateBox(name: string, options: {
  69523. size?: number;
  69524. width?: number;
  69525. height?: number;
  69526. depth?: number;
  69527. faceUV?: Vector4[];
  69528. faceColors?: Color4[];
  69529. sideOrientation?: number;
  69530. frontUVs?: Vector4;
  69531. backUVs?: Vector4;
  69532. wrap?: boolean;
  69533. topBaseAt?: number;
  69534. bottomBaseAt?: number;
  69535. updatable?: boolean;
  69536. }, scene?: Nullable<Scene>): Mesh;
  69537. /**
  69538. * Creates a tiled box mesh
  69539. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69541. * @param name defines the name of the mesh
  69542. * @param options defines the options used to create the mesh
  69543. * @param scene defines the hosting scene
  69544. * @returns the tiled box mesh
  69545. */
  69546. static CreateTiledBox(name: string, options: {
  69547. pattern?: number;
  69548. size?: number;
  69549. width?: number;
  69550. height?: number;
  69551. depth: number;
  69552. tileSize?: number;
  69553. tileWidth?: number;
  69554. tileHeight?: number;
  69555. faceUV?: Vector4[];
  69556. faceColors?: Color4[];
  69557. alignHorizontal?: number;
  69558. alignVertical?: number;
  69559. sideOrientation?: number;
  69560. updatable?: boolean;
  69561. }, scene?: Nullable<Scene>): Mesh;
  69562. /**
  69563. * Creates a sphere mesh
  69564. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69565. * * 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`)
  69566. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69567. * * 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
  69568. * * 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)
  69569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69572. * @param name defines the name of the mesh
  69573. * @param options defines the options used to create the mesh
  69574. * @param scene defines the hosting scene
  69575. * @returns the sphere mesh
  69576. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69577. */
  69578. static CreateSphere(name: string, options: {
  69579. segments?: number;
  69580. diameter?: number;
  69581. diameterX?: number;
  69582. diameterY?: number;
  69583. diameterZ?: number;
  69584. arc?: number;
  69585. slice?: number;
  69586. sideOrientation?: number;
  69587. frontUVs?: Vector4;
  69588. backUVs?: Vector4;
  69589. updatable?: boolean;
  69590. }, scene?: Nullable<Scene>): Mesh;
  69591. /**
  69592. * Creates a plane polygonal mesh. By default, this is a disc
  69593. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69594. * * 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
  69595. * * 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
  69596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69599. * @param name defines the name of the mesh
  69600. * @param options defines the options used to create the mesh
  69601. * @param scene defines the hosting scene
  69602. * @returns the plane polygonal mesh
  69603. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69604. */
  69605. static CreateDisc(name: string, options: {
  69606. radius?: number;
  69607. tessellation?: number;
  69608. arc?: number;
  69609. updatable?: boolean;
  69610. sideOrientation?: number;
  69611. frontUVs?: Vector4;
  69612. backUVs?: Vector4;
  69613. }, scene?: Nullable<Scene>): Mesh;
  69614. /**
  69615. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69616. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69617. * * 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`)
  69618. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69619. * * 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
  69620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69623. * @param name defines the name of the mesh
  69624. * @param options defines the options used to create the mesh
  69625. * @param scene defines the hosting scene
  69626. * @returns the icosahedron mesh
  69627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69628. */
  69629. static CreateIcoSphere(name: string, options: {
  69630. radius?: number;
  69631. radiusX?: number;
  69632. radiusY?: number;
  69633. radiusZ?: number;
  69634. flat?: boolean;
  69635. subdivisions?: number;
  69636. sideOrientation?: number;
  69637. frontUVs?: Vector4;
  69638. backUVs?: Vector4;
  69639. updatable?: boolean;
  69640. }, scene?: Nullable<Scene>): Mesh;
  69641. /**
  69642. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69643. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69644. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69645. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69646. * * 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
  69647. * * 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
  69648. * * 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
  69649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69652. * * 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
  69653. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69654. * * 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
  69655. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69657. * @param name defines the name of the mesh
  69658. * @param options defines the options used to create the mesh
  69659. * @param scene defines the hosting scene
  69660. * @returns the ribbon mesh
  69661. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69663. */
  69664. static CreateRibbon(name: string, options: {
  69665. pathArray: Vector3[][];
  69666. closeArray?: boolean;
  69667. closePath?: boolean;
  69668. offset?: number;
  69669. updatable?: boolean;
  69670. sideOrientation?: number;
  69671. frontUVs?: Vector4;
  69672. backUVs?: Vector4;
  69673. instance?: Mesh;
  69674. invertUV?: boolean;
  69675. uvs?: Vector2[];
  69676. colors?: Color4[];
  69677. }, scene?: Nullable<Scene>): Mesh;
  69678. /**
  69679. * Creates a cylinder or a cone mesh
  69680. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69681. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69682. * * 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.
  69683. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69684. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69685. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69686. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69687. * * 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).
  69688. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69689. * * 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).
  69690. * * 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
  69691. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69692. * * 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
  69693. * * 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.
  69694. * * If `enclose` is false, a ring surface is one element.
  69695. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69696. * * 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
  69697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69700. * @param name defines the name of the mesh
  69701. * @param options defines the options used to create the mesh
  69702. * @param scene defines the hosting scene
  69703. * @returns the cylinder mesh
  69704. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69705. */
  69706. static CreateCylinder(name: string, options: {
  69707. height?: number;
  69708. diameterTop?: number;
  69709. diameterBottom?: number;
  69710. diameter?: number;
  69711. tessellation?: number;
  69712. subdivisions?: number;
  69713. arc?: number;
  69714. faceColors?: Color4[];
  69715. faceUV?: Vector4[];
  69716. updatable?: boolean;
  69717. hasRings?: boolean;
  69718. enclose?: boolean;
  69719. cap?: number;
  69720. sideOrientation?: number;
  69721. frontUVs?: Vector4;
  69722. backUVs?: Vector4;
  69723. }, scene?: Nullable<Scene>): Mesh;
  69724. /**
  69725. * Creates a torus mesh
  69726. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69727. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69728. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69732. * @param name defines the name of the mesh
  69733. * @param options defines the options used to create the mesh
  69734. * @param scene defines the hosting scene
  69735. * @returns the torus mesh
  69736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69737. */
  69738. static CreateTorus(name: string, options: {
  69739. diameter?: number;
  69740. thickness?: number;
  69741. tessellation?: number;
  69742. updatable?: boolean;
  69743. sideOrientation?: number;
  69744. frontUVs?: Vector4;
  69745. backUVs?: Vector4;
  69746. }, scene?: Nullable<Scene>): Mesh;
  69747. /**
  69748. * Creates a torus knot mesh
  69749. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69750. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69751. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69752. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69756. * @param name defines the name of the mesh
  69757. * @param options defines the options used to create the mesh
  69758. * @param scene defines the hosting scene
  69759. * @returns the torus knot mesh
  69760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69761. */
  69762. static CreateTorusKnot(name: string, options: {
  69763. radius?: number;
  69764. tube?: number;
  69765. radialSegments?: number;
  69766. tubularSegments?: number;
  69767. p?: number;
  69768. q?: number;
  69769. updatable?: boolean;
  69770. sideOrientation?: number;
  69771. frontUVs?: Vector4;
  69772. backUVs?: Vector4;
  69773. }, scene?: Nullable<Scene>): Mesh;
  69774. /**
  69775. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69776. * * 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
  69777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69778. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69779. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69780. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69781. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69782. * * 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
  69783. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69786. * @param name defines the name of the new line system
  69787. * @param options defines the options used to create the line system
  69788. * @param scene defines the hosting scene
  69789. * @returns a new line system mesh
  69790. */
  69791. static CreateLineSystem(name: string, options: {
  69792. lines: Vector3[][];
  69793. updatable?: boolean;
  69794. instance?: Nullable<LinesMesh>;
  69795. colors?: Nullable<Color4[][]>;
  69796. useVertexAlpha?: boolean;
  69797. }, scene: Nullable<Scene>): LinesMesh;
  69798. /**
  69799. * Creates a line mesh
  69800. * 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
  69801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69802. * * The parameter `points` is an array successive Vector3
  69803. * * 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
  69804. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69805. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69806. * * When updating an instance, remember that only point positions can change, not the number of points
  69807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69809. * @param name defines the name of the new line system
  69810. * @param options defines the options used to create the line system
  69811. * @param scene defines the hosting scene
  69812. * @returns a new line mesh
  69813. */
  69814. static CreateLines(name: string, options: {
  69815. points: Vector3[];
  69816. updatable?: boolean;
  69817. instance?: Nullable<LinesMesh>;
  69818. colors?: Color4[];
  69819. useVertexAlpha?: boolean;
  69820. }, scene?: Nullable<Scene>): LinesMesh;
  69821. /**
  69822. * Creates a dashed line mesh
  69823. * * 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
  69824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69825. * * The parameter `points` is an array successive Vector3
  69826. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69827. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69828. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69829. * * 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
  69830. * * When updating an instance, remember that only point positions can change, not the number of points
  69831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69832. * @param name defines the name of the mesh
  69833. * @param options defines the options used to create the mesh
  69834. * @param scene defines the hosting scene
  69835. * @returns the dashed line mesh
  69836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69837. */
  69838. static CreateDashedLines(name: string, options: {
  69839. points: Vector3[];
  69840. dashSize?: number;
  69841. gapSize?: number;
  69842. dashNb?: number;
  69843. updatable?: boolean;
  69844. instance?: LinesMesh;
  69845. }, scene?: Nullable<Scene>): LinesMesh;
  69846. /**
  69847. * 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.
  69848. * * 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.
  69849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69850. * * 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.
  69851. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69852. * * 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
  69853. * * 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
  69854. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69859. * @param name defines the name of the mesh
  69860. * @param options defines the options used to create the mesh
  69861. * @param scene defines the hosting scene
  69862. * @returns the extruded shape mesh
  69863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69865. */
  69866. static ExtrudeShape(name: string, options: {
  69867. shape: Vector3[];
  69868. path: Vector3[];
  69869. scale?: number;
  69870. rotation?: number;
  69871. cap?: number;
  69872. updatable?: boolean;
  69873. sideOrientation?: number;
  69874. frontUVs?: Vector4;
  69875. backUVs?: Vector4;
  69876. instance?: Mesh;
  69877. invertUV?: boolean;
  69878. }, scene?: Nullable<Scene>): Mesh;
  69879. /**
  69880. * Creates an custom extruded shape mesh.
  69881. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69882. * * 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.
  69883. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69884. * * 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
  69885. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69886. * * 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
  69887. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69888. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69889. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69890. * * 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
  69891. * * 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
  69892. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69897. * @param name defines the name of the mesh
  69898. * @param options defines the options used to create the mesh
  69899. * @param scene defines the hosting scene
  69900. * @returns the custom extruded shape mesh
  69901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69904. */
  69905. static ExtrudeShapeCustom(name: string, options: {
  69906. shape: Vector3[];
  69907. path: Vector3[];
  69908. scaleFunction?: any;
  69909. rotationFunction?: any;
  69910. ribbonCloseArray?: boolean;
  69911. ribbonClosePath?: boolean;
  69912. cap?: number;
  69913. updatable?: boolean;
  69914. sideOrientation?: number;
  69915. frontUVs?: Vector4;
  69916. backUVs?: Vector4;
  69917. instance?: Mesh;
  69918. invertUV?: boolean;
  69919. }, scene?: Nullable<Scene>): Mesh;
  69920. /**
  69921. * Creates lathe mesh.
  69922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69923. * * 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
  69924. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69925. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69926. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69927. * * 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
  69928. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69929. * * 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
  69930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69934. * @param name defines the name of the mesh
  69935. * @param options defines the options used to create the mesh
  69936. * @param scene defines the hosting scene
  69937. * @returns the lathe mesh
  69938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69939. */
  69940. static CreateLathe(name: string, options: {
  69941. shape: Vector3[];
  69942. radius?: number;
  69943. tessellation?: number;
  69944. clip?: number;
  69945. arc?: number;
  69946. closed?: boolean;
  69947. updatable?: boolean;
  69948. sideOrientation?: number;
  69949. frontUVs?: Vector4;
  69950. backUVs?: Vector4;
  69951. cap?: number;
  69952. invertUV?: boolean;
  69953. }, scene?: Nullable<Scene>): Mesh;
  69954. /**
  69955. * Creates a tiled plane mesh
  69956. * * You can set a limited pattern arrangement with the tiles
  69957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69960. * @param name defines the name of the mesh
  69961. * @param options defines the options used to create the mesh
  69962. * @param scene defines the hosting scene
  69963. * @returns the plane mesh
  69964. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69965. */
  69966. static CreateTiledPlane(name: string, options: {
  69967. pattern?: number;
  69968. tileSize?: number;
  69969. tileWidth?: number;
  69970. tileHeight?: number;
  69971. size?: number;
  69972. width?: number;
  69973. height?: number;
  69974. alignHorizontal?: number;
  69975. alignVertical?: number;
  69976. sideOrientation?: number;
  69977. frontUVs?: Vector4;
  69978. backUVs?: Vector4;
  69979. updatable?: boolean;
  69980. }, scene?: Nullable<Scene>): Mesh;
  69981. /**
  69982. * Creates a plane mesh
  69983. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69984. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69985. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69989. * @param name defines the name of the mesh
  69990. * @param options defines the options used to create the mesh
  69991. * @param scene defines the hosting scene
  69992. * @returns the plane mesh
  69993. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69994. */
  69995. static CreatePlane(name: string, options: {
  69996. size?: number;
  69997. width?: number;
  69998. height?: number;
  69999. sideOrientation?: number;
  70000. frontUVs?: Vector4;
  70001. backUVs?: Vector4;
  70002. updatable?: boolean;
  70003. sourcePlane?: Plane;
  70004. }, scene?: Nullable<Scene>): Mesh;
  70005. /**
  70006. * Creates a ground mesh
  70007. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70008. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70010. * @param name defines the name of the mesh
  70011. * @param options defines the options used to create the mesh
  70012. * @param scene defines the hosting scene
  70013. * @returns the ground mesh
  70014. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70015. */
  70016. static CreateGround(name: string, options: {
  70017. width?: number;
  70018. height?: number;
  70019. subdivisions?: number;
  70020. subdivisionsX?: number;
  70021. subdivisionsY?: number;
  70022. updatable?: boolean;
  70023. }, scene?: Nullable<Scene>): Mesh;
  70024. /**
  70025. * Creates a tiled ground mesh
  70026. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70027. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70028. * * 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
  70029. * * 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
  70030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70031. * @param name defines the name of the mesh
  70032. * @param options defines the options used to create the mesh
  70033. * @param scene defines the hosting scene
  70034. * @returns the tiled ground mesh
  70035. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70036. */
  70037. static CreateTiledGround(name: string, options: {
  70038. xmin: number;
  70039. zmin: number;
  70040. xmax: number;
  70041. zmax: number;
  70042. subdivisions?: {
  70043. w: number;
  70044. h: number;
  70045. };
  70046. precision?: {
  70047. w: number;
  70048. h: number;
  70049. };
  70050. updatable?: boolean;
  70051. }, scene?: Nullable<Scene>): Mesh;
  70052. /**
  70053. * Creates a ground mesh from a height map
  70054. * * The parameter `url` sets the URL of the height map image resource.
  70055. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70056. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70057. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70058. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70059. * * 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.
  70060. * * 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).
  70061. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70063. * @param name defines the name of the mesh
  70064. * @param url defines the url to the height map
  70065. * @param options defines the options used to create the mesh
  70066. * @param scene defines the hosting scene
  70067. * @returns the ground mesh
  70068. * @see https://doc.babylonjs.com/babylon101/height_map
  70069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70070. */
  70071. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70072. width?: number;
  70073. height?: number;
  70074. subdivisions?: number;
  70075. minHeight?: number;
  70076. maxHeight?: number;
  70077. colorFilter?: Color3;
  70078. alphaFilter?: number;
  70079. updatable?: boolean;
  70080. onReady?: (mesh: GroundMesh) => void;
  70081. }, scene?: Nullable<Scene>): GroundMesh;
  70082. /**
  70083. * Creates a polygon mesh
  70084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70085. * * 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
  70086. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70089. * * Remember you can only change the shape positions, not their number when updating a polygon
  70090. * @param name defines the name of the mesh
  70091. * @param options defines the options used to create the mesh
  70092. * @param scene defines the hosting scene
  70093. * @param earcutInjection can be used to inject your own earcut reference
  70094. * @returns the polygon mesh
  70095. */
  70096. static CreatePolygon(name: string, options: {
  70097. shape: Vector3[];
  70098. holes?: Vector3[][];
  70099. depth?: number;
  70100. faceUV?: Vector4[];
  70101. faceColors?: Color4[];
  70102. updatable?: boolean;
  70103. sideOrientation?: number;
  70104. frontUVs?: Vector4;
  70105. backUVs?: Vector4;
  70106. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70107. /**
  70108. * Creates an extruded polygon mesh, with depth in the Y direction.
  70109. * * 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)
  70110. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70111. * @param name defines the name of the mesh
  70112. * @param options defines the options used to create the mesh
  70113. * @param scene defines the hosting scene
  70114. * @param earcutInjection can be used to inject your own earcut reference
  70115. * @returns the polygon mesh
  70116. */
  70117. static ExtrudePolygon(name: string, options: {
  70118. shape: Vector3[];
  70119. holes?: Vector3[][];
  70120. depth?: number;
  70121. faceUV?: Vector4[];
  70122. faceColors?: Color4[];
  70123. updatable?: boolean;
  70124. sideOrientation?: number;
  70125. frontUVs?: Vector4;
  70126. backUVs?: Vector4;
  70127. wrap?: boolean;
  70128. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70129. /**
  70130. * Creates a tube mesh.
  70131. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70132. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70133. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70134. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70135. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70136. * * 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)
  70137. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70138. * * 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
  70139. * * 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
  70140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70144. * @param name defines the name of the mesh
  70145. * @param options defines the options used to create the mesh
  70146. * @param scene defines the hosting scene
  70147. * @returns the tube mesh
  70148. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70149. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70150. */
  70151. static CreateTube(name: string, options: {
  70152. path: Vector3[];
  70153. radius?: number;
  70154. tessellation?: number;
  70155. radiusFunction?: {
  70156. (i: number, distance: number): number;
  70157. };
  70158. cap?: number;
  70159. arc?: number;
  70160. updatable?: boolean;
  70161. sideOrientation?: number;
  70162. frontUVs?: Vector4;
  70163. backUVs?: Vector4;
  70164. instance?: Mesh;
  70165. invertUV?: boolean;
  70166. }, scene?: Nullable<Scene>): Mesh;
  70167. /**
  70168. * Creates a polyhedron mesh
  70169. * * 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
  70170. * * The parameter `size` (positive float, default 1) sets the polygon size
  70171. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70172. * * 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`
  70173. * * 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
  70174. * * 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)`)
  70175. * * 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
  70176. * * 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
  70177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70180. * @param name defines the name of the mesh
  70181. * @param options defines the options used to create the mesh
  70182. * @param scene defines the hosting scene
  70183. * @returns the polyhedron mesh
  70184. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70185. */
  70186. static CreatePolyhedron(name: string, options: {
  70187. type?: number;
  70188. size?: number;
  70189. sizeX?: number;
  70190. sizeY?: number;
  70191. sizeZ?: number;
  70192. custom?: any;
  70193. faceUV?: Vector4[];
  70194. faceColors?: Color4[];
  70195. flat?: boolean;
  70196. updatable?: boolean;
  70197. sideOrientation?: number;
  70198. frontUVs?: Vector4;
  70199. backUVs?: Vector4;
  70200. }, scene?: Nullable<Scene>): Mesh;
  70201. /**
  70202. * Creates a decal mesh.
  70203. * 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
  70204. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70205. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70206. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70207. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70208. * @param name defines the name of the mesh
  70209. * @param sourceMesh defines the mesh where the decal must be applied
  70210. * @param options defines the options used to create the mesh
  70211. * @param scene defines the hosting scene
  70212. * @returns the decal mesh
  70213. * @see https://doc.babylonjs.com/how_to/decals
  70214. */
  70215. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70216. position?: Vector3;
  70217. normal?: Vector3;
  70218. size?: Vector3;
  70219. angle?: number;
  70220. }): Mesh;
  70221. /**
  70222. * Creates a Capsule Mesh
  70223. * @param name defines the name of the mesh.
  70224. * @param options the constructors options used to shape the mesh.
  70225. * @param scene defines the scene the mesh is scoped to.
  70226. * @returns the capsule mesh
  70227. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70228. */
  70229. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70230. }
  70231. }
  70232. declare module "babylonjs/Meshes/meshSimplification" {
  70233. import { Mesh } from "babylonjs/Meshes/mesh";
  70234. /**
  70235. * A simplifier interface for future simplification implementations
  70236. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70237. */
  70238. export interface ISimplifier {
  70239. /**
  70240. * Simplification of a given mesh according to the given settings.
  70241. * Since this requires computation, it is assumed that the function runs async.
  70242. * @param settings The settings of the simplification, including quality and distance
  70243. * @param successCallback A callback that will be called after the mesh was simplified.
  70244. * @param errorCallback in case of an error, this callback will be called. optional.
  70245. */
  70246. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70247. }
  70248. /**
  70249. * Expected simplification settings.
  70250. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70251. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70252. */
  70253. export interface ISimplificationSettings {
  70254. /**
  70255. * Gets or sets the expected quality
  70256. */
  70257. quality: number;
  70258. /**
  70259. * Gets or sets the distance when this optimized version should be used
  70260. */
  70261. distance: number;
  70262. /**
  70263. * Gets an already optimized mesh
  70264. */
  70265. optimizeMesh?: boolean;
  70266. }
  70267. /**
  70268. * Class used to specify simplification options
  70269. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70270. */
  70271. export class SimplificationSettings implements ISimplificationSettings {
  70272. /** expected quality */
  70273. quality: number;
  70274. /** distance when this optimized version should be used */
  70275. distance: number;
  70276. /** already optimized mesh */
  70277. optimizeMesh?: boolean | undefined;
  70278. /**
  70279. * Creates a SimplificationSettings
  70280. * @param quality expected quality
  70281. * @param distance distance when this optimized version should be used
  70282. * @param optimizeMesh already optimized mesh
  70283. */
  70284. constructor(
  70285. /** expected quality */
  70286. quality: number,
  70287. /** distance when this optimized version should be used */
  70288. distance: number,
  70289. /** already optimized mesh */
  70290. optimizeMesh?: boolean | undefined);
  70291. }
  70292. /**
  70293. * Interface used to define a simplification task
  70294. */
  70295. export interface ISimplificationTask {
  70296. /**
  70297. * Array of settings
  70298. */
  70299. settings: Array<ISimplificationSettings>;
  70300. /**
  70301. * Simplification type
  70302. */
  70303. simplificationType: SimplificationType;
  70304. /**
  70305. * Mesh to simplify
  70306. */
  70307. mesh: Mesh;
  70308. /**
  70309. * Callback called on success
  70310. */
  70311. successCallback?: () => void;
  70312. /**
  70313. * Defines if parallel processing can be used
  70314. */
  70315. parallelProcessing: boolean;
  70316. }
  70317. /**
  70318. * Queue used to order the simplification tasks
  70319. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70320. */
  70321. export class SimplificationQueue {
  70322. private _simplificationArray;
  70323. /**
  70324. * Gets a boolean indicating that the process is still running
  70325. */
  70326. running: boolean;
  70327. /**
  70328. * Creates a new queue
  70329. */
  70330. constructor();
  70331. /**
  70332. * Adds a new simplification task
  70333. * @param task defines a task to add
  70334. */
  70335. addTask(task: ISimplificationTask): void;
  70336. /**
  70337. * Execute next task
  70338. */
  70339. executeNext(): void;
  70340. /**
  70341. * Execute a simplification task
  70342. * @param task defines the task to run
  70343. */
  70344. runSimplification(task: ISimplificationTask): void;
  70345. private getSimplifier;
  70346. }
  70347. /**
  70348. * The implemented types of simplification
  70349. * At the moment only Quadratic Error Decimation is implemented
  70350. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70351. */
  70352. export enum SimplificationType {
  70353. /** Quadratic error decimation */
  70354. QUADRATIC = 0
  70355. }
  70356. /**
  70357. * An implementation of the Quadratic Error simplification algorithm.
  70358. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70359. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70360. * @author RaananW
  70361. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70362. */
  70363. export class QuadraticErrorSimplification implements ISimplifier {
  70364. private _mesh;
  70365. private triangles;
  70366. private vertices;
  70367. private references;
  70368. private _reconstructedMesh;
  70369. /** Gets or sets the number pf sync interations */
  70370. syncIterations: number;
  70371. /** Gets or sets the aggressiveness of the simplifier */
  70372. aggressiveness: number;
  70373. /** Gets or sets the number of allowed iterations for decimation */
  70374. decimationIterations: number;
  70375. /** Gets or sets the espilon to use for bounding box computation */
  70376. boundingBoxEpsilon: number;
  70377. /**
  70378. * Creates a new QuadraticErrorSimplification
  70379. * @param _mesh defines the target mesh
  70380. */
  70381. constructor(_mesh: Mesh);
  70382. /**
  70383. * Simplification of a given mesh according to the given settings.
  70384. * Since this requires computation, it is assumed that the function runs async.
  70385. * @param settings The settings of the simplification, including quality and distance
  70386. * @param successCallback A callback that will be called after the mesh was simplified.
  70387. */
  70388. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70389. private runDecimation;
  70390. private initWithMesh;
  70391. private init;
  70392. private reconstructMesh;
  70393. private initDecimatedMesh;
  70394. private isFlipped;
  70395. private updateTriangles;
  70396. private identifyBorder;
  70397. private updateMesh;
  70398. private vertexError;
  70399. private calculateError;
  70400. }
  70401. }
  70402. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70403. import { Scene } from "babylonjs/scene";
  70404. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70405. import { ISceneComponent } from "babylonjs/sceneComponent";
  70406. module "babylonjs/scene" {
  70407. interface Scene {
  70408. /** @hidden (Backing field) */
  70409. _simplificationQueue: SimplificationQueue;
  70410. /**
  70411. * Gets or sets the simplification queue attached to the scene
  70412. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70413. */
  70414. simplificationQueue: SimplificationQueue;
  70415. }
  70416. }
  70417. module "babylonjs/Meshes/mesh" {
  70418. interface Mesh {
  70419. /**
  70420. * Simplify the mesh according to the given array of settings.
  70421. * Function will return immediately and will simplify async
  70422. * @param settings a collection of simplification settings
  70423. * @param parallelProcessing should all levels calculate parallel or one after the other
  70424. * @param simplificationType the type of simplification to run
  70425. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70426. * @returns the current mesh
  70427. */
  70428. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70429. }
  70430. }
  70431. /**
  70432. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70433. * created in a scene
  70434. */
  70435. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70436. /**
  70437. * The component name helpfull to identify the component in the list of scene components.
  70438. */
  70439. readonly name: string;
  70440. /**
  70441. * The scene the component belongs to.
  70442. */
  70443. scene: Scene;
  70444. /**
  70445. * Creates a new instance of the component for the given scene
  70446. * @param scene Defines the scene to register the component in
  70447. */
  70448. constructor(scene: Scene);
  70449. /**
  70450. * Registers the component in a given scene
  70451. */
  70452. register(): void;
  70453. /**
  70454. * Rebuilds the elements related to this component in case of
  70455. * context lost for instance.
  70456. */
  70457. rebuild(): void;
  70458. /**
  70459. * Disposes the component and the associated ressources
  70460. */
  70461. dispose(): void;
  70462. private _beforeCameraUpdate;
  70463. }
  70464. }
  70465. declare module "babylonjs/Meshes/Builders/index" {
  70466. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70467. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70468. export * from "babylonjs/Meshes/Builders/discBuilder";
  70469. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70470. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70471. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70472. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70473. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70474. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70475. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70476. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70477. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70478. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70479. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70480. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70481. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70482. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70483. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70484. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70485. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70486. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70487. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70488. }
  70489. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70490. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70492. import { Matrix } from "babylonjs/Maths/math.vector";
  70493. module "babylonjs/Meshes/mesh" {
  70494. interface Mesh {
  70495. /**
  70496. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70497. */
  70498. thinInstanceEnablePicking: boolean;
  70499. /**
  70500. * Creates a new thin instance
  70501. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70502. * @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
  70503. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70504. */
  70505. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70506. /**
  70507. * Adds the transformation (matrix) of the current mesh as a thin instance
  70508. * @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
  70509. * @returns the thin instance index number
  70510. */
  70511. thinInstanceAddSelf(refresh: boolean): number;
  70512. /**
  70513. * Registers a custom attribute to be used with thin instances
  70514. * @param kind name of the attribute
  70515. * @param stride size in floats of the attribute
  70516. */
  70517. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70518. /**
  70519. * Sets the matrix of a thin instance
  70520. * @param index index of the thin instance
  70521. * @param matrix matrix to set
  70522. * @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
  70523. */
  70524. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70525. /**
  70526. * Sets the value of a custom attribute for a thin instance
  70527. * @param kind name of the attribute
  70528. * @param index index of the thin instance
  70529. * @param value value to set
  70530. * @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
  70531. */
  70532. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70533. /**
  70534. * 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.
  70535. */
  70536. thinInstanceCount: number;
  70537. /**
  70538. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70539. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70540. * @param buffer buffer to set
  70541. * @param stride size in floats of each value of the buffer
  70542. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70543. */
  70544. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70545. /**
  70546. * Gets the list of world matrices
  70547. * @return an array containing all the world matrices from the thin instances
  70548. */
  70549. thinInstanceGetWorldMatrices(): Matrix[];
  70550. /**
  70551. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70552. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70553. */
  70554. thinInstanceBufferUpdated(kind: string): void;
  70555. /**
  70556. * Applies a partial update to a buffer directly on the GPU
  70557. * 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
  70558. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70559. * @param data the data to set in the GPU buffer
  70560. * @param offset the offset in the GPU buffer where to update the data
  70561. */
  70562. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70563. /**
  70564. * Refreshes the bounding info, taking into account all the thin instances defined
  70565. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70566. */
  70567. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70568. /** @hidden */
  70569. _thinInstanceInitializeUserStorage(): void;
  70570. /** @hidden */
  70571. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70572. /** @hidden */
  70573. _userThinInstanceBuffersStorage: {
  70574. data: {
  70575. [key: string]: Float32Array;
  70576. };
  70577. sizes: {
  70578. [key: string]: number;
  70579. };
  70580. vertexBuffers: {
  70581. [key: string]: Nullable<VertexBuffer>;
  70582. };
  70583. strides: {
  70584. [key: string]: number;
  70585. };
  70586. };
  70587. }
  70588. }
  70589. }
  70590. declare module "babylonjs/Meshes/index" {
  70591. export * from "babylonjs/Meshes/abstractMesh";
  70592. export * from "babylonjs/Meshes/buffer";
  70593. export * from "babylonjs/Meshes/Compression/index";
  70594. export * from "babylonjs/Meshes/csg";
  70595. export * from "babylonjs/Meshes/geometry";
  70596. export * from "babylonjs/Meshes/groundMesh";
  70597. export * from "babylonjs/Meshes/trailMesh";
  70598. export * from "babylonjs/Meshes/instancedMesh";
  70599. export * from "babylonjs/Meshes/linesMesh";
  70600. export * from "babylonjs/Meshes/mesh";
  70601. export * from "babylonjs/Meshes/mesh.vertexData";
  70602. export * from "babylonjs/Meshes/meshBuilder";
  70603. export * from "babylonjs/Meshes/meshSimplification";
  70604. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70605. export * from "babylonjs/Meshes/polygonMesh";
  70606. export * from "babylonjs/Meshes/subMesh";
  70607. export * from "babylonjs/Meshes/meshLODLevel";
  70608. export * from "babylonjs/Meshes/transformNode";
  70609. export * from "babylonjs/Meshes/Builders/index";
  70610. export * from "babylonjs/Meshes/dataBuffer";
  70611. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70612. import "babylonjs/Meshes/thinInstanceMesh";
  70613. export * from "babylonjs/Meshes/thinInstanceMesh";
  70614. }
  70615. declare module "babylonjs/Morph/index" {
  70616. export * from "babylonjs/Morph/morphTarget";
  70617. export * from "babylonjs/Morph/morphTargetManager";
  70618. }
  70619. declare module "babylonjs/Navigation/INavigationEngine" {
  70620. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70621. import { Vector3 } from "babylonjs/Maths/math";
  70622. import { Mesh } from "babylonjs/Meshes/mesh";
  70623. import { Scene } from "babylonjs/scene";
  70624. /**
  70625. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70626. */
  70627. export interface INavigationEnginePlugin {
  70628. /**
  70629. * plugin name
  70630. */
  70631. name: string;
  70632. /**
  70633. * Creates a navigation mesh
  70634. * @param meshes array of all the geometry used to compute the navigatio mesh
  70635. * @param parameters bunch of parameters used to filter geometry
  70636. */
  70637. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70638. /**
  70639. * Create a navigation mesh debug mesh
  70640. * @param scene is where the mesh will be added
  70641. * @returns debug display mesh
  70642. */
  70643. createDebugNavMesh(scene: Scene): Mesh;
  70644. /**
  70645. * Get a navigation mesh constrained position, closest to the parameter position
  70646. * @param position world position
  70647. * @returns the closest point to position constrained by the navigation mesh
  70648. */
  70649. getClosestPoint(position: Vector3): Vector3;
  70650. /**
  70651. * Get a navigation mesh constrained position, closest to the parameter position
  70652. * @param position world position
  70653. * @param result output the closest point to position constrained by the navigation mesh
  70654. */
  70655. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70656. /**
  70657. * Get a navigation mesh constrained position, within a particular radius
  70658. * @param position world position
  70659. * @param maxRadius the maximum distance to the constrained world position
  70660. * @returns the closest point to position constrained by the navigation mesh
  70661. */
  70662. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70663. /**
  70664. * Get a navigation mesh constrained position, within a particular radius
  70665. * @param position world position
  70666. * @param maxRadius the maximum distance to the constrained world position
  70667. * @param result output the closest point to position constrained by the navigation mesh
  70668. */
  70669. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70670. /**
  70671. * Compute the final position from a segment made of destination-position
  70672. * @param position world position
  70673. * @param destination world position
  70674. * @returns the resulting point along the navmesh
  70675. */
  70676. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70677. /**
  70678. * Compute the final position from a segment made of destination-position
  70679. * @param position world position
  70680. * @param destination world position
  70681. * @param result output the resulting point along the navmesh
  70682. */
  70683. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70684. /**
  70685. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70686. * @param start world position
  70687. * @param end world position
  70688. * @returns array containing world position composing the path
  70689. */
  70690. computePath(start: Vector3, end: Vector3): Vector3[];
  70691. /**
  70692. * If this plugin is supported
  70693. * @returns true if plugin is supported
  70694. */
  70695. isSupported(): boolean;
  70696. /**
  70697. * Create a new Crowd so you can add agents
  70698. * @param maxAgents the maximum agent count in the crowd
  70699. * @param maxAgentRadius the maximum radius an agent can have
  70700. * @param scene to attach the crowd to
  70701. * @returns the crowd you can add agents to
  70702. */
  70703. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70704. /**
  70705. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70706. * The queries will try to find a solution within those bounds
  70707. * default is (1,1,1)
  70708. * @param extent x,y,z value that define the extent around the queries point of reference
  70709. */
  70710. setDefaultQueryExtent(extent: Vector3): void;
  70711. /**
  70712. * Get the Bounding box extent specified by setDefaultQueryExtent
  70713. * @returns the box extent values
  70714. */
  70715. getDefaultQueryExtent(): Vector3;
  70716. /**
  70717. * build the navmesh from a previously saved state using getNavmeshData
  70718. * @param data the Uint8Array returned by getNavmeshData
  70719. */
  70720. buildFromNavmeshData(data: Uint8Array): void;
  70721. /**
  70722. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70723. * @returns data the Uint8Array that can be saved and reused
  70724. */
  70725. getNavmeshData(): Uint8Array;
  70726. /**
  70727. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70728. * @param result output the box extent values
  70729. */
  70730. getDefaultQueryExtentToRef(result: Vector3): void;
  70731. /**
  70732. * Release all resources
  70733. */
  70734. dispose(): void;
  70735. }
  70736. /**
  70737. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70738. */
  70739. export interface ICrowd {
  70740. /**
  70741. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70742. * You can attach anything to that node. The node position is updated in the scene update tick.
  70743. * @param pos world position that will be constrained by the navigation mesh
  70744. * @param parameters agent parameters
  70745. * @param transform hooked to the agent that will be update by the scene
  70746. * @returns agent index
  70747. */
  70748. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70749. /**
  70750. * Returns the agent position in world space
  70751. * @param index agent index returned by addAgent
  70752. * @returns world space position
  70753. */
  70754. getAgentPosition(index: number): Vector3;
  70755. /**
  70756. * Gets the agent position result in world space
  70757. * @param index agent index returned by addAgent
  70758. * @param result output world space position
  70759. */
  70760. getAgentPositionToRef(index: number, result: Vector3): void;
  70761. /**
  70762. * Gets the agent velocity in world space
  70763. * @param index agent index returned by addAgent
  70764. * @returns world space velocity
  70765. */
  70766. getAgentVelocity(index: number): Vector3;
  70767. /**
  70768. * Gets the agent velocity result in world space
  70769. * @param index agent index returned by addAgent
  70770. * @param result output world space velocity
  70771. */
  70772. getAgentVelocityToRef(index: number, result: Vector3): void;
  70773. /**
  70774. * remove a particular agent previously created
  70775. * @param index agent index returned by addAgent
  70776. */
  70777. removeAgent(index: number): void;
  70778. /**
  70779. * get the list of all agents attached to this crowd
  70780. * @returns list of agent indices
  70781. */
  70782. getAgents(): number[];
  70783. /**
  70784. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70785. * @param deltaTime in seconds
  70786. */
  70787. update(deltaTime: number): void;
  70788. /**
  70789. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70790. * @param index agent index returned by addAgent
  70791. * @param destination targeted world position
  70792. */
  70793. agentGoto(index: number, destination: Vector3): void;
  70794. /**
  70795. * Teleport the agent to a new position
  70796. * @param index agent index returned by addAgent
  70797. * @param destination targeted world position
  70798. */
  70799. agentTeleport(index: number, destination: Vector3): void;
  70800. /**
  70801. * Update agent parameters
  70802. * @param index agent index returned by addAgent
  70803. * @param parameters agent parameters
  70804. */
  70805. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70806. /**
  70807. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70808. * The queries will try to find a solution within those bounds
  70809. * default is (1,1,1)
  70810. * @param extent x,y,z value that define the extent around the queries point of reference
  70811. */
  70812. setDefaultQueryExtent(extent: Vector3): void;
  70813. /**
  70814. * Get the Bounding box extent specified by setDefaultQueryExtent
  70815. * @returns the box extent values
  70816. */
  70817. getDefaultQueryExtent(): Vector3;
  70818. /**
  70819. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70820. * @param result output the box extent values
  70821. */
  70822. getDefaultQueryExtentToRef(result: Vector3): void;
  70823. /**
  70824. * Release all resources
  70825. */
  70826. dispose(): void;
  70827. }
  70828. /**
  70829. * Configures an agent
  70830. */
  70831. export interface IAgentParameters {
  70832. /**
  70833. * Agent radius. [Limit: >= 0]
  70834. */
  70835. radius: number;
  70836. /**
  70837. * Agent height. [Limit: > 0]
  70838. */
  70839. height: number;
  70840. /**
  70841. * Maximum allowed acceleration. [Limit: >= 0]
  70842. */
  70843. maxAcceleration: number;
  70844. /**
  70845. * Maximum allowed speed. [Limit: >= 0]
  70846. */
  70847. maxSpeed: number;
  70848. /**
  70849. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70850. */
  70851. collisionQueryRange: number;
  70852. /**
  70853. * The path visibility optimization range. [Limit: > 0]
  70854. */
  70855. pathOptimizationRange: number;
  70856. /**
  70857. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70858. */
  70859. separationWeight: number;
  70860. }
  70861. /**
  70862. * Configures the navigation mesh creation
  70863. */
  70864. export interface INavMeshParameters {
  70865. /**
  70866. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70867. */
  70868. cs: number;
  70869. /**
  70870. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70871. */
  70872. ch: number;
  70873. /**
  70874. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70875. */
  70876. walkableSlopeAngle: number;
  70877. /**
  70878. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70879. * be considered walkable. [Limit: >= 3] [Units: vx]
  70880. */
  70881. walkableHeight: number;
  70882. /**
  70883. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70884. */
  70885. walkableClimb: number;
  70886. /**
  70887. * The distance to erode/shrink the walkable area of the heightfield away from
  70888. * obstructions. [Limit: >=0] [Units: vx]
  70889. */
  70890. walkableRadius: number;
  70891. /**
  70892. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70893. */
  70894. maxEdgeLen: number;
  70895. /**
  70896. * The maximum distance a simplfied contour's border edges should deviate
  70897. * the original raw contour. [Limit: >=0] [Units: vx]
  70898. */
  70899. maxSimplificationError: number;
  70900. /**
  70901. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70902. */
  70903. minRegionArea: number;
  70904. /**
  70905. * Any regions with a span count smaller than this value will, if possible,
  70906. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70907. */
  70908. mergeRegionArea: number;
  70909. /**
  70910. * The maximum number of vertices allowed for polygons generated during the
  70911. * contour to polygon conversion process. [Limit: >= 3]
  70912. */
  70913. maxVertsPerPoly: number;
  70914. /**
  70915. * Sets the sampling distance to use when generating the detail mesh.
  70916. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70917. */
  70918. detailSampleDist: number;
  70919. /**
  70920. * The maximum distance the detail mesh surface should deviate from heightfield
  70921. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70922. */
  70923. detailSampleMaxError: number;
  70924. }
  70925. }
  70926. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70927. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70928. import { Mesh } from "babylonjs/Meshes/mesh";
  70929. import { Scene } from "babylonjs/scene";
  70930. import { Vector3 } from "babylonjs/Maths/math";
  70931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70932. /**
  70933. * RecastJS navigation plugin
  70934. */
  70935. export class RecastJSPlugin implements INavigationEnginePlugin {
  70936. /**
  70937. * Reference to the Recast library
  70938. */
  70939. bjsRECAST: any;
  70940. /**
  70941. * plugin name
  70942. */
  70943. name: string;
  70944. /**
  70945. * the first navmesh created. We might extend this to support multiple navmeshes
  70946. */
  70947. navMesh: any;
  70948. /**
  70949. * Initializes the recastJS plugin
  70950. * @param recastInjection can be used to inject your own recast reference
  70951. */
  70952. constructor(recastInjection?: any);
  70953. /**
  70954. * Creates a navigation mesh
  70955. * @param meshes array of all the geometry used to compute the navigatio mesh
  70956. * @param parameters bunch of parameters used to filter geometry
  70957. */
  70958. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70959. /**
  70960. * Create a navigation mesh debug mesh
  70961. * @param scene is where the mesh will be added
  70962. * @returns debug display mesh
  70963. */
  70964. createDebugNavMesh(scene: Scene): Mesh;
  70965. /**
  70966. * Get a navigation mesh constrained position, closest to the parameter position
  70967. * @param position world position
  70968. * @returns the closest point to position constrained by the navigation mesh
  70969. */
  70970. getClosestPoint(position: Vector3): Vector3;
  70971. /**
  70972. * Get a navigation mesh constrained position, closest to the parameter position
  70973. * @param position world position
  70974. * @param result output the closest point to position constrained by the navigation mesh
  70975. */
  70976. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70977. /**
  70978. * Get a navigation mesh constrained position, within a particular radius
  70979. * @param position world position
  70980. * @param maxRadius the maximum distance to the constrained world position
  70981. * @returns the closest point to position constrained by the navigation mesh
  70982. */
  70983. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70984. /**
  70985. * Get a navigation mesh constrained position, within a particular radius
  70986. * @param position world position
  70987. * @param maxRadius the maximum distance to the constrained world position
  70988. * @param result output the closest point to position constrained by the navigation mesh
  70989. */
  70990. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70991. /**
  70992. * Compute the final position from a segment made of destination-position
  70993. * @param position world position
  70994. * @param destination world position
  70995. * @returns the resulting point along the navmesh
  70996. */
  70997. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70998. /**
  70999. * Compute the final position from a segment made of destination-position
  71000. * @param position world position
  71001. * @param destination world position
  71002. * @param result output the resulting point along the navmesh
  71003. */
  71004. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71005. /**
  71006. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71007. * @param start world position
  71008. * @param end world position
  71009. * @returns array containing world position composing the path
  71010. */
  71011. computePath(start: Vector3, end: Vector3): Vector3[];
  71012. /**
  71013. * Create a new Crowd so you can add agents
  71014. * @param maxAgents the maximum agent count in the crowd
  71015. * @param maxAgentRadius the maximum radius an agent can have
  71016. * @param scene to attach the crowd to
  71017. * @returns the crowd you can add agents to
  71018. */
  71019. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71020. /**
  71021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71022. * The queries will try to find a solution within those bounds
  71023. * default is (1,1,1)
  71024. * @param extent x,y,z value that define the extent around the queries point of reference
  71025. */
  71026. setDefaultQueryExtent(extent: Vector3): void;
  71027. /**
  71028. * Get the Bounding box extent specified by setDefaultQueryExtent
  71029. * @returns the box extent values
  71030. */
  71031. getDefaultQueryExtent(): Vector3;
  71032. /**
  71033. * build the navmesh from a previously saved state using getNavmeshData
  71034. * @param data the Uint8Array returned by getNavmeshData
  71035. */
  71036. buildFromNavmeshData(data: Uint8Array): void;
  71037. /**
  71038. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71039. * @returns data the Uint8Array that can be saved and reused
  71040. */
  71041. getNavmeshData(): Uint8Array;
  71042. /**
  71043. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71044. * @param result output the box extent values
  71045. */
  71046. getDefaultQueryExtentToRef(result: Vector3): void;
  71047. /**
  71048. * Disposes
  71049. */
  71050. dispose(): void;
  71051. /**
  71052. * If this plugin is supported
  71053. * @returns true if plugin is supported
  71054. */
  71055. isSupported(): boolean;
  71056. }
  71057. /**
  71058. * Recast detour crowd implementation
  71059. */
  71060. export class RecastJSCrowd implements ICrowd {
  71061. /**
  71062. * Recast/detour plugin
  71063. */
  71064. bjsRECASTPlugin: RecastJSPlugin;
  71065. /**
  71066. * Link to the detour crowd
  71067. */
  71068. recastCrowd: any;
  71069. /**
  71070. * One transform per agent
  71071. */
  71072. transforms: TransformNode[];
  71073. /**
  71074. * All agents created
  71075. */
  71076. agents: number[];
  71077. /**
  71078. * Link to the scene is kept to unregister the crowd from the scene
  71079. */
  71080. private _scene;
  71081. /**
  71082. * Observer for crowd updates
  71083. */
  71084. private _onBeforeAnimationsObserver;
  71085. /**
  71086. * Constructor
  71087. * @param plugin recastJS plugin
  71088. * @param maxAgents the maximum agent count in the crowd
  71089. * @param maxAgentRadius the maximum radius an agent can have
  71090. * @param scene to attach the crowd to
  71091. * @returns the crowd you can add agents to
  71092. */
  71093. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71094. /**
  71095. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71096. * You can attach anything to that node. The node position is updated in the scene update tick.
  71097. * @param pos world position that will be constrained by the navigation mesh
  71098. * @param parameters agent parameters
  71099. * @param transform hooked to the agent that will be update by the scene
  71100. * @returns agent index
  71101. */
  71102. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71103. /**
  71104. * Returns the agent position in world space
  71105. * @param index agent index returned by addAgent
  71106. * @returns world space position
  71107. */
  71108. getAgentPosition(index: number): Vector3;
  71109. /**
  71110. * Returns the agent position result in world space
  71111. * @param index agent index returned by addAgent
  71112. * @param result output world space position
  71113. */
  71114. getAgentPositionToRef(index: number, result: Vector3): void;
  71115. /**
  71116. * Returns the agent velocity in world space
  71117. * @param index agent index returned by addAgent
  71118. * @returns world space velocity
  71119. */
  71120. getAgentVelocity(index: number): Vector3;
  71121. /**
  71122. * Returns the agent velocity result in world space
  71123. * @param index agent index returned by addAgent
  71124. * @param result output world space velocity
  71125. */
  71126. getAgentVelocityToRef(index: number, result: Vector3): void;
  71127. /**
  71128. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71129. * @param index agent index returned by addAgent
  71130. * @param destination targeted world position
  71131. */
  71132. agentGoto(index: number, destination: Vector3): void;
  71133. /**
  71134. * Teleport the agent to a new position
  71135. * @param index agent index returned by addAgent
  71136. * @param destination targeted world position
  71137. */
  71138. agentTeleport(index: number, destination: Vector3): void;
  71139. /**
  71140. * Update agent parameters
  71141. * @param index agent index returned by addAgent
  71142. * @param parameters agent parameters
  71143. */
  71144. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71145. /**
  71146. * remove a particular agent previously created
  71147. * @param index agent index returned by addAgent
  71148. */
  71149. removeAgent(index: number): void;
  71150. /**
  71151. * get the list of all agents attached to this crowd
  71152. * @returns list of agent indices
  71153. */
  71154. getAgents(): number[];
  71155. /**
  71156. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71157. * @param deltaTime in seconds
  71158. */
  71159. update(deltaTime: number): void;
  71160. /**
  71161. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71162. * The queries will try to find a solution within those bounds
  71163. * default is (1,1,1)
  71164. * @param extent x,y,z value that define the extent around the queries point of reference
  71165. */
  71166. setDefaultQueryExtent(extent: Vector3): void;
  71167. /**
  71168. * Get the Bounding box extent specified by setDefaultQueryExtent
  71169. * @returns the box extent values
  71170. */
  71171. getDefaultQueryExtent(): Vector3;
  71172. /**
  71173. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71174. * @param result output the box extent values
  71175. */
  71176. getDefaultQueryExtentToRef(result: Vector3): void;
  71177. /**
  71178. * Release all resources
  71179. */
  71180. dispose(): void;
  71181. }
  71182. }
  71183. declare module "babylonjs/Navigation/Plugins/index" {
  71184. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71185. }
  71186. declare module "babylonjs/Navigation/index" {
  71187. export * from "babylonjs/Navigation/INavigationEngine";
  71188. export * from "babylonjs/Navigation/Plugins/index";
  71189. }
  71190. declare module "babylonjs/Offline/database" {
  71191. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71192. /**
  71193. * Class used to enable access to IndexedDB
  71194. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71195. */
  71196. export class Database implements IOfflineProvider {
  71197. private _callbackManifestChecked;
  71198. private _currentSceneUrl;
  71199. private _db;
  71200. private _enableSceneOffline;
  71201. private _enableTexturesOffline;
  71202. private _manifestVersionFound;
  71203. private _mustUpdateRessources;
  71204. private _hasReachedQuota;
  71205. private _isSupported;
  71206. private _idbFactory;
  71207. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71208. private static IsUASupportingBlobStorage;
  71209. /**
  71210. * Gets a boolean indicating if Database storate is enabled (off by default)
  71211. */
  71212. static IDBStorageEnabled: boolean;
  71213. /**
  71214. * Gets a boolean indicating if scene must be saved in the database
  71215. */
  71216. get enableSceneOffline(): boolean;
  71217. /**
  71218. * Gets a boolean indicating if textures must be saved in the database
  71219. */
  71220. get enableTexturesOffline(): boolean;
  71221. /**
  71222. * Creates a new Database
  71223. * @param urlToScene defines the url to load the scene
  71224. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71225. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71226. */
  71227. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71228. private static _ParseURL;
  71229. private static _ReturnFullUrlLocation;
  71230. private _checkManifestFile;
  71231. /**
  71232. * Open the database and make it available
  71233. * @param successCallback defines the callback to call on success
  71234. * @param errorCallback defines the callback to call on error
  71235. */
  71236. open(successCallback: () => void, errorCallback: () => void): void;
  71237. /**
  71238. * Loads an image from the database
  71239. * @param url defines the url to load from
  71240. * @param image defines the target DOM image
  71241. */
  71242. loadImage(url: string, image: HTMLImageElement): void;
  71243. private _loadImageFromDBAsync;
  71244. private _saveImageIntoDBAsync;
  71245. private _checkVersionFromDB;
  71246. private _loadVersionFromDBAsync;
  71247. private _saveVersionIntoDBAsync;
  71248. /**
  71249. * Loads a file from database
  71250. * @param url defines the URL to load from
  71251. * @param sceneLoaded defines a callback to call on success
  71252. * @param progressCallBack defines a callback to call when progress changed
  71253. * @param errorCallback defines a callback to call on error
  71254. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71255. */
  71256. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71257. private _loadFileAsync;
  71258. private _saveFileAsync;
  71259. /**
  71260. * Validates if xhr data is correct
  71261. * @param xhr defines the request to validate
  71262. * @param dataType defines the expected data type
  71263. * @returns true if data is correct
  71264. */
  71265. private static _ValidateXHRData;
  71266. }
  71267. }
  71268. declare module "babylonjs/Offline/index" {
  71269. export * from "babylonjs/Offline/database";
  71270. export * from "babylonjs/Offline/IOfflineProvider";
  71271. }
  71272. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71273. /** @hidden */
  71274. export var gpuUpdateParticlesPixelShader: {
  71275. name: string;
  71276. shader: string;
  71277. };
  71278. }
  71279. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71280. /** @hidden */
  71281. export var gpuUpdateParticlesVertexShader: {
  71282. name: string;
  71283. shader: string;
  71284. };
  71285. }
  71286. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71287. /** @hidden */
  71288. export var clipPlaneFragmentDeclaration2: {
  71289. name: string;
  71290. shader: string;
  71291. };
  71292. }
  71293. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71295. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71296. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71297. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71298. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71299. /** @hidden */
  71300. export var gpuRenderParticlesPixelShader: {
  71301. name: string;
  71302. shader: string;
  71303. };
  71304. }
  71305. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71306. /** @hidden */
  71307. export var clipPlaneVertexDeclaration2: {
  71308. name: string;
  71309. shader: string;
  71310. };
  71311. }
  71312. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71313. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71314. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71315. /** @hidden */
  71316. export var gpuRenderParticlesVertexShader: {
  71317. name: string;
  71318. shader: string;
  71319. };
  71320. }
  71321. declare module "babylonjs/Particles/gpuParticleSystem" {
  71322. import { Nullable } from "babylonjs/types";
  71323. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71324. import { Observable } from "babylonjs/Misc/observable";
  71325. import { Matrix } from "babylonjs/Maths/math.vector";
  71326. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71327. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71328. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71329. import { IDisposable } from "babylonjs/scene";
  71330. import { Effect } from "babylonjs/Materials/effect";
  71331. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71332. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71333. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71334. import { Scene } from "babylonjs/scene";
  71335. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71336. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71337. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71338. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71339. /**
  71340. * This represents a GPU particle system in Babylon
  71341. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71342. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71343. */
  71344. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71345. /**
  71346. * The layer mask we are rendering the particles through.
  71347. */
  71348. layerMask: number;
  71349. private _capacity;
  71350. private _activeCount;
  71351. private _currentActiveCount;
  71352. private _accumulatedCount;
  71353. private _renderEffect;
  71354. private _updateEffect;
  71355. private _buffer0;
  71356. private _buffer1;
  71357. private _spriteBuffer;
  71358. private _updateVAO;
  71359. private _renderVAO;
  71360. private _targetIndex;
  71361. private _sourceBuffer;
  71362. private _targetBuffer;
  71363. private _currentRenderId;
  71364. private _started;
  71365. private _stopped;
  71366. private _timeDelta;
  71367. private _randomTexture;
  71368. private _randomTexture2;
  71369. private _attributesStrideSize;
  71370. private _updateEffectOptions;
  71371. private _randomTextureSize;
  71372. private _actualFrame;
  71373. private _customEffect;
  71374. private readonly _rawTextureWidth;
  71375. /**
  71376. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71377. */
  71378. static get IsSupported(): boolean;
  71379. /**
  71380. * An event triggered when the system is disposed.
  71381. */
  71382. onDisposeObservable: Observable<IParticleSystem>;
  71383. /**
  71384. * Gets the maximum number of particles active at the same time.
  71385. * @returns The max number of active particles.
  71386. */
  71387. getCapacity(): number;
  71388. /**
  71389. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71390. * to override the particles.
  71391. */
  71392. forceDepthWrite: boolean;
  71393. /**
  71394. * Gets or set the number of active particles
  71395. */
  71396. get activeParticleCount(): number;
  71397. set activeParticleCount(value: number);
  71398. private _preWarmDone;
  71399. /**
  71400. * Specifies if the particles are updated in emitter local space or world space.
  71401. */
  71402. isLocal: boolean;
  71403. /** Gets or sets a matrix to use to compute projection */
  71404. defaultProjectionMatrix: Matrix;
  71405. /**
  71406. * Is this system ready to be used/rendered
  71407. * @return true if the system is ready
  71408. */
  71409. isReady(): boolean;
  71410. /**
  71411. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71412. * @returns True if it has been started, otherwise false.
  71413. */
  71414. isStarted(): boolean;
  71415. /**
  71416. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71417. * @returns True if it has been stopped, otherwise false.
  71418. */
  71419. isStopped(): boolean;
  71420. /**
  71421. * Gets a boolean indicating that the system is stopping
  71422. * @returns true if the system is currently stopping
  71423. */
  71424. isStopping(): boolean;
  71425. /**
  71426. * Gets the number of particles active at the same time.
  71427. * @returns The number of active particles.
  71428. */
  71429. getActiveCount(): number;
  71430. /**
  71431. * Starts the particle system and begins to emit
  71432. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71433. */
  71434. start(delay?: number): void;
  71435. /**
  71436. * Stops the particle system.
  71437. */
  71438. stop(): void;
  71439. /**
  71440. * Remove all active particles
  71441. */
  71442. reset(): void;
  71443. /**
  71444. * Returns the string "GPUParticleSystem"
  71445. * @returns a string containing the class name
  71446. */
  71447. getClassName(): string;
  71448. /**
  71449. * Gets the custom effect used to render the particles
  71450. * @param blendMode Blend mode for which the effect should be retrieved
  71451. * @returns The effect
  71452. */
  71453. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71454. /**
  71455. * Sets the custom effect used to render the particles
  71456. * @param effect The effect to set
  71457. * @param blendMode Blend mode for which the effect should be set
  71458. */
  71459. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71460. /** @hidden */
  71461. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71462. /**
  71463. * Observable that will be called just before the particles are drawn
  71464. */
  71465. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71466. /**
  71467. * Gets the name of the particle vertex shader
  71468. */
  71469. get vertexShaderName(): string;
  71470. private _colorGradientsTexture;
  71471. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71472. /**
  71473. * Adds a new color gradient
  71474. * @param gradient defines the gradient to use (between 0 and 1)
  71475. * @param color1 defines the color to affect to the specified gradient
  71476. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71477. * @returns the current particle system
  71478. */
  71479. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71480. private _refreshColorGradient;
  71481. /** Force the system to rebuild all gradients that need to be resync */
  71482. forceRefreshGradients(): void;
  71483. /**
  71484. * Remove a specific color gradient
  71485. * @param gradient defines the gradient to remove
  71486. * @returns the current particle system
  71487. */
  71488. removeColorGradient(gradient: number): GPUParticleSystem;
  71489. private _angularSpeedGradientsTexture;
  71490. private _sizeGradientsTexture;
  71491. private _velocityGradientsTexture;
  71492. private _limitVelocityGradientsTexture;
  71493. private _dragGradientsTexture;
  71494. private _addFactorGradient;
  71495. /**
  71496. * Adds a new size gradient
  71497. * @param gradient defines the gradient to use (between 0 and 1)
  71498. * @param factor defines the size factor to affect to the specified gradient
  71499. * @returns the current particle system
  71500. */
  71501. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71502. /**
  71503. * Remove a specific size gradient
  71504. * @param gradient defines the gradient to remove
  71505. * @returns the current particle system
  71506. */
  71507. removeSizeGradient(gradient: number): GPUParticleSystem;
  71508. private _refreshFactorGradient;
  71509. /**
  71510. * Adds a new angular speed gradient
  71511. * @param gradient defines the gradient to use (between 0 and 1)
  71512. * @param factor defines the angular speed to affect to the specified gradient
  71513. * @returns the current particle system
  71514. */
  71515. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71516. /**
  71517. * Remove a specific angular speed gradient
  71518. * @param gradient defines the gradient to remove
  71519. * @returns the current particle system
  71520. */
  71521. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71522. /**
  71523. * Adds a new velocity gradient
  71524. * @param gradient defines the gradient to use (between 0 and 1)
  71525. * @param factor defines the velocity to affect to the specified gradient
  71526. * @returns the current particle system
  71527. */
  71528. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71529. /**
  71530. * Remove a specific velocity gradient
  71531. * @param gradient defines the gradient to remove
  71532. * @returns the current particle system
  71533. */
  71534. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71535. /**
  71536. * Adds a new limit velocity gradient
  71537. * @param gradient defines the gradient to use (between 0 and 1)
  71538. * @param factor defines the limit velocity value to affect to the specified gradient
  71539. * @returns the current particle system
  71540. */
  71541. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71542. /**
  71543. * Remove a specific limit velocity gradient
  71544. * @param gradient defines the gradient to remove
  71545. * @returns the current particle system
  71546. */
  71547. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71548. /**
  71549. * Adds a new drag gradient
  71550. * @param gradient defines the gradient to use (between 0 and 1)
  71551. * @param factor defines the drag value to affect to the specified gradient
  71552. * @returns the current particle system
  71553. */
  71554. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71555. /**
  71556. * Remove a specific drag gradient
  71557. * @param gradient defines the gradient to remove
  71558. * @returns the current particle system
  71559. */
  71560. removeDragGradient(gradient: number): GPUParticleSystem;
  71561. /**
  71562. * Not supported by GPUParticleSystem
  71563. * @param gradient defines the gradient to use (between 0 and 1)
  71564. * @param factor defines the emit rate value to affect to the specified gradient
  71565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71566. * @returns the current particle system
  71567. */
  71568. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71569. /**
  71570. * Not supported by GPUParticleSystem
  71571. * @param gradient defines the gradient to remove
  71572. * @returns the current particle system
  71573. */
  71574. removeEmitRateGradient(gradient: number): IParticleSystem;
  71575. /**
  71576. * Not supported by GPUParticleSystem
  71577. * @param gradient defines the gradient to use (between 0 and 1)
  71578. * @param factor defines the start size value to affect to the specified gradient
  71579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71580. * @returns the current particle system
  71581. */
  71582. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71583. /**
  71584. * Not supported by GPUParticleSystem
  71585. * @param gradient defines the gradient to remove
  71586. * @returns the current particle system
  71587. */
  71588. removeStartSizeGradient(gradient: number): IParticleSystem;
  71589. /**
  71590. * Not supported by GPUParticleSystem
  71591. * @param gradient defines the gradient to use (between 0 and 1)
  71592. * @param min defines the color remap minimal range
  71593. * @param max defines the color remap maximal range
  71594. * @returns the current particle system
  71595. */
  71596. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71597. /**
  71598. * Not supported by GPUParticleSystem
  71599. * @param gradient defines the gradient to remove
  71600. * @returns the current particle system
  71601. */
  71602. removeColorRemapGradient(): IParticleSystem;
  71603. /**
  71604. * Not supported by GPUParticleSystem
  71605. * @param gradient defines the gradient to use (between 0 and 1)
  71606. * @param min defines the alpha remap minimal range
  71607. * @param max defines the alpha remap maximal range
  71608. * @returns the current particle system
  71609. */
  71610. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71611. /**
  71612. * Not supported by GPUParticleSystem
  71613. * @param gradient defines the gradient to remove
  71614. * @returns the current particle system
  71615. */
  71616. removeAlphaRemapGradient(): IParticleSystem;
  71617. /**
  71618. * Not supported by GPUParticleSystem
  71619. * @param gradient defines the gradient to use (between 0 and 1)
  71620. * @param color defines the color to affect to the specified gradient
  71621. * @returns the current particle system
  71622. */
  71623. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71624. /**
  71625. * Not supported by GPUParticleSystem
  71626. * @param gradient defines the gradient to remove
  71627. * @returns the current particle system
  71628. */
  71629. removeRampGradient(): IParticleSystem;
  71630. /**
  71631. * Not supported by GPUParticleSystem
  71632. * @returns the list of ramp gradients
  71633. */
  71634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71635. /**
  71636. * Not supported by GPUParticleSystem
  71637. * Gets or sets a boolean indicating that ramp gradients must be used
  71638. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71639. */
  71640. get useRampGradients(): boolean;
  71641. set useRampGradients(value: boolean);
  71642. /**
  71643. * Not supported by GPUParticleSystem
  71644. * @param gradient defines the gradient to use (between 0 and 1)
  71645. * @param factor defines the life time factor to affect to the specified gradient
  71646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71647. * @returns the current particle system
  71648. */
  71649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71650. /**
  71651. * Not supported by GPUParticleSystem
  71652. * @param gradient defines the gradient to remove
  71653. * @returns the current particle system
  71654. */
  71655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71656. /**
  71657. * Instantiates a GPU particle system.
  71658. * 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.
  71659. * @param name The name of the particle system
  71660. * @param options The options used to create the system
  71661. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71662. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71663. * @param customEffect a custom effect used to change the way particles are rendered by default
  71664. */
  71665. constructor(name: string, options: Partial<{
  71666. capacity: number;
  71667. randomTextureSize: number;
  71668. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71669. protected _reset(): void;
  71670. private _createUpdateVAO;
  71671. private _createRenderVAO;
  71672. private _initialize;
  71673. /** @hidden */
  71674. _recreateUpdateEffect(): void;
  71675. private _getEffect;
  71676. /**
  71677. * Fill the defines array according to the current settings of the particle system
  71678. * @param defines Array to be updated
  71679. * @param blendMode blend mode to take into account when updating the array
  71680. */
  71681. fillDefines(defines: Array<string>, blendMode?: number): void;
  71682. /**
  71683. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71684. * @param uniforms Uniforms array to fill
  71685. * @param attributes Attributes array to fill
  71686. * @param samplers Samplers array to fill
  71687. */
  71688. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71689. /** @hidden */
  71690. _recreateRenderEffect(): Effect;
  71691. /**
  71692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71693. * @param preWarm defines if we are in the pre-warmimg phase
  71694. */
  71695. animate(preWarm?: boolean): void;
  71696. private _createFactorGradientTexture;
  71697. private _createSizeGradientTexture;
  71698. private _createAngularSpeedGradientTexture;
  71699. private _createVelocityGradientTexture;
  71700. private _createLimitVelocityGradientTexture;
  71701. private _createDragGradientTexture;
  71702. private _createColorGradientTexture;
  71703. /**
  71704. * Renders the particle system in its current state
  71705. * @param preWarm defines if the system should only update the particles but not render them
  71706. * @returns the current number of particles
  71707. */
  71708. render(preWarm?: boolean): number;
  71709. /**
  71710. * Rebuilds the particle system
  71711. */
  71712. rebuild(): void;
  71713. private _releaseBuffers;
  71714. private _releaseVAOs;
  71715. /**
  71716. * Disposes the particle system and free the associated resources
  71717. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71718. */
  71719. dispose(disposeTexture?: boolean): void;
  71720. /**
  71721. * Clones the particle system.
  71722. * @param name The name of the cloned object
  71723. * @param newEmitter The new emitter to use
  71724. * @returns the cloned particle system
  71725. */
  71726. clone(name: string, newEmitter: any): GPUParticleSystem;
  71727. /**
  71728. * Serializes the particle system to a JSON object
  71729. * @param serializeTexture defines if the texture must be serialized as well
  71730. * @returns the JSON object
  71731. */
  71732. serialize(serializeTexture?: boolean): any;
  71733. /**
  71734. * Parses a JSON object to create a GPU particle system.
  71735. * @param parsedParticleSystem The JSON object to parse
  71736. * @param sceneOrEngine The scene or the engine to create the particle system in
  71737. * @param rootUrl The root url to use to load external dependencies like texture
  71738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71739. * @returns the parsed GPU particle system
  71740. */
  71741. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71742. }
  71743. }
  71744. declare module "babylonjs/Particles/particleSystemSet" {
  71745. import { Nullable } from "babylonjs/types";
  71746. import { Color3 } from "babylonjs/Maths/math.color";
  71747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71749. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71750. import { Scene, IDisposable } from "babylonjs/scene";
  71751. /**
  71752. * Represents a set of particle systems working together to create a specific effect
  71753. */
  71754. export class ParticleSystemSet implements IDisposable {
  71755. /**
  71756. * Gets or sets base Assets URL
  71757. */
  71758. static BaseAssetsUrl: string;
  71759. private _emitterCreationOptions;
  71760. private _emitterNode;
  71761. /**
  71762. * Gets the particle system list
  71763. */
  71764. systems: IParticleSystem[];
  71765. /**
  71766. * Gets the emitter node used with this set
  71767. */
  71768. get emitterNode(): Nullable<TransformNode>;
  71769. /**
  71770. * Creates a new emitter mesh as a sphere
  71771. * @param options defines the options used to create the sphere
  71772. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71773. * @param scene defines the hosting scene
  71774. */
  71775. setEmitterAsSphere(options: {
  71776. diameter: number;
  71777. segments: number;
  71778. color: Color3;
  71779. }, renderingGroupId: number, scene: Scene): void;
  71780. /**
  71781. * Starts all particle systems of the set
  71782. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71783. */
  71784. start(emitter?: AbstractMesh): void;
  71785. /**
  71786. * Release all associated resources
  71787. */
  71788. dispose(): void;
  71789. /**
  71790. * Serialize the set into a JSON compatible object
  71791. * @param serializeTexture defines if the texture must be serialized as well
  71792. * @returns a JSON compatible representation of the set
  71793. */
  71794. serialize(serializeTexture?: boolean): any;
  71795. /**
  71796. * Parse a new ParticleSystemSet from a serialized source
  71797. * @param data defines a JSON compatible representation of the set
  71798. * @param scene defines the hosting scene
  71799. * @param gpu defines if we want GPU particles or CPU particles
  71800. * @returns a new ParticleSystemSet
  71801. */
  71802. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71803. }
  71804. }
  71805. declare module "babylonjs/Particles/particleHelper" {
  71806. import { Nullable } from "babylonjs/types";
  71807. import { Scene } from "babylonjs/scene";
  71808. import { Vector3 } from "babylonjs/Maths/math.vector";
  71809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71810. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71811. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71812. /**
  71813. * This class is made for on one-liner static method to help creating particle system set.
  71814. */
  71815. export class ParticleHelper {
  71816. /**
  71817. * Gets or sets base Assets URL
  71818. */
  71819. static BaseAssetsUrl: string;
  71820. /** Define the Url to load snippets */
  71821. static SnippetUrl: string;
  71822. /**
  71823. * Create a default particle system that you can tweak
  71824. * @param emitter defines the emitter to use
  71825. * @param capacity defines the system capacity (default is 500 particles)
  71826. * @param scene defines the hosting scene
  71827. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71828. * @returns the new Particle system
  71829. */
  71830. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71831. /**
  71832. * This is the main static method (one-liner) of this helper to create different particle systems
  71833. * @param type This string represents the type to the particle system to create
  71834. * @param scene The scene where the particle system should live
  71835. * @param gpu If the system will use gpu
  71836. * @returns the ParticleSystemSet created
  71837. */
  71838. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71839. /**
  71840. * Static function used to export a particle system to a ParticleSystemSet variable.
  71841. * Please note that the emitter shape is not exported
  71842. * @param systems defines the particle systems to export
  71843. * @returns the created particle system set
  71844. */
  71845. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71846. /**
  71847. * Creates a particle system from a snippet saved in a remote file
  71848. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71849. * @param url defines the url to load from
  71850. * @param scene defines the hosting scene
  71851. * @param gpu If the system will use gpu
  71852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71853. * @returns a promise that will resolve to the new particle system
  71854. */
  71855. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71856. /**
  71857. * Creates a particle system from a snippet saved by the particle system editor
  71858. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71859. * @param scene defines the hosting scene
  71860. * @param gpu If the system will use gpu
  71861. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71862. * @returns a promise that will resolve to the new particle system
  71863. */
  71864. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71865. }
  71866. }
  71867. declare module "babylonjs/Particles/particleSystemComponent" {
  71868. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71869. import { Effect } from "babylonjs/Materials/effect";
  71870. import "babylonjs/Shaders/particles.vertex";
  71871. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71872. module "babylonjs/Engines/engine" {
  71873. interface Engine {
  71874. /**
  71875. * Create an effect to use with particle systems.
  71876. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71877. * the particle system for which you want to create a custom effect in the last parameter
  71878. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71879. * @param uniformsNames defines a list of attribute names
  71880. * @param samplers defines an array of string used to represent textures
  71881. * @param defines defines the string containing the defines to use to compile the shaders
  71882. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71883. * @param onCompiled defines a function to call when the effect creation is successful
  71884. * @param onError defines a function to call when the effect creation has failed
  71885. * @param particleSystem the particle system you want to create the effect for
  71886. * @returns the new Effect
  71887. */
  71888. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71889. }
  71890. }
  71891. module "babylonjs/Meshes/mesh" {
  71892. interface Mesh {
  71893. /**
  71894. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71895. * @returns an array of IParticleSystem
  71896. */
  71897. getEmittedParticleSystems(): IParticleSystem[];
  71898. /**
  71899. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71900. * @returns an array of IParticleSystem
  71901. */
  71902. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71903. }
  71904. }
  71905. }
  71906. declare module "babylonjs/Particles/pointsCloudSystem" {
  71907. import { Color4 } from "babylonjs/Maths/math";
  71908. import { Mesh } from "babylonjs/Meshes/mesh";
  71909. import { Scene, IDisposable } from "babylonjs/scene";
  71910. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71911. /** Defines the 4 color options */
  71912. export enum PointColor {
  71913. /** color value */
  71914. Color = 2,
  71915. /** uv value */
  71916. UV = 1,
  71917. /** random value */
  71918. Random = 0,
  71919. /** stated value */
  71920. Stated = 3
  71921. }
  71922. /**
  71923. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71924. * 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.
  71925. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71926. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71927. *
  71928. * Full documentation here : TO BE ENTERED
  71929. */
  71930. export class PointsCloudSystem implements IDisposable {
  71931. /**
  71932. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71933. * Example : var p = SPS.particles[i];
  71934. */
  71935. particles: CloudPoint[];
  71936. /**
  71937. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71938. */
  71939. nbParticles: number;
  71940. /**
  71941. * This a counter for your own usage. It's not set by any SPS functions.
  71942. */
  71943. counter: number;
  71944. /**
  71945. * The PCS name. This name is also given to the underlying mesh.
  71946. */
  71947. name: string;
  71948. /**
  71949. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71950. */
  71951. mesh: Mesh;
  71952. /**
  71953. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71954. * Please read :
  71955. */
  71956. vars: any;
  71957. /**
  71958. * @hidden
  71959. */
  71960. _size: number;
  71961. private _scene;
  71962. private _promises;
  71963. private _positions;
  71964. private _indices;
  71965. private _normals;
  71966. private _colors;
  71967. private _uvs;
  71968. private _indices32;
  71969. private _positions32;
  71970. private _colors32;
  71971. private _uvs32;
  71972. private _updatable;
  71973. private _isVisibilityBoxLocked;
  71974. private _alwaysVisible;
  71975. private _groups;
  71976. private _groupCounter;
  71977. private _computeParticleColor;
  71978. private _computeParticleTexture;
  71979. private _computeParticleRotation;
  71980. private _computeBoundingBox;
  71981. private _isReady;
  71982. /**
  71983. * Creates a PCS (Points Cloud System) object
  71984. * @param name (String) is the PCS name, this will be the underlying mesh name
  71985. * @param pointSize (number) is the size for each point
  71986. * @param scene (Scene) is the scene in which the PCS is added
  71987. * @param options defines the options of the PCS e.g.
  71988. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71989. */
  71990. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71991. updatable?: boolean;
  71992. });
  71993. /**
  71994. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71995. * If no points were added to the PCS, the returned mesh is just a single point.
  71996. * @returns a promise for the created mesh
  71997. */
  71998. buildMeshAsync(): Promise<Mesh>;
  71999. /**
  72000. * @hidden
  72001. */
  72002. private _buildMesh;
  72003. private _addParticle;
  72004. private _randomUnitVector;
  72005. private _getColorIndicesForCoord;
  72006. private _setPointsColorOrUV;
  72007. private _colorFromTexture;
  72008. private _calculateDensity;
  72009. /**
  72010. * Adds points to the PCS in random positions within a unit sphere
  72011. * @param nb (positive integer) the number of particles to be created from this model
  72012. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72013. * @returns the number of groups in the system
  72014. */
  72015. addPoints(nb: number, pointFunction?: any): number;
  72016. /**
  72017. * Adds points to the PCS from the surface of the model shape
  72018. * @param mesh is any Mesh object that will be used as a surface model for the points
  72019. * @param nb (positive integer) the number of particles to be created from this model
  72020. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72021. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72022. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72023. * @returns the number of groups in the system
  72024. */
  72025. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72026. /**
  72027. * Adds points to the PCS inside the model shape
  72028. * @param mesh is any Mesh object that will be used as a surface model for the points
  72029. * @param nb (positive integer) the number of particles to be created from this model
  72030. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72031. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72032. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72033. * @returns the number of groups in the system
  72034. */
  72035. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72036. /**
  72037. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72038. * This method calls `updateParticle()` for each particle of the SPS.
  72039. * For an animated SPS, it is usually called within the render loop.
  72040. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72041. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72042. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72043. * @returns the PCS.
  72044. */
  72045. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72046. /**
  72047. * Disposes the PCS.
  72048. */
  72049. dispose(): void;
  72050. /**
  72051. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72052. * doc :
  72053. * @returns the PCS.
  72054. */
  72055. refreshVisibleSize(): PointsCloudSystem;
  72056. /**
  72057. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72058. * @param size the size (float) of the visibility box
  72059. * note : this doesn't lock the PCS mesh bounding box.
  72060. * doc :
  72061. */
  72062. setVisibilityBox(size: number): void;
  72063. /**
  72064. * Gets whether the PCS is always visible or not
  72065. * doc :
  72066. */
  72067. get isAlwaysVisible(): boolean;
  72068. /**
  72069. * Sets the PCS as always visible or not
  72070. * doc :
  72071. */
  72072. set isAlwaysVisible(val: boolean);
  72073. /**
  72074. * Tells to `setParticles()` to compute the particle rotations or not
  72075. * Default value : false. The PCS is faster when it's set to false
  72076. * Note : particle rotations are only applied to parent particles
  72077. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72078. */
  72079. set computeParticleRotation(val: boolean);
  72080. /**
  72081. * Tells to `setParticles()` to compute the particle colors or not.
  72082. * Default value : true. The PCS is faster when it's set to false.
  72083. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72084. */
  72085. set computeParticleColor(val: boolean);
  72086. set computeParticleTexture(val: boolean);
  72087. /**
  72088. * Gets if `setParticles()` computes the particle colors or not.
  72089. * Default value : false. The PCS is faster when it's set to false.
  72090. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72091. */
  72092. get computeParticleColor(): boolean;
  72093. /**
  72094. * Gets if `setParticles()` computes the particle textures or not.
  72095. * Default value : false. The PCS is faster when it's set to false.
  72096. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72097. */
  72098. get computeParticleTexture(): boolean;
  72099. /**
  72100. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72101. */
  72102. set computeBoundingBox(val: boolean);
  72103. /**
  72104. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72105. */
  72106. get computeBoundingBox(): boolean;
  72107. /**
  72108. * This function does nothing. It may be overwritten to set all the particle first values.
  72109. * The PCS doesn't call this function, you may have to call it by your own.
  72110. * doc :
  72111. */
  72112. initParticles(): void;
  72113. /**
  72114. * This function does nothing. It may be overwritten to recycle a particle
  72115. * The PCS doesn't call this function, you can to call it
  72116. * doc :
  72117. * @param particle The particle to recycle
  72118. * @returns the recycled particle
  72119. */
  72120. recycleParticle(particle: CloudPoint): CloudPoint;
  72121. /**
  72122. * Updates a particle : this function should be overwritten by the user.
  72123. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72124. * doc :
  72125. * @example : just set a particle position or velocity and recycle conditions
  72126. * @param particle The particle to update
  72127. * @returns the updated particle
  72128. */
  72129. updateParticle(particle: CloudPoint): CloudPoint;
  72130. /**
  72131. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72132. * This does nothing and may be overwritten by the user.
  72133. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72134. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72135. * @param update the boolean update value actually passed to setParticles()
  72136. */
  72137. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72138. /**
  72139. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72140. * This will be passed three parameters.
  72141. * This does nothing and may be overwritten by the user.
  72142. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72143. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72144. * @param update the boolean update value actually passed to setParticles()
  72145. */
  72146. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72147. }
  72148. }
  72149. declare module "babylonjs/Particles/cloudPoint" {
  72150. import { Nullable } from "babylonjs/types";
  72151. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72152. import { Mesh } from "babylonjs/Meshes/mesh";
  72153. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72154. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72155. /**
  72156. * Represents one particle of a points cloud system.
  72157. */
  72158. export class CloudPoint {
  72159. /**
  72160. * particle global index
  72161. */
  72162. idx: number;
  72163. /**
  72164. * The color of the particle
  72165. */
  72166. color: Nullable<Color4>;
  72167. /**
  72168. * The world space position of the particle.
  72169. */
  72170. position: Vector3;
  72171. /**
  72172. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72173. */
  72174. rotation: Vector3;
  72175. /**
  72176. * The world space rotation quaternion of the particle.
  72177. */
  72178. rotationQuaternion: Nullable<Quaternion>;
  72179. /**
  72180. * The uv of the particle.
  72181. */
  72182. uv: Nullable<Vector2>;
  72183. /**
  72184. * The current speed of the particle.
  72185. */
  72186. velocity: Vector3;
  72187. /**
  72188. * The pivot point in the particle local space.
  72189. */
  72190. pivot: Vector3;
  72191. /**
  72192. * Must the particle be translated from its pivot point in its local space ?
  72193. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72194. * Default : false
  72195. */
  72196. translateFromPivot: boolean;
  72197. /**
  72198. * Index of this particle in the global "positions" array (Internal use)
  72199. * @hidden
  72200. */
  72201. _pos: number;
  72202. /**
  72203. * @hidden Index of this particle in the global "indices" array (Internal use)
  72204. */
  72205. _ind: number;
  72206. /**
  72207. * Group this particle belongs to
  72208. */
  72209. _group: PointsGroup;
  72210. /**
  72211. * Group id of this particle
  72212. */
  72213. groupId: number;
  72214. /**
  72215. * Index of the particle in its group id (Internal use)
  72216. */
  72217. idxInGroup: number;
  72218. /**
  72219. * @hidden Particle BoundingInfo object (Internal use)
  72220. */
  72221. _boundingInfo: BoundingInfo;
  72222. /**
  72223. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72224. */
  72225. _pcs: PointsCloudSystem;
  72226. /**
  72227. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72228. */
  72229. _stillInvisible: boolean;
  72230. /**
  72231. * @hidden Last computed particle rotation matrix
  72232. */
  72233. _rotationMatrix: number[];
  72234. /**
  72235. * Parent particle Id, if any.
  72236. * Default null.
  72237. */
  72238. parentId: Nullable<number>;
  72239. /**
  72240. * @hidden Internal global position in the PCS.
  72241. */
  72242. _globalPosition: Vector3;
  72243. /**
  72244. * Creates a Point Cloud object.
  72245. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72246. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72247. * @param group (PointsGroup) is the group the particle belongs to
  72248. * @param groupId (integer) is the group identifier in the PCS.
  72249. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72250. * @param pcs defines the PCS it is associated to
  72251. */
  72252. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72253. /**
  72254. * get point size
  72255. */
  72256. get size(): Vector3;
  72257. /**
  72258. * Set point size
  72259. */
  72260. set size(scale: Vector3);
  72261. /**
  72262. * Legacy support, changed quaternion to rotationQuaternion
  72263. */
  72264. get quaternion(): Nullable<Quaternion>;
  72265. /**
  72266. * Legacy support, changed quaternion to rotationQuaternion
  72267. */
  72268. set quaternion(q: Nullable<Quaternion>);
  72269. /**
  72270. * Returns a boolean. True if the particle intersects a mesh, else false
  72271. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72272. * @param target is the object (point or mesh) what the intersection is computed against
  72273. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72274. * @returns true if it intersects
  72275. */
  72276. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72277. /**
  72278. * get the rotation matrix of the particle
  72279. * @hidden
  72280. */
  72281. getRotationMatrix(m: Matrix): void;
  72282. }
  72283. /**
  72284. * Represents a group of points in a points cloud system
  72285. * * PCS internal tool, don't use it manually.
  72286. */
  72287. export class PointsGroup {
  72288. /**
  72289. * The group id
  72290. * @hidden
  72291. */
  72292. groupID: number;
  72293. /**
  72294. * image data for group (internal use)
  72295. * @hidden
  72296. */
  72297. _groupImageData: Nullable<ArrayBufferView>;
  72298. /**
  72299. * Image Width (internal use)
  72300. * @hidden
  72301. */
  72302. _groupImgWidth: number;
  72303. /**
  72304. * Image Height (internal use)
  72305. * @hidden
  72306. */
  72307. _groupImgHeight: number;
  72308. /**
  72309. * Custom position function (internal use)
  72310. * @hidden
  72311. */
  72312. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72313. /**
  72314. * density per facet for surface points
  72315. * @hidden
  72316. */
  72317. _groupDensity: number[];
  72318. /**
  72319. * Only when points are colored by texture carries pointer to texture list array
  72320. * @hidden
  72321. */
  72322. _textureNb: number;
  72323. /**
  72324. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72325. * PCS internal tool, don't use it manually.
  72326. * @hidden
  72327. */
  72328. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72329. }
  72330. }
  72331. declare module "babylonjs/Particles/index" {
  72332. export * from "babylonjs/Particles/baseParticleSystem";
  72333. export * from "babylonjs/Particles/EmitterTypes/index";
  72334. export * from "babylonjs/Particles/gpuParticleSystem";
  72335. export * from "babylonjs/Particles/IParticleSystem";
  72336. export * from "babylonjs/Particles/particle";
  72337. export * from "babylonjs/Particles/particleHelper";
  72338. export * from "babylonjs/Particles/particleSystem";
  72339. import "babylonjs/Particles/particleSystemComponent";
  72340. export * from "babylonjs/Particles/particleSystemComponent";
  72341. export * from "babylonjs/Particles/particleSystemSet";
  72342. export * from "babylonjs/Particles/solidParticle";
  72343. export * from "babylonjs/Particles/solidParticleSystem";
  72344. export * from "babylonjs/Particles/cloudPoint";
  72345. export * from "babylonjs/Particles/pointsCloudSystem";
  72346. export * from "babylonjs/Particles/subEmitter";
  72347. }
  72348. declare module "babylonjs/Physics/physicsEngineComponent" {
  72349. import { Nullable } from "babylonjs/types";
  72350. import { Observable, Observer } from "babylonjs/Misc/observable";
  72351. import { Vector3 } from "babylonjs/Maths/math.vector";
  72352. import { Mesh } from "babylonjs/Meshes/mesh";
  72353. import { ISceneComponent } from "babylonjs/sceneComponent";
  72354. import { Scene } from "babylonjs/scene";
  72355. import { Node } from "babylonjs/node";
  72356. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72358. module "babylonjs/scene" {
  72359. interface Scene {
  72360. /** @hidden (Backing field) */
  72361. _physicsEngine: Nullable<IPhysicsEngine>;
  72362. /** @hidden */
  72363. _physicsTimeAccumulator: number;
  72364. /**
  72365. * Gets the current physics engine
  72366. * @returns a IPhysicsEngine or null if none attached
  72367. */
  72368. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72369. /**
  72370. * Enables physics to the current scene
  72371. * @param gravity defines the scene's gravity for the physics engine
  72372. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72373. * @return a boolean indicating if the physics engine was initialized
  72374. */
  72375. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72376. /**
  72377. * Disables and disposes the physics engine associated with the scene
  72378. */
  72379. disablePhysicsEngine(): void;
  72380. /**
  72381. * Gets a boolean indicating if there is an active physics engine
  72382. * @returns a boolean indicating if there is an active physics engine
  72383. */
  72384. isPhysicsEnabled(): boolean;
  72385. /**
  72386. * Deletes a physics compound impostor
  72387. * @param compound defines the compound to delete
  72388. */
  72389. deleteCompoundImpostor(compound: any): void;
  72390. /**
  72391. * An event triggered when physic simulation is about to be run
  72392. */
  72393. onBeforePhysicsObservable: Observable<Scene>;
  72394. /**
  72395. * An event triggered when physic simulation has been done
  72396. */
  72397. onAfterPhysicsObservable: Observable<Scene>;
  72398. }
  72399. }
  72400. module "babylonjs/Meshes/abstractMesh" {
  72401. interface AbstractMesh {
  72402. /** @hidden */
  72403. _physicsImpostor: Nullable<PhysicsImpostor>;
  72404. /**
  72405. * Gets or sets impostor used for physic simulation
  72406. * @see https://doc.babylonjs.com/features/physics_engine
  72407. */
  72408. physicsImpostor: Nullable<PhysicsImpostor>;
  72409. /**
  72410. * Gets the current physics impostor
  72411. * @see https://doc.babylonjs.com/features/physics_engine
  72412. * @returns a physics impostor or null
  72413. */
  72414. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72415. /** Apply a physic impulse to the mesh
  72416. * @param force defines the force to apply
  72417. * @param contactPoint defines where to apply the force
  72418. * @returns the current mesh
  72419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72420. */
  72421. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72422. /**
  72423. * Creates a physic joint between two meshes
  72424. * @param otherMesh defines the other mesh to use
  72425. * @param pivot1 defines the pivot to use on this mesh
  72426. * @param pivot2 defines the pivot to use on the other mesh
  72427. * @param options defines additional options (can be plugin dependent)
  72428. * @returns the current mesh
  72429. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72430. */
  72431. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72432. /** @hidden */
  72433. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72434. }
  72435. }
  72436. /**
  72437. * Defines the physics engine scene component responsible to manage a physics engine
  72438. */
  72439. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72440. /**
  72441. * The component name helpful to identify the component in the list of scene components.
  72442. */
  72443. readonly name: string;
  72444. /**
  72445. * The scene the component belongs to.
  72446. */
  72447. scene: Scene;
  72448. /**
  72449. * Creates a new instance of the component for the given scene
  72450. * @param scene Defines the scene to register the component in
  72451. */
  72452. constructor(scene: Scene);
  72453. /**
  72454. * Registers the component in a given scene
  72455. */
  72456. register(): void;
  72457. /**
  72458. * Rebuilds the elements related to this component in case of
  72459. * context lost for instance.
  72460. */
  72461. rebuild(): void;
  72462. /**
  72463. * Disposes the component and the associated ressources
  72464. */
  72465. dispose(): void;
  72466. }
  72467. }
  72468. declare module "babylonjs/Physics/physicsHelper" {
  72469. import { Nullable } from "babylonjs/types";
  72470. import { Vector3 } from "babylonjs/Maths/math.vector";
  72471. import { Mesh } from "babylonjs/Meshes/mesh";
  72472. import { Scene } from "babylonjs/scene";
  72473. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72474. /**
  72475. * A helper for physics simulations
  72476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72477. */
  72478. export class PhysicsHelper {
  72479. private _scene;
  72480. private _physicsEngine;
  72481. /**
  72482. * Initializes the Physics helper
  72483. * @param scene Babylon.js scene
  72484. */
  72485. constructor(scene: Scene);
  72486. /**
  72487. * Applies a radial explosion impulse
  72488. * @param origin the origin of the explosion
  72489. * @param radiusOrEventOptions the radius or the options of radial explosion
  72490. * @param strength the explosion strength
  72491. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72492. * @returns A physics radial explosion event, or null
  72493. */
  72494. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72495. /**
  72496. * Applies a radial explosion force
  72497. * @param origin the origin of the explosion
  72498. * @param radiusOrEventOptions the radius or the options of radial explosion
  72499. * @param strength the explosion strength
  72500. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72501. * @returns A physics radial explosion event, or null
  72502. */
  72503. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72504. /**
  72505. * Creates a gravitational field
  72506. * @param origin the origin of the explosion
  72507. * @param radiusOrEventOptions the radius or the options of radial explosion
  72508. * @param strength the explosion strength
  72509. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72510. * @returns A physics gravitational field event, or null
  72511. */
  72512. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72513. /**
  72514. * Creates a physics updraft event
  72515. * @param origin the origin of the updraft
  72516. * @param radiusOrEventOptions the radius or the options of the updraft
  72517. * @param strength the strength of the updraft
  72518. * @param height the height of the updraft
  72519. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72520. * @returns A physics updraft event, or null
  72521. */
  72522. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72523. /**
  72524. * Creates a physics vortex event
  72525. * @param origin the of the vortex
  72526. * @param radiusOrEventOptions the radius or the options of the vortex
  72527. * @param strength the strength of the vortex
  72528. * @param height the height of the vortex
  72529. * @returns a Physics vortex event, or null
  72530. * A physics vortex event or null
  72531. */
  72532. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72533. }
  72534. /**
  72535. * Represents a physics radial explosion event
  72536. */
  72537. class PhysicsRadialExplosionEvent {
  72538. private _scene;
  72539. private _options;
  72540. private _sphere;
  72541. private _dataFetched;
  72542. /**
  72543. * Initializes a radial explosioin event
  72544. * @param _scene BabylonJS scene
  72545. * @param _options The options for the vortex event
  72546. */
  72547. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72548. /**
  72549. * Returns the data related to the radial explosion event (sphere).
  72550. * @returns The radial explosion event data
  72551. */
  72552. getData(): PhysicsRadialExplosionEventData;
  72553. /**
  72554. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72555. * @param impostor A physics imposter
  72556. * @param origin the origin of the explosion
  72557. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72558. */
  72559. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72560. /**
  72561. * Triggers affecterd impostors callbacks
  72562. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72563. */
  72564. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72565. /**
  72566. * Disposes the sphere.
  72567. * @param force Specifies if the sphere should be disposed by force
  72568. */
  72569. dispose(force?: boolean): void;
  72570. /*** Helpers ***/
  72571. private _prepareSphere;
  72572. private _intersectsWithSphere;
  72573. }
  72574. /**
  72575. * Represents a gravitational field event
  72576. */
  72577. class PhysicsGravitationalFieldEvent {
  72578. private _physicsHelper;
  72579. private _scene;
  72580. private _origin;
  72581. private _options;
  72582. private _tickCallback;
  72583. private _sphere;
  72584. private _dataFetched;
  72585. /**
  72586. * Initializes the physics gravitational field event
  72587. * @param _physicsHelper A physics helper
  72588. * @param _scene BabylonJS scene
  72589. * @param _origin The origin position of the gravitational field event
  72590. * @param _options The options for the vortex event
  72591. */
  72592. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72593. /**
  72594. * Returns the data related to the gravitational field event (sphere).
  72595. * @returns A gravitational field event
  72596. */
  72597. getData(): PhysicsGravitationalFieldEventData;
  72598. /**
  72599. * Enables the gravitational field.
  72600. */
  72601. enable(): void;
  72602. /**
  72603. * Disables the gravitational field.
  72604. */
  72605. disable(): void;
  72606. /**
  72607. * Disposes the sphere.
  72608. * @param force The force to dispose from the gravitational field event
  72609. */
  72610. dispose(force?: boolean): void;
  72611. private _tick;
  72612. }
  72613. /**
  72614. * Represents a physics updraft event
  72615. */
  72616. class PhysicsUpdraftEvent {
  72617. private _scene;
  72618. private _origin;
  72619. private _options;
  72620. private _physicsEngine;
  72621. private _originTop;
  72622. private _originDirection;
  72623. private _tickCallback;
  72624. private _cylinder;
  72625. private _cylinderPosition;
  72626. private _dataFetched;
  72627. /**
  72628. * Initializes the physics updraft event
  72629. * @param _scene BabylonJS scene
  72630. * @param _origin The origin position of the updraft
  72631. * @param _options The options for the updraft event
  72632. */
  72633. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72634. /**
  72635. * Returns the data related to the updraft event (cylinder).
  72636. * @returns A physics updraft event
  72637. */
  72638. getData(): PhysicsUpdraftEventData;
  72639. /**
  72640. * Enables the updraft.
  72641. */
  72642. enable(): void;
  72643. /**
  72644. * Disables the updraft.
  72645. */
  72646. disable(): void;
  72647. /**
  72648. * Disposes the cylinder.
  72649. * @param force Specifies if the updraft should be disposed by force
  72650. */
  72651. dispose(force?: boolean): void;
  72652. private getImpostorHitData;
  72653. private _tick;
  72654. /*** Helpers ***/
  72655. private _prepareCylinder;
  72656. private _intersectsWithCylinder;
  72657. }
  72658. /**
  72659. * Represents a physics vortex event
  72660. */
  72661. class PhysicsVortexEvent {
  72662. private _scene;
  72663. private _origin;
  72664. private _options;
  72665. private _physicsEngine;
  72666. private _originTop;
  72667. private _tickCallback;
  72668. private _cylinder;
  72669. private _cylinderPosition;
  72670. private _dataFetched;
  72671. /**
  72672. * Initializes the physics vortex event
  72673. * @param _scene The BabylonJS scene
  72674. * @param _origin The origin position of the vortex
  72675. * @param _options The options for the vortex event
  72676. */
  72677. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72678. /**
  72679. * Returns the data related to the vortex event (cylinder).
  72680. * @returns The physics vortex event data
  72681. */
  72682. getData(): PhysicsVortexEventData;
  72683. /**
  72684. * Enables the vortex.
  72685. */
  72686. enable(): void;
  72687. /**
  72688. * Disables the cortex.
  72689. */
  72690. disable(): void;
  72691. /**
  72692. * Disposes the sphere.
  72693. * @param force
  72694. */
  72695. dispose(force?: boolean): void;
  72696. private getImpostorHitData;
  72697. private _tick;
  72698. /*** Helpers ***/
  72699. private _prepareCylinder;
  72700. private _intersectsWithCylinder;
  72701. }
  72702. /**
  72703. * Options fot the radial explosion event
  72704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72705. */
  72706. export class PhysicsRadialExplosionEventOptions {
  72707. /**
  72708. * The radius of the sphere for the radial explosion.
  72709. */
  72710. radius: number;
  72711. /**
  72712. * The strenth of the explosion.
  72713. */
  72714. strength: number;
  72715. /**
  72716. * The strenght of the force in correspondence to the distance of the affected object
  72717. */
  72718. falloff: PhysicsRadialImpulseFalloff;
  72719. /**
  72720. * Sphere options for the radial explosion.
  72721. */
  72722. sphere: {
  72723. segments: number;
  72724. diameter: number;
  72725. };
  72726. /**
  72727. * Sphere options for the radial explosion.
  72728. */
  72729. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72730. }
  72731. /**
  72732. * Options fot the updraft event
  72733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72734. */
  72735. export class PhysicsUpdraftEventOptions {
  72736. /**
  72737. * The radius of the cylinder for the vortex
  72738. */
  72739. radius: number;
  72740. /**
  72741. * The strenth of the updraft.
  72742. */
  72743. strength: number;
  72744. /**
  72745. * The height of the cylinder for the updraft.
  72746. */
  72747. height: number;
  72748. /**
  72749. * The mode for the the updraft.
  72750. */
  72751. updraftMode: PhysicsUpdraftMode;
  72752. }
  72753. /**
  72754. * Options fot the vortex event
  72755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72756. */
  72757. export class PhysicsVortexEventOptions {
  72758. /**
  72759. * The radius of the cylinder for the vortex
  72760. */
  72761. radius: number;
  72762. /**
  72763. * The strenth of the vortex.
  72764. */
  72765. strength: number;
  72766. /**
  72767. * The height of the cylinder for the vortex.
  72768. */
  72769. height: number;
  72770. /**
  72771. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72772. */
  72773. centripetalForceThreshold: number;
  72774. /**
  72775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72776. */
  72777. centripetalForceMultiplier: number;
  72778. /**
  72779. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72780. */
  72781. centrifugalForceMultiplier: number;
  72782. /**
  72783. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72784. */
  72785. updraftForceMultiplier: number;
  72786. }
  72787. /**
  72788. * The strenght of the force in correspondence to the distance of the affected object
  72789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72790. */
  72791. export enum PhysicsRadialImpulseFalloff {
  72792. /** Defines that impulse is constant in strength across it's whole radius */
  72793. Constant = 0,
  72794. /** Defines that impulse gets weaker if it's further from the origin */
  72795. Linear = 1
  72796. }
  72797. /**
  72798. * The strength of the force in correspondence to the distance of the affected object
  72799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72800. */
  72801. export enum PhysicsUpdraftMode {
  72802. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72803. Center = 0,
  72804. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72805. Perpendicular = 1
  72806. }
  72807. /**
  72808. * Interface for a physics hit data
  72809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72810. */
  72811. export interface PhysicsHitData {
  72812. /**
  72813. * The force applied at the contact point
  72814. */
  72815. force: Vector3;
  72816. /**
  72817. * The contact point
  72818. */
  72819. contactPoint: Vector3;
  72820. /**
  72821. * The distance from the origin to the contact point
  72822. */
  72823. distanceFromOrigin: number;
  72824. }
  72825. /**
  72826. * Interface for radial explosion event data
  72827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72828. */
  72829. export interface PhysicsRadialExplosionEventData {
  72830. /**
  72831. * A sphere used for the radial explosion event
  72832. */
  72833. sphere: Mesh;
  72834. }
  72835. /**
  72836. * Interface for gravitational field event data
  72837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72838. */
  72839. export interface PhysicsGravitationalFieldEventData {
  72840. /**
  72841. * A sphere mesh used for the gravitational field event
  72842. */
  72843. sphere: Mesh;
  72844. }
  72845. /**
  72846. * Interface for updraft event data
  72847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72848. */
  72849. export interface PhysicsUpdraftEventData {
  72850. /**
  72851. * A cylinder used for the updraft event
  72852. */
  72853. cylinder: Mesh;
  72854. }
  72855. /**
  72856. * Interface for vortex event data
  72857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72858. */
  72859. export interface PhysicsVortexEventData {
  72860. /**
  72861. * A cylinder used for the vortex event
  72862. */
  72863. cylinder: Mesh;
  72864. }
  72865. /**
  72866. * Interface for an affected physics impostor
  72867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72868. */
  72869. export interface PhysicsAffectedImpostorWithData {
  72870. /**
  72871. * The impostor affected by the effect
  72872. */
  72873. impostor: PhysicsImpostor;
  72874. /**
  72875. * The data about the hit/horce from the explosion
  72876. */
  72877. hitData: PhysicsHitData;
  72878. }
  72879. }
  72880. declare module "babylonjs/Physics/Plugins/index" {
  72881. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72882. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72883. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72884. }
  72885. declare module "babylonjs/Physics/index" {
  72886. export * from "babylonjs/Physics/IPhysicsEngine";
  72887. export * from "babylonjs/Physics/physicsEngine";
  72888. export * from "babylonjs/Physics/physicsEngineComponent";
  72889. export * from "babylonjs/Physics/physicsHelper";
  72890. export * from "babylonjs/Physics/physicsImpostor";
  72891. export * from "babylonjs/Physics/physicsJoint";
  72892. export * from "babylonjs/Physics/Plugins/index";
  72893. }
  72894. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72895. /** @hidden */
  72896. export var blackAndWhitePixelShader: {
  72897. name: string;
  72898. shader: string;
  72899. };
  72900. }
  72901. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72903. import { Camera } from "babylonjs/Cameras/camera";
  72904. import { Engine } from "babylonjs/Engines/engine";
  72905. import "babylonjs/Shaders/blackAndWhite.fragment";
  72906. import { Nullable } from "babylonjs/types";
  72907. import { Scene } from "babylonjs/scene";
  72908. /**
  72909. * Post process used to render in black and white
  72910. */
  72911. export class BlackAndWhitePostProcess extends PostProcess {
  72912. /**
  72913. * Linear about to convert he result to black and white (default: 1)
  72914. */
  72915. degree: number;
  72916. /**
  72917. * Gets a string identifying the name of the class
  72918. * @returns "BlackAndWhitePostProcess" string
  72919. */
  72920. getClassName(): string;
  72921. /**
  72922. * Creates a black and white post process
  72923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72924. * @param name The name of the effect.
  72925. * @param options The required width/height ratio to downsize to before computing the render pass.
  72926. * @param camera The camera to apply the render pass to.
  72927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72928. * @param engine The engine which the post process will be applied. (default: current engine)
  72929. * @param reusable If the post process can be reused on the same frame. (default: false)
  72930. */
  72931. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72932. /** @hidden */
  72933. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72934. }
  72935. }
  72936. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72937. import { Nullable } from "babylonjs/types";
  72938. import { Camera } from "babylonjs/Cameras/camera";
  72939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72940. import { Engine } from "babylonjs/Engines/engine";
  72941. /**
  72942. * This represents a set of one or more post processes in Babylon.
  72943. * A post process can be used to apply a shader to a texture after it is rendered.
  72944. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72945. */
  72946. export class PostProcessRenderEffect {
  72947. private _postProcesses;
  72948. private _getPostProcesses;
  72949. private _singleInstance;
  72950. private _cameras;
  72951. private _indicesForCamera;
  72952. /**
  72953. * Name of the effect
  72954. * @hidden
  72955. */
  72956. _name: string;
  72957. /**
  72958. * Instantiates a post process render effect.
  72959. * A post process can be used to apply a shader to a texture after it is rendered.
  72960. * @param engine The engine the effect is tied to
  72961. * @param name The name of the effect
  72962. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72963. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72964. */
  72965. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72966. /**
  72967. * Checks if all the post processes in the effect are supported.
  72968. */
  72969. get isSupported(): boolean;
  72970. /**
  72971. * Updates the current state of the effect
  72972. * @hidden
  72973. */
  72974. _update(): void;
  72975. /**
  72976. * Attaches the effect on cameras
  72977. * @param cameras The camera to attach to.
  72978. * @hidden
  72979. */
  72980. _attachCameras(cameras: Camera): void;
  72981. /**
  72982. * Attaches the effect on cameras
  72983. * @param cameras The camera to attach to.
  72984. * @hidden
  72985. */
  72986. _attachCameras(cameras: Camera[]): void;
  72987. /**
  72988. * Detaches the effect on cameras
  72989. * @param cameras The camera to detatch from.
  72990. * @hidden
  72991. */
  72992. _detachCameras(cameras: Camera): void;
  72993. /**
  72994. * Detatches the effect on cameras
  72995. * @param cameras The camera to detatch from.
  72996. * @hidden
  72997. */
  72998. _detachCameras(cameras: Camera[]): void;
  72999. /**
  73000. * Enables the effect on given cameras
  73001. * @param cameras The camera to enable.
  73002. * @hidden
  73003. */
  73004. _enable(cameras: Camera): void;
  73005. /**
  73006. * Enables the effect on given cameras
  73007. * @param cameras The camera to enable.
  73008. * @hidden
  73009. */
  73010. _enable(cameras: Nullable<Camera[]>): void;
  73011. /**
  73012. * Disables the effect on the given cameras
  73013. * @param cameras The camera to disable.
  73014. * @hidden
  73015. */
  73016. _disable(cameras: Camera): void;
  73017. /**
  73018. * Disables the effect on the given cameras
  73019. * @param cameras The camera to disable.
  73020. * @hidden
  73021. */
  73022. _disable(cameras: Nullable<Camera[]>): void;
  73023. /**
  73024. * Gets a list of the post processes contained in the effect.
  73025. * @param camera The camera to get the post processes on.
  73026. * @returns The list of the post processes in the effect.
  73027. */
  73028. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73029. }
  73030. }
  73031. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73032. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73033. /** @hidden */
  73034. export var extractHighlightsPixelShader: {
  73035. name: string;
  73036. shader: string;
  73037. };
  73038. }
  73039. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73040. import { Nullable } from "babylonjs/types";
  73041. import { Camera } from "babylonjs/Cameras/camera";
  73042. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73043. import { Engine } from "babylonjs/Engines/engine";
  73044. import "babylonjs/Shaders/extractHighlights.fragment";
  73045. /**
  73046. * 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.
  73047. */
  73048. export class ExtractHighlightsPostProcess extends PostProcess {
  73049. /**
  73050. * The luminance threshold, pixels below this value will be set to black.
  73051. */
  73052. threshold: number;
  73053. /** @hidden */
  73054. _exposure: number;
  73055. /**
  73056. * Post process which has the input texture to be used when performing highlight extraction
  73057. * @hidden
  73058. */
  73059. _inputPostProcess: Nullable<PostProcess>;
  73060. /**
  73061. * Gets a string identifying the name of the class
  73062. * @returns "ExtractHighlightsPostProcess" string
  73063. */
  73064. getClassName(): string;
  73065. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73066. }
  73067. }
  73068. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73069. /** @hidden */
  73070. export var bloomMergePixelShader: {
  73071. name: string;
  73072. shader: string;
  73073. };
  73074. }
  73075. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73077. import { Nullable } from "babylonjs/types";
  73078. import { Engine } from "babylonjs/Engines/engine";
  73079. import { Camera } from "babylonjs/Cameras/camera";
  73080. import "babylonjs/Shaders/bloomMerge.fragment";
  73081. /**
  73082. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73083. */
  73084. export class BloomMergePostProcess extends PostProcess {
  73085. /** Weight of the bloom to be added to the original input. */
  73086. weight: number;
  73087. /**
  73088. * Gets a string identifying the name of the class
  73089. * @returns "BloomMergePostProcess" string
  73090. */
  73091. getClassName(): string;
  73092. /**
  73093. * Creates a new instance of @see BloomMergePostProcess
  73094. * @param name The name of the effect.
  73095. * @param originalFromInput Post process which's input will be used for the merge.
  73096. * @param blurred Blurred highlights post process which's output will be used.
  73097. * @param weight Weight of the bloom to be added to the original input.
  73098. * @param options The required width/height ratio to downsize to before computing the render pass.
  73099. * @param camera The camera to apply the render pass to.
  73100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73101. * @param engine The engine which the post process will be applied. (default: current engine)
  73102. * @param reusable If the post process can be reused on the same frame. (default: false)
  73103. * @param textureType Type of textures used when performing the post process. (default: 0)
  73104. * @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)
  73105. */
  73106. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73107. /** Weight of the bloom to be added to the original input. */
  73108. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73109. }
  73110. }
  73111. declare module "babylonjs/PostProcesses/bloomEffect" {
  73112. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73113. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73114. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73115. import { Camera } from "babylonjs/Cameras/camera";
  73116. import { Scene } from "babylonjs/scene";
  73117. /**
  73118. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73119. */
  73120. export class BloomEffect extends PostProcessRenderEffect {
  73121. private bloomScale;
  73122. /**
  73123. * @hidden Internal
  73124. */
  73125. _effects: Array<PostProcess>;
  73126. /**
  73127. * @hidden Internal
  73128. */
  73129. _downscale: ExtractHighlightsPostProcess;
  73130. private _blurX;
  73131. private _blurY;
  73132. private _merge;
  73133. /**
  73134. * The luminance threshold to find bright areas of the image to bloom.
  73135. */
  73136. get threshold(): number;
  73137. set threshold(value: number);
  73138. /**
  73139. * The strength of the bloom.
  73140. */
  73141. get weight(): number;
  73142. set weight(value: number);
  73143. /**
  73144. * Specifies the size of the bloom blur kernel, relative to the final output size
  73145. */
  73146. get kernel(): number;
  73147. set kernel(value: number);
  73148. /**
  73149. * Creates a new instance of @see BloomEffect
  73150. * @param scene The scene the effect belongs to.
  73151. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73152. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73153. * @param bloomWeight The the strength of bloom.
  73154. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73155. * @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)
  73156. */
  73157. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73158. /**
  73159. * Disposes each of the internal effects for a given camera.
  73160. * @param camera The camera to dispose the effect on.
  73161. */
  73162. disposeEffects(camera: Camera): void;
  73163. /**
  73164. * @hidden Internal
  73165. */
  73166. _updateEffects(): void;
  73167. /**
  73168. * Internal
  73169. * @returns if all the contained post processes are ready.
  73170. * @hidden
  73171. */
  73172. _isReady(): boolean;
  73173. }
  73174. }
  73175. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73176. /** @hidden */
  73177. export var chromaticAberrationPixelShader: {
  73178. name: string;
  73179. shader: string;
  73180. };
  73181. }
  73182. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73183. import { Vector2 } from "babylonjs/Maths/math.vector";
  73184. import { Nullable } from "babylonjs/types";
  73185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73186. import { Camera } from "babylonjs/Cameras/camera";
  73187. import { Engine } from "babylonjs/Engines/engine";
  73188. import "babylonjs/Shaders/chromaticAberration.fragment";
  73189. import { Scene } from "babylonjs/scene";
  73190. /**
  73191. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73192. */
  73193. export class ChromaticAberrationPostProcess extends PostProcess {
  73194. /**
  73195. * The amount of seperation of rgb channels (default: 30)
  73196. */
  73197. aberrationAmount: number;
  73198. /**
  73199. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73200. */
  73201. radialIntensity: number;
  73202. /**
  73203. * 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))
  73204. */
  73205. direction: Vector2;
  73206. /**
  73207. * 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))
  73208. */
  73209. centerPosition: Vector2;
  73210. /** The width of the screen to apply the effect on */
  73211. screenWidth: number;
  73212. /** The height of the screen to apply the effect on */
  73213. screenHeight: number;
  73214. /**
  73215. * Gets a string identifying the name of the class
  73216. * @returns "ChromaticAberrationPostProcess" string
  73217. */
  73218. getClassName(): string;
  73219. /**
  73220. * Creates a new instance ChromaticAberrationPostProcess
  73221. * @param name The name of the effect.
  73222. * @param screenWidth The width of the screen to apply the effect on.
  73223. * @param screenHeight The height of the screen to apply the effect on.
  73224. * @param options The required width/height ratio to downsize to before computing the render pass.
  73225. * @param camera The camera to apply the render pass to.
  73226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73227. * @param engine The engine which the post process will be applied. (default: current engine)
  73228. * @param reusable If the post process can be reused on the same frame. (default: false)
  73229. * @param textureType Type of textures used when performing the post process. (default: 0)
  73230. * @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)
  73231. */
  73232. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73233. /** @hidden */
  73234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73235. }
  73236. }
  73237. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73238. /** @hidden */
  73239. export var circleOfConfusionPixelShader: {
  73240. name: string;
  73241. shader: string;
  73242. };
  73243. }
  73244. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73245. import { Nullable } from "babylonjs/types";
  73246. import { Engine } from "babylonjs/Engines/engine";
  73247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73248. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73249. import { Camera } from "babylonjs/Cameras/camera";
  73250. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73251. /**
  73252. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73253. */
  73254. export class CircleOfConfusionPostProcess extends PostProcess {
  73255. /**
  73256. * 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.
  73257. */
  73258. lensSize: number;
  73259. /**
  73260. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73261. */
  73262. fStop: number;
  73263. /**
  73264. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73265. */
  73266. focusDistance: number;
  73267. /**
  73268. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73269. */
  73270. focalLength: number;
  73271. /**
  73272. * Gets a string identifying the name of the class
  73273. * @returns "CircleOfConfusionPostProcess" string
  73274. */
  73275. getClassName(): string;
  73276. private _depthTexture;
  73277. /**
  73278. * Creates a new instance CircleOfConfusionPostProcess
  73279. * @param name The name of the effect.
  73280. * @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.
  73281. * @param options The required width/height ratio to downsize to before computing the render pass.
  73282. * @param camera The camera to apply the render pass to.
  73283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73284. * @param engine The engine which the post process will be applied. (default: current engine)
  73285. * @param reusable If the post process can be reused on the same frame. (default: false)
  73286. * @param textureType Type of textures used when performing the post process. (default: 0)
  73287. * @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)
  73288. */
  73289. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73290. /**
  73291. * 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.
  73292. */
  73293. set depthTexture(value: RenderTargetTexture);
  73294. }
  73295. }
  73296. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73297. /** @hidden */
  73298. export var colorCorrectionPixelShader: {
  73299. name: string;
  73300. shader: string;
  73301. };
  73302. }
  73303. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73305. import { Engine } from "babylonjs/Engines/engine";
  73306. import { Camera } from "babylonjs/Cameras/camera";
  73307. import "babylonjs/Shaders/colorCorrection.fragment";
  73308. import { Nullable } from "babylonjs/types";
  73309. import { Scene } from "babylonjs/scene";
  73310. /**
  73311. *
  73312. * This post-process allows the modification of rendered colors by using
  73313. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73314. *
  73315. * The object needs to be provided an url to a texture containing the color
  73316. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73317. * Use an image editing software to tweak the LUT to match your needs.
  73318. *
  73319. * For an example of a color LUT, see here:
  73320. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73321. * For explanations on color grading, see here:
  73322. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73323. *
  73324. */
  73325. export class ColorCorrectionPostProcess extends PostProcess {
  73326. private _colorTableTexture;
  73327. /**
  73328. * Gets the color table url used to create the LUT texture
  73329. */
  73330. colorTableUrl: string;
  73331. /**
  73332. * Gets a string identifying the name of the class
  73333. * @returns "ColorCorrectionPostProcess" string
  73334. */
  73335. getClassName(): string;
  73336. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73337. /** @hidden */
  73338. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73339. }
  73340. }
  73341. declare module "babylonjs/Shaders/convolution.fragment" {
  73342. /** @hidden */
  73343. export var convolutionPixelShader: {
  73344. name: string;
  73345. shader: string;
  73346. };
  73347. }
  73348. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73350. import { Nullable } from "babylonjs/types";
  73351. import { Camera } from "babylonjs/Cameras/camera";
  73352. import { Engine } from "babylonjs/Engines/engine";
  73353. import "babylonjs/Shaders/convolution.fragment";
  73354. import { Scene } from "babylonjs/scene";
  73355. /**
  73356. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73357. * input texture to perform effects such as edge detection or sharpening
  73358. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73359. */
  73360. export class ConvolutionPostProcess extends PostProcess {
  73361. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73362. kernel: number[];
  73363. /**
  73364. * Gets a string identifying the name of the class
  73365. * @returns "ConvolutionPostProcess" string
  73366. */
  73367. getClassName(): string;
  73368. /**
  73369. * Creates a new instance ConvolutionPostProcess
  73370. * @param name The name of the effect.
  73371. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73372. * @param options The required width/height ratio to downsize to before computing the render pass.
  73373. * @param camera The camera to apply the render pass to.
  73374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73375. * @param engine The engine which the post process will be applied. (default: current engine)
  73376. * @param reusable If the post process can be reused on the same frame. (default: false)
  73377. * @param textureType Type of textures used when performing the post process. (default: 0)
  73378. */
  73379. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73380. /** @hidden */
  73381. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73382. /**
  73383. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73384. */
  73385. static EdgeDetect0Kernel: number[];
  73386. /**
  73387. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73388. */
  73389. static EdgeDetect1Kernel: number[];
  73390. /**
  73391. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73392. */
  73393. static EdgeDetect2Kernel: number[];
  73394. /**
  73395. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73396. */
  73397. static SharpenKernel: number[];
  73398. /**
  73399. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73400. */
  73401. static EmbossKernel: number[];
  73402. /**
  73403. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73404. */
  73405. static GaussianKernel: number[];
  73406. }
  73407. }
  73408. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73409. import { Nullable } from "babylonjs/types";
  73410. import { Vector2 } from "babylonjs/Maths/math.vector";
  73411. import { Camera } from "babylonjs/Cameras/camera";
  73412. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73413. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73414. import { Engine } from "babylonjs/Engines/engine";
  73415. import { Scene } from "babylonjs/scene";
  73416. /**
  73417. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73418. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73419. * based on samples that have a large difference in distance than the center pixel.
  73420. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73421. */
  73422. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73423. /**
  73424. * The direction the blur should be applied
  73425. */
  73426. direction: Vector2;
  73427. /**
  73428. * Gets a string identifying the name of the class
  73429. * @returns "DepthOfFieldBlurPostProcess" string
  73430. */
  73431. getClassName(): string;
  73432. /**
  73433. * Creates a new instance CircleOfConfusionPostProcess
  73434. * @param name The name of the effect.
  73435. * @param scene The scene the effect belongs to.
  73436. * @param direction The direction the blur should be applied.
  73437. * @param kernel The size of the kernel used to blur.
  73438. * @param options The required width/height ratio to downsize to before computing the render pass.
  73439. * @param camera The camera to apply the render pass to.
  73440. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73441. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73443. * @param engine The engine which the post process will be applied. (default: current engine)
  73444. * @param reusable If the post process can be reused on the same frame. (default: false)
  73445. * @param textureType Type of textures used when performing the post process. (default: 0)
  73446. * @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)
  73447. */
  73448. 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);
  73449. }
  73450. }
  73451. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73452. /** @hidden */
  73453. export var depthOfFieldMergePixelShader: {
  73454. name: string;
  73455. shader: string;
  73456. };
  73457. }
  73458. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73459. import { Nullable } from "babylonjs/types";
  73460. import { Camera } from "babylonjs/Cameras/camera";
  73461. import { Effect } from "babylonjs/Materials/effect";
  73462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73463. import { Engine } from "babylonjs/Engines/engine";
  73464. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73465. /**
  73466. * Options to be set when merging outputs from the default pipeline.
  73467. */
  73468. export class DepthOfFieldMergePostProcessOptions {
  73469. /**
  73470. * The original image to merge on top of
  73471. */
  73472. originalFromInput: PostProcess;
  73473. /**
  73474. * Parameters to perform the merge of the depth of field effect
  73475. */
  73476. depthOfField?: {
  73477. circleOfConfusion: PostProcess;
  73478. blurSteps: Array<PostProcess>;
  73479. };
  73480. /**
  73481. * Parameters to perform the merge of bloom effect
  73482. */
  73483. bloom?: {
  73484. blurred: PostProcess;
  73485. weight: number;
  73486. };
  73487. }
  73488. /**
  73489. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73490. */
  73491. export class DepthOfFieldMergePostProcess extends PostProcess {
  73492. private blurSteps;
  73493. /**
  73494. * Gets a string identifying the name of the class
  73495. * @returns "DepthOfFieldMergePostProcess" string
  73496. */
  73497. getClassName(): string;
  73498. /**
  73499. * Creates a new instance of DepthOfFieldMergePostProcess
  73500. * @param name The name of the effect.
  73501. * @param originalFromInput Post process which's input will be used for the merge.
  73502. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73503. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73504. * @param options The required width/height ratio to downsize to before computing the render pass.
  73505. * @param camera The camera to apply the render pass to.
  73506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73507. * @param engine The engine which the post process will be applied. (default: current engine)
  73508. * @param reusable If the post process can be reused on the same frame. (default: false)
  73509. * @param textureType Type of textures used when performing the post process. (default: 0)
  73510. * @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)
  73511. */
  73512. 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);
  73513. /**
  73514. * Updates the effect with the current post process compile time values and recompiles the shader.
  73515. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73516. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73517. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73518. * @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
  73519. * @param onCompiled Called when the shader has been compiled.
  73520. * @param onError Called if there is an error when compiling a shader.
  73521. */
  73522. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73523. }
  73524. }
  73525. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73526. import { Nullable } from "babylonjs/types";
  73527. import { Camera } from "babylonjs/Cameras/camera";
  73528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73530. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73531. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73532. import { Scene } from "babylonjs/scene";
  73533. /**
  73534. * Specifies the level of max blur that should be applied when using the depth of field effect
  73535. */
  73536. export enum DepthOfFieldEffectBlurLevel {
  73537. /**
  73538. * Subtle blur
  73539. */
  73540. Low = 0,
  73541. /**
  73542. * Medium blur
  73543. */
  73544. Medium = 1,
  73545. /**
  73546. * Large blur
  73547. */
  73548. High = 2
  73549. }
  73550. /**
  73551. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73552. */
  73553. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73554. private _circleOfConfusion;
  73555. /**
  73556. * @hidden Internal, blurs from high to low
  73557. */
  73558. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73559. private _depthOfFieldBlurY;
  73560. private _dofMerge;
  73561. /**
  73562. * @hidden Internal post processes in depth of field effect
  73563. */
  73564. _effects: Array<PostProcess>;
  73565. /**
  73566. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73567. */
  73568. set focalLength(value: number);
  73569. get focalLength(): number;
  73570. /**
  73571. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73572. */
  73573. set fStop(value: number);
  73574. get fStop(): number;
  73575. /**
  73576. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73577. */
  73578. set focusDistance(value: number);
  73579. get focusDistance(): number;
  73580. /**
  73581. * 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.
  73582. */
  73583. set lensSize(value: number);
  73584. get lensSize(): number;
  73585. /**
  73586. * Creates a new instance DepthOfFieldEffect
  73587. * @param scene The scene the effect belongs to.
  73588. * @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.
  73589. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73590. * @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)
  73591. */
  73592. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73593. /**
  73594. * Get the current class name of the current effet
  73595. * @returns "DepthOfFieldEffect"
  73596. */
  73597. getClassName(): string;
  73598. /**
  73599. * 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.
  73600. */
  73601. set depthTexture(value: RenderTargetTexture);
  73602. /**
  73603. * Disposes each of the internal effects for a given camera.
  73604. * @param camera The camera to dispose the effect on.
  73605. */
  73606. disposeEffects(camera: Camera): void;
  73607. /**
  73608. * @hidden Internal
  73609. */
  73610. _updateEffects(): void;
  73611. /**
  73612. * Internal
  73613. * @returns if all the contained post processes are ready.
  73614. * @hidden
  73615. */
  73616. _isReady(): boolean;
  73617. }
  73618. }
  73619. declare module "babylonjs/Shaders/displayPass.fragment" {
  73620. /** @hidden */
  73621. export var displayPassPixelShader: {
  73622. name: string;
  73623. shader: string;
  73624. };
  73625. }
  73626. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73627. import { Nullable } from "babylonjs/types";
  73628. import { Camera } from "babylonjs/Cameras/camera";
  73629. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73630. import { Engine } from "babylonjs/Engines/engine";
  73631. import "babylonjs/Shaders/displayPass.fragment";
  73632. import { Scene } from "babylonjs/scene";
  73633. /**
  73634. * DisplayPassPostProcess which produces an output the same as it's input
  73635. */
  73636. export class DisplayPassPostProcess extends PostProcess {
  73637. /**
  73638. * Gets a string identifying the name of the class
  73639. * @returns "DisplayPassPostProcess" string
  73640. */
  73641. getClassName(): string;
  73642. /**
  73643. * Creates the DisplayPassPostProcess
  73644. * @param name The name of the effect.
  73645. * @param options The required width/height ratio to downsize to before computing the render pass.
  73646. * @param camera The camera to apply the render pass to.
  73647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73648. * @param engine The engine which the post process will be applied. (default: current engine)
  73649. * @param reusable If the post process can be reused on the same frame. (default: false)
  73650. */
  73651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73652. /** @hidden */
  73653. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73654. }
  73655. }
  73656. declare module "babylonjs/Shaders/filter.fragment" {
  73657. /** @hidden */
  73658. export var filterPixelShader: {
  73659. name: string;
  73660. shader: string;
  73661. };
  73662. }
  73663. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73664. import { Nullable } from "babylonjs/types";
  73665. import { Matrix } from "babylonjs/Maths/math.vector";
  73666. import { Camera } from "babylonjs/Cameras/camera";
  73667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73668. import { Engine } from "babylonjs/Engines/engine";
  73669. import "babylonjs/Shaders/filter.fragment";
  73670. import { Scene } from "babylonjs/scene";
  73671. /**
  73672. * Applies a kernel filter to the image
  73673. */
  73674. export class FilterPostProcess extends PostProcess {
  73675. /** The matrix to be applied to the image */
  73676. kernelMatrix: Matrix;
  73677. /**
  73678. * Gets a string identifying the name of the class
  73679. * @returns "FilterPostProcess" string
  73680. */
  73681. getClassName(): string;
  73682. /**
  73683. *
  73684. * @param name The name of the effect.
  73685. * @param kernelMatrix The matrix to be applied to the image
  73686. * @param options The required width/height ratio to downsize to before computing the render pass.
  73687. * @param camera The camera to apply the render pass to.
  73688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73689. * @param engine The engine which the post process will be applied. (default: current engine)
  73690. * @param reusable If the post process can be reused on the same frame. (default: false)
  73691. */
  73692. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73693. /** @hidden */
  73694. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73695. }
  73696. }
  73697. declare module "babylonjs/Shaders/fxaa.fragment" {
  73698. /** @hidden */
  73699. export var fxaaPixelShader: {
  73700. name: string;
  73701. shader: string;
  73702. };
  73703. }
  73704. declare module "babylonjs/Shaders/fxaa.vertex" {
  73705. /** @hidden */
  73706. export var fxaaVertexShader: {
  73707. name: string;
  73708. shader: string;
  73709. };
  73710. }
  73711. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73712. import { Nullable } from "babylonjs/types";
  73713. import { Camera } from "babylonjs/Cameras/camera";
  73714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73715. import { Engine } from "babylonjs/Engines/engine";
  73716. import "babylonjs/Shaders/fxaa.fragment";
  73717. import "babylonjs/Shaders/fxaa.vertex";
  73718. import { Scene } from "babylonjs/scene";
  73719. /**
  73720. * Fxaa post process
  73721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73722. */
  73723. export class FxaaPostProcess extends PostProcess {
  73724. /**
  73725. * Gets a string identifying the name of the class
  73726. * @returns "FxaaPostProcess" string
  73727. */
  73728. getClassName(): string;
  73729. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73730. private _getDefines;
  73731. /** @hidden */
  73732. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73733. }
  73734. }
  73735. declare module "babylonjs/Shaders/grain.fragment" {
  73736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73737. /** @hidden */
  73738. export var grainPixelShader: {
  73739. name: string;
  73740. shader: string;
  73741. };
  73742. }
  73743. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73744. import { Nullable } from "babylonjs/types";
  73745. import { Camera } from "babylonjs/Cameras/camera";
  73746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73747. import { Engine } from "babylonjs/Engines/engine";
  73748. import "babylonjs/Shaders/grain.fragment";
  73749. import { Scene } from "babylonjs/scene";
  73750. /**
  73751. * The GrainPostProcess adds noise to the image at mid luminance levels
  73752. */
  73753. export class GrainPostProcess extends PostProcess {
  73754. /**
  73755. * The intensity of the grain added (default: 30)
  73756. */
  73757. intensity: number;
  73758. /**
  73759. * If the grain should be randomized on every frame
  73760. */
  73761. animated: boolean;
  73762. /**
  73763. * Gets a string identifying the name of the class
  73764. * @returns "GrainPostProcess" string
  73765. */
  73766. getClassName(): string;
  73767. /**
  73768. * Creates a new instance of @see GrainPostProcess
  73769. * @param name The name of the effect.
  73770. * @param options The required width/height ratio to downsize to before computing the render pass.
  73771. * @param camera The camera to apply the render pass to.
  73772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73773. * @param engine The engine which the post process will be applied. (default: current engine)
  73774. * @param reusable If the post process can be reused on the same frame. (default: false)
  73775. * @param textureType Type of textures used when performing the post process. (default: 0)
  73776. * @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)
  73777. */
  73778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73779. /** @hidden */
  73780. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73781. }
  73782. }
  73783. declare module "babylonjs/Shaders/highlights.fragment" {
  73784. /** @hidden */
  73785. export var highlightsPixelShader: {
  73786. name: string;
  73787. shader: string;
  73788. };
  73789. }
  73790. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73791. import { Nullable } from "babylonjs/types";
  73792. import { Camera } from "babylonjs/Cameras/camera";
  73793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73794. import { Engine } from "babylonjs/Engines/engine";
  73795. import "babylonjs/Shaders/highlights.fragment";
  73796. /**
  73797. * Extracts highlights from the image
  73798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73799. */
  73800. export class HighlightsPostProcess extends PostProcess {
  73801. /**
  73802. * Gets a string identifying the name of the class
  73803. * @returns "HighlightsPostProcess" string
  73804. */
  73805. getClassName(): string;
  73806. /**
  73807. * Extracts highlights from the image
  73808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73809. * @param name The name of the effect.
  73810. * @param options The required width/height ratio to downsize to before computing the render pass.
  73811. * @param camera The camera to apply the render pass to.
  73812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73813. * @param engine The engine which the post process will be applied. (default: current engine)
  73814. * @param reusable If the post process can be reused on the same frame. (default: false)
  73815. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73816. */
  73817. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73818. }
  73819. }
  73820. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73821. /** @hidden */
  73822. export var mrtFragmentDeclaration: {
  73823. name: string;
  73824. shader: string;
  73825. };
  73826. }
  73827. declare module "babylonjs/Shaders/geometry.fragment" {
  73828. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73829. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73831. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73832. /** @hidden */
  73833. export var geometryPixelShader: {
  73834. name: string;
  73835. shader: string;
  73836. };
  73837. }
  73838. declare module "babylonjs/Shaders/geometry.vertex" {
  73839. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73840. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73842. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73844. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73845. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73846. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73847. /** @hidden */
  73848. export var geometryVertexShader: {
  73849. name: string;
  73850. shader: string;
  73851. };
  73852. }
  73853. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73854. import { Matrix } from "babylonjs/Maths/math.vector";
  73855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73856. import { Mesh } from "babylonjs/Meshes/mesh";
  73857. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73858. import { Effect } from "babylonjs/Materials/effect";
  73859. import { Scene } from "babylonjs/scene";
  73860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73861. import "babylonjs/Shaders/geometry.fragment";
  73862. import "babylonjs/Shaders/geometry.vertex";
  73863. /** @hidden */
  73864. interface ISavedTransformationMatrix {
  73865. world: Matrix;
  73866. viewProjection: Matrix;
  73867. }
  73868. /**
  73869. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73870. */
  73871. export class GeometryBufferRenderer {
  73872. /**
  73873. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73874. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73875. */
  73876. static readonly POSITION_TEXTURE_TYPE: number;
  73877. /**
  73878. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73879. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73880. */
  73881. static readonly VELOCITY_TEXTURE_TYPE: number;
  73882. /**
  73883. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73884. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73885. */
  73886. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73887. /**
  73888. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73889. * in order to compute objects velocities when enableVelocity is set to "true"
  73890. * @hidden
  73891. */
  73892. _previousTransformationMatrices: {
  73893. [index: number]: ISavedTransformationMatrix;
  73894. };
  73895. /**
  73896. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73897. * in order to compute objects velocities when enableVelocity is set to "true"
  73898. * @hidden
  73899. */
  73900. _previousBonesTransformationMatrices: {
  73901. [index: number]: Float32Array;
  73902. };
  73903. /**
  73904. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73905. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73906. */
  73907. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73908. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73909. renderTransparentMeshes: boolean;
  73910. private _scene;
  73911. private _resizeObserver;
  73912. private _multiRenderTarget;
  73913. private _ratio;
  73914. private _enablePosition;
  73915. private _enableVelocity;
  73916. private _enableReflectivity;
  73917. private _positionIndex;
  73918. private _velocityIndex;
  73919. private _reflectivityIndex;
  73920. protected _effect: Effect;
  73921. protected _cachedDefines: string;
  73922. /**
  73923. * Set the render list (meshes to be rendered) used in the G buffer.
  73924. */
  73925. set renderList(meshes: Mesh[]);
  73926. /**
  73927. * Gets wether or not G buffer are supported by the running hardware.
  73928. * This requires draw buffer supports
  73929. */
  73930. get isSupported(): boolean;
  73931. /**
  73932. * Returns the index of the given texture type in the G-Buffer textures array
  73933. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73934. * @returns the index of the given texture type in the G-Buffer textures array
  73935. */
  73936. getTextureIndex(textureType: number): number;
  73937. /**
  73938. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73939. */
  73940. get enablePosition(): boolean;
  73941. /**
  73942. * Sets whether or not objects positions are enabled for the G buffer.
  73943. */
  73944. set enablePosition(enable: boolean);
  73945. /**
  73946. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73947. */
  73948. get enableVelocity(): boolean;
  73949. /**
  73950. * Sets wether or not objects velocities are enabled for the G buffer.
  73951. */
  73952. set enableVelocity(enable: boolean);
  73953. /**
  73954. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73955. */
  73956. get enableReflectivity(): boolean;
  73957. /**
  73958. * Sets wether or not objects roughness are enabled for the G buffer.
  73959. */
  73960. set enableReflectivity(enable: boolean);
  73961. /**
  73962. * Gets the scene associated with the buffer.
  73963. */
  73964. get scene(): Scene;
  73965. /**
  73966. * Gets the ratio used by the buffer during its creation.
  73967. * How big is the buffer related to the main canvas.
  73968. */
  73969. get ratio(): number;
  73970. /** @hidden */
  73971. static _SceneComponentInitialization: (scene: Scene) => void;
  73972. /**
  73973. * Creates a new G Buffer for the scene
  73974. * @param scene The scene the buffer belongs to
  73975. * @param ratio How big is the buffer related to the main canvas.
  73976. */
  73977. constructor(scene: Scene, ratio?: number);
  73978. /**
  73979. * Checks wether everything is ready to render a submesh to the G buffer.
  73980. * @param subMesh the submesh to check readiness for
  73981. * @param useInstances is the mesh drawn using instance or not
  73982. * @returns true if ready otherwise false
  73983. */
  73984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73985. /**
  73986. * Gets the current underlying G Buffer.
  73987. * @returns the buffer
  73988. */
  73989. getGBuffer(): MultiRenderTarget;
  73990. /**
  73991. * Gets the number of samples used to render the buffer (anti aliasing).
  73992. */
  73993. get samples(): number;
  73994. /**
  73995. * Sets the number of samples used to render the buffer (anti aliasing).
  73996. */
  73997. set samples(value: number);
  73998. /**
  73999. * Disposes the renderer and frees up associated resources.
  74000. */
  74001. dispose(): void;
  74002. protected _createRenderTargets(): void;
  74003. private _copyBonesTransformationMatrices;
  74004. }
  74005. }
  74006. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74007. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74008. /**
  74009. * Contains all parameters needed for the prepass to perform
  74010. * motion blur
  74011. */
  74012. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74013. /**
  74014. * Is motion blur enabled
  74015. */
  74016. enabled: boolean;
  74017. /**
  74018. * Name of the configuration
  74019. */
  74020. name: string;
  74021. /**
  74022. * Textures that should be present in the MRT for this effect to work
  74023. */
  74024. readonly texturesRequired: number[];
  74025. }
  74026. }
  74027. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74028. import { Nullable } from "babylonjs/types";
  74029. import { Scene } from "babylonjs/scene";
  74030. import { ISceneComponent } from "babylonjs/sceneComponent";
  74031. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74032. module "babylonjs/scene" {
  74033. interface Scene {
  74034. /** @hidden (Backing field) */
  74035. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74036. /**
  74037. * Gets or Sets the current geometry buffer associated to the scene.
  74038. */
  74039. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74040. /**
  74041. * Enables a GeometryBufferRender and associates it with the scene
  74042. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74043. * @returns the GeometryBufferRenderer
  74044. */
  74045. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74046. /**
  74047. * Disables the GeometryBufferRender associated with the scene
  74048. */
  74049. disableGeometryBufferRenderer(): void;
  74050. }
  74051. }
  74052. /**
  74053. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74054. * in several rendering techniques.
  74055. */
  74056. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74057. /**
  74058. * The component name helpful to identify the component in the list of scene components.
  74059. */
  74060. readonly name: string;
  74061. /**
  74062. * The scene the component belongs to.
  74063. */
  74064. scene: Scene;
  74065. /**
  74066. * Creates a new instance of the component for the given scene
  74067. * @param scene Defines the scene to register the component in
  74068. */
  74069. constructor(scene: Scene);
  74070. /**
  74071. * Registers the component in a given scene
  74072. */
  74073. register(): void;
  74074. /**
  74075. * Rebuilds the elements related to this component in case of
  74076. * context lost for instance.
  74077. */
  74078. rebuild(): void;
  74079. /**
  74080. * Disposes the component and the associated ressources
  74081. */
  74082. dispose(): void;
  74083. private _gatherRenderTargets;
  74084. }
  74085. }
  74086. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74087. /** @hidden */
  74088. export var motionBlurPixelShader: {
  74089. name: string;
  74090. shader: string;
  74091. };
  74092. }
  74093. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74094. import { Nullable } from "babylonjs/types";
  74095. import { Camera } from "babylonjs/Cameras/camera";
  74096. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74098. import "babylonjs/Animations/animatable";
  74099. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74100. import "babylonjs/Shaders/motionBlur.fragment";
  74101. import { Engine } from "babylonjs/Engines/engine";
  74102. import { Scene } from "babylonjs/scene";
  74103. /**
  74104. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74105. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74106. * As an example, all you have to do is to create the post-process:
  74107. * var mb = new BABYLON.MotionBlurPostProcess(
  74108. * 'mb', // The name of the effect.
  74109. * scene, // The scene containing the objects to blur according to their velocity.
  74110. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74111. * camera // The camera to apply the render pass to.
  74112. * );
  74113. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74114. */
  74115. export class MotionBlurPostProcess extends PostProcess {
  74116. /**
  74117. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74118. */
  74119. motionStrength: number;
  74120. /**
  74121. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74122. */
  74123. get motionBlurSamples(): number;
  74124. /**
  74125. * Sets the number of iterations to be used for motion blur quality
  74126. */
  74127. set motionBlurSamples(samples: number);
  74128. private _motionBlurSamples;
  74129. private _forceGeometryBuffer;
  74130. private _geometryBufferRenderer;
  74131. private _prePassRenderer;
  74132. /**
  74133. * Gets a string identifying the name of the class
  74134. * @returns "MotionBlurPostProcess" string
  74135. */
  74136. getClassName(): string;
  74137. /**
  74138. * Creates a new instance MotionBlurPostProcess
  74139. * @param name The name of the effect.
  74140. * @param scene The scene containing the objects to blur according to their velocity.
  74141. * @param options The required width/height ratio to downsize to before computing the render pass.
  74142. * @param camera The camera to apply the render pass to.
  74143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74144. * @param engine The engine which the post process will be applied. (default: current engine)
  74145. * @param reusable If the post process can be reused on the same frame. (default: false)
  74146. * @param textureType Type of textures used when performing the post process. (default: 0)
  74147. * @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)
  74148. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74149. */
  74150. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74151. /**
  74152. * Excludes the given skinned mesh from computing bones velocities.
  74153. * 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.
  74154. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74155. */
  74156. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74157. /**
  74158. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74159. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74160. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74161. */
  74162. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74163. /**
  74164. * Disposes the post process.
  74165. * @param camera The camera to dispose the post process on.
  74166. */
  74167. dispose(camera?: Camera): void;
  74168. /** @hidden */
  74169. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74170. }
  74171. }
  74172. declare module "babylonjs/Shaders/refraction.fragment" {
  74173. /** @hidden */
  74174. export var refractionPixelShader: {
  74175. name: string;
  74176. shader: string;
  74177. };
  74178. }
  74179. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74180. import { Color3 } from "babylonjs/Maths/math.color";
  74181. import { Camera } from "babylonjs/Cameras/camera";
  74182. import { Texture } from "babylonjs/Materials/Textures/texture";
  74183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74184. import { Engine } from "babylonjs/Engines/engine";
  74185. import "babylonjs/Shaders/refraction.fragment";
  74186. import { Scene } from "babylonjs/scene";
  74187. /**
  74188. * Post process which applies a refractin texture
  74189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74190. */
  74191. export class RefractionPostProcess extends PostProcess {
  74192. private _refTexture;
  74193. private _ownRefractionTexture;
  74194. /** the base color of the refraction (used to taint the rendering) */
  74195. color: Color3;
  74196. /** simulated refraction depth */
  74197. depth: number;
  74198. /** the coefficient of the base color (0 to remove base color tainting) */
  74199. colorLevel: number;
  74200. /** Gets the url used to load the refraction texture */
  74201. refractionTextureUrl: string;
  74202. /**
  74203. * Gets or sets the refraction texture
  74204. * Please note that you are responsible for disposing the texture if you set it manually
  74205. */
  74206. get refractionTexture(): Texture;
  74207. set refractionTexture(value: Texture);
  74208. /**
  74209. * Gets a string identifying the name of the class
  74210. * @returns "RefractionPostProcess" string
  74211. */
  74212. getClassName(): string;
  74213. /**
  74214. * Initializes the RefractionPostProcess
  74215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74216. * @param name The name of the effect.
  74217. * @param refractionTextureUrl Url of the refraction texture to use
  74218. * @param color the base color of the refraction (used to taint the rendering)
  74219. * @param depth simulated refraction depth
  74220. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74221. * @param camera The camera to apply the render pass to.
  74222. * @param options The required width/height ratio to downsize to before computing the render pass.
  74223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74224. * @param engine The engine which the post process will be applied. (default: current engine)
  74225. * @param reusable If the post process can be reused on the same frame. (default: false)
  74226. */
  74227. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74228. /**
  74229. * Disposes of the post process
  74230. * @param camera Camera to dispose post process on
  74231. */
  74232. dispose(camera: Camera): void;
  74233. /** @hidden */
  74234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74235. }
  74236. }
  74237. declare module "babylonjs/Shaders/sharpen.fragment" {
  74238. /** @hidden */
  74239. export var sharpenPixelShader: {
  74240. name: string;
  74241. shader: string;
  74242. };
  74243. }
  74244. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74245. import { Nullable } from "babylonjs/types";
  74246. import { Camera } from "babylonjs/Cameras/camera";
  74247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74248. import "babylonjs/Shaders/sharpen.fragment";
  74249. import { Engine } from "babylonjs/Engines/engine";
  74250. import { Scene } from "babylonjs/scene";
  74251. /**
  74252. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74253. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74254. */
  74255. export class SharpenPostProcess extends PostProcess {
  74256. /**
  74257. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74258. */
  74259. colorAmount: number;
  74260. /**
  74261. * How much sharpness should be applied (default: 0.3)
  74262. */
  74263. edgeAmount: number;
  74264. /**
  74265. * Gets a string identifying the name of the class
  74266. * @returns "SharpenPostProcess" string
  74267. */
  74268. getClassName(): string;
  74269. /**
  74270. * Creates a new instance ConvolutionPostProcess
  74271. * @param name The name of the effect.
  74272. * @param options The required width/height ratio to downsize to before computing the render pass.
  74273. * @param camera The camera to apply the render pass to.
  74274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74275. * @param engine The engine which the post process will be applied. (default: current engine)
  74276. * @param reusable If the post process can be reused on the same frame. (default: false)
  74277. * @param textureType Type of textures used when performing the post process. (default: 0)
  74278. * @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)
  74279. */
  74280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74281. /** @hidden */
  74282. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74283. }
  74284. }
  74285. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74286. import { Nullable } from "babylonjs/types";
  74287. import { Camera } from "babylonjs/Cameras/camera";
  74288. import { Engine } from "babylonjs/Engines/engine";
  74289. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74290. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74291. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74292. /**
  74293. * PostProcessRenderPipeline
  74294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74295. */
  74296. export class PostProcessRenderPipeline {
  74297. private engine;
  74298. private _renderEffects;
  74299. private _renderEffectsForIsolatedPass;
  74300. /**
  74301. * List of inspectable custom properties (used by the Inspector)
  74302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74303. */
  74304. inspectableCustomProperties: IInspectable[];
  74305. /**
  74306. * @hidden
  74307. */
  74308. protected _cameras: Camera[];
  74309. /** @hidden */
  74310. _name: string;
  74311. /**
  74312. * Gets pipeline name
  74313. */
  74314. get name(): string;
  74315. /** Gets the list of attached cameras */
  74316. get cameras(): Camera[];
  74317. /**
  74318. * Initializes a PostProcessRenderPipeline
  74319. * @param engine engine to add the pipeline to
  74320. * @param name name of the pipeline
  74321. */
  74322. constructor(engine: Engine, name: string);
  74323. /**
  74324. * Gets the class name
  74325. * @returns "PostProcessRenderPipeline"
  74326. */
  74327. getClassName(): string;
  74328. /**
  74329. * If all the render effects in the pipeline are supported
  74330. */
  74331. get isSupported(): boolean;
  74332. /**
  74333. * Adds an effect to the pipeline
  74334. * @param renderEffect the effect to add
  74335. */
  74336. addEffect(renderEffect: PostProcessRenderEffect): void;
  74337. /** @hidden */
  74338. _rebuild(): void;
  74339. /** @hidden */
  74340. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74341. /** @hidden */
  74342. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74343. /** @hidden */
  74344. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74345. /** @hidden */
  74346. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74347. /** @hidden */
  74348. _attachCameras(cameras: Camera, unique: boolean): void;
  74349. /** @hidden */
  74350. _attachCameras(cameras: Camera[], unique: boolean): void;
  74351. /** @hidden */
  74352. _detachCameras(cameras: Camera): void;
  74353. /** @hidden */
  74354. _detachCameras(cameras: Nullable<Camera[]>): void;
  74355. /** @hidden */
  74356. _update(): void;
  74357. /** @hidden */
  74358. _reset(): void;
  74359. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74360. /**
  74361. * Sets the required values to the prepass renderer.
  74362. * @param prePassRenderer defines the prepass renderer to setup.
  74363. * @returns true if the pre pass is needed.
  74364. */
  74365. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74366. /**
  74367. * Disposes of the pipeline
  74368. */
  74369. dispose(): void;
  74370. }
  74371. }
  74372. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74373. import { Camera } from "babylonjs/Cameras/camera";
  74374. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74375. /**
  74376. * PostProcessRenderPipelineManager class
  74377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74378. */
  74379. export class PostProcessRenderPipelineManager {
  74380. private _renderPipelines;
  74381. /**
  74382. * Initializes a PostProcessRenderPipelineManager
  74383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74384. */
  74385. constructor();
  74386. /**
  74387. * Gets the list of supported render pipelines
  74388. */
  74389. get supportedPipelines(): PostProcessRenderPipeline[];
  74390. /**
  74391. * Adds a pipeline to the manager
  74392. * @param renderPipeline The pipeline to add
  74393. */
  74394. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74395. /**
  74396. * Attaches a camera to the pipeline
  74397. * @param renderPipelineName The name of the pipeline to attach to
  74398. * @param cameras the camera to attach
  74399. * @param unique if the camera can be attached multiple times to the pipeline
  74400. */
  74401. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74402. /**
  74403. * Detaches a camera from the pipeline
  74404. * @param renderPipelineName The name of the pipeline to detach from
  74405. * @param cameras the camera to detach
  74406. */
  74407. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74408. /**
  74409. * Enables an effect by name on a pipeline
  74410. * @param renderPipelineName the name of the pipeline to enable the effect in
  74411. * @param renderEffectName the name of the effect to enable
  74412. * @param cameras the cameras that the effect should be enabled on
  74413. */
  74414. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74415. /**
  74416. * Disables an effect by name on a pipeline
  74417. * @param renderPipelineName the name of the pipeline to disable the effect in
  74418. * @param renderEffectName the name of the effect to disable
  74419. * @param cameras the cameras that the effect should be disabled on
  74420. */
  74421. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74422. /**
  74423. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74424. */
  74425. update(): void;
  74426. /** @hidden */
  74427. _rebuild(): void;
  74428. /**
  74429. * Disposes of the manager and pipelines
  74430. */
  74431. dispose(): void;
  74432. }
  74433. }
  74434. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74435. import { ISceneComponent } from "babylonjs/sceneComponent";
  74436. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74437. import { Scene } from "babylonjs/scene";
  74438. module "babylonjs/scene" {
  74439. interface Scene {
  74440. /** @hidden (Backing field) */
  74441. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74442. /**
  74443. * Gets the postprocess render pipeline manager
  74444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74445. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74446. */
  74447. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74448. }
  74449. }
  74450. /**
  74451. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74452. */
  74453. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74454. /**
  74455. * The component name helpfull to identify the component in the list of scene components.
  74456. */
  74457. readonly name: string;
  74458. /**
  74459. * The scene the component belongs to.
  74460. */
  74461. scene: Scene;
  74462. /**
  74463. * Creates a new instance of the component for the given scene
  74464. * @param scene Defines the scene to register the component in
  74465. */
  74466. constructor(scene: Scene);
  74467. /**
  74468. * Registers the component in a given scene
  74469. */
  74470. register(): void;
  74471. /**
  74472. * Rebuilds the elements related to this component in case of
  74473. * context lost for instance.
  74474. */
  74475. rebuild(): void;
  74476. /**
  74477. * Disposes the component and the associated ressources
  74478. */
  74479. dispose(): void;
  74480. private _gatherRenderTargets;
  74481. }
  74482. }
  74483. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74484. import { Nullable } from "babylonjs/types";
  74485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74486. import { Camera } from "babylonjs/Cameras/camera";
  74487. import { IDisposable } from "babylonjs/scene";
  74488. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74489. import { Scene } from "babylonjs/scene";
  74490. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74491. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74492. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74493. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74494. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74495. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74496. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74497. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74498. import { Animation } from "babylonjs/Animations/animation";
  74499. /**
  74500. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74501. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74502. */
  74503. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74504. private _scene;
  74505. private _camerasToBeAttached;
  74506. /**
  74507. * ID of the sharpen post process,
  74508. */
  74509. private readonly SharpenPostProcessId;
  74510. /**
  74511. * @ignore
  74512. * ID of the image processing post process;
  74513. */
  74514. readonly ImageProcessingPostProcessId: string;
  74515. /**
  74516. * @ignore
  74517. * ID of the Fast Approximate Anti-Aliasing post process;
  74518. */
  74519. readonly FxaaPostProcessId: string;
  74520. /**
  74521. * ID of the chromatic aberration post process,
  74522. */
  74523. private readonly ChromaticAberrationPostProcessId;
  74524. /**
  74525. * ID of the grain post process
  74526. */
  74527. private readonly GrainPostProcessId;
  74528. /**
  74529. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74530. */
  74531. sharpen: SharpenPostProcess;
  74532. private _sharpenEffect;
  74533. private bloom;
  74534. /**
  74535. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74536. */
  74537. depthOfField: DepthOfFieldEffect;
  74538. /**
  74539. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74540. */
  74541. fxaa: FxaaPostProcess;
  74542. /**
  74543. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74544. */
  74545. imageProcessing: ImageProcessingPostProcess;
  74546. /**
  74547. * Chromatic aberration post process which will shift rgb colors in the image
  74548. */
  74549. chromaticAberration: ChromaticAberrationPostProcess;
  74550. private _chromaticAberrationEffect;
  74551. /**
  74552. * Grain post process which add noise to the image
  74553. */
  74554. grain: GrainPostProcess;
  74555. private _grainEffect;
  74556. /**
  74557. * Glow post process which adds a glow to emissive areas of the image
  74558. */
  74559. private _glowLayer;
  74560. /**
  74561. * Animations which can be used to tweak settings over a period of time
  74562. */
  74563. animations: Animation[];
  74564. private _imageProcessingConfigurationObserver;
  74565. private _sharpenEnabled;
  74566. private _bloomEnabled;
  74567. private _depthOfFieldEnabled;
  74568. private _depthOfFieldBlurLevel;
  74569. private _fxaaEnabled;
  74570. private _imageProcessingEnabled;
  74571. private _defaultPipelineTextureType;
  74572. private _bloomScale;
  74573. private _chromaticAberrationEnabled;
  74574. private _grainEnabled;
  74575. private _buildAllowed;
  74576. /**
  74577. * Gets active scene
  74578. */
  74579. get scene(): Scene;
  74580. /**
  74581. * Enable or disable the sharpen process from the pipeline
  74582. */
  74583. set sharpenEnabled(enabled: boolean);
  74584. get sharpenEnabled(): boolean;
  74585. private _resizeObserver;
  74586. private _hardwareScaleLevel;
  74587. private _bloomKernel;
  74588. /**
  74589. * Specifies the size of the bloom blur kernel, relative to the final output size
  74590. */
  74591. get bloomKernel(): number;
  74592. set bloomKernel(value: number);
  74593. /**
  74594. * Specifies the weight of the bloom in the final rendering
  74595. */
  74596. private _bloomWeight;
  74597. /**
  74598. * Specifies the luma threshold for the area that will be blurred by the bloom
  74599. */
  74600. private _bloomThreshold;
  74601. private _hdr;
  74602. /**
  74603. * The strength of the bloom.
  74604. */
  74605. set bloomWeight(value: number);
  74606. get bloomWeight(): number;
  74607. /**
  74608. * The strength of the bloom.
  74609. */
  74610. set bloomThreshold(value: number);
  74611. get bloomThreshold(): number;
  74612. /**
  74613. * The scale of the bloom, lower value will provide better performance.
  74614. */
  74615. set bloomScale(value: number);
  74616. get bloomScale(): number;
  74617. /**
  74618. * Enable or disable the bloom from the pipeline
  74619. */
  74620. set bloomEnabled(enabled: boolean);
  74621. get bloomEnabled(): boolean;
  74622. private _rebuildBloom;
  74623. /**
  74624. * If the depth of field is enabled.
  74625. */
  74626. get depthOfFieldEnabled(): boolean;
  74627. set depthOfFieldEnabled(enabled: boolean);
  74628. /**
  74629. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74630. */
  74631. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74632. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74633. /**
  74634. * If the anti aliasing is enabled.
  74635. */
  74636. set fxaaEnabled(enabled: boolean);
  74637. get fxaaEnabled(): boolean;
  74638. private _samples;
  74639. /**
  74640. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74641. */
  74642. set samples(sampleCount: number);
  74643. get samples(): number;
  74644. /**
  74645. * If image processing is enabled.
  74646. */
  74647. set imageProcessingEnabled(enabled: boolean);
  74648. get imageProcessingEnabled(): boolean;
  74649. /**
  74650. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74651. */
  74652. set glowLayerEnabled(enabled: boolean);
  74653. get glowLayerEnabled(): boolean;
  74654. /**
  74655. * Gets the glow layer (or null if not defined)
  74656. */
  74657. get glowLayer(): Nullable<GlowLayer>;
  74658. /**
  74659. * Enable or disable the chromaticAberration process from the pipeline
  74660. */
  74661. set chromaticAberrationEnabled(enabled: boolean);
  74662. get chromaticAberrationEnabled(): boolean;
  74663. /**
  74664. * Enable or disable the grain process from the pipeline
  74665. */
  74666. set grainEnabled(enabled: boolean);
  74667. get grainEnabled(): boolean;
  74668. /**
  74669. * @constructor
  74670. * @param name - The rendering pipeline name (default: "")
  74671. * @param hdr - If high dynamic range textures should be used (default: true)
  74672. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74673. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74674. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74675. */
  74676. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74677. /**
  74678. * Get the class name
  74679. * @returns "DefaultRenderingPipeline"
  74680. */
  74681. getClassName(): string;
  74682. /**
  74683. * Force the compilation of the entire pipeline.
  74684. */
  74685. prepare(): void;
  74686. private _hasCleared;
  74687. private _prevPostProcess;
  74688. private _prevPrevPostProcess;
  74689. private _setAutoClearAndTextureSharing;
  74690. private _depthOfFieldSceneObserver;
  74691. private _buildPipeline;
  74692. private _disposePostProcesses;
  74693. /**
  74694. * Adds a camera to the pipeline
  74695. * @param camera the camera to be added
  74696. */
  74697. addCamera(camera: Camera): void;
  74698. /**
  74699. * Removes a camera from the pipeline
  74700. * @param camera the camera to remove
  74701. */
  74702. removeCamera(camera: Camera): void;
  74703. /**
  74704. * Dispose of the pipeline and stop all post processes
  74705. */
  74706. dispose(): void;
  74707. /**
  74708. * Serialize the rendering pipeline (Used when exporting)
  74709. * @returns the serialized object
  74710. */
  74711. serialize(): any;
  74712. /**
  74713. * Parse the serialized pipeline
  74714. * @param source Source pipeline.
  74715. * @param scene The scene to load the pipeline to.
  74716. * @param rootUrl The URL of the serialized pipeline.
  74717. * @returns An instantiated pipeline from the serialized object.
  74718. */
  74719. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74720. }
  74721. }
  74722. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74723. /** @hidden */
  74724. export var lensHighlightsPixelShader: {
  74725. name: string;
  74726. shader: string;
  74727. };
  74728. }
  74729. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74730. /** @hidden */
  74731. export var depthOfFieldPixelShader: {
  74732. name: string;
  74733. shader: string;
  74734. };
  74735. }
  74736. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74737. import { Camera } from "babylonjs/Cameras/camera";
  74738. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74739. import { Scene } from "babylonjs/scene";
  74740. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74741. import "babylonjs/Shaders/chromaticAberration.fragment";
  74742. import "babylonjs/Shaders/lensHighlights.fragment";
  74743. import "babylonjs/Shaders/depthOfField.fragment";
  74744. /**
  74745. * BABYLON.JS Chromatic Aberration GLSL Shader
  74746. * Author: Olivier Guyot
  74747. * Separates very slightly R, G and B colors on the edges of the screen
  74748. * Inspired by Francois Tarlier & Martins Upitis
  74749. */
  74750. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74751. /**
  74752. * @ignore
  74753. * The chromatic aberration PostProcess id in the pipeline
  74754. */
  74755. LensChromaticAberrationEffect: string;
  74756. /**
  74757. * @ignore
  74758. * The highlights enhancing PostProcess id in the pipeline
  74759. */
  74760. HighlightsEnhancingEffect: string;
  74761. /**
  74762. * @ignore
  74763. * The depth-of-field PostProcess id in the pipeline
  74764. */
  74765. LensDepthOfFieldEffect: string;
  74766. private _scene;
  74767. private _depthTexture;
  74768. private _grainTexture;
  74769. private _chromaticAberrationPostProcess;
  74770. private _highlightsPostProcess;
  74771. private _depthOfFieldPostProcess;
  74772. private _edgeBlur;
  74773. private _grainAmount;
  74774. private _chromaticAberration;
  74775. private _distortion;
  74776. private _highlightsGain;
  74777. private _highlightsThreshold;
  74778. private _dofDistance;
  74779. private _dofAperture;
  74780. private _dofDarken;
  74781. private _dofPentagon;
  74782. private _blurNoise;
  74783. /**
  74784. * @constructor
  74785. *
  74786. * Effect parameters are as follow:
  74787. * {
  74788. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74789. * edge_blur: number; // from 0 to x (1 for realism)
  74790. * distortion: number; // from 0 to x (1 for realism)
  74791. * grain_amount: number; // from 0 to 1
  74792. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74793. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74794. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74795. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74796. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74797. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74798. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74799. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74800. * }
  74801. * Note: if an effect parameter is unset, effect is disabled
  74802. *
  74803. * @param name The rendering pipeline name
  74804. * @param parameters - An object containing all parameters (see above)
  74805. * @param scene The scene linked to this pipeline
  74806. * @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)
  74807. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74808. */
  74809. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74810. /**
  74811. * Get the class name
  74812. * @returns "LensRenderingPipeline"
  74813. */
  74814. getClassName(): string;
  74815. /**
  74816. * Gets associated scene
  74817. */
  74818. get scene(): Scene;
  74819. /**
  74820. * Gets or sets the edge blur
  74821. */
  74822. get edgeBlur(): number;
  74823. set edgeBlur(value: number);
  74824. /**
  74825. * Gets or sets the grain amount
  74826. */
  74827. get grainAmount(): number;
  74828. set grainAmount(value: number);
  74829. /**
  74830. * Gets or sets the chromatic aberration amount
  74831. */
  74832. get chromaticAberration(): number;
  74833. set chromaticAberration(value: number);
  74834. /**
  74835. * Gets or sets the depth of field aperture
  74836. */
  74837. get dofAperture(): number;
  74838. set dofAperture(value: number);
  74839. /**
  74840. * Gets or sets the edge distortion
  74841. */
  74842. get edgeDistortion(): number;
  74843. set edgeDistortion(value: number);
  74844. /**
  74845. * Gets or sets the depth of field distortion
  74846. */
  74847. get dofDistortion(): number;
  74848. set dofDistortion(value: number);
  74849. /**
  74850. * Gets or sets the darken out of focus amount
  74851. */
  74852. get darkenOutOfFocus(): number;
  74853. set darkenOutOfFocus(value: number);
  74854. /**
  74855. * Gets or sets a boolean indicating if blur noise is enabled
  74856. */
  74857. get blurNoise(): boolean;
  74858. set blurNoise(value: boolean);
  74859. /**
  74860. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74861. */
  74862. get pentagonBokeh(): boolean;
  74863. set pentagonBokeh(value: boolean);
  74864. /**
  74865. * Gets or sets the highlight grain amount
  74866. */
  74867. get highlightsGain(): number;
  74868. set highlightsGain(value: number);
  74869. /**
  74870. * Gets or sets the highlight threshold
  74871. */
  74872. get highlightsThreshold(): number;
  74873. set highlightsThreshold(value: number);
  74874. /**
  74875. * Sets the amount of blur at the edges
  74876. * @param amount blur amount
  74877. */
  74878. setEdgeBlur(amount: number): void;
  74879. /**
  74880. * Sets edge blur to 0
  74881. */
  74882. disableEdgeBlur(): void;
  74883. /**
  74884. * Sets the amout of grain
  74885. * @param amount Amount of grain
  74886. */
  74887. setGrainAmount(amount: number): void;
  74888. /**
  74889. * Set grain amount to 0
  74890. */
  74891. disableGrain(): void;
  74892. /**
  74893. * Sets the chromatic aberration amount
  74894. * @param amount amount of chromatic aberration
  74895. */
  74896. setChromaticAberration(amount: number): void;
  74897. /**
  74898. * Sets chromatic aberration amount to 0
  74899. */
  74900. disableChromaticAberration(): void;
  74901. /**
  74902. * Sets the EdgeDistortion amount
  74903. * @param amount amount of EdgeDistortion
  74904. */
  74905. setEdgeDistortion(amount: number): void;
  74906. /**
  74907. * Sets edge distortion to 0
  74908. */
  74909. disableEdgeDistortion(): void;
  74910. /**
  74911. * Sets the FocusDistance amount
  74912. * @param amount amount of FocusDistance
  74913. */
  74914. setFocusDistance(amount: number): void;
  74915. /**
  74916. * Disables depth of field
  74917. */
  74918. disableDepthOfField(): void;
  74919. /**
  74920. * Sets the Aperture amount
  74921. * @param amount amount of Aperture
  74922. */
  74923. setAperture(amount: number): void;
  74924. /**
  74925. * Sets the DarkenOutOfFocus amount
  74926. * @param amount amount of DarkenOutOfFocus
  74927. */
  74928. setDarkenOutOfFocus(amount: number): void;
  74929. private _pentagonBokehIsEnabled;
  74930. /**
  74931. * Creates a pentagon bokeh effect
  74932. */
  74933. enablePentagonBokeh(): void;
  74934. /**
  74935. * Disables the pentagon bokeh effect
  74936. */
  74937. disablePentagonBokeh(): void;
  74938. /**
  74939. * Enables noise blur
  74940. */
  74941. enableNoiseBlur(): void;
  74942. /**
  74943. * Disables noise blur
  74944. */
  74945. disableNoiseBlur(): void;
  74946. /**
  74947. * Sets the HighlightsGain amount
  74948. * @param amount amount of HighlightsGain
  74949. */
  74950. setHighlightsGain(amount: number): void;
  74951. /**
  74952. * Sets the HighlightsThreshold amount
  74953. * @param amount amount of HighlightsThreshold
  74954. */
  74955. setHighlightsThreshold(amount: number): void;
  74956. /**
  74957. * Disables highlights
  74958. */
  74959. disableHighlights(): void;
  74960. /**
  74961. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74962. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74963. */
  74964. dispose(disableDepthRender?: boolean): void;
  74965. private _createChromaticAberrationPostProcess;
  74966. private _createHighlightsPostProcess;
  74967. private _createDepthOfFieldPostProcess;
  74968. private _createGrainTexture;
  74969. }
  74970. }
  74971. declare module "babylonjs/Rendering/ssao2Configuration" {
  74972. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74973. /**
  74974. * Contains all parameters needed for the prepass to perform
  74975. * screen space subsurface scattering
  74976. */
  74977. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74978. /**
  74979. * Is subsurface enabled
  74980. */
  74981. enabled: boolean;
  74982. /**
  74983. * Name of the configuration
  74984. */
  74985. name: string;
  74986. /**
  74987. * Textures that should be present in the MRT for this effect to work
  74988. */
  74989. readonly texturesRequired: number[];
  74990. }
  74991. }
  74992. declare module "babylonjs/Shaders/ssao2.fragment" {
  74993. /** @hidden */
  74994. export var ssao2PixelShader: {
  74995. name: string;
  74996. shader: string;
  74997. };
  74998. }
  74999. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75000. /** @hidden */
  75001. export var ssaoCombinePixelShader: {
  75002. name: string;
  75003. shader: string;
  75004. };
  75005. }
  75006. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75007. import { Camera } from "babylonjs/Cameras/camera";
  75008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75009. import { Scene } from "babylonjs/scene";
  75010. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75011. import "babylonjs/Shaders/ssao2.fragment";
  75012. import "babylonjs/Shaders/ssaoCombine.fragment";
  75013. /**
  75014. * Render pipeline to produce ssao effect
  75015. */
  75016. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75017. /**
  75018. * @ignore
  75019. * The PassPostProcess id in the pipeline that contains the original scene color
  75020. */
  75021. SSAOOriginalSceneColorEffect: string;
  75022. /**
  75023. * @ignore
  75024. * The SSAO PostProcess id in the pipeline
  75025. */
  75026. SSAORenderEffect: string;
  75027. /**
  75028. * @ignore
  75029. * The horizontal blur PostProcess id in the pipeline
  75030. */
  75031. SSAOBlurHRenderEffect: string;
  75032. /**
  75033. * @ignore
  75034. * The vertical blur PostProcess id in the pipeline
  75035. */
  75036. SSAOBlurVRenderEffect: string;
  75037. /**
  75038. * @ignore
  75039. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75040. */
  75041. SSAOCombineRenderEffect: string;
  75042. /**
  75043. * The output strength of the SSAO post-process. Default value is 1.0.
  75044. */
  75045. totalStrength: number;
  75046. /**
  75047. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75048. */
  75049. maxZ: number;
  75050. /**
  75051. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75052. */
  75053. minZAspect: number;
  75054. private _samples;
  75055. /**
  75056. * Number of samples used for the SSAO calculations. Default value is 8
  75057. */
  75058. set samples(n: number);
  75059. get samples(): number;
  75060. private _textureSamples;
  75061. /**
  75062. * Number of samples to use for antialiasing
  75063. */
  75064. set textureSamples(n: number);
  75065. get textureSamples(): number;
  75066. /**
  75067. * Force rendering the geometry through geometry buffer
  75068. */
  75069. private _forceGeometryBuffer;
  75070. /**
  75071. * Ratio object used for SSAO ratio and blur ratio
  75072. */
  75073. private _ratio;
  75074. /**
  75075. * Dynamically generated sphere sampler.
  75076. */
  75077. private _sampleSphere;
  75078. /**
  75079. * Blur filter offsets
  75080. */
  75081. private _samplerOffsets;
  75082. private _expensiveBlur;
  75083. /**
  75084. * If bilateral blur should be used
  75085. */
  75086. set expensiveBlur(b: boolean);
  75087. get expensiveBlur(): boolean;
  75088. /**
  75089. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75090. */
  75091. radius: number;
  75092. /**
  75093. * The base color of the SSAO post-process
  75094. * The final result is "base + ssao" between [0, 1]
  75095. */
  75096. base: number;
  75097. /**
  75098. * Support test.
  75099. */
  75100. static get IsSupported(): boolean;
  75101. private _scene;
  75102. private _randomTexture;
  75103. private _originalColorPostProcess;
  75104. private _ssaoPostProcess;
  75105. private _blurHPostProcess;
  75106. private _blurVPostProcess;
  75107. private _ssaoCombinePostProcess;
  75108. private _prePassRenderer;
  75109. /**
  75110. * Gets active scene
  75111. */
  75112. get scene(): Scene;
  75113. /**
  75114. * @constructor
  75115. * @param name The rendering pipeline name
  75116. * @param scene The scene linked to this pipeline
  75117. * @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 }
  75118. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75119. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75120. */
  75121. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75122. /**
  75123. * Get the class name
  75124. * @returns "SSAO2RenderingPipeline"
  75125. */
  75126. getClassName(): string;
  75127. /**
  75128. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75129. */
  75130. dispose(disableGeometryBufferRenderer?: boolean): void;
  75131. private _createBlurPostProcess;
  75132. /** @hidden */
  75133. _rebuild(): void;
  75134. private _bits;
  75135. private _radicalInverse_VdC;
  75136. private _hammersley;
  75137. private _hemisphereSample_uniform;
  75138. private _generateHemisphere;
  75139. private _getDefinesForSSAO;
  75140. private _createSSAOPostProcess;
  75141. private _createSSAOCombinePostProcess;
  75142. private _createRandomTexture;
  75143. /**
  75144. * Serialize the rendering pipeline (Used when exporting)
  75145. * @returns the serialized object
  75146. */
  75147. serialize(): any;
  75148. /**
  75149. * Parse the serialized pipeline
  75150. * @param source Source pipeline.
  75151. * @param scene The scene to load the pipeline to.
  75152. * @param rootUrl The URL of the serialized pipeline.
  75153. * @returns An instantiated pipeline from the serialized object.
  75154. */
  75155. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75156. }
  75157. }
  75158. declare module "babylonjs/Shaders/ssao.fragment" {
  75159. /** @hidden */
  75160. export var ssaoPixelShader: {
  75161. name: string;
  75162. shader: string;
  75163. };
  75164. }
  75165. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75166. import { Camera } from "babylonjs/Cameras/camera";
  75167. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75168. import { Scene } from "babylonjs/scene";
  75169. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75170. import "babylonjs/Shaders/ssao.fragment";
  75171. import "babylonjs/Shaders/ssaoCombine.fragment";
  75172. /**
  75173. * Render pipeline to produce ssao effect
  75174. */
  75175. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75176. /**
  75177. * @ignore
  75178. * The PassPostProcess id in the pipeline that contains the original scene color
  75179. */
  75180. SSAOOriginalSceneColorEffect: string;
  75181. /**
  75182. * @ignore
  75183. * The SSAO PostProcess id in the pipeline
  75184. */
  75185. SSAORenderEffect: string;
  75186. /**
  75187. * @ignore
  75188. * The horizontal blur PostProcess id in the pipeline
  75189. */
  75190. SSAOBlurHRenderEffect: string;
  75191. /**
  75192. * @ignore
  75193. * The vertical blur PostProcess id in the pipeline
  75194. */
  75195. SSAOBlurVRenderEffect: string;
  75196. /**
  75197. * @ignore
  75198. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75199. */
  75200. SSAOCombineRenderEffect: string;
  75201. /**
  75202. * The output strength of the SSAO post-process. Default value is 1.0.
  75203. */
  75204. totalStrength: number;
  75205. /**
  75206. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75207. */
  75208. radius: number;
  75209. /**
  75210. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75211. * Must not be equal to fallOff and superior to fallOff.
  75212. * Default value is 0.0075
  75213. */
  75214. area: number;
  75215. /**
  75216. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75217. * Must not be equal to area and inferior to area.
  75218. * Default value is 0.000001
  75219. */
  75220. fallOff: number;
  75221. /**
  75222. * The base color of the SSAO post-process
  75223. * The final result is "base + ssao" between [0, 1]
  75224. */
  75225. base: number;
  75226. private _scene;
  75227. private _depthTexture;
  75228. private _randomTexture;
  75229. private _originalColorPostProcess;
  75230. private _ssaoPostProcess;
  75231. private _blurHPostProcess;
  75232. private _blurVPostProcess;
  75233. private _ssaoCombinePostProcess;
  75234. private _firstUpdate;
  75235. /**
  75236. * Gets active scene
  75237. */
  75238. get scene(): Scene;
  75239. /**
  75240. * @constructor
  75241. * @param name - The rendering pipeline name
  75242. * @param scene - The scene linked to this pipeline
  75243. * @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 }
  75244. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75245. */
  75246. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75247. /**
  75248. * Get the class name
  75249. * @returns "SSAORenderingPipeline"
  75250. */
  75251. getClassName(): string;
  75252. /**
  75253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75254. */
  75255. dispose(disableDepthRender?: boolean): void;
  75256. private _createBlurPostProcess;
  75257. /** @hidden */
  75258. _rebuild(): void;
  75259. private _createSSAOPostProcess;
  75260. private _createSSAOCombinePostProcess;
  75261. private _createRandomTexture;
  75262. }
  75263. }
  75264. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75265. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75266. /**
  75267. * Contains all parameters needed for the prepass to perform
  75268. * screen space reflections
  75269. */
  75270. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75271. /**
  75272. * Is ssr enabled
  75273. */
  75274. enabled: boolean;
  75275. /**
  75276. * Name of the configuration
  75277. */
  75278. name: string;
  75279. /**
  75280. * Textures that should be present in the MRT for this effect to work
  75281. */
  75282. readonly texturesRequired: number[];
  75283. }
  75284. }
  75285. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75286. /** @hidden */
  75287. export var screenSpaceReflectionPixelShader: {
  75288. name: string;
  75289. shader: string;
  75290. };
  75291. }
  75292. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75293. import { Nullable } from "babylonjs/types";
  75294. import { Camera } from "babylonjs/Cameras/camera";
  75295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75296. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75297. import { Engine } from "babylonjs/Engines/engine";
  75298. import { Scene } from "babylonjs/scene";
  75299. /**
  75300. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75301. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75302. */
  75303. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75304. /**
  75305. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75306. */
  75307. threshold: number;
  75308. /**
  75309. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75310. */
  75311. strength: number;
  75312. /**
  75313. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75314. */
  75315. reflectionSpecularFalloffExponent: number;
  75316. /**
  75317. * 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]
  75318. */
  75319. step: number;
  75320. /**
  75321. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75322. */
  75323. roughnessFactor: number;
  75324. private _forceGeometryBuffer;
  75325. private _geometryBufferRenderer;
  75326. private _prePassRenderer;
  75327. private _enableSmoothReflections;
  75328. private _reflectionSamples;
  75329. private _smoothSteps;
  75330. /**
  75331. * Gets a string identifying the name of the class
  75332. * @returns "ScreenSpaceReflectionPostProcess" string
  75333. */
  75334. getClassName(): string;
  75335. /**
  75336. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75337. * @param name The name of the effect.
  75338. * @param scene The scene containing the objects to calculate reflections.
  75339. * @param options The required width/height ratio to downsize to before computing the render pass.
  75340. * @param camera The camera to apply the render pass to.
  75341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75342. * @param engine The engine which the post process will be applied. (default: current engine)
  75343. * @param reusable If the post process can be reused on the same frame. (default: false)
  75344. * @param textureType Type of textures used when performing the post process. (default: 0)
  75345. * @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)
  75346. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75347. */
  75348. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75349. /**
  75350. * Gets wether or not smoothing reflections is enabled.
  75351. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75352. */
  75353. get enableSmoothReflections(): boolean;
  75354. /**
  75355. * Sets wether or not smoothing reflections is enabled.
  75356. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75357. */
  75358. set enableSmoothReflections(enabled: boolean);
  75359. /**
  75360. * Gets the number of samples taken while computing reflections. More samples count is high,
  75361. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75362. */
  75363. get reflectionSamples(): number;
  75364. /**
  75365. * Sets the number of samples taken while computing reflections. More samples count is high,
  75366. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75367. */
  75368. set reflectionSamples(samples: number);
  75369. /**
  75370. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75371. * more the post-process will require GPU power and can generate a drop in FPS.
  75372. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75373. */
  75374. get smoothSteps(): number;
  75375. set smoothSteps(steps: number);
  75376. private _updateEffectDefines;
  75377. /** @hidden */
  75378. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75379. }
  75380. }
  75381. declare module "babylonjs/Shaders/standard.fragment" {
  75382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75383. /** @hidden */
  75384. export var standardPixelShader: {
  75385. name: string;
  75386. shader: string;
  75387. };
  75388. }
  75389. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75390. import { Nullable } from "babylonjs/types";
  75391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75392. import { Camera } from "babylonjs/Cameras/camera";
  75393. import { Texture } from "babylonjs/Materials/Textures/texture";
  75394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75395. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75396. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75397. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75398. import { IDisposable } from "babylonjs/scene";
  75399. import { SpotLight } from "babylonjs/Lights/spotLight";
  75400. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75401. import { Scene } from "babylonjs/scene";
  75402. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75403. import { Animation } from "babylonjs/Animations/animation";
  75404. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75405. import "babylonjs/Shaders/standard.fragment";
  75406. /**
  75407. * Standard rendering pipeline
  75408. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75409. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75410. */
  75411. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75412. /**
  75413. * Public members
  75414. */
  75415. /**
  75416. * Post-process which contains the original scene color before the pipeline applies all the effects
  75417. */
  75418. originalPostProcess: Nullable<PostProcess>;
  75419. /**
  75420. * Post-process used to down scale an image x4
  75421. */
  75422. downSampleX4PostProcess: Nullable<PostProcess>;
  75423. /**
  75424. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75425. */
  75426. brightPassPostProcess: Nullable<PostProcess>;
  75427. /**
  75428. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75429. */
  75430. blurHPostProcesses: PostProcess[];
  75431. /**
  75432. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75433. */
  75434. blurVPostProcesses: PostProcess[];
  75435. /**
  75436. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75437. */
  75438. textureAdderPostProcess: Nullable<PostProcess>;
  75439. /**
  75440. * Post-process used to create volumetric lighting effect
  75441. */
  75442. volumetricLightPostProcess: Nullable<PostProcess>;
  75443. /**
  75444. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75445. */
  75446. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75447. /**
  75448. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75449. */
  75450. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75451. /**
  75452. * Post-process used to merge the volumetric light effect and the real scene color
  75453. */
  75454. volumetricLightMergePostProces: Nullable<PostProcess>;
  75455. /**
  75456. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75457. */
  75458. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75459. /**
  75460. * Base post-process used to calculate the average luminance of the final image for HDR
  75461. */
  75462. luminancePostProcess: Nullable<PostProcess>;
  75463. /**
  75464. * Post-processes used to create down sample post-processes in order to get
  75465. * the average luminance of the final image for HDR
  75466. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75467. */
  75468. luminanceDownSamplePostProcesses: PostProcess[];
  75469. /**
  75470. * Post-process used to create a HDR effect (light adaptation)
  75471. */
  75472. hdrPostProcess: Nullable<PostProcess>;
  75473. /**
  75474. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75475. */
  75476. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75477. /**
  75478. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75479. */
  75480. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75481. /**
  75482. * Post-process used to merge the final HDR post-process and the real scene color
  75483. */
  75484. hdrFinalPostProcess: Nullable<PostProcess>;
  75485. /**
  75486. * Post-process used to create a lens flare effect
  75487. */
  75488. lensFlarePostProcess: Nullable<PostProcess>;
  75489. /**
  75490. * Post-process that merges the result of the lens flare post-process and the real scene color
  75491. */
  75492. lensFlareComposePostProcess: Nullable<PostProcess>;
  75493. /**
  75494. * Post-process used to create a motion blur effect
  75495. */
  75496. motionBlurPostProcess: Nullable<PostProcess>;
  75497. /**
  75498. * Post-process used to create a depth of field effect
  75499. */
  75500. depthOfFieldPostProcess: Nullable<PostProcess>;
  75501. /**
  75502. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75503. */
  75504. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75505. /**
  75506. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75507. */
  75508. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75509. /**
  75510. * Represents the brightness threshold in order to configure the illuminated surfaces
  75511. */
  75512. brightThreshold: number;
  75513. /**
  75514. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75515. */
  75516. blurWidth: number;
  75517. /**
  75518. * Sets if the blur for highlighted surfaces must be only horizontal
  75519. */
  75520. horizontalBlur: boolean;
  75521. /**
  75522. * Gets the overall exposure used by the pipeline
  75523. */
  75524. get exposure(): number;
  75525. /**
  75526. * Sets the overall exposure used by the pipeline
  75527. */
  75528. set exposure(value: number);
  75529. /**
  75530. * Texture used typically to simulate "dirty" on camera lens
  75531. */
  75532. lensTexture: Nullable<Texture>;
  75533. /**
  75534. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75535. */
  75536. volumetricLightCoefficient: number;
  75537. /**
  75538. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75539. */
  75540. volumetricLightPower: number;
  75541. /**
  75542. * Used the set the blur intensity to smooth the volumetric lights
  75543. */
  75544. volumetricLightBlurScale: number;
  75545. /**
  75546. * Light (spot or directional) used to generate the volumetric lights rays
  75547. * The source light must have a shadow generate so the pipeline can get its
  75548. * depth map
  75549. */
  75550. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75551. /**
  75552. * For eye adaptation, represents the minimum luminance the eye can see
  75553. */
  75554. hdrMinimumLuminance: number;
  75555. /**
  75556. * For eye adaptation, represents the decrease luminance speed
  75557. */
  75558. hdrDecreaseRate: number;
  75559. /**
  75560. * For eye adaptation, represents the increase luminance speed
  75561. */
  75562. hdrIncreaseRate: number;
  75563. /**
  75564. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75565. */
  75566. get hdrAutoExposure(): boolean;
  75567. /**
  75568. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75569. */
  75570. set hdrAutoExposure(value: boolean);
  75571. /**
  75572. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75573. */
  75574. lensColorTexture: Nullable<Texture>;
  75575. /**
  75576. * The overall strengh for the lens flare effect
  75577. */
  75578. lensFlareStrength: number;
  75579. /**
  75580. * Dispersion coefficient for lens flare ghosts
  75581. */
  75582. lensFlareGhostDispersal: number;
  75583. /**
  75584. * Main lens flare halo width
  75585. */
  75586. lensFlareHaloWidth: number;
  75587. /**
  75588. * Based on the lens distortion effect, defines how much the lens flare result
  75589. * is distorted
  75590. */
  75591. lensFlareDistortionStrength: number;
  75592. /**
  75593. * Configures the blur intensity used for for lens flare (halo)
  75594. */
  75595. lensFlareBlurWidth: number;
  75596. /**
  75597. * Lens star texture must be used to simulate rays on the flares and is available
  75598. * in the documentation
  75599. */
  75600. lensStarTexture: Nullable<Texture>;
  75601. /**
  75602. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75603. * flare effect by taking account of the dirt texture
  75604. */
  75605. lensFlareDirtTexture: Nullable<Texture>;
  75606. /**
  75607. * Represents the focal length for the depth of field effect
  75608. */
  75609. depthOfFieldDistance: number;
  75610. /**
  75611. * Represents the blur intensity for the blurred part of the depth of field effect
  75612. */
  75613. depthOfFieldBlurWidth: number;
  75614. /**
  75615. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75616. */
  75617. get motionStrength(): number;
  75618. /**
  75619. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75620. */
  75621. set motionStrength(strength: number);
  75622. /**
  75623. * Gets wether or not the motion blur post-process is object based or screen based.
  75624. */
  75625. get objectBasedMotionBlur(): boolean;
  75626. /**
  75627. * Sets wether or not the motion blur post-process should be object based or screen based
  75628. */
  75629. set objectBasedMotionBlur(value: boolean);
  75630. /**
  75631. * List of animations for the pipeline (IAnimatable implementation)
  75632. */
  75633. animations: Animation[];
  75634. /**
  75635. * Private members
  75636. */
  75637. private _scene;
  75638. private _currentDepthOfFieldSource;
  75639. private _basePostProcess;
  75640. private _fixedExposure;
  75641. private _currentExposure;
  75642. private _hdrAutoExposure;
  75643. private _hdrCurrentLuminance;
  75644. private _motionStrength;
  75645. private _isObjectBasedMotionBlur;
  75646. private _floatTextureType;
  75647. private _camerasToBeAttached;
  75648. private _ratio;
  75649. private _bloomEnabled;
  75650. private _depthOfFieldEnabled;
  75651. private _vlsEnabled;
  75652. private _lensFlareEnabled;
  75653. private _hdrEnabled;
  75654. private _motionBlurEnabled;
  75655. private _fxaaEnabled;
  75656. private _screenSpaceReflectionsEnabled;
  75657. private _motionBlurSamples;
  75658. private _volumetricLightStepsCount;
  75659. private _samples;
  75660. /**
  75661. * @ignore
  75662. * Specifies if the bloom pipeline is enabled
  75663. */
  75664. get BloomEnabled(): boolean;
  75665. set BloomEnabled(enabled: boolean);
  75666. /**
  75667. * @ignore
  75668. * Specifies if the depth of field pipeline is enabed
  75669. */
  75670. get DepthOfFieldEnabled(): boolean;
  75671. set DepthOfFieldEnabled(enabled: boolean);
  75672. /**
  75673. * @ignore
  75674. * Specifies if the lens flare pipeline is enabed
  75675. */
  75676. get LensFlareEnabled(): boolean;
  75677. set LensFlareEnabled(enabled: boolean);
  75678. /**
  75679. * @ignore
  75680. * Specifies if the HDR pipeline is enabled
  75681. */
  75682. get HDREnabled(): boolean;
  75683. set HDREnabled(enabled: boolean);
  75684. /**
  75685. * @ignore
  75686. * Specifies if the volumetric lights scattering effect is enabled
  75687. */
  75688. get VLSEnabled(): boolean;
  75689. set VLSEnabled(enabled: boolean);
  75690. /**
  75691. * @ignore
  75692. * Specifies if the motion blur effect is enabled
  75693. */
  75694. get MotionBlurEnabled(): boolean;
  75695. set MotionBlurEnabled(enabled: boolean);
  75696. /**
  75697. * Specifies if anti-aliasing is enabled
  75698. */
  75699. get fxaaEnabled(): boolean;
  75700. set fxaaEnabled(enabled: boolean);
  75701. /**
  75702. * Specifies if screen space reflections are enabled.
  75703. */
  75704. get screenSpaceReflectionsEnabled(): boolean;
  75705. set screenSpaceReflectionsEnabled(enabled: boolean);
  75706. /**
  75707. * Specifies the number of steps used to calculate the volumetric lights
  75708. * Typically in interval [50, 200]
  75709. */
  75710. get volumetricLightStepsCount(): number;
  75711. set volumetricLightStepsCount(count: number);
  75712. /**
  75713. * Specifies the number of samples used for the motion blur effect
  75714. * Typically in interval [16, 64]
  75715. */
  75716. get motionBlurSamples(): number;
  75717. set motionBlurSamples(samples: number);
  75718. /**
  75719. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75720. */
  75721. get samples(): number;
  75722. set samples(sampleCount: number);
  75723. /**
  75724. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75725. * @constructor
  75726. * @param name The rendering pipeline name
  75727. * @param scene The scene linked to this pipeline
  75728. * @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)
  75729. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75730. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75731. */
  75732. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75733. private _buildPipeline;
  75734. private _createDownSampleX4PostProcess;
  75735. private _createBrightPassPostProcess;
  75736. private _createBlurPostProcesses;
  75737. private _createTextureAdderPostProcess;
  75738. private _createVolumetricLightPostProcess;
  75739. private _createLuminancePostProcesses;
  75740. private _createHdrPostProcess;
  75741. private _createLensFlarePostProcess;
  75742. private _createDepthOfFieldPostProcess;
  75743. private _createMotionBlurPostProcess;
  75744. private _getDepthTexture;
  75745. private _disposePostProcesses;
  75746. /**
  75747. * Dispose of the pipeline and stop all post processes
  75748. */
  75749. dispose(): void;
  75750. /**
  75751. * Serialize the rendering pipeline (Used when exporting)
  75752. * @returns the serialized object
  75753. */
  75754. serialize(): any;
  75755. /**
  75756. * Parse the serialized pipeline
  75757. * @param source Source pipeline.
  75758. * @param scene The scene to load the pipeline to.
  75759. * @param rootUrl The URL of the serialized pipeline.
  75760. * @returns An instantiated pipeline from the serialized object.
  75761. */
  75762. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75763. /**
  75764. * Luminance steps
  75765. */
  75766. static LuminanceSteps: number;
  75767. }
  75768. }
  75769. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75770. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75771. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75772. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75773. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75774. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75775. }
  75776. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75777. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75778. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75779. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75780. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75781. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75782. }
  75783. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75784. /** @hidden */
  75785. export var stereoscopicInterlacePixelShader: {
  75786. name: string;
  75787. shader: string;
  75788. };
  75789. }
  75790. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75791. import { Camera } from "babylonjs/Cameras/camera";
  75792. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75793. import { Engine } from "babylonjs/Engines/engine";
  75794. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75795. /**
  75796. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75797. */
  75798. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75799. private _stepSize;
  75800. private _passedProcess;
  75801. /**
  75802. * Gets a string identifying the name of the class
  75803. * @returns "StereoscopicInterlacePostProcessI" string
  75804. */
  75805. getClassName(): string;
  75806. /**
  75807. * Initializes a StereoscopicInterlacePostProcessI
  75808. * @param name The name of the effect.
  75809. * @param rigCameras The rig cameras to be appled to the post process
  75810. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75811. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75813. * @param engine The engine which the post process will be applied. (default: current engine)
  75814. * @param reusable If the post process can be reused on the same frame. (default: false)
  75815. */
  75816. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75817. }
  75818. /**
  75819. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75820. */
  75821. export class StereoscopicInterlacePostProcess extends PostProcess {
  75822. private _stepSize;
  75823. private _passedProcess;
  75824. /**
  75825. * Gets a string identifying the name of the class
  75826. * @returns "StereoscopicInterlacePostProcess" string
  75827. */
  75828. getClassName(): string;
  75829. /**
  75830. * Initializes a StereoscopicInterlacePostProcess
  75831. * @param name The name of the effect.
  75832. * @param rigCameras The rig cameras to be appled to the post process
  75833. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75835. * @param engine The engine which the post process will be applied. (default: current engine)
  75836. * @param reusable If the post process can be reused on the same frame. (default: false)
  75837. */
  75838. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75839. }
  75840. }
  75841. declare module "babylonjs/Shaders/tonemap.fragment" {
  75842. /** @hidden */
  75843. export var tonemapPixelShader: {
  75844. name: string;
  75845. shader: string;
  75846. };
  75847. }
  75848. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75849. import { Camera } from "babylonjs/Cameras/camera";
  75850. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75851. import "babylonjs/Shaders/tonemap.fragment";
  75852. import { Engine } from "babylonjs/Engines/engine";
  75853. /** Defines operator used for tonemapping */
  75854. export enum TonemappingOperator {
  75855. /** Hable */
  75856. Hable = 0,
  75857. /** Reinhard */
  75858. Reinhard = 1,
  75859. /** HejiDawson */
  75860. HejiDawson = 2,
  75861. /** Photographic */
  75862. Photographic = 3
  75863. }
  75864. /**
  75865. * Defines a post process to apply tone mapping
  75866. */
  75867. export class TonemapPostProcess extends PostProcess {
  75868. private _operator;
  75869. /** Defines the required exposure adjustement */
  75870. exposureAdjustment: number;
  75871. /**
  75872. * Gets a string identifying the name of the class
  75873. * @returns "TonemapPostProcess" string
  75874. */
  75875. getClassName(): string;
  75876. /**
  75877. * Creates a new TonemapPostProcess
  75878. * @param name defines the name of the postprocess
  75879. * @param _operator defines the operator to use
  75880. * @param exposureAdjustment defines the required exposure adjustement
  75881. * @param camera defines the camera to use (can be null)
  75882. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75883. * @param engine defines the hosting engine (can be ignore if camera is set)
  75884. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75885. */
  75886. constructor(name: string, _operator: TonemappingOperator,
  75887. /** Defines the required exposure adjustement */
  75888. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75889. }
  75890. }
  75891. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75892. /** @hidden */
  75893. export var volumetricLightScatteringPixelShader: {
  75894. name: string;
  75895. shader: string;
  75896. };
  75897. }
  75898. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75899. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75900. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75901. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75902. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75904. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75905. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75906. /** @hidden */
  75907. export var volumetricLightScatteringPassVertexShader: {
  75908. name: string;
  75909. shader: string;
  75910. };
  75911. }
  75912. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75913. /** @hidden */
  75914. export var volumetricLightScatteringPassPixelShader: {
  75915. name: string;
  75916. shader: string;
  75917. };
  75918. }
  75919. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75920. import { Vector3 } from "babylonjs/Maths/math.vector";
  75921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75922. import { Mesh } from "babylonjs/Meshes/mesh";
  75923. import { Camera } from "babylonjs/Cameras/camera";
  75924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75925. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75926. import { Scene } from "babylonjs/scene";
  75927. import "babylonjs/Meshes/Builders/planeBuilder";
  75928. import "babylonjs/Shaders/depth.vertex";
  75929. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75930. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75931. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75932. import { Engine } from "babylonjs/Engines/engine";
  75933. /**
  75934. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75935. */
  75936. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75937. private _volumetricLightScatteringPass;
  75938. private _volumetricLightScatteringRTT;
  75939. private _viewPort;
  75940. private _screenCoordinates;
  75941. private _cachedDefines;
  75942. /**
  75943. * If not undefined, the mesh position is computed from the attached node position
  75944. */
  75945. attachedNode: {
  75946. position: Vector3;
  75947. };
  75948. /**
  75949. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75950. */
  75951. customMeshPosition: Vector3;
  75952. /**
  75953. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75954. */
  75955. useCustomMeshPosition: boolean;
  75956. /**
  75957. * If the post-process should inverse the light scattering direction
  75958. */
  75959. invert: boolean;
  75960. /**
  75961. * The internal mesh used by the post-process
  75962. */
  75963. mesh: Mesh;
  75964. /**
  75965. * @hidden
  75966. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75967. */
  75968. get useDiffuseColor(): boolean;
  75969. set useDiffuseColor(useDiffuseColor: boolean);
  75970. /**
  75971. * Array containing the excluded meshes not rendered in the internal pass
  75972. */
  75973. excludedMeshes: AbstractMesh[];
  75974. /**
  75975. * Controls the overall intensity of the post-process
  75976. */
  75977. exposure: number;
  75978. /**
  75979. * Dissipates each sample's contribution in range [0, 1]
  75980. */
  75981. decay: number;
  75982. /**
  75983. * Controls the overall intensity of each sample
  75984. */
  75985. weight: number;
  75986. /**
  75987. * Controls the density of each sample
  75988. */
  75989. density: number;
  75990. /**
  75991. * @constructor
  75992. * @param name The post-process name
  75993. * @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)
  75994. * @param camera The camera that the post-process will be attached to
  75995. * @param mesh The mesh used to create the light scattering
  75996. * @param samples The post-process quality, default 100
  75997. * @param samplingModeThe post-process filtering mode
  75998. * @param engine The babylon engine
  75999. * @param reusable If the post-process is reusable
  76000. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76001. */
  76002. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76003. /**
  76004. * Returns the string "VolumetricLightScatteringPostProcess"
  76005. * @returns "VolumetricLightScatteringPostProcess"
  76006. */
  76007. getClassName(): string;
  76008. private _isReady;
  76009. /**
  76010. * Sets the new light position for light scattering effect
  76011. * @param position The new custom light position
  76012. */
  76013. setCustomMeshPosition(position: Vector3): void;
  76014. /**
  76015. * Returns the light position for light scattering effect
  76016. * @return Vector3 The custom light position
  76017. */
  76018. getCustomMeshPosition(): Vector3;
  76019. /**
  76020. * Disposes the internal assets and detaches the post-process from the camera
  76021. */
  76022. dispose(camera: Camera): void;
  76023. /**
  76024. * Returns the render target texture used by the post-process
  76025. * @return the render target texture used by the post-process
  76026. */
  76027. getPass(): RenderTargetTexture;
  76028. private _meshExcluded;
  76029. private _createPass;
  76030. private _updateMeshScreenCoordinates;
  76031. /**
  76032. * Creates a default mesh for the Volumeric Light Scattering post-process
  76033. * @param name The mesh name
  76034. * @param scene The scene where to create the mesh
  76035. * @return the default mesh
  76036. */
  76037. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76038. }
  76039. }
  76040. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76041. /** @hidden */
  76042. export var screenSpaceCurvaturePixelShader: {
  76043. name: string;
  76044. shader: string;
  76045. };
  76046. }
  76047. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76048. import { Nullable } from "babylonjs/types";
  76049. import { Camera } from "babylonjs/Cameras/camera";
  76050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76051. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76052. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76053. import { Engine } from "babylonjs/Engines/engine";
  76054. import { Scene } from "babylonjs/scene";
  76055. /**
  76056. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76057. */
  76058. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76059. /**
  76060. * Defines how much ridge the curvature effect displays.
  76061. */
  76062. ridge: number;
  76063. /**
  76064. * Defines how much valley the curvature effect displays.
  76065. */
  76066. valley: number;
  76067. private _geometryBufferRenderer;
  76068. /**
  76069. * Gets a string identifying the name of the class
  76070. * @returns "ScreenSpaceCurvaturePostProcess" string
  76071. */
  76072. getClassName(): string;
  76073. /**
  76074. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76075. * @param name The name of the effect.
  76076. * @param scene The scene containing the objects to blur according to their velocity.
  76077. * @param options The required width/height ratio to downsize to before computing the render pass.
  76078. * @param camera The camera to apply the render pass to.
  76079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76080. * @param engine The engine which the post process will be applied. (default: current engine)
  76081. * @param reusable If the post process can be reused on the same frame. (default: false)
  76082. * @param textureType Type of textures used when performing the post process. (default: 0)
  76083. * @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)
  76084. */
  76085. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76086. /**
  76087. * Support test.
  76088. */
  76089. static get IsSupported(): boolean;
  76090. /** @hidden */
  76091. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76092. }
  76093. }
  76094. declare module "babylonjs/PostProcesses/index" {
  76095. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76096. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76097. export * from "babylonjs/PostProcesses/bloomEffect";
  76098. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76099. export * from "babylonjs/PostProcesses/blurPostProcess";
  76100. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76101. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76102. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76103. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76104. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76105. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76106. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76107. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76108. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76109. export * from "babylonjs/PostProcesses/filterPostProcess";
  76110. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76111. export * from "babylonjs/PostProcesses/grainPostProcess";
  76112. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76113. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76114. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76115. export * from "babylonjs/PostProcesses/passPostProcess";
  76116. export * from "babylonjs/PostProcesses/postProcess";
  76117. export * from "babylonjs/PostProcesses/postProcessManager";
  76118. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76119. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76120. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76121. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76122. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76123. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76124. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76125. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76126. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76127. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76128. }
  76129. declare module "babylonjs/Probes/index" {
  76130. export * from "babylonjs/Probes/reflectionProbe";
  76131. }
  76132. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76133. import { Scene } from "babylonjs/scene";
  76134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76135. import { SmartArray } from "babylonjs/Misc/smartArray";
  76136. import { ISceneComponent } from "babylonjs/sceneComponent";
  76137. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76138. import "babylonjs/Meshes/Builders/boxBuilder";
  76139. import "babylonjs/Shaders/color.fragment";
  76140. import "babylonjs/Shaders/color.vertex";
  76141. import { Color3 } from "babylonjs/Maths/math.color";
  76142. import { Observable } from "babylonjs/Misc/observable";
  76143. module "babylonjs/scene" {
  76144. interface Scene {
  76145. /** @hidden (Backing field) */
  76146. _boundingBoxRenderer: BoundingBoxRenderer;
  76147. /** @hidden (Backing field) */
  76148. _forceShowBoundingBoxes: boolean;
  76149. /**
  76150. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76151. */
  76152. forceShowBoundingBoxes: boolean;
  76153. /**
  76154. * Gets the bounding box renderer associated with the scene
  76155. * @returns a BoundingBoxRenderer
  76156. */
  76157. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76158. }
  76159. }
  76160. module "babylonjs/Meshes/abstractMesh" {
  76161. interface AbstractMesh {
  76162. /** @hidden (Backing field) */
  76163. _showBoundingBox: boolean;
  76164. /**
  76165. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76166. */
  76167. showBoundingBox: boolean;
  76168. }
  76169. }
  76170. /**
  76171. * Component responsible of rendering the bounding box of the meshes in a scene.
  76172. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76173. */
  76174. export class BoundingBoxRenderer implements ISceneComponent {
  76175. /**
  76176. * The component name helpfull to identify the component in the list of scene components.
  76177. */
  76178. readonly name: string;
  76179. /**
  76180. * The scene the component belongs to.
  76181. */
  76182. scene: Scene;
  76183. /**
  76184. * Color of the bounding box lines placed in front of an object
  76185. */
  76186. frontColor: Color3;
  76187. /**
  76188. * Color of the bounding box lines placed behind an object
  76189. */
  76190. backColor: Color3;
  76191. /**
  76192. * Defines if the renderer should show the back lines or not
  76193. */
  76194. showBackLines: boolean;
  76195. /**
  76196. * Observable raised before rendering a bounding box
  76197. */
  76198. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76199. /**
  76200. * Observable raised after rendering a bounding box
  76201. */
  76202. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76203. /**
  76204. * @hidden
  76205. */
  76206. renderList: SmartArray<BoundingBox>;
  76207. private _colorShader;
  76208. private _vertexBuffers;
  76209. private _indexBuffer;
  76210. private _fillIndexBuffer;
  76211. private _fillIndexData;
  76212. /**
  76213. * Instantiates a new bounding box renderer in a scene.
  76214. * @param scene the scene the renderer renders in
  76215. */
  76216. constructor(scene: Scene);
  76217. /**
  76218. * Registers the component in a given scene
  76219. */
  76220. register(): void;
  76221. private _evaluateSubMesh;
  76222. private _activeMesh;
  76223. private _prepareRessources;
  76224. private _createIndexBuffer;
  76225. /**
  76226. * Rebuilds the elements related to this component in case of
  76227. * context lost for instance.
  76228. */
  76229. rebuild(): void;
  76230. /**
  76231. * @hidden
  76232. */
  76233. reset(): void;
  76234. /**
  76235. * Render the bounding boxes of a specific rendering group
  76236. * @param renderingGroupId defines the rendering group to render
  76237. */
  76238. render(renderingGroupId: number): void;
  76239. /**
  76240. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76241. * @param mesh Define the mesh to render the occlusion bounding box for
  76242. */
  76243. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76244. /**
  76245. * Dispose and release the resources attached to this renderer.
  76246. */
  76247. dispose(): void;
  76248. }
  76249. }
  76250. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76251. import { Nullable } from "babylonjs/types";
  76252. import { Scene } from "babylonjs/scene";
  76253. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76254. import { Camera } from "babylonjs/Cameras/camera";
  76255. import { ISceneComponent } from "babylonjs/sceneComponent";
  76256. module "babylonjs/scene" {
  76257. interface Scene {
  76258. /** @hidden (Backing field) */
  76259. _depthRenderer: {
  76260. [id: string]: DepthRenderer;
  76261. };
  76262. /**
  76263. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76264. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76265. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76266. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76267. * @returns the created depth renderer
  76268. */
  76269. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76270. /**
  76271. * Disables a depth renderer for a given camera
  76272. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76273. */
  76274. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76275. }
  76276. }
  76277. /**
  76278. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76279. * in several rendering techniques.
  76280. */
  76281. export class DepthRendererSceneComponent implements ISceneComponent {
  76282. /**
  76283. * The component name helpfull to identify the component in the list of scene components.
  76284. */
  76285. readonly name: string;
  76286. /**
  76287. * The scene the component belongs to.
  76288. */
  76289. scene: Scene;
  76290. /**
  76291. * Creates a new instance of the component for the given scene
  76292. * @param scene Defines the scene to register the component in
  76293. */
  76294. constructor(scene: Scene);
  76295. /**
  76296. * Registers the component in a given scene
  76297. */
  76298. register(): void;
  76299. /**
  76300. * Rebuilds the elements related to this component in case of
  76301. * context lost for instance.
  76302. */
  76303. rebuild(): void;
  76304. /**
  76305. * Disposes the component and the associated ressources
  76306. */
  76307. dispose(): void;
  76308. private _gatherRenderTargets;
  76309. private _gatherActiveCameraRenderTargets;
  76310. }
  76311. }
  76312. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76313. import { Nullable } from "babylonjs/types";
  76314. import { Scene } from "babylonjs/scene";
  76315. import { ISceneComponent } from "babylonjs/sceneComponent";
  76316. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76317. module "babylonjs/abstractScene" {
  76318. interface AbstractScene {
  76319. /** @hidden (Backing field) */
  76320. _prePassRenderer: Nullable<PrePassRenderer>;
  76321. /**
  76322. * Gets or Sets the current prepass renderer associated to the scene.
  76323. */
  76324. prePassRenderer: Nullable<PrePassRenderer>;
  76325. /**
  76326. * Enables the prepass and associates it with the scene
  76327. * @returns the PrePassRenderer
  76328. */
  76329. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76330. /**
  76331. * Disables the prepass associated with the scene
  76332. */
  76333. disablePrePassRenderer(): void;
  76334. }
  76335. }
  76336. /**
  76337. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76338. * in several rendering techniques.
  76339. */
  76340. export class PrePassRendererSceneComponent implements ISceneComponent {
  76341. /**
  76342. * The component name helpful to identify the component in the list of scene components.
  76343. */
  76344. readonly name: string;
  76345. /**
  76346. * The scene the component belongs to.
  76347. */
  76348. scene: Scene;
  76349. /**
  76350. * Creates a new instance of the component for the given scene
  76351. * @param scene Defines the scene to register the component in
  76352. */
  76353. constructor(scene: Scene);
  76354. /**
  76355. * Registers the component in a given scene
  76356. */
  76357. register(): void;
  76358. private _beforeCameraDraw;
  76359. private _afterCameraDraw;
  76360. private _beforeClearStage;
  76361. /**
  76362. * Rebuilds the elements related to this component in case of
  76363. * context lost for instance.
  76364. */
  76365. rebuild(): void;
  76366. /**
  76367. * Disposes the component and the associated ressources
  76368. */
  76369. dispose(): void;
  76370. }
  76371. }
  76372. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76373. /** @hidden */
  76374. export var fibonacci: {
  76375. name: string;
  76376. shader: string;
  76377. };
  76378. }
  76379. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76380. /** @hidden */
  76381. export var diffusionProfile: {
  76382. name: string;
  76383. shader: string;
  76384. };
  76385. }
  76386. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76387. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76388. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76389. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76390. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76391. /** @hidden */
  76392. export var subSurfaceScatteringPixelShader: {
  76393. name: string;
  76394. shader: string;
  76395. };
  76396. }
  76397. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76398. import { Nullable } from "babylonjs/types";
  76399. import { Camera } from "babylonjs/Cameras/camera";
  76400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76401. import { Engine } from "babylonjs/Engines/engine";
  76402. import { Scene } from "babylonjs/scene";
  76403. import "babylonjs/Shaders/imageProcessing.fragment";
  76404. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76405. import "babylonjs/Shaders/postprocess.vertex";
  76406. /**
  76407. * Sub surface scattering post process
  76408. */
  76409. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76410. /**
  76411. * Gets a string identifying the name of the class
  76412. * @returns "SubSurfaceScatteringPostProcess" string
  76413. */
  76414. getClassName(): string;
  76415. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76416. }
  76417. }
  76418. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76419. import { Scene } from "babylonjs/scene";
  76420. import { Color3 } from "babylonjs/Maths/math.color";
  76421. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76422. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76423. /**
  76424. * Contains all parameters needed for the prepass to perform
  76425. * screen space subsurface scattering
  76426. */
  76427. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76428. /** @hidden */
  76429. static _SceneComponentInitialization: (scene: Scene) => void;
  76430. private _ssDiffusionS;
  76431. private _ssFilterRadii;
  76432. private _ssDiffusionD;
  76433. /**
  76434. * Post process to attach for screen space subsurface scattering
  76435. */
  76436. postProcess: SubSurfaceScatteringPostProcess;
  76437. /**
  76438. * Diffusion profile color for subsurface scattering
  76439. */
  76440. get ssDiffusionS(): number[];
  76441. /**
  76442. * Diffusion profile max color channel value for subsurface scattering
  76443. */
  76444. get ssDiffusionD(): number[];
  76445. /**
  76446. * Diffusion profile filter radius for subsurface scattering
  76447. */
  76448. get ssFilterRadii(): number[];
  76449. /**
  76450. * Is subsurface enabled
  76451. */
  76452. enabled: boolean;
  76453. /**
  76454. * Name of the configuration
  76455. */
  76456. name: string;
  76457. /**
  76458. * Diffusion profile colors for subsurface scattering
  76459. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76460. * See ...
  76461. * Note that you can only store up to 5 of them
  76462. */
  76463. ssDiffusionProfileColors: Color3[];
  76464. /**
  76465. * Defines the ratio real world => scene units.
  76466. * Used for subsurface scattering
  76467. */
  76468. metersPerUnit: number;
  76469. /**
  76470. * Textures that should be present in the MRT for this effect to work
  76471. */
  76472. readonly texturesRequired: number[];
  76473. private _scene;
  76474. /**
  76475. * Builds a subsurface configuration object
  76476. * @param scene The scene
  76477. */
  76478. constructor(scene: Scene);
  76479. /**
  76480. * Adds a new diffusion profile.
  76481. * Useful for more realistic subsurface scattering on diverse materials.
  76482. * @param color The color of the diffusion profile. Should be the average color of the material.
  76483. * @return The index of the diffusion profile for the material subsurface configuration
  76484. */
  76485. addDiffusionProfile(color: Color3): number;
  76486. /**
  76487. * Creates the sss post process
  76488. * @return The created post process
  76489. */
  76490. createPostProcess(): SubSurfaceScatteringPostProcess;
  76491. /**
  76492. * Deletes all diffusion profiles.
  76493. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76494. */
  76495. clearAllDiffusionProfiles(): void;
  76496. /**
  76497. * Disposes this object
  76498. */
  76499. dispose(): void;
  76500. /**
  76501. * @hidden
  76502. * https://zero-radiance.github.io/post/sampling-diffusion/
  76503. *
  76504. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76505. * ------------------------------------------------------------------------------------
  76506. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76507. * PDF[r, phi, s] = r * R[r, phi, s]
  76508. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76509. * ------------------------------------------------------------------------------------
  76510. * We importance sample the color channel with the widest scattering distance.
  76511. */
  76512. getDiffusionProfileParameters(color: Color3): number;
  76513. /**
  76514. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76515. * 'u' is the random number (the value of the CDF): [0, 1).
  76516. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76517. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76518. */
  76519. private _sampleBurleyDiffusionProfile;
  76520. }
  76521. }
  76522. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76523. import { Nullable } from "babylonjs/types";
  76524. import { Scene } from "babylonjs/scene";
  76525. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76526. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76527. import { AbstractScene } from "babylonjs/abstractScene";
  76528. module "babylonjs/abstractScene" {
  76529. interface AbstractScene {
  76530. /** @hidden (Backing field) */
  76531. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76532. /**
  76533. * Gets or Sets the current prepass renderer associated to the scene.
  76534. */
  76535. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76536. /**
  76537. * Enables the subsurface effect for prepass
  76538. * @returns the SubSurfaceConfiguration
  76539. */
  76540. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76541. /**
  76542. * Disables the subsurface effect for prepass
  76543. */
  76544. disableSubSurfaceForPrePass(): void;
  76545. }
  76546. }
  76547. /**
  76548. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76549. * in several rendering techniques.
  76550. */
  76551. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76552. /**
  76553. * The component name helpful to identify the component in the list of scene components.
  76554. */
  76555. readonly name: string;
  76556. /**
  76557. * The scene the component belongs to.
  76558. */
  76559. scene: Scene;
  76560. /**
  76561. * Creates a new instance of the component for the given scene
  76562. * @param scene Defines the scene to register the component in
  76563. */
  76564. constructor(scene: Scene);
  76565. /**
  76566. * Registers the component in a given scene
  76567. */
  76568. register(): void;
  76569. /**
  76570. * Serializes the component data to the specified json object
  76571. * @param serializationObject The object to serialize to
  76572. */
  76573. serialize(serializationObject: any): void;
  76574. /**
  76575. * Adds all the elements from the container to the scene
  76576. * @param container the container holding the elements
  76577. */
  76578. addFromContainer(container: AbstractScene): void;
  76579. /**
  76580. * Removes all the elements in the container from the scene
  76581. * @param container contains the elements to remove
  76582. * @param dispose if the removed element should be disposed (default: false)
  76583. */
  76584. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76585. /**
  76586. * Rebuilds the elements related to this component in case of
  76587. * context lost for instance.
  76588. */
  76589. rebuild(): void;
  76590. /**
  76591. * Disposes the component and the associated ressources
  76592. */
  76593. dispose(): void;
  76594. }
  76595. }
  76596. declare module "babylonjs/Shaders/outline.fragment" {
  76597. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76598. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76599. /** @hidden */
  76600. export var outlinePixelShader: {
  76601. name: string;
  76602. shader: string;
  76603. };
  76604. }
  76605. declare module "babylonjs/Shaders/outline.vertex" {
  76606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76608. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76610. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76612. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76613. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76614. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76615. /** @hidden */
  76616. export var outlineVertexShader: {
  76617. name: string;
  76618. shader: string;
  76619. };
  76620. }
  76621. declare module "babylonjs/Rendering/outlineRenderer" {
  76622. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76623. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76624. import { Scene } from "babylonjs/scene";
  76625. import { ISceneComponent } from "babylonjs/sceneComponent";
  76626. import "babylonjs/Shaders/outline.fragment";
  76627. import "babylonjs/Shaders/outline.vertex";
  76628. module "babylonjs/scene" {
  76629. interface Scene {
  76630. /** @hidden */
  76631. _outlineRenderer: OutlineRenderer;
  76632. /**
  76633. * Gets the outline renderer associated with the scene
  76634. * @returns a OutlineRenderer
  76635. */
  76636. getOutlineRenderer(): OutlineRenderer;
  76637. }
  76638. }
  76639. module "babylonjs/Meshes/abstractMesh" {
  76640. interface AbstractMesh {
  76641. /** @hidden (Backing field) */
  76642. _renderOutline: boolean;
  76643. /**
  76644. * Gets or sets a boolean indicating if the outline must be rendered as well
  76645. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76646. */
  76647. renderOutline: boolean;
  76648. /** @hidden (Backing field) */
  76649. _renderOverlay: boolean;
  76650. /**
  76651. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76652. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76653. */
  76654. renderOverlay: boolean;
  76655. }
  76656. }
  76657. /**
  76658. * This class is responsible to draw bothe outline/overlay of meshes.
  76659. * It should not be used directly but through the available method on mesh.
  76660. */
  76661. export class OutlineRenderer implements ISceneComponent {
  76662. /**
  76663. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76664. */
  76665. private static _StencilReference;
  76666. /**
  76667. * The name of the component. Each component must have a unique name.
  76668. */
  76669. name: string;
  76670. /**
  76671. * The scene the component belongs to.
  76672. */
  76673. scene: Scene;
  76674. /**
  76675. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76676. */
  76677. zOffset: number;
  76678. private _engine;
  76679. private _effect;
  76680. private _cachedDefines;
  76681. private _savedDepthWrite;
  76682. /**
  76683. * Instantiates a new outline renderer. (There could be only one per scene).
  76684. * @param scene Defines the scene it belongs to
  76685. */
  76686. constructor(scene: Scene);
  76687. /**
  76688. * Register the component to one instance of a scene.
  76689. */
  76690. register(): void;
  76691. /**
  76692. * Rebuilds the elements related to this component in case of
  76693. * context lost for instance.
  76694. */
  76695. rebuild(): void;
  76696. /**
  76697. * Disposes the component and the associated ressources.
  76698. */
  76699. dispose(): void;
  76700. /**
  76701. * Renders the outline in the canvas.
  76702. * @param subMesh Defines the sumesh to render
  76703. * @param batch Defines the batch of meshes in case of instances
  76704. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76705. */
  76706. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76707. /**
  76708. * Returns whether or not the outline renderer is ready for a given submesh.
  76709. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76710. * @param subMesh Defines the submesh to check readyness for
  76711. * @param useInstances Defines wheter wee are trying to render instances or not
  76712. * @returns true if ready otherwise false
  76713. */
  76714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76715. private _beforeRenderingMesh;
  76716. private _afterRenderingMesh;
  76717. }
  76718. }
  76719. declare module "babylonjs/Rendering/index" {
  76720. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76721. export * from "babylonjs/Rendering/depthRenderer";
  76722. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76723. export * from "babylonjs/Rendering/edgesRenderer";
  76724. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76725. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76726. export * from "babylonjs/Rendering/prePassRenderer";
  76727. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76728. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76729. export * from "babylonjs/Rendering/outlineRenderer";
  76730. export * from "babylonjs/Rendering/renderingGroup";
  76731. export * from "babylonjs/Rendering/renderingManager";
  76732. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76733. }
  76734. declare module "babylonjs/Sprites/ISprites" {
  76735. /**
  76736. * Defines the basic options interface of a Sprite Frame Source Size.
  76737. */
  76738. export interface ISpriteJSONSpriteSourceSize {
  76739. /**
  76740. * number of the original width of the Frame
  76741. */
  76742. w: number;
  76743. /**
  76744. * number of the original height of the Frame
  76745. */
  76746. h: number;
  76747. }
  76748. /**
  76749. * Defines the basic options interface of a Sprite Frame Data.
  76750. */
  76751. export interface ISpriteJSONSpriteFrameData {
  76752. /**
  76753. * number of the x offset of the Frame
  76754. */
  76755. x: number;
  76756. /**
  76757. * number of the y offset of the Frame
  76758. */
  76759. y: number;
  76760. /**
  76761. * number of the width of the Frame
  76762. */
  76763. w: number;
  76764. /**
  76765. * number of the height of the Frame
  76766. */
  76767. h: number;
  76768. }
  76769. /**
  76770. * Defines the basic options interface of a JSON Sprite.
  76771. */
  76772. export interface ISpriteJSONSprite {
  76773. /**
  76774. * string name of the Frame
  76775. */
  76776. filename: string;
  76777. /**
  76778. * ISpriteJSONSpriteFrame basic object of the frame data
  76779. */
  76780. frame: ISpriteJSONSpriteFrameData;
  76781. /**
  76782. * boolean to flag is the frame was rotated.
  76783. */
  76784. rotated: boolean;
  76785. /**
  76786. * boolean to flag is the frame was trimmed.
  76787. */
  76788. trimmed: boolean;
  76789. /**
  76790. * ISpriteJSONSpriteFrame basic object of the source data
  76791. */
  76792. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76793. /**
  76794. * ISpriteJSONSpriteFrame basic object of the source data
  76795. */
  76796. sourceSize: ISpriteJSONSpriteSourceSize;
  76797. }
  76798. /**
  76799. * Defines the basic options interface of a JSON atlas.
  76800. */
  76801. export interface ISpriteJSONAtlas {
  76802. /**
  76803. * Array of objects that contain the frame data.
  76804. */
  76805. frames: Array<ISpriteJSONSprite>;
  76806. /**
  76807. * object basic object containing the sprite meta data.
  76808. */
  76809. meta?: object;
  76810. }
  76811. }
  76812. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76813. /** @hidden */
  76814. export var spriteMapPixelShader: {
  76815. name: string;
  76816. shader: string;
  76817. };
  76818. }
  76819. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76820. /** @hidden */
  76821. export var spriteMapVertexShader: {
  76822. name: string;
  76823. shader: string;
  76824. };
  76825. }
  76826. declare module "babylonjs/Sprites/spriteMap" {
  76827. import { IDisposable, Scene } from "babylonjs/scene";
  76828. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76829. import { Texture } from "babylonjs/Materials/Textures/texture";
  76830. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76831. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76832. import "babylonjs/Meshes/Builders/planeBuilder";
  76833. import "babylonjs/Shaders/spriteMap.fragment";
  76834. import "babylonjs/Shaders/spriteMap.vertex";
  76835. /**
  76836. * Defines the basic options interface of a SpriteMap
  76837. */
  76838. export interface ISpriteMapOptions {
  76839. /**
  76840. * Vector2 of the number of cells in the grid.
  76841. */
  76842. stageSize?: Vector2;
  76843. /**
  76844. * Vector2 of the size of the output plane in World Units.
  76845. */
  76846. outputSize?: Vector2;
  76847. /**
  76848. * Vector3 of the position of the output plane in World Units.
  76849. */
  76850. outputPosition?: Vector3;
  76851. /**
  76852. * Vector3 of the rotation of the output plane.
  76853. */
  76854. outputRotation?: Vector3;
  76855. /**
  76856. * number of layers that the system will reserve in resources.
  76857. */
  76858. layerCount?: number;
  76859. /**
  76860. * number of max animation frames a single cell will reserve in resources.
  76861. */
  76862. maxAnimationFrames?: number;
  76863. /**
  76864. * number cell index of the base tile when the system compiles.
  76865. */
  76866. baseTile?: number;
  76867. /**
  76868. * boolean flip the sprite after its been repositioned by the framing data.
  76869. */
  76870. flipU?: boolean;
  76871. /**
  76872. * Vector3 scalar of the global RGB values of the SpriteMap.
  76873. */
  76874. colorMultiply?: Vector3;
  76875. }
  76876. /**
  76877. * Defines the IDisposable interface in order to be cleanable from resources.
  76878. */
  76879. export interface ISpriteMap extends IDisposable {
  76880. /**
  76881. * String name of the SpriteMap.
  76882. */
  76883. name: string;
  76884. /**
  76885. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76886. */
  76887. atlasJSON: ISpriteJSONAtlas;
  76888. /**
  76889. * Texture of the SpriteMap.
  76890. */
  76891. spriteSheet: Texture;
  76892. /**
  76893. * The parameters to initialize the SpriteMap with.
  76894. */
  76895. options: ISpriteMapOptions;
  76896. }
  76897. /**
  76898. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76899. */
  76900. export class SpriteMap implements ISpriteMap {
  76901. /** The Name of the spriteMap */
  76902. name: string;
  76903. /** The JSON file with the frame and meta data */
  76904. atlasJSON: ISpriteJSONAtlas;
  76905. /** The systems Sprite Sheet Texture */
  76906. spriteSheet: Texture;
  76907. /** Arguments passed with the Constructor */
  76908. options: ISpriteMapOptions;
  76909. /** Public Sprite Storage array, parsed from atlasJSON */
  76910. sprites: Array<ISpriteJSONSprite>;
  76911. /** Returns the Number of Sprites in the System */
  76912. get spriteCount(): number;
  76913. /** Returns the Position of Output Plane*/
  76914. get position(): Vector3;
  76915. /** Returns the Position of Output Plane*/
  76916. set position(v: Vector3);
  76917. /** Returns the Rotation of Output Plane*/
  76918. get rotation(): Vector3;
  76919. /** Returns the Rotation of Output Plane*/
  76920. set rotation(v: Vector3);
  76921. /** Sets the AnimationMap*/
  76922. get animationMap(): RawTexture;
  76923. /** Sets the AnimationMap*/
  76924. set animationMap(v: RawTexture);
  76925. /** Scene that the SpriteMap was created in */
  76926. private _scene;
  76927. /** Texture Buffer of Float32 that holds tile frame data*/
  76928. private _frameMap;
  76929. /** Texture Buffers of Float32 that holds tileMap data*/
  76930. private _tileMaps;
  76931. /** Texture Buffer of Float32 that holds Animation Data*/
  76932. private _animationMap;
  76933. /** Custom ShaderMaterial Central to the System*/
  76934. private _material;
  76935. /** Custom ShaderMaterial Central to the System*/
  76936. private _output;
  76937. /** Systems Time Ticker*/
  76938. private _time;
  76939. /**
  76940. * Creates a new SpriteMap
  76941. * @param name defines the SpriteMaps Name
  76942. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76943. * @param spriteSheet is the Texture that the Sprites are on.
  76944. * @param options a basic deployment configuration
  76945. * @param scene The Scene that the map is deployed on
  76946. */
  76947. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76948. /**
  76949. * Returns tileID location
  76950. * @returns Vector2 the cell position ID
  76951. */
  76952. getTileID(): Vector2;
  76953. /**
  76954. * Gets the UV location of the mouse over the SpriteMap.
  76955. * @returns Vector2 the UV position of the mouse interaction
  76956. */
  76957. getMousePosition(): Vector2;
  76958. /**
  76959. * Creates the "frame" texture Buffer
  76960. * -------------------------------------
  76961. * Structure of frames
  76962. * "filename": "Falling-Water-2.png",
  76963. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76964. * "rotated": true,
  76965. * "trimmed": true,
  76966. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76967. * "sourceSize": {"w":32,"h":32}
  76968. * @returns RawTexture of the frameMap
  76969. */
  76970. private _createFrameBuffer;
  76971. /**
  76972. * Creates the tileMap texture Buffer
  76973. * @param buffer normally and array of numbers, or a false to generate from scratch
  76974. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76975. * @returns RawTexture of the tileMap
  76976. */
  76977. private _createTileBuffer;
  76978. /**
  76979. * Modifies the data of the tileMaps
  76980. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76981. * @param pos is the iVector2 Coordinates of the Tile
  76982. * @param tile The SpriteIndex of the new Tile
  76983. */
  76984. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76985. /**
  76986. * Creates the animationMap texture Buffer
  76987. * @param buffer normally and array of numbers, or a false to generate from scratch
  76988. * @returns RawTexture of the animationMap
  76989. */
  76990. private _createTileAnimationBuffer;
  76991. /**
  76992. * Modifies the data of the animationMap
  76993. * @param cellID is the Index of the Sprite
  76994. * @param _frame is the target Animation frame
  76995. * @param toCell is the Target Index of the next frame of the animation
  76996. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76997. * @param speed is a global scalar of the time variable on the map.
  76998. */
  76999. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77000. /**
  77001. * Exports the .tilemaps file
  77002. */
  77003. saveTileMaps(): void;
  77004. /**
  77005. * Imports the .tilemaps file
  77006. * @param url of the .tilemaps file
  77007. */
  77008. loadTileMaps(url: string): void;
  77009. /**
  77010. * Release associated resources
  77011. */
  77012. dispose(): void;
  77013. }
  77014. }
  77015. declare module "babylonjs/Sprites/spritePackedManager" {
  77016. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77017. import { Scene } from "babylonjs/scene";
  77018. /**
  77019. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77020. * @see https://doc.babylonjs.com/babylon101/sprites
  77021. */
  77022. export class SpritePackedManager extends SpriteManager {
  77023. /** defines the packed manager's name */
  77024. name: string;
  77025. /**
  77026. * Creates a new sprite manager from a packed sprite sheet
  77027. * @param name defines the manager's name
  77028. * @param imgUrl defines the sprite sheet url
  77029. * @param capacity defines the maximum allowed number of sprites
  77030. * @param scene defines the hosting scene
  77031. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77032. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77033. * @param samplingMode defines the smapling mode to use with spritesheet
  77034. * @param fromPacked set to true; do not alter
  77035. */
  77036. constructor(
  77037. /** defines the packed manager's name */
  77038. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77039. }
  77040. }
  77041. declare module "babylonjs/Sprites/index" {
  77042. export * from "babylonjs/Sprites/sprite";
  77043. export * from "babylonjs/Sprites/ISprites";
  77044. export * from "babylonjs/Sprites/spriteManager";
  77045. export * from "babylonjs/Sprites/spriteMap";
  77046. export * from "babylonjs/Sprites/spritePackedManager";
  77047. export * from "babylonjs/Sprites/spriteSceneComponent";
  77048. }
  77049. declare module "babylonjs/States/index" {
  77050. export * from "babylonjs/States/alphaCullingState";
  77051. export * from "babylonjs/States/depthCullingState";
  77052. export * from "babylonjs/States/stencilState";
  77053. }
  77054. declare module "babylonjs/Misc/assetsManager" {
  77055. import { Scene } from "babylonjs/scene";
  77056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77057. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77058. import { Skeleton } from "babylonjs/Bones/skeleton";
  77059. import { Observable } from "babylonjs/Misc/observable";
  77060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77061. import { Texture } from "babylonjs/Materials/Textures/texture";
  77062. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77063. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77064. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77065. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77066. import { AssetContainer } from "babylonjs/assetContainer";
  77067. /**
  77068. * Defines the list of states available for a task inside a AssetsManager
  77069. */
  77070. export enum AssetTaskState {
  77071. /**
  77072. * Initialization
  77073. */
  77074. INIT = 0,
  77075. /**
  77076. * Running
  77077. */
  77078. RUNNING = 1,
  77079. /**
  77080. * Done
  77081. */
  77082. DONE = 2,
  77083. /**
  77084. * Error
  77085. */
  77086. ERROR = 3
  77087. }
  77088. /**
  77089. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77090. */
  77091. export abstract class AbstractAssetTask {
  77092. /**
  77093. * Task name
  77094. */ name: string;
  77095. /**
  77096. * Callback called when the task is successful
  77097. */
  77098. onSuccess: (task: any) => void;
  77099. /**
  77100. * Callback called when the task is not successful
  77101. */
  77102. onError: (task: any, message?: string, exception?: any) => void;
  77103. /**
  77104. * Creates a new AssetsManager
  77105. * @param name defines the name of the task
  77106. */
  77107. constructor(
  77108. /**
  77109. * Task name
  77110. */ name: string);
  77111. private _isCompleted;
  77112. private _taskState;
  77113. private _errorObject;
  77114. /**
  77115. * Get if the task is completed
  77116. */
  77117. get isCompleted(): boolean;
  77118. /**
  77119. * Gets the current state of the task
  77120. */
  77121. get taskState(): AssetTaskState;
  77122. /**
  77123. * Gets the current error object (if task is in error)
  77124. */
  77125. get errorObject(): {
  77126. message?: string;
  77127. exception?: any;
  77128. };
  77129. /**
  77130. * Internal only
  77131. * @hidden
  77132. */
  77133. _setErrorObject(message?: string, exception?: any): void;
  77134. /**
  77135. * Execute the current task
  77136. * @param scene defines the scene where you want your assets to be loaded
  77137. * @param onSuccess is a callback called when the task is successfully executed
  77138. * @param onError is a callback called if an error occurs
  77139. */
  77140. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77141. /**
  77142. * Execute the current task
  77143. * @param scene defines the scene where you want your assets to be loaded
  77144. * @param onSuccess is a callback called when the task is successfully executed
  77145. * @param onError is a callback called if an error occurs
  77146. */
  77147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77148. /**
  77149. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77150. * This can be used with failed tasks that have the reason for failure fixed.
  77151. */
  77152. reset(): void;
  77153. private onErrorCallback;
  77154. private onDoneCallback;
  77155. }
  77156. /**
  77157. * Define the interface used by progress events raised during assets loading
  77158. */
  77159. export interface IAssetsProgressEvent {
  77160. /**
  77161. * Defines the number of remaining tasks to process
  77162. */
  77163. remainingCount: number;
  77164. /**
  77165. * Defines the total number of tasks
  77166. */
  77167. totalCount: number;
  77168. /**
  77169. * Defines the task that was just processed
  77170. */
  77171. task: AbstractAssetTask;
  77172. }
  77173. /**
  77174. * Class used to share progress information about assets loading
  77175. */
  77176. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77177. /**
  77178. * Defines the number of remaining tasks to process
  77179. */
  77180. remainingCount: number;
  77181. /**
  77182. * Defines the total number of tasks
  77183. */
  77184. totalCount: number;
  77185. /**
  77186. * Defines the task that was just processed
  77187. */
  77188. task: AbstractAssetTask;
  77189. /**
  77190. * Creates a AssetsProgressEvent
  77191. * @param remainingCount defines the number of remaining tasks to process
  77192. * @param totalCount defines the total number of tasks
  77193. * @param task defines the task that was just processed
  77194. */
  77195. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77196. }
  77197. /**
  77198. * Define a task used by AssetsManager to load assets into a container
  77199. */
  77200. export class ContainerAssetTask extends AbstractAssetTask {
  77201. /**
  77202. * Defines the name of the task
  77203. */
  77204. name: string;
  77205. /**
  77206. * Defines the list of mesh's names you want to load
  77207. */
  77208. meshesNames: any;
  77209. /**
  77210. * Defines the root url to use as a base to load your meshes and associated resources
  77211. */
  77212. rootUrl: string;
  77213. /**
  77214. * Defines the filename or File of the scene to load from
  77215. */
  77216. sceneFilename: string | File;
  77217. /**
  77218. * Get the loaded asset container
  77219. */
  77220. loadedContainer: AssetContainer;
  77221. /**
  77222. * Gets the list of loaded meshes
  77223. */
  77224. loadedMeshes: Array<AbstractMesh>;
  77225. /**
  77226. * Gets the list of loaded particle systems
  77227. */
  77228. loadedParticleSystems: Array<IParticleSystem>;
  77229. /**
  77230. * Gets the list of loaded skeletons
  77231. */
  77232. loadedSkeletons: Array<Skeleton>;
  77233. /**
  77234. * Gets the list of loaded animation groups
  77235. */
  77236. loadedAnimationGroups: Array<AnimationGroup>;
  77237. /**
  77238. * Callback called when the task is successful
  77239. */
  77240. onSuccess: (task: ContainerAssetTask) => void;
  77241. /**
  77242. * Callback called when the task is successful
  77243. */
  77244. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77245. /**
  77246. * Creates a new ContainerAssetTask
  77247. * @param name defines the name of the task
  77248. * @param meshesNames defines the list of mesh's names you want to load
  77249. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77250. * @param sceneFilename defines the filename or File of the scene to load from
  77251. */
  77252. constructor(
  77253. /**
  77254. * Defines the name of the task
  77255. */
  77256. name: string,
  77257. /**
  77258. * Defines the list of mesh's names you want to load
  77259. */
  77260. meshesNames: any,
  77261. /**
  77262. * Defines the root url to use as a base to load your meshes and associated resources
  77263. */
  77264. rootUrl: string,
  77265. /**
  77266. * Defines the filename or File of the scene to load from
  77267. */
  77268. sceneFilename: string | File);
  77269. /**
  77270. * Execute the current task
  77271. * @param scene defines the scene where you want your assets to be loaded
  77272. * @param onSuccess is a callback called when the task is successfully executed
  77273. * @param onError is a callback called if an error occurs
  77274. */
  77275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77276. }
  77277. /**
  77278. * Define a task used by AssetsManager to load meshes
  77279. */
  77280. export class MeshAssetTask extends AbstractAssetTask {
  77281. /**
  77282. * Defines the name of the task
  77283. */
  77284. name: string;
  77285. /**
  77286. * Defines the list of mesh's names you want to load
  77287. */
  77288. meshesNames: any;
  77289. /**
  77290. * Defines the root url to use as a base to load your meshes and associated resources
  77291. */
  77292. rootUrl: string;
  77293. /**
  77294. * Defines the filename or File of the scene to load from
  77295. */
  77296. sceneFilename: string | File;
  77297. /**
  77298. * Gets the list of loaded meshes
  77299. */
  77300. loadedMeshes: Array<AbstractMesh>;
  77301. /**
  77302. * Gets the list of loaded particle systems
  77303. */
  77304. loadedParticleSystems: Array<IParticleSystem>;
  77305. /**
  77306. * Gets the list of loaded skeletons
  77307. */
  77308. loadedSkeletons: Array<Skeleton>;
  77309. /**
  77310. * Gets the list of loaded animation groups
  77311. */
  77312. loadedAnimationGroups: Array<AnimationGroup>;
  77313. /**
  77314. * Callback called when the task is successful
  77315. */
  77316. onSuccess: (task: MeshAssetTask) => void;
  77317. /**
  77318. * Callback called when the task is successful
  77319. */
  77320. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77321. /**
  77322. * Creates a new MeshAssetTask
  77323. * @param name defines the name of the task
  77324. * @param meshesNames defines the list of mesh's names you want to load
  77325. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77326. * @param sceneFilename defines the filename or File of the scene to load from
  77327. */
  77328. constructor(
  77329. /**
  77330. * Defines the name of the task
  77331. */
  77332. name: string,
  77333. /**
  77334. * Defines the list of mesh's names you want to load
  77335. */
  77336. meshesNames: any,
  77337. /**
  77338. * Defines the root url to use as a base to load your meshes and associated resources
  77339. */
  77340. rootUrl: string,
  77341. /**
  77342. * Defines the filename or File of the scene to load from
  77343. */
  77344. sceneFilename: string | File);
  77345. /**
  77346. * Execute the current task
  77347. * @param scene defines the scene where you want your assets to be loaded
  77348. * @param onSuccess is a callback called when the task is successfully executed
  77349. * @param onError is a callback called if an error occurs
  77350. */
  77351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77352. }
  77353. /**
  77354. * Define a task used by AssetsManager to load text content
  77355. */
  77356. export class TextFileAssetTask extends AbstractAssetTask {
  77357. /**
  77358. * Defines the name of the task
  77359. */
  77360. name: string;
  77361. /**
  77362. * Defines the location of the file to load
  77363. */
  77364. url: string;
  77365. /**
  77366. * Gets the loaded text string
  77367. */
  77368. text: string;
  77369. /**
  77370. * Callback called when the task is successful
  77371. */
  77372. onSuccess: (task: TextFileAssetTask) => void;
  77373. /**
  77374. * Callback called when the task is successful
  77375. */
  77376. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77377. /**
  77378. * Creates a new TextFileAssetTask object
  77379. * @param name defines the name of the task
  77380. * @param url defines the location of the file to load
  77381. */
  77382. constructor(
  77383. /**
  77384. * Defines the name of the task
  77385. */
  77386. name: string,
  77387. /**
  77388. * Defines the location of the file to load
  77389. */
  77390. url: string);
  77391. /**
  77392. * Execute the current task
  77393. * @param scene defines the scene where you want your assets to be loaded
  77394. * @param onSuccess is a callback called when the task is successfully executed
  77395. * @param onError is a callback called if an error occurs
  77396. */
  77397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77398. }
  77399. /**
  77400. * Define a task used by AssetsManager to load binary data
  77401. */
  77402. export class BinaryFileAssetTask extends AbstractAssetTask {
  77403. /**
  77404. * Defines the name of the task
  77405. */
  77406. name: string;
  77407. /**
  77408. * Defines the location of the file to load
  77409. */
  77410. url: string;
  77411. /**
  77412. * Gets the lodaded data (as an array buffer)
  77413. */
  77414. data: ArrayBuffer;
  77415. /**
  77416. * Callback called when the task is successful
  77417. */
  77418. onSuccess: (task: BinaryFileAssetTask) => void;
  77419. /**
  77420. * Callback called when the task is successful
  77421. */
  77422. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77423. /**
  77424. * Creates a new BinaryFileAssetTask object
  77425. * @param name defines the name of the new task
  77426. * @param url defines the location of the file to load
  77427. */
  77428. constructor(
  77429. /**
  77430. * Defines the name of the task
  77431. */
  77432. name: string,
  77433. /**
  77434. * Defines the location of the file to load
  77435. */
  77436. url: string);
  77437. /**
  77438. * Execute the current task
  77439. * @param scene defines the scene where you want your assets to be loaded
  77440. * @param onSuccess is a callback called when the task is successfully executed
  77441. * @param onError is a callback called if an error occurs
  77442. */
  77443. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77444. }
  77445. /**
  77446. * Define a task used by AssetsManager to load images
  77447. */
  77448. export class ImageAssetTask extends AbstractAssetTask {
  77449. /**
  77450. * Defines the name of the task
  77451. */
  77452. name: string;
  77453. /**
  77454. * Defines the location of the image to load
  77455. */
  77456. url: string;
  77457. /**
  77458. * Gets the loaded images
  77459. */
  77460. image: HTMLImageElement;
  77461. /**
  77462. * Callback called when the task is successful
  77463. */
  77464. onSuccess: (task: ImageAssetTask) => void;
  77465. /**
  77466. * Callback called when the task is successful
  77467. */
  77468. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77469. /**
  77470. * Creates a new ImageAssetTask
  77471. * @param name defines the name of the task
  77472. * @param url defines the location of the image to load
  77473. */
  77474. constructor(
  77475. /**
  77476. * Defines the name of the task
  77477. */
  77478. name: string,
  77479. /**
  77480. * Defines the location of the image to load
  77481. */
  77482. url: string);
  77483. /**
  77484. * Execute the current task
  77485. * @param scene defines the scene where you want your assets to be loaded
  77486. * @param onSuccess is a callback called when the task is successfully executed
  77487. * @param onError is a callback called if an error occurs
  77488. */
  77489. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77490. }
  77491. /**
  77492. * Defines the interface used by texture loading tasks
  77493. */
  77494. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77495. /**
  77496. * Gets the loaded texture
  77497. */
  77498. texture: TEX;
  77499. }
  77500. /**
  77501. * Define a task used by AssetsManager to load 2D textures
  77502. */
  77503. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77504. /**
  77505. * Defines the name of the task
  77506. */
  77507. name: string;
  77508. /**
  77509. * Defines the location of the file to load
  77510. */
  77511. url: string;
  77512. /**
  77513. * Defines if mipmap should not be generated (default is false)
  77514. */
  77515. noMipmap?: boolean | undefined;
  77516. /**
  77517. * Defines if texture must be inverted on Y axis (default is true)
  77518. */
  77519. invertY: boolean;
  77520. /**
  77521. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77522. */
  77523. samplingMode: number;
  77524. /**
  77525. * Gets the loaded texture
  77526. */
  77527. texture: Texture;
  77528. /**
  77529. * Callback called when the task is successful
  77530. */
  77531. onSuccess: (task: TextureAssetTask) => void;
  77532. /**
  77533. * Callback called when the task is successful
  77534. */
  77535. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77536. /**
  77537. * Creates a new TextureAssetTask object
  77538. * @param name defines the name of the task
  77539. * @param url defines the location of the file to load
  77540. * @param noMipmap defines if mipmap should not be generated (default is false)
  77541. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77542. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77543. */
  77544. constructor(
  77545. /**
  77546. * Defines the name of the task
  77547. */
  77548. name: string,
  77549. /**
  77550. * Defines the location of the file to load
  77551. */
  77552. url: string,
  77553. /**
  77554. * Defines if mipmap should not be generated (default is false)
  77555. */
  77556. noMipmap?: boolean | undefined,
  77557. /**
  77558. * Defines if texture must be inverted on Y axis (default is true)
  77559. */
  77560. invertY?: boolean,
  77561. /**
  77562. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77563. */
  77564. samplingMode?: number);
  77565. /**
  77566. * Execute the current task
  77567. * @param scene defines the scene where you want your assets to be loaded
  77568. * @param onSuccess is a callback called when the task is successfully executed
  77569. * @param onError is a callback called if an error occurs
  77570. */
  77571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77572. }
  77573. /**
  77574. * Define a task used by AssetsManager to load cube textures
  77575. */
  77576. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77577. /**
  77578. * Defines the name of the task
  77579. */
  77580. name: string;
  77581. /**
  77582. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77583. */
  77584. url: string;
  77585. /**
  77586. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77587. */
  77588. extensions?: string[] | undefined;
  77589. /**
  77590. * Defines if mipmaps should not be generated (default is false)
  77591. */
  77592. noMipmap?: boolean | undefined;
  77593. /**
  77594. * Defines the explicit list of files (undefined by default)
  77595. */
  77596. files?: string[] | undefined;
  77597. /**
  77598. * Gets the loaded texture
  77599. */
  77600. texture: CubeTexture;
  77601. /**
  77602. * Callback called when the task is successful
  77603. */
  77604. onSuccess: (task: CubeTextureAssetTask) => void;
  77605. /**
  77606. * Callback called when the task is successful
  77607. */
  77608. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77609. /**
  77610. * Creates a new CubeTextureAssetTask
  77611. * @param name defines the name of the task
  77612. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77613. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77614. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77615. * @param files defines the explicit list of files (undefined by default)
  77616. */
  77617. constructor(
  77618. /**
  77619. * Defines the name of the task
  77620. */
  77621. name: string,
  77622. /**
  77623. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77624. */
  77625. url: string,
  77626. /**
  77627. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77628. */
  77629. extensions?: string[] | undefined,
  77630. /**
  77631. * Defines if mipmaps should not be generated (default is false)
  77632. */
  77633. noMipmap?: boolean | undefined,
  77634. /**
  77635. * Defines the explicit list of files (undefined by default)
  77636. */
  77637. files?: string[] | undefined);
  77638. /**
  77639. * Execute the current task
  77640. * @param scene defines the scene where you want your assets to be loaded
  77641. * @param onSuccess is a callback called when the task is successfully executed
  77642. * @param onError is a callback called if an error occurs
  77643. */
  77644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77645. }
  77646. /**
  77647. * Define a task used by AssetsManager to load HDR cube textures
  77648. */
  77649. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77650. /**
  77651. * Defines the name of the task
  77652. */
  77653. name: string;
  77654. /**
  77655. * Defines the location of the file to load
  77656. */
  77657. url: string;
  77658. /**
  77659. * Defines the desired size (the more it increases the longer the generation will be)
  77660. */
  77661. size: number;
  77662. /**
  77663. * Defines if mipmaps should not be generated (default is false)
  77664. */
  77665. noMipmap: boolean;
  77666. /**
  77667. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77668. */
  77669. generateHarmonics: boolean;
  77670. /**
  77671. * 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)
  77672. */
  77673. gammaSpace: boolean;
  77674. /**
  77675. * Internal Use Only
  77676. */
  77677. reserved: boolean;
  77678. /**
  77679. * Gets the loaded texture
  77680. */
  77681. texture: HDRCubeTexture;
  77682. /**
  77683. * Callback called when the task is successful
  77684. */
  77685. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77686. /**
  77687. * Callback called when the task is successful
  77688. */
  77689. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77690. /**
  77691. * Creates a new HDRCubeTextureAssetTask object
  77692. * @param name defines the name of the task
  77693. * @param url defines the location of the file to load
  77694. * @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.
  77695. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77696. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77697. * @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)
  77698. * @param reserved Internal use only
  77699. */
  77700. constructor(
  77701. /**
  77702. * Defines the name of the task
  77703. */
  77704. name: string,
  77705. /**
  77706. * Defines the location of the file to load
  77707. */
  77708. url: string,
  77709. /**
  77710. * Defines the desired size (the more it increases the longer the generation will be)
  77711. */
  77712. size: number,
  77713. /**
  77714. * Defines if mipmaps should not be generated (default is false)
  77715. */
  77716. noMipmap?: boolean,
  77717. /**
  77718. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77719. */
  77720. generateHarmonics?: boolean,
  77721. /**
  77722. * 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)
  77723. */
  77724. gammaSpace?: boolean,
  77725. /**
  77726. * Internal Use Only
  77727. */
  77728. reserved?: boolean);
  77729. /**
  77730. * Execute the current task
  77731. * @param scene defines the scene where you want your assets to be loaded
  77732. * @param onSuccess is a callback called when the task is successfully executed
  77733. * @param onError is a callback called if an error occurs
  77734. */
  77735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77736. }
  77737. /**
  77738. * Define a task used by AssetsManager to load Equirectangular cube textures
  77739. */
  77740. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77741. /**
  77742. * Defines the name of the task
  77743. */
  77744. name: string;
  77745. /**
  77746. * Defines the location of the file to load
  77747. */
  77748. url: string;
  77749. /**
  77750. * Defines the desired size (the more it increases the longer the generation will be)
  77751. */
  77752. size: number;
  77753. /**
  77754. * Defines if mipmaps should not be generated (default is false)
  77755. */
  77756. noMipmap: boolean;
  77757. /**
  77758. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77759. * but the standard material would require them in Gamma space) (default is true)
  77760. */
  77761. gammaSpace: boolean;
  77762. /**
  77763. * Gets the loaded texture
  77764. */
  77765. texture: EquiRectangularCubeTexture;
  77766. /**
  77767. * Callback called when the task is successful
  77768. */
  77769. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77770. /**
  77771. * Callback called when the task is successful
  77772. */
  77773. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77774. /**
  77775. * Creates a new EquiRectangularCubeTextureAssetTask object
  77776. * @param name defines the name of the task
  77777. * @param url defines the location of the file to load
  77778. * @param size defines the desired size (the more it increases the longer the generation will be)
  77779. * If the size is omitted this implies you are using a preprocessed cubemap.
  77780. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77781. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77782. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77783. * (default is true)
  77784. */
  77785. constructor(
  77786. /**
  77787. * Defines the name of the task
  77788. */
  77789. name: string,
  77790. /**
  77791. * Defines the location of the file to load
  77792. */
  77793. url: string,
  77794. /**
  77795. * Defines the desired size (the more it increases the longer the generation will be)
  77796. */
  77797. size: number,
  77798. /**
  77799. * Defines if mipmaps should not be generated (default is false)
  77800. */
  77801. noMipmap?: boolean,
  77802. /**
  77803. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77804. * but the standard material would require them in Gamma space) (default is true)
  77805. */
  77806. gammaSpace?: boolean);
  77807. /**
  77808. * Execute the current task
  77809. * @param scene defines the scene where you want your assets to be loaded
  77810. * @param onSuccess is a callback called when the task is successfully executed
  77811. * @param onError is a callback called if an error occurs
  77812. */
  77813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77814. }
  77815. /**
  77816. * This class can be used to easily import assets into a scene
  77817. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77818. */
  77819. export class AssetsManager {
  77820. private _scene;
  77821. private _isLoading;
  77822. protected _tasks: AbstractAssetTask[];
  77823. protected _waitingTasksCount: number;
  77824. protected _totalTasksCount: number;
  77825. /**
  77826. * Callback called when all tasks are processed
  77827. */
  77828. onFinish: (tasks: AbstractAssetTask[]) => void;
  77829. /**
  77830. * Callback called when a task is successful
  77831. */
  77832. onTaskSuccess: (task: AbstractAssetTask) => void;
  77833. /**
  77834. * Callback called when a task had an error
  77835. */
  77836. onTaskError: (task: AbstractAssetTask) => void;
  77837. /**
  77838. * Callback called when a task is done (whatever the result is)
  77839. */
  77840. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77841. /**
  77842. * Observable called when all tasks are processed
  77843. */
  77844. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77845. /**
  77846. * Observable called when a task had an error
  77847. */
  77848. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77849. /**
  77850. * Observable called when all tasks were executed
  77851. */
  77852. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77853. /**
  77854. * Observable called when a task is done (whatever the result is)
  77855. */
  77856. onProgressObservable: Observable<IAssetsProgressEvent>;
  77857. /**
  77858. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77859. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77860. */
  77861. useDefaultLoadingScreen: boolean;
  77862. /**
  77863. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77864. * when all assets have been downloaded.
  77865. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77866. */
  77867. autoHideLoadingUI: boolean;
  77868. /**
  77869. * Creates a new AssetsManager
  77870. * @param scene defines the scene to work on
  77871. */
  77872. constructor(scene: Scene);
  77873. /**
  77874. * Add a ContainerAssetTask to the list of active tasks
  77875. * @param taskName defines the name of the new task
  77876. * @param meshesNames defines the name of meshes to load
  77877. * @param rootUrl defines the root url to use to locate files
  77878. * @param sceneFilename defines the filename of the scene file
  77879. * @returns a new ContainerAssetTask object
  77880. */
  77881. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77882. /**
  77883. * Add a MeshAssetTask to the list of active tasks
  77884. * @param taskName defines the name of the new task
  77885. * @param meshesNames defines the name of meshes to load
  77886. * @param rootUrl defines the root url to use to locate files
  77887. * @param sceneFilename defines the filename of the scene file
  77888. * @returns a new MeshAssetTask object
  77889. */
  77890. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77891. /**
  77892. * Add a TextFileAssetTask to the list of active tasks
  77893. * @param taskName defines the name of the new task
  77894. * @param url defines the url of the file to load
  77895. * @returns a new TextFileAssetTask object
  77896. */
  77897. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77898. /**
  77899. * Add a BinaryFileAssetTask to the list of active tasks
  77900. * @param taskName defines the name of the new task
  77901. * @param url defines the url of the file to load
  77902. * @returns a new BinaryFileAssetTask object
  77903. */
  77904. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77905. /**
  77906. * Add a ImageAssetTask to the list of active tasks
  77907. * @param taskName defines the name of the new task
  77908. * @param url defines the url of the file to load
  77909. * @returns a new ImageAssetTask object
  77910. */
  77911. addImageTask(taskName: string, url: string): ImageAssetTask;
  77912. /**
  77913. * Add a TextureAssetTask to the list of active tasks
  77914. * @param taskName defines the name of the new task
  77915. * @param url defines the url of the file to load
  77916. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77917. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77918. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77919. * @returns a new TextureAssetTask object
  77920. */
  77921. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77922. /**
  77923. * Add a CubeTextureAssetTask to the list of active tasks
  77924. * @param taskName defines the name of the new task
  77925. * @param url defines the url of the file to load
  77926. * @param extensions defines the extension to use to load the cube map (can be null)
  77927. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77928. * @param files defines the list of files to load (can be null)
  77929. * @returns a new CubeTextureAssetTask object
  77930. */
  77931. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77932. /**
  77933. *
  77934. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77935. * @param taskName defines the name of the new task
  77936. * @param url defines the url of the file to load
  77937. * @param size defines the size you want for the cubemap (can be null)
  77938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77939. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77940. * @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)
  77941. * @param reserved Internal use only
  77942. * @returns a new HDRCubeTextureAssetTask object
  77943. */
  77944. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77945. /**
  77946. *
  77947. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77948. * @param taskName defines the name of the new task
  77949. * @param url defines the url of the file to load
  77950. * @param size defines the size you want for the cubemap (can be null)
  77951. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77952. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77953. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77954. * @returns a new EquiRectangularCubeTextureAssetTask object
  77955. */
  77956. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77957. /**
  77958. * Remove a task from the assets manager.
  77959. * @param task the task to remove
  77960. */
  77961. removeTask(task: AbstractAssetTask): void;
  77962. private _decreaseWaitingTasksCount;
  77963. private _runTask;
  77964. /**
  77965. * Reset the AssetsManager and remove all tasks
  77966. * @return the current instance of the AssetsManager
  77967. */
  77968. reset(): AssetsManager;
  77969. /**
  77970. * Start the loading process
  77971. * @return the current instance of the AssetsManager
  77972. */
  77973. load(): AssetsManager;
  77974. /**
  77975. * Start the loading process as an async operation
  77976. * @return a promise returning the list of failed tasks
  77977. */
  77978. loadAsync(): Promise<void>;
  77979. }
  77980. }
  77981. declare module "babylonjs/Misc/deferred" {
  77982. /**
  77983. * Wrapper class for promise with external resolve and reject.
  77984. */
  77985. export class Deferred<T> {
  77986. /**
  77987. * The promise associated with this deferred object.
  77988. */
  77989. readonly promise: Promise<T>;
  77990. private _resolve;
  77991. private _reject;
  77992. /**
  77993. * The resolve method of the promise associated with this deferred object.
  77994. */
  77995. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77996. /**
  77997. * The reject method of the promise associated with this deferred object.
  77998. */
  77999. get reject(): (reason?: any) => void;
  78000. /**
  78001. * Constructor for this deferred object.
  78002. */
  78003. constructor();
  78004. }
  78005. }
  78006. declare module "babylonjs/Misc/meshExploder" {
  78007. import { Mesh } from "babylonjs/Meshes/mesh";
  78008. /**
  78009. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78010. */
  78011. export class MeshExploder {
  78012. private _centerMesh;
  78013. private _meshes;
  78014. private _meshesOrigins;
  78015. private _toCenterVectors;
  78016. private _scaledDirection;
  78017. private _newPosition;
  78018. private _centerPosition;
  78019. /**
  78020. * Explodes meshes from a center mesh.
  78021. * @param meshes The meshes to explode.
  78022. * @param centerMesh The mesh to be center of explosion.
  78023. */
  78024. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78025. private _setCenterMesh;
  78026. /**
  78027. * Get class name
  78028. * @returns "MeshExploder"
  78029. */
  78030. getClassName(): string;
  78031. /**
  78032. * "Exploded meshes"
  78033. * @returns Array of meshes with the centerMesh at index 0.
  78034. */
  78035. getMeshes(): Array<Mesh>;
  78036. /**
  78037. * Explodes meshes giving a specific direction
  78038. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78039. */
  78040. explode(direction?: number): void;
  78041. }
  78042. }
  78043. declare module "babylonjs/Misc/filesInput" {
  78044. import { Engine } from "babylonjs/Engines/engine";
  78045. import { Scene } from "babylonjs/scene";
  78046. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78047. import { Nullable } from "babylonjs/types";
  78048. /**
  78049. * Class used to help managing file picking and drag'n'drop
  78050. */
  78051. export class FilesInput {
  78052. /**
  78053. * List of files ready to be loaded
  78054. */
  78055. static get FilesToLoad(): {
  78056. [key: string]: File;
  78057. };
  78058. /**
  78059. * Callback called when a file is processed
  78060. */
  78061. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78062. private _engine;
  78063. private _currentScene;
  78064. private _sceneLoadedCallback;
  78065. private _progressCallback;
  78066. private _additionalRenderLoopLogicCallback;
  78067. private _textureLoadingCallback;
  78068. private _startingProcessingFilesCallback;
  78069. private _onReloadCallback;
  78070. private _errorCallback;
  78071. private _elementToMonitor;
  78072. private _sceneFileToLoad;
  78073. private _filesToLoad;
  78074. /**
  78075. * Creates a new FilesInput
  78076. * @param engine defines the rendering engine
  78077. * @param scene defines the hosting scene
  78078. * @param sceneLoadedCallback callback called when scene is loaded
  78079. * @param progressCallback callback called to track progress
  78080. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78081. * @param textureLoadingCallback callback called when a texture is loading
  78082. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78083. * @param onReloadCallback callback called when a reload is requested
  78084. * @param errorCallback callback call if an error occurs
  78085. */
  78086. 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>);
  78087. private _dragEnterHandler;
  78088. private _dragOverHandler;
  78089. private _dropHandler;
  78090. /**
  78091. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78092. * @param elementToMonitor defines the DOM element to track
  78093. */
  78094. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78095. /** Gets the current list of files to load */
  78096. get filesToLoad(): File[];
  78097. /**
  78098. * Release all associated resources
  78099. */
  78100. dispose(): void;
  78101. private renderFunction;
  78102. private drag;
  78103. private drop;
  78104. private _traverseFolder;
  78105. private _processFiles;
  78106. /**
  78107. * Load files from a drop event
  78108. * @param event defines the drop event to use as source
  78109. */
  78110. loadFiles(event: any): void;
  78111. private _processReload;
  78112. /**
  78113. * Reload the current scene from the loaded files
  78114. */
  78115. reload(): void;
  78116. }
  78117. }
  78118. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78119. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78120. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78121. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78122. }
  78123. declare module "babylonjs/Misc/sceneOptimizer" {
  78124. import { Scene, IDisposable } from "babylonjs/scene";
  78125. import { Observable } from "babylonjs/Misc/observable";
  78126. /**
  78127. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78128. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78129. */
  78130. export class SceneOptimization {
  78131. /**
  78132. * Defines the priority of this optimization (0 by default which means first in the list)
  78133. */
  78134. priority: number;
  78135. /**
  78136. * Gets a string describing the action executed by the current optimization
  78137. * @returns description string
  78138. */
  78139. getDescription(): string;
  78140. /**
  78141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78142. * @param scene defines the current scene where to apply this optimization
  78143. * @param optimizer defines the current optimizer
  78144. * @returns true if everything that can be done was applied
  78145. */
  78146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78147. /**
  78148. * Creates the SceneOptimization object
  78149. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78150. * @param desc defines the description associated with the optimization
  78151. */
  78152. constructor(
  78153. /**
  78154. * Defines the priority of this optimization (0 by default which means first in the list)
  78155. */
  78156. priority?: number);
  78157. }
  78158. /**
  78159. * Defines an optimization used to reduce the size of render target textures
  78160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78161. */
  78162. export class TextureOptimization extends SceneOptimization {
  78163. /**
  78164. * Defines the priority of this optimization (0 by default which means first in the list)
  78165. */
  78166. priority: number;
  78167. /**
  78168. * 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
  78169. */
  78170. maximumSize: number;
  78171. /**
  78172. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78173. */
  78174. step: number;
  78175. /**
  78176. * Gets a string describing the action executed by the current optimization
  78177. * @returns description string
  78178. */
  78179. getDescription(): string;
  78180. /**
  78181. * Creates the TextureOptimization object
  78182. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78183. * @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
  78184. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78185. */
  78186. constructor(
  78187. /**
  78188. * Defines the priority of this optimization (0 by default which means first in the list)
  78189. */
  78190. priority?: number,
  78191. /**
  78192. * 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
  78193. */
  78194. maximumSize?: number,
  78195. /**
  78196. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78197. */
  78198. step?: number);
  78199. /**
  78200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78201. * @param scene defines the current scene where to apply this optimization
  78202. * @param optimizer defines the current optimizer
  78203. * @returns true if everything that can be done was applied
  78204. */
  78205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78206. }
  78207. /**
  78208. * Defines an optimization used to increase or decrease the rendering resolution
  78209. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78210. */
  78211. export class HardwareScalingOptimization extends SceneOptimization {
  78212. /**
  78213. * Defines the priority of this optimization (0 by default which means first in the list)
  78214. */
  78215. priority: number;
  78216. /**
  78217. * Defines the maximum scale to use (2 by default)
  78218. */
  78219. maximumScale: number;
  78220. /**
  78221. * Defines the step to use between two passes (0.5 by default)
  78222. */
  78223. step: number;
  78224. private _currentScale;
  78225. private _directionOffset;
  78226. /**
  78227. * Gets a string describing the action executed by the current optimization
  78228. * @return description string
  78229. */
  78230. getDescription(): string;
  78231. /**
  78232. * Creates the HardwareScalingOptimization object
  78233. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78234. * @param maximumScale defines the maximum scale to use (2 by default)
  78235. * @param step defines the step to use between two passes (0.5 by default)
  78236. */
  78237. constructor(
  78238. /**
  78239. * Defines the priority of this optimization (0 by default which means first in the list)
  78240. */
  78241. priority?: number,
  78242. /**
  78243. * Defines the maximum scale to use (2 by default)
  78244. */
  78245. maximumScale?: number,
  78246. /**
  78247. * Defines the step to use between two passes (0.5 by default)
  78248. */
  78249. step?: number);
  78250. /**
  78251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78252. * @param scene defines the current scene where to apply this optimization
  78253. * @param optimizer defines the current optimizer
  78254. * @returns true if everything that can be done was applied
  78255. */
  78256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78257. }
  78258. /**
  78259. * Defines an optimization used to remove shadows
  78260. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78261. */
  78262. export class ShadowsOptimization extends SceneOptimization {
  78263. /**
  78264. * Gets a string describing the action executed by the current optimization
  78265. * @return description string
  78266. */
  78267. getDescription(): string;
  78268. /**
  78269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78270. * @param scene defines the current scene where to apply this optimization
  78271. * @param optimizer defines the current optimizer
  78272. * @returns true if everything that can be done was applied
  78273. */
  78274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78275. }
  78276. /**
  78277. * Defines an optimization used to turn post-processes off
  78278. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78279. */
  78280. export class PostProcessesOptimization extends SceneOptimization {
  78281. /**
  78282. * Gets a string describing the action executed by the current optimization
  78283. * @return description string
  78284. */
  78285. getDescription(): string;
  78286. /**
  78287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78288. * @param scene defines the current scene where to apply this optimization
  78289. * @param optimizer defines the current optimizer
  78290. * @returns true if everything that can be done was applied
  78291. */
  78292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78293. }
  78294. /**
  78295. * Defines an optimization used to turn lens flares off
  78296. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78297. */
  78298. export class LensFlaresOptimization extends SceneOptimization {
  78299. /**
  78300. * Gets a string describing the action executed by the current optimization
  78301. * @return description string
  78302. */
  78303. getDescription(): string;
  78304. /**
  78305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78306. * @param scene defines the current scene where to apply this optimization
  78307. * @param optimizer defines the current optimizer
  78308. * @returns true if everything that can be done was applied
  78309. */
  78310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78311. }
  78312. /**
  78313. * Defines an optimization based on user defined callback.
  78314. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78315. */
  78316. export class CustomOptimization extends SceneOptimization {
  78317. /**
  78318. * Callback called to apply the custom optimization.
  78319. */
  78320. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78321. /**
  78322. * Callback called to get custom description
  78323. */
  78324. onGetDescription: () => string;
  78325. /**
  78326. * Gets a string describing the action executed by the current optimization
  78327. * @returns description string
  78328. */
  78329. getDescription(): string;
  78330. /**
  78331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78332. * @param scene defines the current scene where to apply this optimization
  78333. * @param optimizer defines the current optimizer
  78334. * @returns true if everything that can be done was applied
  78335. */
  78336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78337. }
  78338. /**
  78339. * Defines an optimization used to turn particles off
  78340. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78341. */
  78342. export class ParticlesOptimization extends SceneOptimization {
  78343. /**
  78344. * Gets a string describing the action executed by the current optimization
  78345. * @return description string
  78346. */
  78347. getDescription(): string;
  78348. /**
  78349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78350. * @param scene defines the current scene where to apply this optimization
  78351. * @param optimizer defines the current optimizer
  78352. * @returns true if everything that can be done was applied
  78353. */
  78354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78355. }
  78356. /**
  78357. * Defines an optimization used to turn render targets off
  78358. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78359. */
  78360. export class RenderTargetsOptimization extends SceneOptimization {
  78361. /**
  78362. * Gets a string describing the action executed by the current optimization
  78363. * @return description string
  78364. */
  78365. getDescription(): string;
  78366. /**
  78367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78368. * @param scene defines the current scene where to apply this optimization
  78369. * @param optimizer defines the current optimizer
  78370. * @returns true if everything that can be done was applied
  78371. */
  78372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78373. }
  78374. /**
  78375. * Defines an optimization used to merge meshes with compatible materials
  78376. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78377. */
  78378. export class MergeMeshesOptimization extends SceneOptimization {
  78379. private static _UpdateSelectionTree;
  78380. /**
  78381. * Gets or sets a boolean which defines if optimization octree has to be updated
  78382. */
  78383. static get UpdateSelectionTree(): boolean;
  78384. /**
  78385. * Gets or sets a boolean which defines if optimization octree has to be updated
  78386. */
  78387. static set UpdateSelectionTree(value: boolean);
  78388. /**
  78389. * Gets a string describing the action executed by the current optimization
  78390. * @return description string
  78391. */
  78392. getDescription(): string;
  78393. private _canBeMerged;
  78394. /**
  78395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78396. * @param scene defines the current scene where to apply this optimization
  78397. * @param optimizer defines the current optimizer
  78398. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78399. * @returns true if everything that can be done was applied
  78400. */
  78401. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78402. }
  78403. /**
  78404. * Defines a list of options used by SceneOptimizer
  78405. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78406. */
  78407. export class SceneOptimizerOptions {
  78408. /**
  78409. * Defines the target frame rate to reach (60 by default)
  78410. */
  78411. targetFrameRate: number;
  78412. /**
  78413. * Defines the interval between two checkes (2000ms by default)
  78414. */
  78415. trackerDuration: number;
  78416. /**
  78417. * Gets the list of optimizations to apply
  78418. */
  78419. optimizations: SceneOptimization[];
  78420. /**
  78421. * Creates a new list of options used by SceneOptimizer
  78422. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78423. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78424. */
  78425. constructor(
  78426. /**
  78427. * Defines the target frame rate to reach (60 by default)
  78428. */
  78429. targetFrameRate?: number,
  78430. /**
  78431. * Defines the interval between two checkes (2000ms by default)
  78432. */
  78433. trackerDuration?: number);
  78434. /**
  78435. * Add a new optimization
  78436. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78437. * @returns the current SceneOptimizerOptions
  78438. */
  78439. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78440. /**
  78441. * Add a new custom optimization
  78442. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78443. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78445. * @returns the current SceneOptimizerOptions
  78446. */
  78447. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78448. /**
  78449. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78450. * @param targetFrameRate defines the target frame rate (60 by default)
  78451. * @returns a SceneOptimizerOptions object
  78452. */
  78453. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78454. /**
  78455. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78456. * @param targetFrameRate defines the target frame rate (60 by default)
  78457. * @returns a SceneOptimizerOptions object
  78458. */
  78459. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78460. /**
  78461. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78462. * @param targetFrameRate defines the target frame rate (60 by default)
  78463. * @returns a SceneOptimizerOptions object
  78464. */
  78465. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78466. }
  78467. /**
  78468. * Class used to run optimizations in order to reach a target frame rate
  78469. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78470. */
  78471. export class SceneOptimizer implements IDisposable {
  78472. private _isRunning;
  78473. private _options;
  78474. private _scene;
  78475. private _currentPriorityLevel;
  78476. private _targetFrameRate;
  78477. private _trackerDuration;
  78478. private _currentFrameRate;
  78479. private _sceneDisposeObserver;
  78480. private _improvementMode;
  78481. /**
  78482. * Defines an observable called when the optimizer reaches the target frame rate
  78483. */
  78484. onSuccessObservable: Observable<SceneOptimizer>;
  78485. /**
  78486. * Defines an observable called when the optimizer enables an optimization
  78487. */
  78488. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78489. /**
  78490. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78491. */
  78492. onFailureObservable: Observable<SceneOptimizer>;
  78493. /**
  78494. * Gets a boolean indicating if the optimizer is in improvement mode
  78495. */
  78496. get isInImprovementMode(): boolean;
  78497. /**
  78498. * Gets the current priority level (0 at start)
  78499. */
  78500. get currentPriorityLevel(): number;
  78501. /**
  78502. * Gets the current frame rate checked by the SceneOptimizer
  78503. */
  78504. get currentFrameRate(): number;
  78505. /**
  78506. * Gets or sets the current target frame rate (60 by default)
  78507. */
  78508. get targetFrameRate(): number;
  78509. /**
  78510. * Gets or sets the current target frame rate (60 by default)
  78511. */
  78512. set targetFrameRate(value: number);
  78513. /**
  78514. * Gets or sets the current interval between two checks (every 2000ms by default)
  78515. */
  78516. get trackerDuration(): number;
  78517. /**
  78518. * Gets or sets the current interval between two checks (every 2000ms by default)
  78519. */
  78520. set trackerDuration(value: number);
  78521. /**
  78522. * Gets the list of active optimizations
  78523. */
  78524. get optimizations(): SceneOptimization[];
  78525. /**
  78526. * Creates a new SceneOptimizer
  78527. * @param scene defines the scene to work on
  78528. * @param options defines the options to use with the SceneOptimizer
  78529. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78530. * @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)
  78531. */
  78532. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78533. /**
  78534. * Stops the current optimizer
  78535. */
  78536. stop(): void;
  78537. /**
  78538. * Reset the optimizer to initial step (current priority level = 0)
  78539. */
  78540. reset(): void;
  78541. /**
  78542. * Start the optimizer. By default it will try to reach a specific framerate
  78543. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78544. */
  78545. start(): void;
  78546. private _checkCurrentState;
  78547. /**
  78548. * Release all resources
  78549. */
  78550. dispose(): void;
  78551. /**
  78552. * Helper function to create a SceneOptimizer with one single line of code
  78553. * @param scene defines the scene to work on
  78554. * @param options defines the options to use with the SceneOptimizer
  78555. * @param onSuccess defines a callback to call on success
  78556. * @param onFailure defines a callback to call on failure
  78557. * @returns the new SceneOptimizer object
  78558. */
  78559. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78560. }
  78561. }
  78562. declare module "babylonjs/Misc/sceneSerializer" {
  78563. import { Scene } from "babylonjs/scene";
  78564. /**
  78565. * Class used to serialize a scene into a string
  78566. */
  78567. export class SceneSerializer {
  78568. /**
  78569. * Clear cache used by a previous serialization
  78570. */
  78571. static ClearCache(): void;
  78572. /**
  78573. * Serialize a scene into a JSON compatible object
  78574. * @param scene defines the scene to serialize
  78575. * @returns a JSON compatible object
  78576. */
  78577. static Serialize(scene: Scene): any;
  78578. /**
  78579. * Serialize a mesh into a JSON compatible object
  78580. * @param toSerialize defines the mesh to serialize
  78581. * @param withParents defines if parents must be serialized as well
  78582. * @param withChildren defines if children must be serialized as well
  78583. * @returns a JSON compatible object
  78584. */
  78585. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78586. }
  78587. }
  78588. declare module "babylonjs/Misc/textureTools" {
  78589. import { Texture } from "babylonjs/Materials/Textures/texture";
  78590. /**
  78591. * Class used to host texture specific utilities
  78592. */
  78593. export class TextureTools {
  78594. /**
  78595. * Uses the GPU to create a copy texture rescaled at a given size
  78596. * @param texture Texture to copy from
  78597. * @param width defines the desired width
  78598. * @param height defines the desired height
  78599. * @param useBilinearMode defines if bilinear mode has to be used
  78600. * @return the generated texture
  78601. */
  78602. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78603. }
  78604. }
  78605. declare module "babylonjs/Misc/videoRecorder" {
  78606. import { Nullable } from "babylonjs/types";
  78607. import { Engine } from "babylonjs/Engines/engine";
  78608. /**
  78609. * This represents the different options available for the video capture.
  78610. */
  78611. export interface VideoRecorderOptions {
  78612. /** Defines the mime type of the video. */
  78613. mimeType: string;
  78614. /** Defines the FPS the video should be recorded at. */
  78615. fps: number;
  78616. /** Defines the chunk size for the recording data. */
  78617. recordChunckSize: number;
  78618. /** The audio tracks to attach to the recording. */
  78619. audioTracks?: MediaStreamTrack[];
  78620. }
  78621. /**
  78622. * This can help with recording videos from BabylonJS.
  78623. * This is based on the available WebRTC functionalities of the browser.
  78624. *
  78625. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78626. */
  78627. export class VideoRecorder {
  78628. private static readonly _defaultOptions;
  78629. /**
  78630. * Returns whether or not the VideoRecorder is available in your browser.
  78631. * @param engine Defines the Babylon Engine.
  78632. * @returns true if supported otherwise false.
  78633. */
  78634. static IsSupported(engine: Engine): boolean;
  78635. private readonly _options;
  78636. private _canvas;
  78637. private _mediaRecorder;
  78638. private _recordedChunks;
  78639. private _fileName;
  78640. private _resolve;
  78641. private _reject;
  78642. /**
  78643. * True when a recording is already in progress.
  78644. */
  78645. get isRecording(): boolean;
  78646. /**
  78647. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78648. * @param engine Defines the BabylonJS Engine you wish to record.
  78649. * @param options Defines options that can be used to customize the capture.
  78650. */
  78651. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78652. /**
  78653. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78654. */
  78655. stopRecording(): void;
  78656. /**
  78657. * Starts recording the canvas for a max duration specified in parameters.
  78658. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78659. * If null no automatic download will start and you can rely on the promise to get the data back.
  78660. * @param maxDuration Defines the maximum recording time in seconds.
  78661. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78662. * @return A promise callback at the end of the recording with the video data in Blob.
  78663. */
  78664. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78665. /**
  78666. * Releases internal resources used during the recording.
  78667. */
  78668. dispose(): void;
  78669. private _handleDataAvailable;
  78670. private _handleError;
  78671. private _handleStop;
  78672. }
  78673. }
  78674. declare module "babylonjs/Misc/screenshotTools" {
  78675. import { Camera } from "babylonjs/Cameras/camera";
  78676. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78677. import { Engine } from "babylonjs/Engines/engine";
  78678. /**
  78679. * Class containing a set of static utilities functions for screenshots
  78680. */
  78681. export class ScreenshotTools {
  78682. /**
  78683. * Captures a screenshot of the current rendering
  78684. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78685. * @param engine defines the rendering engine
  78686. * @param camera defines the source camera
  78687. * @param size This parameter can be set to a single number or to an object with the
  78688. * following (optional) properties: precision, width, height. If a single number is passed,
  78689. * it will be used for both width and height. If an object is passed, the screenshot size
  78690. * will be derived from the parameters. The precision property is a multiplier allowing
  78691. * rendering at a higher or lower resolution
  78692. * @param successCallback defines the callback receives a single parameter which contains the
  78693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78694. * src parameter of an <img> to display it
  78695. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78696. * Check your browser for supported MIME types
  78697. */
  78698. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78699. /**
  78700. * Captures a screenshot of the current rendering
  78701. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78702. * @param engine defines the rendering engine
  78703. * @param camera defines the source camera
  78704. * @param size This parameter can be set to a single number or to an object with the
  78705. * following (optional) properties: precision, width, height. If a single number is passed,
  78706. * it will be used for both width and height. If an object is passed, the screenshot size
  78707. * will be derived from the parameters. The precision property is a multiplier allowing
  78708. * rendering at a higher or lower resolution
  78709. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78710. * Check your browser for supported MIME types
  78711. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78712. * to the src parameter of an <img> to display it
  78713. */
  78714. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78715. /**
  78716. * Generates an image screenshot from the specified camera.
  78717. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78718. * @param engine The engine to use for rendering
  78719. * @param camera The camera to use for rendering
  78720. * @param size This parameter can be set to a single number or to an object with the
  78721. * following (optional) properties: precision, width, height. If a single number is passed,
  78722. * it will be used for both width and height. If an object is passed, the screenshot size
  78723. * will be derived from the parameters. The precision property is a multiplier allowing
  78724. * rendering at a higher or lower resolution
  78725. * @param successCallback The callback receives a single parameter which contains the
  78726. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78727. * src parameter of an <img> to display it
  78728. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78729. * Check your browser for supported MIME types
  78730. * @param samples Texture samples (default: 1)
  78731. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78732. * @param fileName A name for for the downloaded file.
  78733. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78734. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78735. */
  78736. 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;
  78737. /**
  78738. * Generates an image screenshot from the specified camera.
  78739. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78740. * @param engine The engine to use for rendering
  78741. * @param camera The camera to use for rendering
  78742. * @param size This parameter can be set to a single number or to an object with the
  78743. * following (optional) properties: precision, width, height. If a single number is passed,
  78744. * it will be used for both width and height. If an object is passed, the screenshot size
  78745. * will be derived from the parameters. The precision property is a multiplier allowing
  78746. * rendering at a higher or lower resolution
  78747. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78748. * Check your browser for supported MIME types
  78749. * @param samples Texture samples (default: 1)
  78750. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78751. * @param fileName A name for for the downloaded file.
  78752. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78753. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78754. * to the src parameter of an <img> to display it
  78755. */
  78756. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78757. /**
  78758. * Gets height and width for screenshot size
  78759. * @private
  78760. */
  78761. private static _getScreenshotSize;
  78762. }
  78763. }
  78764. declare module "babylonjs/Misc/dataReader" {
  78765. /**
  78766. * Interface for a data buffer
  78767. */
  78768. export interface IDataBuffer {
  78769. /**
  78770. * Reads bytes from the data buffer.
  78771. * @param byteOffset The byte offset to read
  78772. * @param byteLength The byte length to read
  78773. * @returns A promise that resolves when the bytes are read
  78774. */
  78775. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78776. /**
  78777. * The byte length of the buffer.
  78778. */
  78779. readonly byteLength: number;
  78780. }
  78781. /**
  78782. * Utility class for reading from a data buffer
  78783. */
  78784. export class DataReader {
  78785. /**
  78786. * The data buffer associated with this data reader.
  78787. */
  78788. readonly buffer: IDataBuffer;
  78789. /**
  78790. * The current byte offset from the beginning of the data buffer.
  78791. */
  78792. byteOffset: number;
  78793. private _dataView;
  78794. private _dataByteOffset;
  78795. /**
  78796. * Constructor
  78797. * @param buffer The buffer to read
  78798. */
  78799. constructor(buffer: IDataBuffer);
  78800. /**
  78801. * Loads the given byte length.
  78802. * @param byteLength The byte length to load
  78803. * @returns A promise that resolves when the load is complete
  78804. */
  78805. loadAsync(byteLength: number): Promise<void>;
  78806. /**
  78807. * Read a unsigned 32-bit integer from the currently loaded data range.
  78808. * @returns The 32-bit integer read
  78809. */
  78810. readUint32(): number;
  78811. /**
  78812. * Read a byte array from the currently loaded data range.
  78813. * @param byteLength The byte length to read
  78814. * @returns The byte array read
  78815. */
  78816. readUint8Array(byteLength: number): Uint8Array;
  78817. /**
  78818. * Read a string from the currently loaded data range.
  78819. * @param byteLength The byte length to read
  78820. * @returns The string read
  78821. */
  78822. readString(byteLength: number): string;
  78823. /**
  78824. * Skips the given byte length the currently loaded data range.
  78825. * @param byteLength The byte length to skip
  78826. */
  78827. skipBytes(byteLength: number): void;
  78828. }
  78829. }
  78830. declare module "babylonjs/Misc/dataStorage" {
  78831. /**
  78832. * Class for storing data to local storage if available or in-memory storage otherwise
  78833. */
  78834. export class DataStorage {
  78835. private static _Storage;
  78836. private static _GetStorage;
  78837. /**
  78838. * Reads a string from the data storage
  78839. * @param key The key to read
  78840. * @param defaultValue The value if the key doesn't exist
  78841. * @returns The string value
  78842. */
  78843. static ReadString(key: string, defaultValue: string): string;
  78844. /**
  78845. * Writes a string to the data storage
  78846. * @param key The key to write
  78847. * @param value The value to write
  78848. */
  78849. static WriteString(key: string, value: string): void;
  78850. /**
  78851. * Reads a boolean from the data storage
  78852. * @param key The key to read
  78853. * @param defaultValue The value if the key doesn't exist
  78854. * @returns The boolean value
  78855. */
  78856. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78857. /**
  78858. * Writes a boolean to the data storage
  78859. * @param key The key to write
  78860. * @param value The value to write
  78861. */
  78862. static WriteBoolean(key: string, value: boolean): void;
  78863. /**
  78864. * Reads a number from the data storage
  78865. * @param key The key to read
  78866. * @param defaultValue The value if the key doesn't exist
  78867. * @returns The number value
  78868. */
  78869. static ReadNumber(key: string, defaultValue: number): number;
  78870. /**
  78871. * Writes a number to the data storage
  78872. * @param key The key to write
  78873. * @param value The value to write
  78874. */
  78875. static WriteNumber(key: string, value: number): void;
  78876. }
  78877. }
  78878. declare module "babylonjs/Misc/sceneRecorder" {
  78879. import { Scene } from "babylonjs/scene";
  78880. /**
  78881. * Class used to record delta files between 2 scene states
  78882. */
  78883. export class SceneRecorder {
  78884. private _trackedScene;
  78885. private _savedJSON;
  78886. /**
  78887. * Track a given scene. This means the current scene state will be considered the original state
  78888. * @param scene defines the scene to track
  78889. */
  78890. track(scene: Scene): void;
  78891. /**
  78892. * Get the delta between current state and original state
  78893. * @returns a string containing the delta
  78894. */
  78895. getDelta(): any;
  78896. private _compareArray;
  78897. private _compareObjects;
  78898. private _compareCollections;
  78899. private static GetShadowGeneratorById;
  78900. /**
  78901. * Apply a given delta to a given scene
  78902. * @param deltaJSON defines the JSON containing the delta
  78903. * @param scene defines the scene to apply the delta to
  78904. */
  78905. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78906. private static _ApplyPropertiesToEntity;
  78907. private static _ApplyDeltaForEntity;
  78908. }
  78909. }
  78910. declare module "babylonjs/Misc/trajectoryClassifier" {
  78911. import { DeepImmutable, Nullable } from "babylonjs/types";
  78912. import { Vector3 } from "babylonjs/Maths/math.vector";
  78913. /**
  78914. * A 3D trajectory consisting of an order list of vectors describing a
  78915. * path of motion through 3D space.
  78916. */
  78917. export class Trajectory {
  78918. private _points;
  78919. private readonly _segmentLength;
  78920. /**
  78921. * Serialize to JSON.
  78922. * @returns serialized JSON string
  78923. */
  78924. serialize(): string;
  78925. /**
  78926. * Deserialize from JSON.
  78927. * @param json serialized JSON string
  78928. * @returns deserialized Trajectory
  78929. */
  78930. static Deserialize(json: string): Trajectory;
  78931. /**
  78932. * Create a new empty Trajectory.
  78933. * @param segmentLength radius of discretization for Trajectory points
  78934. */
  78935. constructor(segmentLength?: number);
  78936. /**
  78937. * Get the length of the Trajectory.
  78938. * @returns length of the Trajectory
  78939. */
  78940. getLength(): number;
  78941. /**
  78942. * Append a new point to the Trajectory.
  78943. * NOTE: This implementation has many allocations.
  78944. * @param point point to append to the Trajectory
  78945. */
  78946. add(point: DeepImmutable<Vector3>): void;
  78947. /**
  78948. * Create a new Trajectory with a segment length chosen to make it
  78949. * probable that the new Trajectory will have a specified number of
  78950. * segments. This operation is imprecise.
  78951. * @param targetResolution number of segments desired
  78952. * @returns new Trajectory with approximately the requested number of segments
  78953. */
  78954. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78955. /**
  78956. * Convert Trajectory segments into tokenized representation. This
  78957. * representation is an array of numbers where each nth number is the
  78958. * index of the token which is most similar to the nth segment of the
  78959. * Trajectory.
  78960. * @param tokens list of vectors which serve as discrete tokens
  78961. * @returns list of indices of most similar token per segment
  78962. */
  78963. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78964. private static _forwardDir;
  78965. private static _inverseFromVec;
  78966. private static _upDir;
  78967. private static _fromToVec;
  78968. private static _lookMatrix;
  78969. /**
  78970. * Transform the rotation (i.e., direction) of a segment to isolate
  78971. * the relative transformation represented by the segment. This operation
  78972. * may or may not succeed due to singularities in the equations that define
  78973. * motion relativity in this context.
  78974. * @param priorVec the origin of the prior segment
  78975. * @param fromVec the origin of the current segment
  78976. * @param toVec the destination of the current segment
  78977. * @param result reference to output variable
  78978. * @returns whether or not transformation was successful
  78979. */
  78980. private static _transformSegmentDirToRef;
  78981. private static _bestMatch;
  78982. private static _score;
  78983. private static _bestScore;
  78984. /**
  78985. * Determine which token vector is most similar to the
  78986. * segment vector.
  78987. * @param segment segment vector
  78988. * @param tokens token vector list
  78989. * @returns index of the most similar token to the segment
  78990. */
  78991. private static _tokenizeSegment;
  78992. }
  78993. /**
  78994. * Class representing a set of known, named trajectories to which Trajectories can be
  78995. * added and using which Trajectories can be recognized.
  78996. */
  78997. export class TrajectoryClassifier {
  78998. private _maximumAllowableMatchCost;
  78999. private _vector3Alphabet;
  79000. private _levenshteinAlphabet;
  79001. private _nameToDescribedTrajectory;
  79002. /**
  79003. * Serialize to JSON.
  79004. * @returns JSON serialization
  79005. */
  79006. serialize(): string;
  79007. /**
  79008. * Deserialize from JSON.
  79009. * @param json JSON serialization
  79010. * @returns deserialized TrajectorySet
  79011. */
  79012. static Deserialize(json: string): TrajectoryClassifier;
  79013. /**
  79014. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79015. * VERY naive, need to be generating these things from known
  79016. * sets. Better version later, probably eliminating this one.
  79017. * @returns auto-generated TrajectorySet
  79018. */
  79019. static Generate(): TrajectoryClassifier;
  79020. private constructor();
  79021. /**
  79022. * Add a new Trajectory to the set with a given name.
  79023. * @param trajectory new Trajectory to be added
  79024. * @param classification name to which to add the Trajectory
  79025. */
  79026. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79027. /**
  79028. * Remove a known named trajectory and all Trajectories associated with it.
  79029. * @param classification name to remove
  79030. * @returns whether anything was removed
  79031. */
  79032. deleteClassification(classification: string): boolean;
  79033. /**
  79034. * Attempt to recognize a Trajectory from among all the classifications
  79035. * already known to the classifier.
  79036. * @param trajectory Trajectory to be recognized
  79037. * @returns classification of Trajectory if recognized, null otherwise
  79038. */
  79039. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79040. }
  79041. }
  79042. declare module "babylonjs/Misc/index" {
  79043. export * from "babylonjs/Misc/andOrNotEvaluator";
  79044. export * from "babylonjs/Misc/assetsManager";
  79045. export * from "babylonjs/Misc/basis";
  79046. export * from "babylonjs/Misc/dds";
  79047. export * from "babylonjs/Misc/decorators";
  79048. export * from "babylonjs/Misc/deferred";
  79049. export * from "babylonjs/Misc/environmentTextureTools";
  79050. export * from "babylonjs/Misc/meshExploder";
  79051. export * from "babylonjs/Misc/filesInput";
  79052. export * from "babylonjs/Misc/HighDynamicRange/index";
  79053. export * from "babylonjs/Misc/khronosTextureContainer";
  79054. export * from "babylonjs/Misc/observable";
  79055. export * from "babylonjs/Misc/performanceMonitor";
  79056. export * from "babylonjs/Misc/promise";
  79057. export * from "babylonjs/Misc/sceneOptimizer";
  79058. export * from "babylonjs/Misc/sceneSerializer";
  79059. export * from "babylonjs/Misc/smartArray";
  79060. export * from "babylonjs/Misc/stringDictionary";
  79061. export * from "babylonjs/Misc/tags";
  79062. export * from "babylonjs/Misc/textureTools";
  79063. export * from "babylonjs/Misc/tga";
  79064. export * from "babylonjs/Misc/tools";
  79065. export * from "babylonjs/Misc/videoRecorder";
  79066. export * from "babylonjs/Misc/virtualJoystick";
  79067. export * from "babylonjs/Misc/workerPool";
  79068. export * from "babylonjs/Misc/logger";
  79069. export * from "babylonjs/Misc/typeStore";
  79070. export * from "babylonjs/Misc/filesInputStore";
  79071. export * from "babylonjs/Misc/deepCopier";
  79072. export * from "babylonjs/Misc/pivotTools";
  79073. export * from "babylonjs/Misc/precisionDate";
  79074. export * from "babylonjs/Misc/screenshotTools";
  79075. export * from "babylonjs/Misc/typeStore";
  79076. export * from "babylonjs/Misc/webRequest";
  79077. export * from "babylonjs/Misc/iInspectable";
  79078. export * from "babylonjs/Misc/brdfTextureTools";
  79079. export * from "babylonjs/Misc/rgbdTextureTools";
  79080. export * from "babylonjs/Misc/gradients";
  79081. export * from "babylonjs/Misc/perfCounter";
  79082. export * from "babylonjs/Misc/fileRequest";
  79083. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79084. export * from "babylonjs/Misc/retryStrategy";
  79085. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79086. export * from "babylonjs/Misc/canvasGenerator";
  79087. export * from "babylonjs/Misc/fileTools";
  79088. export * from "babylonjs/Misc/stringTools";
  79089. export * from "babylonjs/Misc/dataReader";
  79090. export * from "babylonjs/Misc/minMaxReducer";
  79091. export * from "babylonjs/Misc/depthReducer";
  79092. export * from "babylonjs/Misc/dataStorage";
  79093. export * from "babylonjs/Misc/sceneRecorder";
  79094. export * from "babylonjs/Misc/khronosTextureContainer2";
  79095. export * from "babylonjs/Misc/trajectoryClassifier";
  79096. }
  79097. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79098. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79099. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79100. import { Observable } from "babylonjs/Misc/observable";
  79101. import { Matrix } from "babylonjs/Maths/math.vector";
  79102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79103. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79104. /**
  79105. * An interface for all Hit test features
  79106. */
  79107. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79108. /**
  79109. * Triggered when new babylon (transformed) hit test results are available
  79110. */
  79111. onHitTestResultObservable: Observable<T[]>;
  79112. }
  79113. /**
  79114. * Options used for hit testing
  79115. */
  79116. export interface IWebXRLegacyHitTestOptions {
  79117. /**
  79118. * Only test when user interacted with the scene. Default - hit test every frame
  79119. */
  79120. testOnPointerDownOnly?: boolean;
  79121. /**
  79122. * The node to use to transform the local results to world coordinates
  79123. */
  79124. worldParentNode?: TransformNode;
  79125. }
  79126. /**
  79127. * Interface defining the babylon result of raycasting/hit-test
  79128. */
  79129. export interface IWebXRLegacyHitResult {
  79130. /**
  79131. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79132. */
  79133. transformationMatrix: Matrix;
  79134. /**
  79135. * The native hit test result
  79136. */
  79137. xrHitResult: XRHitResult | XRHitTestResult;
  79138. }
  79139. /**
  79140. * The currently-working hit-test module.
  79141. * Hit test (or Ray-casting) is used to interact with the real world.
  79142. * For further information read here - https://github.com/immersive-web/hit-test
  79143. */
  79144. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79145. /**
  79146. * options to use when constructing this feature
  79147. */
  79148. readonly options: IWebXRLegacyHitTestOptions;
  79149. private _direction;
  79150. private _mat;
  79151. private _onSelectEnabled;
  79152. private _origin;
  79153. /**
  79154. * The module's name
  79155. */
  79156. static readonly Name: string;
  79157. /**
  79158. * The (Babylon) version of this module.
  79159. * This is an integer representing the implementation version.
  79160. * This number does not correspond to the WebXR specs version
  79161. */
  79162. static readonly Version: number;
  79163. /**
  79164. * Populated with the last native XR Hit Results
  79165. */
  79166. lastNativeXRHitResults: XRHitResult[];
  79167. /**
  79168. * Triggered when new babylon (transformed) hit test results are available
  79169. */
  79170. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79171. /**
  79172. * Creates a new instance of the (legacy version) hit test feature
  79173. * @param _xrSessionManager an instance of WebXRSessionManager
  79174. * @param options options to use when constructing this feature
  79175. */
  79176. constructor(_xrSessionManager: WebXRSessionManager,
  79177. /**
  79178. * options to use when constructing this feature
  79179. */
  79180. options?: IWebXRLegacyHitTestOptions);
  79181. /**
  79182. * execute a hit test with an XR Ray
  79183. *
  79184. * @param xrSession a native xrSession that will execute this hit test
  79185. * @param xrRay the ray (position and direction) to use for ray-casting
  79186. * @param referenceSpace native XR reference space to use for the hit-test
  79187. * @param filter filter function that will filter the results
  79188. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79189. */
  79190. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79191. /**
  79192. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79193. * @param event the (select) event to use to select with
  79194. * @param referenceSpace the reference space to use for this hit test
  79195. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79196. */
  79197. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79198. /**
  79199. * attach this feature
  79200. * Will usually be called by the features manager
  79201. *
  79202. * @returns true if successful.
  79203. */
  79204. attach(): boolean;
  79205. /**
  79206. * detach this feature.
  79207. * Will usually be called by the features manager
  79208. *
  79209. * @returns true if successful.
  79210. */
  79211. detach(): boolean;
  79212. /**
  79213. * Dispose this feature and all of the resources attached
  79214. */
  79215. dispose(): void;
  79216. protected _onXRFrame(frame: XRFrame): void;
  79217. private _onHitTestResults;
  79218. private _onSelect;
  79219. }
  79220. }
  79221. declare module "babylonjs/XR/features/WebXRHitTest" {
  79222. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79223. import { Observable } from "babylonjs/Misc/observable";
  79224. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79225. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79226. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79227. /**
  79228. * Options used for hit testing (version 2)
  79229. */
  79230. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79231. /**
  79232. * Do not create a permanent hit test. Will usually be used when only
  79233. * transient inputs are needed.
  79234. */
  79235. disablePermanentHitTest?: boolean;
  79236. /**
  79237. * Enable transient (for example touch-based) hit test inspections
  79238. */
  79239. enableTransientHitTest?: boolean;
  79240. /**
  79241. * Offset ray for the permanent hit test
  79242. */
  79243. offsetRay?: Vector3;
  79244. /**
  79245. * Offset ray for the transient hit test
  79246. */
  79247. transientOffsetRay?: Vector3;
  79248. /**
  79249. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79250. */
  79251. useReferenceSpace?: boolean;
  79252. /**
  79253. * Override the default entity type(s) of the hit-test result
  79254. */
  79255. entityTypes?: XRHitTestTrackableType[];
  79256. }
  79257. /**
  79258. * Interface defining the babylon result of hit-test
  79259. */
  79260. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79261. /**
  79262. * The input source that generated this hit test (if transient)
  79263. */
  79264. inputSource?: XRInputSource;
  79265. /**
  79266. * Is this a transient hit test
  79267. */
  79268. isTransient?: boolean;
  79269. /**
  79270. * Position of the hit test result
  79271. */
  79272. position: Vector3;
  79273. /**
  79274. * Rotation of the hit test result
  79275. */
  79276. rotationQuaternion: Quaternion;
  79277. /**
  79278. * The native hit test result
  79279. */
  79280. xrHitResult: XRHitTestResult;
  79281. }
  79282. /**
  79283. * The currently-working hit-test module.
  79284. * Hit test (or Ray-casting) is used to interact with the real world.
  79285. * For further information read here - https://github.com/immersive-web/hit-test
  79286. *
  79287. * Tested on chrome (mobile) 80.
  79288. */
  79289. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79290. /**
  79291. * options to use when constructing this feature
  79292. */
  79293. readonly options: IWebXRHitTestOptions;
  79294. private _tmpMat;
  79295. private _tmpPos;
  79296. private _tmpQuat;
  79297. private _transientXrHitTestSource;
  79298. private _xrHitTestSource;
  79299. private initHitTestSource;
  79300. /**
  79301. * The module's name
  79302. */
  79303. static readonly Name: string;
  79304. /**
  79305. * The (Babylon) version of this module.
  79306. * This is an integer representing the implementation version.
  79307. * This number does not correspond to the WebXR specs version
  79308. */
  79309. static readonly Version: number;
  79310. /**
  79311. * When set to true, each hit test will have its own position/rotation objects
  79312. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79313. * the developers will clone them or copy them as they see fit.
  79314. */
  79315. autoCloneTransformation: boolean;
  79316. /**
  79317. * Triggered when new babylon (transformed) hit test results are available
  79318. * Note - this will be called when results come back from the device. It can be an empty array!!
  79319. */
  79320. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79321. /**
  79322. * Use this to temporarily pause hit test checks.
  79323. */
  79324. paused: boolean;
  79325. /**
  79326. * Creates a new instance of the hit test feature
  79327. * @param _xrSessionManager an instance of WebXRSessionManager
  79328. * @param options options to use when constructing this feature
  79329. */
  79330. constructor(_xrSessionManager: WebXRSessionManager,
  79331. /**
  79332. * options to use when constructing this feature
  79333. */
  79334. options?: IWebXRHitTestOptions);
  79335. /**
  79336. * attach this feature
  79337. * Will usually be called by the features manager
  79338. *
  79339. * @returns true if successful.
  79340. */
  79341. attach(): boolean;
  79342. /**
  79343. * detach this feature.
  79344. * Will usually be called by the features manager
  79345. *
  79346. * @returns true if successful.
  79347. */
  79348. detach(): boolean;
  79349. /**
  79350. * Dispose this feature and all of the resources attached
  79351. */
  79352. dispose(): void;
  79353. protected _onXRFrame(frame: XRFrame): void;
  79354. private _processWebXRHitTestResult;
  79355. }
  79356. }
  79357. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79358. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79359. import { Observable } from "babylonjs/Misc/observable";
  79360. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79361. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79362. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79363. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79364. /**
  79365. * Configuration options of the anchor system
  79366. */
  79367. export interface IWebXRAnchorSystemOptions {
  79368. /**
  79369. * a node that will be used to convert local to world coordinates
  79370. */
  79371. worldParentNode?: TransformNode;
  79372. /**
  79373. * If set to true a reference of the created anchors will be kept until the next session starts
  79374. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79375. */
  79376. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79377. }
  79378. /**
  79379. * A babylon container for an XR Anchor
  79380. */
  79381. export interface IWebXRAnchor {
  79382. /**
  79383. * A babylon-assigned ID for this anchor
  79384. */
  79385. id: number;
  79386. /**
  79387. * Transformation matrix to apply to an object attached to this anchor
  79388. */
  79389. transformationMatrix: Matrix;
  79390. /**
  79391. * The native anchor object
  79392. */
  79393. xrAnchor: XRAnchor;
  79394. /**
  79395. * if defined, this object will be constantly updated by the anchor's position and rotation
  79396. */
  79397. attachedNode?: TransformNode;
  79398. }
  79399. /**
  79400. * An implementation of the anchor system for WebXR.
  79401. * For further information see https://github.com/immersive-web/anchors/
  79402. */
  79403. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79404. private _options;
  79405. private _lastFrameDetected;
  79406. private _trackedAnchors;
  79407. private _referenceSpaceForFrameAnchors;
  79408. private _futureAnchors;
  79409. /**
  79410. * The module's name
  79411. */
  79412. static readonly Name: string;
  79413. /**
  79414. * The (Babylon) version of this module.
  79415. * This is an integer representing the implementation version.
  79416. * This number does not correspond to the WebXR specs version
  79417. */
  79418. static readonly Version: number;
  79419. /**
  79420. * Observers registered here will be executed when a new anchor was added to the session
  79421. */
  79422. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79423. /**
  79424. * Observers registered here will be executed when an anchor was removed from the session
  79425. */
  79426. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79427. /**
  79428. * Observers registered here will be executed when an existing anchor updates
  79429. * This can execute N times every frame
  79430. */
  79431. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79432. /**
  79433. * Set the reference space to use for anchor creation, when not using a hit test.
  79434. * Will default to the session's reference space if not defined
  79435. */
  79436. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79437. /**
  79438. * constructs a new anchor system
  79439. * @param _xrSessionManager an instance of WebXRSessionManager
  79440. * @param _options configuration object for this feature
  79441. */
  79442. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79443. private _tmpVector;
  79444. private _tmpQuaternion;
  79445. private _populateTmpTransformation;
  79446. /**
  79447. * Create a new anchor point using a hit test result at a specific point in the scene
  79448. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79449. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79450. *
  79451. * @param hitTestResult The hit test result to use for this anchor creation
  79452. * @param position an optional position offset for this anchor
  79453. * @param rotationQuaternion an optional rotation offset for this anchor
  79454. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79455. */
  79456. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79457. /**
  79458. * Add a new anchor at a specific position and rotation
  79459. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79460. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79461. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79462. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79463. *
  79464. * @param position the position in which to add an anchor
  79465. * @param rotationQuaternion an optional rotation for the anchor transformation
  79466. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79467. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79468. */
  79469. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79470. /**
  79471. * detach this feature.
  79472. * Will usually be called by the features manager
  79473. *
  79474. * @returns true if successful.
  79475. */
  79476. detach(): boolean;
  79477. /**
  79478. * Dispose this feature and all of the resources attached
  79479. */
  79480. dispose(): void;
  79481. protected _onXRFrame(frame: XRFrame): void;
  79482. /**
  79483. * avoiding using Array.find for global support.
  79484. * @param xrAnchor the plane to find in the array
  79485. */
  79486. private _findIndexInAnchorArray;
  79487. private _updateAnchorWithXRFrame;
  79488. private _createAnchorAtTransformation;
  79489. }
  79490. }
  79491. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79493. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79494. import { Observable } from "babylonjs/Misc/observable";
  79495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79496. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79497. /**
  79498. * Options used in the plane detector module
  79499. */
  79500. export interface IWebXRPlaneDetectorOptions {
  79501. /**
  79502. * The node to use to transform the local results to world coordinates
  79503. */
  79504. worldParentNode?: TransformNode;
  79505. /**
  79506. * If set to true a reference of the created planes will be kept until the next session starts
  79507. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79508. */
  79509. doNotRemovePlanesOnSessionEnded?: boolean;
  79510. }
  79511. /**
  79512. * A babylon interface for a WebXR plane.
  79513. * A Plane is actually a polygon, built from N points in space
  79514. *
  79515. * Supported in chrome 79, not supported in canary 81 ATM
  79516. */
  79517. export interface IWebXRPlane {
  79518. /**
  79519. * a babylon-assigned ID for this polygon
  79520. */
  79521. id: number;
  79522. /**
  79523. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79524. */
  79525. polygonDefinition: Array<Vector3>;
  79526. /**
  79527. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79528. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79529. */
  79530. transformationMatrix: Matrix;
  79531. /**
  79532. * the native xr-plane object
  79533. */
  79534. xrPlane: XRPlane;
  79535. }
  79536. /**
  79537. * The plane detector is used to detect planes in the real world when in AR
  79538. * For more information see https://github.com/immersive-web/real-world-geometry/
  79539. */
  79540. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79541. private _options;
  79542. private _detectedPlanes;
  79543. private _enabled;
  79544. private _lastFrameDetected;
  79545. /**
  79546. * The module's name
  79547. */
  79548. static readonly Name: string;
  79549. /**
  79550. * The (Babylon) version of this module.
  79551. * This is an integer representing the implementation version.
  79552. * This number does not correspond to the WebXR specs version
  79553. */
  79554. static readonly Version: number;
  79555. /**
  79556. * Observers registered here will be executed when a new plane was added to the session
  79557. */
  79558. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79559. /**
  79560. * Observers registered here will be executed when a plane is no longer detected in the session
  79561. */
  79562. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79563. /**
  79564. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79565. * This can execute N times every frame
  79566. */
  79567. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79568. /**
  79569. * construct a new Plane Detector
  79570. * @param _xrSessionManager an instance of xr Session manager
  79571. * @param _options configuration to use when constructing this feature
  79572. */
  79573. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79574. /**
  79575. * detach this feature.
  79576. * Will usually be called by the features manager
  79577. *
  79578. * @returns true if successful.
  79579. */
  79580. detach(): boolean;
  79581. /**
  79582. * Dispose this feature and all of the resources attached
  79583. */
  79584. dispose(): void;
  79585. protected _onXRFrame(frame: XRFrame): void;
  79586. private _init;
  79587. private _updatePlaneWithXRPlane;
  79588. /**
  79589. * avoiding using Array.find for global support.
  79590. * @param xrPlane the plane to find in the array
  79591. */
  79592. private findIndexInPlaneArray;
  79593. }
  79594. }
  79595. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79596. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79598. import { Observable } from "babylonjs/Misc/observable";
  79599. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79600. /**
  79601. * Options interface for the background remover plugin
  79602. */
  79603. export interface IWebXRBackgroundRemoverOptions {
  79604. /**
  79605. * Further background meshes to disable when entering AR
  79606. */
  79607. backgroundMeshes?: AbstractMesh[];
  79608. /**
  79609. * flags to configure the removal of the environment helper.
  79610. * If not set, the entire background will be removed. If set, flags should be set as well.
  79611. */
  79612. environmentHelperRemovalFlags?: {
  79613. /**
  79614. * Should the skybox be removed (default false)
  79615. */
  79616. skyBox?: boolean;
  79617. /**
  79618. * Should the ground be removed (default false)
  79619. */
  79620. ground?: boolean;
  79621. };
  79622. /**
  79623. * don't disable the environment helper
  79624. */
  79625. ignoreEnvironmentHelper?: boolean;
  79626. }
  79627. /**
  79628. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79629. */
  79630. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79631. /**
  79632. * read-only options to be used in this module
  79633. */
  79634. readonly options: IWebXRBackgroundRemoverOptions;
  79635. /**
  79636. * The module's name
  79637. */
  79638. static readonly Name: string;
  79639. /**
  79640. * The (Babylon) version of this module.
  79641. * This is an integer representing the implementation version.
  79642. * This number does not correspond to the WebXR specs version
  79643. */
  79644. static readonly Version: number;
  79645. /**
  79646. * registered observers will be triggered when the background state changes
  79647. */
  79648. onBackgroundStateChangedObservable: Observable<boolean>;
  79649. /**
  79650. * constructs a new background remover module
  79651. * @param _xrSessionManager the session manager for this module
  79652. * @param options read-only options to be used in this module
  79653. */
  79654. constructor(_xrSessionManager: WebXRSessionManager,
  79655. /**
  79656. * read-only options to be used in this module
  79657. */
  79658. options?: IWebXRBackgroundRemoverOptions);
  79659. /**
  79660. * attach this feature
  79661. * Will usually be called by the features manager
  79662. *
  79663. * @returns true if successful.
  79664. */
  79665. attach(): boolean;
  79666. /**
  79667. * detach this feature.
  79668. * Will usually be called by the features manager
  79669. *
  79670. * @returns true if successful.
  79671. */
  79672. detach(): boolean;
  79673. /**
  79674. * Dispose this feature and all of the resources attached
  79675. */
  79676. dispose(): void;
  79677. protected _onXRFrame(_xrFrame: XRFrame): void;
  79678. private _setBackgroundState;
  79679. }
  79680. }
  79681. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79682. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79683. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79684. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79685. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79686. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79687. import { Nullable } from "babylonjs/types";
  79688. /**
  79689. * Options for the controller physics feature
  79690. */
  79691. export class IWebXRControllerPhysicsOptions {
  79692. /**
  79693. * Should the headset get its own impostor
  79694. */
  79695. enableHeadsetImpostor?: boolean;
  79696. /**
  79697. * Optional parameters for the headset impostor
  79698. */
  79699. headsetImpostorParams?: {
  79700. /**
  79701. * The type of impostor to create. Default is sphere
  79702. */
  79703. impostorType: number;
  79704. /**
  79705. * the size of the impostor. Defaults to 10cm
  79706. */
  79707. impostorSize?: number | {
  79708. width: number;
  79709. height: number;
  79710. depth: number;
  79711. };
  79712. /**
  79713. * Friction definitions
  79714. */
  79715. friction?: number;
  79716. /**
  79717. * Restitution
  79718. */
  79719. restitution?: number;
  79720. };
  79721. /**
  79722. * The physics properties of the future impostors
  79723. */
  79724. physicsProperties?: {
  79725. /**
  79726. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79727. * Note that this requires a physics engine that supports mesh impostors!
  79728. */
  79729. useControllerMesh?: boolean;
  79730. /**
  79731. * The type of impostor to create. Default is sphere
  79732. */
  79733. impostorType?: number;
  79734. /**
  79735. * the size of the impostor. Defaults to 10cm
  79736. */
  79737. impostorSize?: number | {
  79738. width: number;
  79739. height: number;
  79740. depth: number;
  79741. };
  79742. /**
  79743. * Friction definitions
  79744. */
  79745. friction?: number;
  79746. /**
  79747. * Restitution
  79748. */
  79749. restitution?: number;
  79750. };
  79751. /**
  79752. * the xr input to use with this pointer selection
  79753. */
  79754. xrInput: WebXRInput;
  79755. }
  79756. /**
  79757. * Add physics impostor to your webxr controllers,
  79758. * including naive calculation of their linear and angular velocity
  79759. */
  79760. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79761. private readonly _options;
  79762. private _attachController;
  79763. private _controllers;
  79764. private _debugMode;
  79765. private _delta;
  79766. private _headsetImpostor?;
  79767. private _headsetMesh?;
  79768. private _lastTimestamp;
  79769. private _tmpQuaternion;
  79770. private _tmpVector;
  79771. /**
  79772. * The module's name
  79773. */
  79774. static readonly Name: string;
  79775. /**
  79776. * The (Babylon) version of this module.
  79777. * This is an integer representing the implementation version.
  79778. * This number does not correspond to the webxr specs version
  79779. */
  79780. static readonly Version: number;
  79781. /**
  79782. * Construct a new Controller Physics Feature
  79783. * @param _xrSessionManager the corresponding xr session manager
  79784. * @param _options options to create this feature with
  79785. */
  79786. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79787. /**
  79788. * @hidden
  79789. * enable debugging - will show console outputs and the impostor mesh
  79790. */
  79791. _enablePhysicsDebug(): void;
  79792. /**
  79793. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79794. * @param xrController the controller to add
  79795. */
  79796. addController(xrController: WebXRInputSource): void;
  79797. /**
  79798. * attach this feature
  79799. * Will usually be called by the features manager
  79800. *
  79801. * @returns true if successful.
  79802. */
  79803. attach(): boolean;
  79804. /**
  79805. * detach this feature.
  79806. * Will usually be called by the features manager
  79807. *
  79808. * @returns true if successful.
  79809. */
  79810. detach(): boolean;
  79811. /**
  79812. * Get the headset impostor, if enabled
  79813. * @returns the impostor
  79814. */
  79815. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79816. /**
  79817. * Get the physics impostor of a specific controller.
  79818. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79819. * @param controller the controller or the controller id of which to get the impostor
  79820. * @returns the impostor or null
  79821. */
  79822. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79823. /**
  79824. * Update the physics properties provided in the constructor
  79825. * @param newProperties the new properties object
  79826. */
  79827. setPhysicsProperties(newProperties: {
  79828. impostorType?: number;
  79829. impostorSize?: number | {
  79830. width: number;
  79831. height: number;
  79832. depth: number;
  79833. };
  79834. friction?: number;
  79835. restitution?: number;
  79836. }): void;
  79837. protected _onXRFrame(_xrFrame: any): void;
  79838. private _detachController;
  79839. }
  79840. }
  79841. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79842. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79843. import { Observable } from "babylonjs/Misc/observable";
  79844. import { Vector3 } from "babylonjs/Maths/math.vector";
  79845. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79846. /**
  79847. * A babylon interface for a "WebXR" feature point.
  79848. * Represents the position and confidence value of a given feature point.
  79849. */
  79850. export interface IWebXRFeaturePoint {
  79851. /**
  79852. * Represents the position of the feature point in world space.
  79853. */
  79854. position: Vector3;
  79855. /**
  79856. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79857. */
  79858. confidenceValue: number;
  79859. }
  79860. /**
  79861. * The feature point system is used to detect feature points from real world geometry.
  79862. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79863. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79864. */
  79865. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79866. private _enabled;
  79867. private _featurePointCloud;
  79868. /**
  79869. * The module's name
  79870. */
  79871. static readonly Name: string;
  79872. /**
  79873. * The (Babylon) version of this module.
  79874. * This is an integer representing the implementation version.
  79875. * This number does not correspond to the WebXR specs version
  79876. */
  79877. static readonly Version: number;
  79878. /**
  79879. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79880. * Will notify the observers about which feature points have been added.
  79881. */
  79882. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79883. /**
  79884. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79885. * Will notify the observers about which feature points have been updated.
  79886. */
  79887. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79888. /**
  79889. * The current feature point cloud maintained across frames.
  79890. */
  79891. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79892. /**
  79893. * construct the feature point system
  79894. * @param _xrSessionManager an instance of xr Session manager
  79895. */
  79896. constructor(_xrSessionManager: WebXRSessionManager);
  79897. /**
  79898. * Detach this feature.
  79899. * Will usually be called by the features manager
  79900. *
  79901. * @returns true if successful.
  79902. */
  79903. detach(): boolean;
  79904. /**
  79905. * Dispose this feature and all of the resources attached
  79906. */
  79907. dispose(): void;
  79908. /**
  79909. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79910. */
  79911. protected _onXRFrame(frame: XRFrame): void;
  79912. /**
  79913. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79914. */
  79915. private _init;
  79916. }
  79917. }
  79918. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79919. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79920. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79922. import { Mesh } from "babylonjs/Meshes/mesh";
  79923. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79924. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79925. import { Nullable } from "babylonjs/types";
  79926. import { IDisposable } from "babylonjs/scene";
  79927. import { Observable } from "babylonjs/Misc/observable";
  79928. /**
  79929. * Configuration interface for the hand tracking feature
  79930. */
  79931. export interface IWebXRHandTrackingOptions {
  79932. /**
  79933. * The xrInput that will be used as source for new hands
  79934. */
  79935. xrInput: WebXRInput;
  79936. /**
  79937. * Configuration object for the joint meshes
  79938. */
  79939. jointMeshes?: {
  79940. /**
  79941. * Should the meshes created be invisible (defaults to false)
  79942. */
  79943. invisible?: boolean;
  79944. /**
  79945. * A source mesh to be used to create instances. Defaults to a sphere.
  79946. * This mesh will be the source for all other (25) meshes.
  79947. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79948. */
  79949. sourceMesh?: Mesh;
  79950. /**
  79951. * Should the source mesh stay visible. Defaults to false
  79952. */
  79953. keepOriginalVisible?: boolean;
  79954. /**
  79955. * Scale factor for all instances (defaults to 2)
  79956. */
  79957. scaleFactor?: number;
  79958. /**
  79959. * Should each instance have its own physics impostor
  79960. */
  79961. enablePhysics?: boolean;
  79962. /**
  79963. * If enabled, override default physics properties
  79964. */
  79965. physicsProps?: {
  79966. friction?: number;
  79967. restitution?: number;
  79968. impostorType?: number;
  79969. };
  79970. /**
  79971. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79972. */
  79973. handMesh?: AbstractMesh;
  79974. };
  79975. }
  79976. /**
  79977. * Parts of the hands divided to writs and finger names
  79978. */
  79979. export const enum HandPart {
  79980. /**
  79981. * HandPart - Wrist
  79982. */
  79983. WRIST = "wrist",
  79984. /**
  79985. * HandPart - The THumb
  79986. */
  79987. THUMB = "thumb",
  79988. /**
  79989. * HandPart - Index finger
  79990. */
  79991. INDEX = "index",
  79992. /**
  79993. * HandPart - Middle finger
  79994. */
  79995. MIDDLE = "middle",
  79996. /**
  79997. * HandPart - Ring finger
  79998. */
  79999. RING = "ring",
  80000. /**
  80001. * HandPart - Little finger
  80002. */
  80003. LITTLE = "little"
  80004. }
  80005. /**
  80006. * Representing a single hand (with its corresponding native XRHand object)
  80007. */
  80008. export class WebXRHand implements IDisposable {
  80009. /** the controller to which the hand correlates */
  80010. readonly xrController: WebXRInputSource;
  80011. /** the meshes to be used to track the hand joints */
  80012. readonly trackedMeshes: AbstractMesh[];
  80013. /**
  80014. * Hand-parts definition (key is HandPart)
  80015. */
  80016. handPartsDefinition: {
  80017. [key: string]: number[];
  80018. };
  80019. /**
  80020. * Populate the HandPartsDefinition object.
  80021. * This is called as a side effect since certain browsers don't have XRHand defined.
  80022. */
  80023. private generateHandPartsDefinition;
  80024. /**
  80025. * Construct a new hand object
  80026. * @param xrController the controller to which the hand correlates
  80027. * @param trackedMeshes the meshes to be used to track the hand joints
  80028. */
  80029. constructor(
  80030. /** the controller to which the hand correlates */
  80031. xrController: WebXRInputSource,
  80032. /** the meshes to be used to track the hand joints */
  80033. trackedMeshes: AbstractMesh[]);
  80034. /**
  80035. * Update this hand from the latest xr frame
  80036. * @param xrFrame xrFrame to update from
  80037. * @param referenceSpace The current viewer reference space
  80038. * @param scaleFactor optional scale factor for the meshes
  80039. */
  80040. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80041. /**
  80042. * Get meshes of part of the hand
  80043. * @param part the part of hand to get
  80044. * @returns An array of meshes that correlate to the hand part requested
  80045. */
  80046. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80047. /**
  80048. * Dispose this Hand object
  80049. */
  80050. dispose(): void;
  80051. }
  80052. /**
  80053. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80054. */
  80055. export class WebXRHandTracking extends WebXRAbstractFeature {
  80056. /**
  80057. * options to use when constructing this feature
  80058. */
  80059. readonly options: IWebXRHandTrackingOptions;
  80060. private static _idCounter;
  80061. /**
  80062. * The module's name
  80063. */
  80064. static readonly Name: string;
  80065. /**
  80066. * The (Babylon) version of this module.
  80067. * This is an integer representing the implementation version.
  80068. * This number does not correspond to the WebXR specs version
  80069. */
  80070. static readonly Version: number;
  80071. /**
  80072. * This observable will notify registered observers when a new hand object was added and initialized
  80073. */
  80074. onHandAddedObservable: Observable<WebXRHand>;
  80075. /**
  80076. * This observable will notify its observers right before the hand object is disposed
  80077. */
  80078. onHandRemovedObservable: Observable<WebXRHand>;
  80079. private _hands;
  80080. /**
  80081. * Creates a new instance of the hit test feature
  80082. * @param _xrSessionManager an instance of WebXRSessionManager
  80083. * @param options options to use when constructing this feature
  80084. */
  80085. constructor(_xrSessionManager: WebXRSessionManager,
  80086. /**
  80087. * options to use when constructing this feature
  80088. */
  80089. options: IWebXRHandTrackingOptions);
  80090. /**
  80091. * Check if the needed objects are defined.
  80092. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80093. */
  80094. isCompatible(): boolean;
  80095. /**
  80096. * attach this feature
  80097. * Will usually be called by the features manager
  80098. *
  80099. * @returns true if successful.
  80100. */
  80101. attach(): boolean;
  80102. /**
  80103. * detach this feature.
  80104. * Will usually be called by the features manager
  80105. *
  80106. * @returns true if successful.
  80107. */
  80108. detach(): boolean;
  80109. /**
  80110. * Dispose this feature and all of the resources attached
  80111. */
  80112. dispose(): void;
  80113. /**
  80114. * Get the hand object according to the controller id
  80115. * @param controllerId the controller id to which we want to get the hand
  80116. * @returns null if not found or the WebXRHand object if found
  80117. */
  80118. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80119. /**
  80120. * Get a hand object according to the requested handedness
  80121. * @param handedness the handedness to request
  80122. * @returns null if not found or the WebXRHand object if found
  80123. */
  80124. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80125. protected _onXRFrame(_xrFrame: XRFrame): void;
  80126. private _attachHand;
  80127. private _detachHand;
  80128. }
  80129. }
  80130. declare module "babylonjs/XR/features/index" {
  80131. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80132. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80133. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80134. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80135. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80136. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80137. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80138. export * from "babylonjs/XR/features/WebXRHitTest";
  80139. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80140. export * from "babylonjs/XR/features/WebXRHandTracking";
  80141. }
  80142. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80143. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80145. import { Scene } from "babylonjs/scene";
  80146. /**
  80147. * The motion controller class for all microsoft mixed reality controllers
  80148. */
  80149. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80150. protected readonly _mapping: {
  80151. defaultButton: {
  80152. valueNodeName: string;
  80153. unpressedNodeName: string;
  80154. pressedNodeName: string;
  80155. };
  80156. defaultAxis: {
  80157. valueNodeName: string;
  80158. minNodeName: string;
  80159. maxNodeName: string;
  80160. };
  80161. buttons: {
  80162. "xr-standard-trigger": {
  80163. rootNodeName: string;
  80164. componentProperty: string;
  80165. states: string[];
  80166. };
  80167. "xr-standard-squeeze": {
  80168. rootNodeName: string;
  80169. componentProperty: string;
  80170. states: string[];
  80171. };
  80172. "xr-standard-touchpad": {
  80173. rootNodeName: string;
  80174. labelAnchorNodeName: string;
  80175. touchPointNodeName: string;
  80176. };
  80177. "xr-standard-thumbstick": {
  80178. rootNodeName: string;
  80179. componentProperty: string;
  80180. states: string[];
  80181. };
  80182. };
  80183. axes: {
  80184. "xr-standard-touchpad": {
  80185. "x-axis": {
  80186. rootNodeName: string;
  80187. };
  80188. "y-axis": {
  80189. rootNodeName: string;
  80190. };
  80191. };
  80192. "xr-standard-thumbstick": {
  80193. "x-axis": {
  80194. rootNodeName: string;
  80195. };
  80196. "y-axis": {
  80197. rootNodeName: string;
  80198. };
  80199. };
  80200. };
  80201. };
  80202. /**
  80203. * The base url used to load the left and right controller models
  80204. */
  80205. static MODEL_BASE_URL: string;
  80206. /**
  80207. * The name of the left controller model file
  80208. */
  80209. static MODEL_LEFT_FILENAME: string;
  80210. /**
  80211. * The name of the right controller model file
  80212. */
  80213. static MODEL_RIGHT_FILENAME: string;
  80214. profileId: string;
  80215. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80216. protected _getFilenameAndPath(): {
  80217. filename: string;
  80218. path: string;
  80219. };
  80220. protected _getModelLoadingConstraints(): boolean;
  80221. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80222. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80223. protected _updateModel(): void;
  80224. }
  80225. }
  80226. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80227. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80229. import { Scene } from "babylonjs/scene";
  80230. /**
  80231. * The motion controller class for oculus touch (quest, rift).
  80232. * This class supports legacy mapping as well the standard xr mapping
  80233. */
  80234. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80235. private _forceLegacyControllers;
  80236. private _modelRootNode;
  80237. /**
  80238. * The base url used to load the left and right controller models
  80239. */
  80240. static MODEL_BASE_URL: string;
  80241. /**
  80242. * The name of the left controller model file
  80243. */
  80244. static MODEL_LEFT_FILENAME: string;
  80245. /**
  80246. * The name of the right controller model file
  80247. */
  80248. static MODEL_RIGHT_FILENAME: string;
  80249. /**
  80250. * Base Url for the Quest controller model.
  80251. */
  80252. static QUEST_MODEL_BASE_URL: string;
  80253. profileId: string;
  80254. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80255. protected _getFilenameAndPath(): {
  80256. filename: string;
  80257. path: string;
  80258. };
  80259. protected _getModelLoadingConstraints(): boolean;
  80260. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80261. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80262. protected _updateModel(): void;
  80263. /**
  80264. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80265. * between the touch and touch 2.
  80266. */
  80267. private _isQuest;
  80268. }
  80269. }
  80270. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80271. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80272. import { Scene } from "babylonjs/scene";
  80273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80274. /**
  80275. * The motion controller class for the standard HTC-Vive controllers
  80276. */
  80277. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80278. private _modelRootNode;
  80279. /**
  80280. * The base url used to load the left and right controller models
  80281. */
  80282. static MODEL_BASE_URL: string;
  80283. /**
  80284. * File name for the controller model.
  80285. */
  80286. static MODEL_FILENAME: string;
  80287. profileId: string;
  80288. /**
  80289. * Create a new Vive motion controller object
  80290. * @param scene the scene to use to create this controller
  80291. * @param gamepadObject the corresponding gamepad object
  80292. * @param handedness the handedness of the controller
  80293. */
  80294. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80295. protected _getFilenameAndPath(): {
  80296. filename: string;
  80297. path: string;
  80298. };
  80299. protected _getModelLoadingConstraints(): boolean;
  80300. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80301. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80302. protected _updateModel(): void;
  80303. }
  80304. }
  80305. declare module "babylonjs/XR/motionController/index" {
  80306. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80307. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80308. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80309. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80310. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80311. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80312. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80313. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80314. }
  80315. declare module "babylonjs/XR/index" {
  80316. export * from "babylonjs/XR/webXRCamera";
  80317. export * from "babylonjs/XR/webXREnterExitUI";
  80318. export * from "babylonjs/XR/webXRExperienceHelper";
  80319. export * from "babylonjs/XR/webXRInput";
  80320. export * from "babylonjs/XR/webXRInputSource";
  80321. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80322. export * from "babylonjs/XR/webXRTypes";
  80323. export * from "babylonjs/XR/webXRSessionManager";
  80324. export * from "babylonjs/XR/webXRDefaultExperience";
  80325. export * from "babylonjs/XR/webXRFeaturesManager";
  80326. export * from "babylonjs/XR/features/index";
  80327. export * from "babylonjs/XR/motionController/index";
  80328. }
  80329. declare module "babylonjs/index" {
  80330. export * from "babylonjs/abstractScene";
  80331. export * from "babylonjs/Actions/index";
  80332. export * from "babylonjs/Animations/index";
  80333. export * from "babylonjs/assetContainer";
  80334. export * from "babylonjs/Audio/index";
  80335. export * from "babylonjs/Behaviors/index";
  80336. export * from "babylonjs/Bones/index";
  80337. export * from "babylonjs/Cameras/index";
  80338. export * from "babylonjs/Collisions/index";
  80339. export * from "babylonjs/Culling/index";
  80340. export * from "babylonjs/Debug/index";
  80341. export * from "babylonjs/DeviceInput/index";
  80342. export * from "babylonjs/Engines/index";
  80343. export * from "babylonjs/Events/index";
  80344. export * from "babylonjs/Gamepads/index";
  80345. export * from "babylonjs/Gizmos/index";
  80346. export * from "babylonjs/Helpers/index";
  80347. export * from "babylonjs/Instrumentation/index";
  80348. export * from "babylonjs/Layers/index";
  80349. export * from "babylonjs/LensFlares/index";
  80350. export * from "babylonjs/Lights/index";
  80351. export * from "babylonjs/Loading/index";
  80352. export * from "babylonjs/Materials/index";
  80353. export * from "babylonjs/Maths/index";
  80354. export * from "babylonjs/Meshes/index";
  80355. export * from "babylonjs/Morph/index";
  80356. export * from "babylonjs/Navigation/index";
  80357. export * from "babylonjs/node";
  80358. export * from "babylonjs/Offline/index";
  80359. export * from "babylonjs/Particles/index";
  80360. export * from "babylonjs/Physics/index";
  80361. export * from "babylonjs/PostProcesses/index";
  80362. export * from "babylonjs/Probes/index";
  80363. export * from "babylonjs/Rendering/index";
  80364. export * from "babylonjs/scene";
  80365. export * from "babylonjs/sceneComponent";
  80366. export * from "babylonjs/Sprites/index";
  80367. export * from "babylonjs/States/index";
  80368. export * from "babylonjs/Misc/index";
  80369. export * from "babylonjs/XR/index";
  80370. export * from "babylonjs/types";
  80371. }
  80372. declare module "babylonjs/Animations/pathCursor" {
  80373. import { Vector3 } from "babylonjs/Maths/math.vector";
  80374. import { Path2 } from "babylonjs/Maths/math.path";
  80375. /**
  80376. * A cursor which tracks a point on a path
  80377. */
  80378. export class PathCursor {
  80379. private path;
  80380. /**
  80381. * Stores path cursor callbacks for when an onchange event is triggered
  80382. */
  80383. private _onchange;
  80384. /**
  80385. * The value of the path cursor
  80386. */
  80387. value: number;
  80388. /**
  80389. * The animation array of the path cursor
  80390. */
  80391. animations: Animation[];
  80392. /**
  80393. * Initializes the path cursor
  80394. * @param path The path to track
  80395. */
  80396. constructor(path: Path2);
  80397. /**
  80398. * Gets the cursor point on the path
  80399. * @returns A point on the path cursor at the cursor location
  80400. */
  80401. getPoint(): Vector3;
  80402. /**
  80403. * Moves the cursor ahead by the step amount
  80404. * @param step The amount to move the cursor forward
  80405. * @returns This path cursor
  80406. */
  80407. moveAhead(step?: number): PathCursor;
  80408. /**
  80409. * Moves the cursor behind by the step amount
  80410. * @param step The amount to move the cursor back
  80411. * @returns This path cursor
  80412. */
  80413. moveBack(step?: number): PathCursor;
  80414. /**
  80415. * Moves the cursor by the step amount
  80416. * If the step amount is greater than one, an exception is thrown
  80417. * @param step The amount to move the cursor
  80418. * @returns This path cursor
  80419. */
  80420. move(step: number): PathCursor;
  80421. /**
  80422. * Ensures that the value is limited between zero and one
  80423. * @returns This path cursor
  80424. */
  80425. private ensureLimits;
  80426. /**
  80427. * Runs onchange callbacks on change (used by the animation engine)
  80428. * @returns This path cursor
  80429. */
  80430. private raiseOnChange;
  80431. /**
  80432. * Executes a function on change
  80433. * @param f A path cursor onchange callback
  80434. * @returns This path cursor
  80435. */
  80436. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80437. }
  80438. }
  80439. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80440. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80441. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80442. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80443. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80444. }
  80445. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80446. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80447. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80448. }
  80449. declare module "babylonjs/Engines/Processors/index" {
  80450. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80451. export * from "babylonjs/Engines/Processors/Expressions/index";
  80452. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80453. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80454. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80455. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80456. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80457. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80458. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80459. }
  80460. declare module "babylonjs/Legacy/legacy" {
  80461. import * as Babylon from "babylonjs/index";
  80462. export * from "babylonjs/index";
  80463. }
  80464. declare module "babylonjs/Shaders/blur.fragment" {
  80465. /** @hidden */
  80466. export var blurPixelShader: {
  80467. name: string;
  80468. shader: string;
  80469. };
  80470. }
  80471. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80472. /** @hidden */
  80473. export var pointCloudVertexDeclaration: {
  80474. name: string;
  80475. shader: string;
  80476. };
  80477. }
  80478. declare module "babylonjs" {
  80479. export * from "babylonjs/Legacy/legacy";
  80480. }
  80481. declare module BABYLON {
  80482. /** Alias type for value that can be null */
  80483. export type Nullable<T> = T | null;
  80484. /**
  80485. * Alias type for number that are floats
  80486. * @ignorenaming
  80487. */
  80488. export type float = number;
  80489. /**
  80490. * Alias type for number that are doubles.
  80491. * @ignorenaming
  80492. */
  80493. export type double = number;
  80494. /**
  80495. * Alias type for number that are integer
  80496. * @ignorenaming
  80497. */
  80498. export type int = number;
  80499. /** Alias type for number array or Float32Array */
  80500. export type FloatArray = number[] | Float32Array;
  80501. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80502. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80503. /**
  80504. * Alias for types that can be used by a Buffer or VertexBuffer.
  80505. */
  80506. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80507. /**
  80508. * Alias type for primitive types
  80509. * @ignorenaming
  80510. */
  80511. type Primitive = undefined | null | boolean | string | number | Function;
  80512. /**
  80513. * Type modifier to make all the properties of an object Readonly
  80514. */
  80515. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80516. /**
  80517. * Type modifier to make all the properties of an object Readonly recursively
  80518. */
  80519. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80520. /**
  80521. * Type modifier to make object properties readonly.
  80522. */
  80523. export type DeepImmutableObject<T> = {
  80524. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80525. };
  80526. /** @hidden */
  80527. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80528. }
  80529. }
  80530. declare module BABYLON {
  80531. /**
  80532. * A class serves as a medium between the observable and its observers
  80533. */
  80534. export class EventState {
  80535. /**
  80536. * Create a new EventState
  80537. * @param mask defines the mask associated with this state
  80538. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80539. * @param target defines the original target of the state
  80540. * @param currentTarget defines the current target of the state
  80541. */
  80542. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80543. /**
  80544. * Initialize the current event state
  80545. * @param mask defines the mask associated with this state
  80546. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80547. * @param target defines the original target of the state
  80548. * @param currentTarget defines the current target of the state
  80549. * @returns the current event state
  80550. */
  80551. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80552. /**
  80553. * An Observer can set this property to true to prevent subsequent observers of being notified
  80554. */
  80555. skipNextObservers: boolean;
  80556. /**
  80557. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80558. */
  80559. mask: number;
  80560. /**
  80561. * The object that originally notified the event
  80562. */
  80563. target?: any;
  80564. /**
  80565. * The current object in the bubbling phase
  80566. */
  80567. currentTarget?: any;
  80568. /**
  80569. * This will be populated with the return value of the last function that was executed.
  80570. * If it is the first function in the callback chain it will be the event data.
  80571. */
  80572. lastReturnValue?: any;
  80573. }
  80574. /**
  80575. * Represent an Observer registered to a given Observable object.
  80576. */
  80577. export class Observer<T> {
  80578. /**
  80579. * Defines the callback to call when the observer is notified
  80580. */
  80581. callback: (eventData: T, eventState: EventState) => void;
  80582. /**
  80583. * Defines the mask of the observer (used to filter notifications)
  80584. */
  80585. mask: number;
  80586. /**
  80587. * Defines the current scope used to restore the JS context
  80588. */
  80589. scope: any;
  80590. /** @hidden */
  80591. _willBeUnregistered: boolean;
  80592. /**
  80593. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80594. */
  80595. unregisterOnNextCall: boolean;
  80596. /**
  80597. * Creates a new observer
  80598. * @param callback defines the callback to call when the observer is notified
  80599. * @param mask defines the mask of the observer (used to filter notifications)
  80600. * @param scope defines the current scope used to restore the JS context
  80601. */
  80602. constructor(
  80603. /**
  80604. * Defines the callback to call when the observer is notified
  80605. */
  80606. callback: (eventData: T, eventState: EventState) => void,
  80607. /**
  80608. * Defines the mask of the observer (used to filter notifications)
  80609. */
  80610. mask: number,
  80611. /**
  80612. * Defines the current scope used to restore the JS context
  80613. */
  80614. scope?: any);
  80615. }
  80616. /**
  80617. * Represent a list of observers registered to multiple Observables object.
  80618. */
  80619. export class MultiObserver<T> {
  80620. private _observers;
  80621. private _observables;
  80622. /**
  80623. * Release associated resources
  80624. */
  80625. dispose(): void;
  80626. /**
  80627. * Raise a callback when one of the observable will notify
  80628. * @param observables defines a list of observables to watch
  80629. * @param callback defines the callback to call on notification
  80630. * @param mask defines the mask used to filter notifications
  80631. * @param scope defines the current scope used to restore the JS context
  80632. * @returns the new MultiObserver
  80633. */
  80634. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80635. }
  80636. /**
  80637. * The Observable class is a simple implementation of the Observable pattern.
  80638. *
  80639. * 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.
  80640. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80641. * 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).
  80642. * 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.
  80643. */
  80644. export class Observable<T> {
  80645. private _observers;
  80646. private _eventState;
  80647. private _onObserverAdded;
  80648. /**
  80649. * Gets the list of observers
  80650. */
  80651. get observers(): Array<Observer<T>>;
  80652. /**
  80653. * Creates a new observable
  80654. * @param onObserverAdded defines a callback to call when a new observer is added
  80655. */
  80656. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80657. /**
  80658. * Create a new Observer with the specified callback
  80659. * @param callback the callback that will be executed for that Observer
  80660. * @param mask the mask used to filter observers
  80661. * @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.
  80662. * @param scope optional scope for the callback to be called from
  80663. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80664. * @returns the new observer created for the callback
  80665. */
  80666. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80667. /**
  80668. * Create a new Observer with the specified callback and unregisters after the next notification
  80669. * @param callback the callback that will be executed for that Observer
  80670. * @returns the new observer created for the callback
  80671. */
  80672. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80673. /**
  80674. * Remove an Observer from the Observable object
  80675. * @param observer the instance of the Observer to remove
  80676. * @returns false if it doesn't belong to this Observable
  80677. */
  80678. remove(observer: Nullable<Observer<T>>): boolean;
  80679. /**
  80680. * Remove a callback from the Observable object
  80681. * @param callback the callback to remove
  80682. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80683. * @returns false if it doesn't belong to this Observable
  80684. */
  80685. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80686. private _deferUnregister;
  80687. private _remove;
  80688. /**
  80689. * Moves the observable to the top of the observer list making it get called first when notified
  80690. * @param observer the observer to move
  80691. */
  80692. makeObserverTopPriority(observer: Observer<T>): void;
  80693. /**
  80694. * Moves the observable to the bottom of the observer list making it get called last when notified
  80695. * @param observer the observer to move
  80696. */
  80697. makeObserverBottomPriority(observer: Observer<T>): void;
  80698. /**
  80699. * Notify all Observers by calling their respective callback with the given data
  80700. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80701. * @param eventData defines the data to send to all observers
  80702. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80703. * @param target defines the original target of the state
  80704. * @param currentTarget defines the current target of the state
  80705. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80706. */
  80707. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80708. /**
  80709. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80710. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80711. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80712. * and it is crucial that all callbacks will be executed.
  80713. * The order of the callbacks is kept, callbacks are not executed parallel.
  80714. *
  80715. * @param eventData The data to be sent to each callback
  80716. * @param mask is used to filter observers defaults to -1
  80717. * @param target defines the callback target (see EventState)
  80718. * @param currentTarget defines he current object in the bubbling phase
  80719. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80720. */
  80721. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80722. /**
  80723. * Notify a specific observer
  80724. * @param observer defines the observer to notify
  80725. * @param eventData defines the data to be sent to each callback
  80726. * @param mask is used to filter observers defaults to -1
  80727. */
  80728. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80729. /**
  80730. * Gets a boolean indicating if the observable has at least one observer
  80731. * @returns true is the Observable has at least one Observer registered
  80732. */
  80733. hasObservers(): boolean;
  80734. /**
  80735. * Clear the list of observers
  80736. */
  80737. clear(): void;
  80738. /**
  80739. * Clone the current observable
  80740. * @returns a new observable
  80741. */
  80742. clone(): Observable<T>;
  80743. /**
  80744. * Does this observable handles observer registered with a given mask
  80745. * @param mask defines the mask to be tested
  80746. * @return whether or not one observer registered with the given mask is handeled
  80747. **/
  80748. hasSpecificMask(mask?: number): boolean;
  80749. }
  80750. }
  80751. declare module BABYLON {
  80752. /**
  80753. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80754. * Babylon.js
  80755. */
  80756. export class DomManagement {
  80757. /**
  80758. * Checks if the window object exists
  80759. * @returns true if the window object exists
  80760. */
  80761. static IsWindowObjectExist(): boolean;
  80762. /**
  80763. * Checks if the navigator object exists
  80764. * @returns true if the navigator object exists
  80765. */
  80766. static IsNavigatorAvailable(): boolean;
  80767. /**
  80768. * Check if the document object exists
  80769. * @returns true if the document object exists
  80770. */
  80771. static IsDocumentAvailable(): boolean;
  80772. /**
  80773. * Extracts text content from a DOM element hierarchy
  80774. * @param element defines the root element
  80775. * @returns a string
  80776. */
  80777. static GetDOMTextContent(element: HTMLElement): string;
  80778. }
  80779. }
  80780. declare module BABYLON {
  80781. /**
  80782. * Logger used througouht the application to allow configuration of
  80783. * the log level required for the messages.
  80784. */
  80785. export class Logger {
  80786. /**
  80787. * No log
  80788. */
  80789. static readonly NoneLogLevel: number;
  80790. /**
  80791. * Only message logs
  80792. */
  80793. static readonly MessageLogLevel: number;
  80794. /**
  80795. * Only warning logs
  80796. */
  80797. static readonly WarningLogLevel: number;
  80798. /**
  80799. * Only error logs
  80800. */
  80801. static readonly ErrorLogLevel: number;
  80802. /**
  80803. * All logs
  80804. */
  80805. static readonly AllLogLevel: number;
  80806. private static _LogCache;
  80807. /**
  80808. * Gets a value indicating the number of loading errors
  80809. * @ignorenaming
  80810. */
  80811. static errorsCount: number;
  80812. /**
  80813. * Callback called when a new log is added
  80814. */
  80815. static OnNewCacheEntry: (entry: string) => void;
  80816. private static _AddLogEntry;
  80817. private static _FormatMessage;
  80818. private static _LogDisabled;
  80819. private static _LogEnabled;
  80820. private static _WarnDisabled;
  80821. private static _WarnEnabled;
  80822. private static _ErrorDisabled;
  80823. private static _ErrorEnabled;
  80824. /**
  80825. * Log a message to the console
  80826. */
  80827. static Log: (message: string) => void;
  80828. /**
  80829. * Write a warning message to the console
  80830. */
  80831. static Warn: (message: string) => void;
  80832. /**
  80833. * Write an error message to the console
  80834. */
  80835. static Error: (message: string) => void;
  80836. /**
  80837. * Gets current log cache (list of logs)
  80838. */
  80839. static get LogCache(): string;
  80840. /**
  80841. * Clears the log cache
  80842. */
  80843. static ClearLogCache(): void;
  80844. /**
  80845. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80846. */
  80847. static set LogLevels(level: number);
  80848. }
  80849. }
  80850. declare module BABYLON {
  80851. /** @hidden */
  80852. export class _TypeStore {
  80853. /** @hidden */
  80854. static RegisteredTypes: {
  80855. [key: string]: Object;
  80856. };
  80857. /** @hidden */
  80858. static GetClass(fqdn: string): any;
  80859. }
  80860. }
  80861. declare module BABYLON {
  80862. /**
  80863. * Helper to manipulate strings
  80864. */
  80865. export class StringTools {
  80866. /**
  80867. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80868. * @param str Source string
  80869. * @param suffix Suffix to search for in the source string
  80870. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80871. */
  80872. static EndsWith(str: string, suffix: string): boolean;
  80873. /**
  80874. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80875. * @param str Source string
  80876. * @param suffix Suffix to search for in the source string
  80877. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80878. */
  80879. static StartsWith(str: string, suffix: string): boolean;
  80880. /**
  80881. * Decodes a buffer into a string
  80882. * @param buffer The buffer to decode
  80883. * @returns The decoded string
  80884. */
  80885. static Decode(buffer: Uint8Array | Uint16Array): string;
  80886. /**
  80887. * Encode a buffer to a base64 string
  80888. * @param buffer defines the buffer to encode
  80889. * @returns the encoded string
  80890. */
  80891. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80892. /**
  80893. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80894. * @param num the number to convert and pad
  80895. * @param length the expected length of the string
  80896. * @returns the padded string
  80897. */
  80898. static PadNumber(num: number, length: number): string;
  80899. }
  80900. }
  80901. declare module BABYLON {
  80902. /**
  80903. * Class containing a set of static utilities functions for deep copy.
  80904. */
  80905. export class DeepCopier {
  80906. /**
  80907. * Tries to copy an object by duplicating every property
  80908. * @param source defines the source object
  80909. * @param destination defines the target object
  80910. * @param doNotCopyList defines a list of properties to avoid
  80911. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80912. */
  80913. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80914. }
  80915. }
  80916. declare module BABYLON {
  80917. /**
  80918. * Class containing a set of static utilities functions for precision date
  80919. */
  80920. export class PrecisionDate {
  80921. /**
  80922. * Gets either window.performance.now() if supported or Date.now() else
  80923. */
  80924. static get Now(): number;
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. /** @hidden */
  80929. export class _DevTools {
  80930. static WarnImport(name: string): string;
  80931. }
  80932. }
  80933. declare module BABYLON {
  80934. /**
  80935. * Interface used to define the mechanism to get data from the network
  80936. */
  80937. export interface IWebRequest {
  80938. /**
  80939. * Returns client's response url
  80940. */
  80941. responseURL: string;
  80942. /**
  80943. * Returns client's status
  80944. */
  80945. status: number;
  80946. /**
  80947. * Returns client's status as a text
  80948. */
  80949. statusText: string;
  80950. }
  80951. }
  80952. declare module BABYLON {
  80953. /**
  80954. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80955. */
  80956. export class WebRequest implements IWebRequest {
  80957. private _xhr;
  80958. /**
  80959. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80960. * i.e. when loading files, where the server/service expects an Authorization header
  80961. */
  80962. static CustomRequestHeaders: {
  80963. [key: string]: string;
  80964. };
  80965. /**
  80966. * Add callback functions in this array to update all the requests before they get sent to the network
  80967. */
  80968. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80969. private _injectCustomRequestHeaders;
  80970. /**
  80971. * Gets or sets a function to be called when loading progress changes
  80972. */
  80973. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80974. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80975. /**
  80976. * Returns client's state
  80977. */
  80978. get readyState(): number;
  80979. /**
  80980. * Returns client's status
  80981. */
  80982. get status(): number;
  80983. /**
  80984. * Returns client's status as a text
  80985. */
  80986. get statusText(): string;
  80987. /**
  80988. * Returns client's response
  80989. */
  80990. get response(): any;
  80991. /**
  80992. * Returns client's response url
  80993. */
  80994. get responseURL(): string;
  80995. /**
  80996. * Returns client's response as text
  80997. */
  80998. get responseText(): string;
  80999. /**
  81000. * Gets or sets the expected response type
  81001. */
  81002. get responseType(): XMLHttpRequestResponseType;
  81003. set responseType(value: XMLHttpRequestResponseType);
  81004. /** @hidden */
  81005. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81006. /** @hidden */
  81007. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81008. /**
  81009. * Cancels any network activity
  81010. */
  81011. abort(): void;
  81012. /**
  81013. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81014. * @param body defines an optional request body
  81015. */
  81016. send(body?: Document | BodyInit | null): void;
  81017. /**
  81018. * Sets the request method, request URL
  81019. * @param method defines the method to use (GET, POST, etc..)
  81020. * @param url defines the url to connect with
  81021. */
  81022. open(method: string, url: string): void;
  81023. /**
  81024. * Sets the value of a request header.
  81025. * @param name The name of the header whose value is to be set
  81026. * @param value The value to set as the body of the header
  81027. */
  81028. setRequestHeader(name: string, value: string): void;
  81029. /**
  81030. * Get the string containing the text of a particular header's value.
  81031. * @param name The name of the header
  81032. * @returns The string containing the text of the given header name
  81033. */
  81034. getResponseHeader(name: string): Nullable<string>;
  81035. }
  81036. }
  81037. declare module BABYLON {
  81038. /**
  81039. * File request interface
  81040. */
  81041. export interface IFileRequest {
  81042. /**
  81043. * Raised when the request is complete (success or error).
  81044. */
  81045. onCompleteObservable: Observable<IFileRequest>;
  81046. /**
  81047. * Aborts the request for a file.
  81048. */
  81049. abort: () => void;
  81050. }
  81051. }
  81052. declare module BABYLON {
  81053. /**
  81054. * Define options used to create a render target texture
  81055. */
  81056. export class RenderTargetCreationOptions {
  81057. /**
  81058. * Specifies is mipmaps must be generated
  81059. */
  81060. generateMipMaps?: boolean;
  81061. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81062. generateDepthBuffer?: boolean;
  81063. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81064. generateStencilBuffer?: boolean;
  81065. /** Defines texture type (int by default) */
  81066. type?: number;
  81067. /** Defines sampling mode (trilinear by default) */
  81068. samplingMode?: number;
  81069. /** Defines format (RGBA by default) */
  81070. format?: number;
  81071. }
  81072. }
  81073. declare module BABYLON {
  81074. /** Defines the cross module used constants to avoid circular dependncies */
  81075. export class Constants {
  81076. /** Defines that alpha blending is disabled */
  81077. static readonly ALPHA_DISABLE: number;
  81078. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81079. static readonly ALPHA_ADD: number;
  81080. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81081. static readonly ALPHA_COMBINE: number;
  81082. /** Defines that alpha blending is DEST - SRC * DEST */
  81083. static readonly ALPHA_SUBTRACT: number;
  81084. /** Defines that alpha blending is SRC * DEST */
  81085. static readonly ALPHA_MULTIPLY: number;
  81086. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81087. static readonly ALPHA_MAXIMIZED: number;
  81088. /** Defines that alpha blending is SRC + DEST */
  81089. static readonly ALPHA_ONEONE: number;
  81090. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81091. static readonly ALPHA_PREMULTIPLIED: number;
  81092. /**
  81093. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81094. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81095. */
  81096. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81097. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81098. static readonly ALPHA_INTERPOLATE: number;
  81099. /**
  81100. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81101. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81102. */
  81103. static readonly ALPHA_SCREENMODE: number;
  81104. /**
  81105. * Defines that alpha blending is SRC + DST
  81106. * Alpha will be set to SRC ALPHA + DST ALPHA
  81107. */
  81108. static readonly ALPHA_ONEONE_ONEONE: number;
  81109. /**
  81110. * Defines that alpha blending is SRC * DST ALPHA + DST
  81111. * Alpha will be set to 0
  81112. */
  81113. static readonly ALPHA_ALPHATOCOLOR: number;
  81114. /**
  81115. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81116. */
  81117. static readonly ALPHA_REVERSEONEMINUS: number;
  81118. /**
  81119. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81120. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81121. */
  81122. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81123. /**
  81124. * Defines that alpha blending is SRC + DST
  81125. * Alpha will be set to SRC ALPHA
  81126. */
  81127. static readonly ALPHA_ONEONE_ONEZERO: number;
  81128. /**
  81129. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81130. * Alpha will be set to DST ALPHA
  81131. */
  81132. static readonly ALPHA_EXCLUSION: number;
  81133. /** Defines that alpha blending equation a SUM */
  81134. static readonly ALPHA_EQUATION_ADD: number;
  81135. /** Defines that alpha blending equation a SUBSTRACTION */
  81136. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81137. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81138. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81139. /** Defines that alpha blending equation a MAX operation */
  81140. static readonly ALPHA_EQUATION_MAX: number;
  81141. /** Defines that alpha blending equation a MIN operation */
  81142. static readonly ALPHA_EQUATION_MIN: number;
  81143. /**
  81144. * Defines that alpha blending equation a DARKEN operation:
  81145. * It takes the min of the src and sums the alpha channels.
  81146. */
  81147. static readonly ALPHA_EQUATION_DARKEN: number;
  81148. /** Defines that the ressource is not delayed*/
  81149. static readonly DELAYLOADSTATE_NONE: number;
  81150. /** Defines that the ressource was successfully delay loaded */
  81151. static readonly DELAYLOADSTATE_LOADED: number;
  81152. /** Defines that the ressource is currently delay loading */
  81153. static readonly DELAYLOADSTATE_LOADING: number;
  81154. /** Defines that the ressource is delayed and has not started loading */
  81155. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81156. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81157. static readonly NEVER: number;
  81158. /** 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 */
  81159. static readonly ALWAYS: number;
  81160. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81161. static readonly LESS: number;
  81162. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81163. static readonly EQUAL: number;
  81164. /** 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 */
  81165. static readonly LEQUAL: number;
  81166. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81167. static readonly GREATER: number;
  81168. /** 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 */
  81169. static readonly GEQUAL: number;
  81170. /** 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 */
  81171. static readonly NOTEQUAL: number;
  81172. /** Passed to stencilOperation to specify that stencil value must be kept */
  81173. static readonly KEEP: number;
  81174. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81175. static readonly REPLACE: number;
  81176. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81177. static readonly INCR: number;
  81178. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81179. static readonly DECR: number;
  81180. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81181. static readonly INVERT: number;
  81182. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81183. static readonly INCR_WRAP: number;
  81184. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81185. static readonly DECR_WRAP: number;
  81186. /** Texture is not repeating outside of 0..1 UVs */
  81187. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81188. /** Texture is repeating outside of 0..1 UVs */
  81189. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81190. /** Texture is repeating and mirrored */
  81191. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81192. /** ALPHA */
  81193. static readonly TEXTUREFORMAT_ALPHA: number;
  81194. /** LUMINANCE */
  81195. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81196. /** LUMINANCE_ALPHA */
  81197. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81198. /** RGB */
  81199. static readonly TEXTUREFORMAT_RGB: number;
  81200. /** RGBA */
  81201. static readonly TEXTUREFORMAT_RGBA: number;
  81202. /** RED */
  81203. static readonly TEXTUREFORMAT_RED: number;
  81204. /** RED (2nd reference) */
  81205. static readonly TEXTUREFORMAT_R: number;
  81206. /** RG */
  81207. static readonly TEXTUREFORMAT_RG: number;
  81208. /** RED_INTEGER */
  81209. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81210. /** RED_INTEGER (2nd reference) */
  81211. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81212. /** RG_INTEGER */
  81213. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81214. /** RGB_INTEGER */
  81215. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81216. /** RGBA_INTEGER */
  81217. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81218. /** UNSIGNED_BYTE */
  81219. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81220. /** UNSIGNED_BYTE (2nd reference) */
  81221. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81222. /** FLOAT */
  81223. static readonly TEXTURETYPE_FLOAT: number;
  81224. /** HALF_FLOAT */
  81225. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81226. /** BYTE */
  81227. static readonly TEXTURETYPE_BYTE: number;
  81228. /** SHORT */
  81229. static readonly TEXTURETYPE_SHORT: number;
  81230. /** UNSIGNED_SHORT */
  81231. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81232. /** INT */
  81233. static readonly TEXTURETYPE_INT: number;
  81234. /** UNSIGNED_INT */
  81235. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81236. /** UNSIGNED_SHORT_4_4_4_4 */
  81237. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81238. /** UNSIGNED_SHORT_5_5_5_1 */
  81239. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81240. /** UNSIGNED_SHORT_5_6_5 */
  81241. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81242. /** UNSIGNED_INT_2_10_10_10_REV */
  81243. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81244. /** UNSIGNED_INT_24_8 */
  81245. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81246. /** UNSIGNED_INT_10F_11F_11F_REV */
  81247. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81248. /** UNSIGNED_INT_5_9_9_9_REV */
  81249. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81250. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81251. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81252. /** nearest is mag = nearest and min = nearest and no mip */
  81253. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81254. /** mag = nearest and min = nearest and mip = none */
  81255. static readonly TEXTURE_NEAREST_NEAREST: number;
  81256. /** Bilinear is mag = linear and min = linear and no mip */
  81257. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81258. /** mag = linear and min = linear and mip = none */
  81259. static readonly TEXTURE_LINEAR_LINEAR: number;
  81260. /** Trilinear is mag = linear and min = linear and mip = linear */
  81261. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81262. /** Trilinear is mag = linear and min = linear and mip = linear */
  81263. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81264. /** mag = nearest and min = nearest and mip = nearest */
  81265. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81266. /** mag = nearest and min = linear and mip = nearest */
  81267. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81268. /** mag = nearest and min = linear and mip = linear */
  81269. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81270. /** mag = nearest and min = linear and mip = none */
  81271. static readonly TEXTURE_NEAREST_LINEAR: number;
  81272. /** nearest is mag = nearest and min = nearest and mip = linear */
  81273. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81274. /** mag = linear and min = nearest and mip = nearest */
  81275. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81276. /** mag = linear and min = nearest and mip = linear */
  81277. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81278. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81279. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81280. /** mag = linear and min = nearest and mip = none */
  81281. static readonly TEXTURE_LINEAR_NEAREST: number;
  81282. /** Explicit coordinates mode */
  81283. static readonly TEXTURE_EXPLICIT_MODE: number;
  81284. /** Spherical coordinates mode */
  81285. static readonly TEXTURE_SPHERICAL_MODE: number;
  81286. /** Planar coordinates mode */
  81287. static readonly TEXTURE_PLANAR_MODE: number;
  81288. /** Cubic coordinates mode */
  81289. static readonly TEXTURE_CUBIC_MODE: number;
  81290. /** Projection coordinates mode */
  81291. static readonly TEXTURE_PROJECTION_MODE: number;
  81292. /** Skybox coordinates mode */
  81293. static readonly TEXTURE_SKYBOX_MODE: number;
  81294. /** Inverse Cubic coordinates mode */
  81295. static readonly TEXTURE_INVCUBIC_MODE: number;
  81296. /** Equirectangular coordinates mode */
  81297. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81298. /** Equirectangular Fixed coordinates mode */
  81299. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81300. /** Equirectangular Fixed Mirrored coordinates mode */
  81301. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81302. /** Offline (baking) quality for texture filtering */
  81303. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81304. /** High quality for texture filtering */
  81305. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81306. /** Medium quality for texture filtering */
  81307. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81308. /** Low quality for texture filtering */
  81309. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81310. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81311. static readonly SCALEMODE_FLOOR: number;
  81312. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81313. static readonly SCALEMODE_NEAREST: number;
  81314. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81315. static readonly SCALEMODE_CEILING: number;
  81316. /**
  81317. * The dirty texture flag value
  81318. */
  81319. static readonly MATERIAL_TextureDirtyFlag: number;
  81320. /**
  81321. * The dirty light flag value
  81322. */
  81323. static readonly MATERIAL_LightDirtyFlag: number;
  81324. /**
  81325. * The dirty fresnel flag value
  81326. */
  81327. static readonly MATERIAL_FresnelDirtyFlag: number;
  81328. /**
  81329. * The dirty attribute flag value
  81330. */
  81331. static readonly MATERIAL_AttributesDirtyFlag: number;
  81332. /**
  81333. * The dirty misc flag value
  81334. */
  81335. static readonly MATERIAL_MiscDirtyFlag: number;
  81336. /**
  81337. * The dirty prepass flag value
  81338. */
  81339. static readonly MATERIAL_PrePassDirtyFlag: number;
  81340. /**
  81341. * The all dirty flag value
  81342. */
  81343. static readonly MATERIAL_AllDirtyFlag: number;
  81344. /**
  81345. * Returns the triangle fill mode
  81346. */
  81347. static readonly MATERIAL_TriangleFillMode: number;
  81348. /**
  81349. * Returns the wireframe mode
  81350. */
  81351. static readonly MATERIAL_WireFrameFillMode: number;
  81352. /**
  81353. * Returns the point fill mode
  81354. */
  81355. static readonly MATERIAL_PointFillMode: number;
  81356. /**
  81357. * Returns the point list draw mode
  81358. */
  81359. static readonly MATERIAL_PointListDrawMode: number;
  81360. /**
  81361. * Returns the line list draw mode
  81362. */
  81363. static readonly MATERIAL_LineListDrawMode: number;
  81364. /**
  81365. * Returns the line loop draw mode
  81366. */
  81367. static readonly MATERIAL_LineLoopDrawMode: number;
  81368. /**
  81369. * Returns the line strip draw mode
  81370. */
  81371. static readonly MATERIAL_LineStripDrawMode: number;
  81372. /**
  81373. * Returns the triangle strip draw mode
  81374. */
  81375. static readonly MATERIAL_TriangleStripDrawMode: number;
  81376. /**
  81377. * Returns the triangle fan draw mode
  81378. */
  81379. static readonly MATERIAL_TriangleFanDrawMode: number;
  81380. /**
  81381. * Stores the clock-wise side orientation
  81382. */
  81383. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81384. /**
  81385. * Stores the counter clock-wise side orientation
  81386. */
  81387. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81388. /**
  81389. * Nothing
  81390. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81391. */
  81392. static readonly ACTION_NothingTrigger: number;
  81393. /**
  81394. * On pick
  81395. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81396. */
  81397. static readonly ACTION_OnPickTrigger: number;
  81398. /**
  81399. * On left pick
  81400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81401. */
  81402. static readonly ACTION_OnLeftPickTrigger: number;
  81403. /**
  81404. * On right pick
  81405. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81406. */
  81407. static readonly ACTION_OnRightPickTrigger: number;
  81408. /**
  81409. * On center pick
  81410. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81411. */
  81412. static readonly ACTION_OnCenterPickTrigger: number;
  81413. /**
  81414. * On pick down
  81415. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81416. */
  81417. static readonly ACTION_OnPickDownTrigger: number;
  81418. /**
  81419. * On double pick
  81420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81421. */
  81422. static readonly ACTION_OnDoublePickTrigger: number;
  81423. /**
  81424. * On pick up
  81425. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81426. */
  81427. static readonly ACTION_OnPickUpTrigger: number;
  81428. /**
  81429. * On pick out.
  81430. * This trigger will only be raised if you also declared a OnPickDown
  81431. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81432. */
  81433. static readonly ACTION_OnPickOutTrigger: number;
  81434. /**
  81435. * On long press
  81436. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81437. */
  81438. static readonly ACTION_OnLongPressTrigger: number;
  81439. /**
  81440. * On pointer over
  81441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81442. */
  81443. static readonly ACTION_OnPointerOverTrigger: number;
  81444. /**
  81445. * On pointer out
  81446. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81447. */
  81448. static readonly ACTION_OnPointerOutTrigger: number;
  81449. /**
  81450. * On every frame
  81451. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81452. */
  81453. static readonly ACTION_OnEveryFrameTrigger: number;
  81454. /**
  81455. * On intersection enter
  81456. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81457. */
  81458. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81459. /**
  81460. * On intersection exit
  81461. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81462. */
  81463. static readonly ACTION_OnIntersectionExitTrigger: number;
  81464. /**
  81465. * On key down
  81466. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81467. */
  81468. static readonly ACTION_OnKeyDownTrigger: number;
  81469. /**
  81470. * On key up
  81471. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81472. */
  81473. static readonly ACTION_OnKeyUpTrigger: number;
  81474. /**
  81475. * Billboard mode will only apply to Y axis
  81476. */
  81477. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81478. /**
  81479. * Billboard mode will apply to all axes
  81480. */
  81481. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81482. /**
  81483. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81484. */
  81485. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81486. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81487. * Test order :
  81488. * Is the bounding sphere outside the frustum ?
  81489. * If not, are the bounding box vertices outside the frustum ?
  81490. * It not, then the cullable object is in the frustum.
  81491. */
  81492. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81493. /** Culling strategy : Bounding Sphere Only.
  81494. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81495. * It's also less accurate than the standard because some not visible objects can still be selected.
  81496. * Test : is the bounding sphere outside the frustum ?
  81497. * If not, then the cullable object is in the frustum.
  81498. */
  81499. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81500. /** Culling strategy : Optimistic Inclusion.
  81501. * This in an inclusion test first, then the standard exclusion test.
  81502. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81503. * 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.
  81504. * Anyway, it's as accurate as the standard strategy.
  81505. * Test :
  81506. * Is the cullable object bounding sphere center in the frustum ?
  81507. * If not, apply the default culling strategy.
  81508. */
  81509. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81510. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81511. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81512. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81513. * 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.
  81514. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81515. * Test :
  81516. * Is the cullable object bounding sphere center in the frustum ?
  81517. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81518. */
  81519. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81520. /**
  81521. * No logging while loading
  81522. */
  81523. static readonly SCENELOADER_NO_LOGGING: number;
  81524. /**
  81525. * Minimal logging while loading
  81526. */
  81527. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81528. /**
  81529. * Summary logging while loading
  81530. */
  81531. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81532. /**
  81533. * Detailled logging while loading
  81534. */
  81535. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81536. /**
  81537. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81538. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81539. */
  81540. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81541. /**
  81542. * Constant used to retrieve the position texture index in the textures array in the prepass
  81543. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81544. */
  81545. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81546. /**
  81547. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81548. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81549. */
  81550. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81551. /**
  81552. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81553. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81554. */
  81555. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81556. /**
  81557. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81558. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81559. */
  81560. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81561. /**
  81562. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81563. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81564. */
  81565. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81566. /**
  81567. * Constant used to retrieve albedo index in the textures array in the prepass
  81568. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81569. */
  81570. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81571. }
  81572. }
  81573. declare module BABYLON {
  81574. /**
  81575. * This represents the required contract to create a new type of texture loader.
  81576. */
  81577. export interface IInternalTextureLoader {
  81578. /**
  81579. * Defines wether the loader supports cascade loading the different faces.
  81580. */
  81581. supportCascades: boolean;
  81582. /**
  81583. * This returns if the loader support the current file information.
  81584. * @param extension defines the file extension of the file being loaded
  81585. * @param mimeType defines the optional mime type of the file being loaded
  81586. * @returns true if the loader can load the specified file
  81587. */
  81588. canLoad(extension: string, mimeType?: string): boolean;
  81589. /**
  81590. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81591. * @param data contains the texture data
  81592. * @param texture defines the BabylonJS internal texture
  81593. * @param createPolynomials will be true if polynomials have been requested
  81594. * @param onLoad defines the callback to trigger once the texture is ready
  81595. * @param onError defines the callback to trigger in case of error
  81596. */
  81597. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81598. /**
  81599. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81600. * @param data contains the texture data
  81601. * @param texture defines the BabylonJS internal texture
  81602. * @param callback defines the method to call once ready to upload
  81603. */
  81604. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81605. }
  81606. }
  81607. declare module BABYLON {
  81608. /**
  81609. * Class used to store and describe the pipeline context associated with an effect
  81610. */
  81611. export interface IPipelineContext {
  81612. /**
  81613. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81614. */
  81615. isAsync: boolean;
  81616. /**
  81617. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81618. */
  81619. isReady: boolean;
  81620. /** @hidden */
  81621. _getVertexShaderCode(): string | null;
  81622. /** @hidden */
  81623. _getFragmentShaderCode(): string | null;
  81624. /** @hidden */
  81625. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81626. }
  81627. }
  81628. declare module BABYLON {
  81629. /**
  81630. * Class used to store gfx data (like WebGLBuffer)
  81631. */
  81632. export class DataBuffer {
  81633. /**
  81634. * Gets or sets the number of objects referencing this buffer
  81635. */
  81636. references: number;
  81637. /** Gets or sets the size of the underlying buffer */
  81638. capacity: number;
  81639. /**
  81640. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81641. */
  81642. is32Bits: boolean;
  81643. /**
  81644. * Gets the underlying buffer
  81645. */
  81646. get underlyingResource(): any;
  81647. }
  81648. }
  81649. declare module BABYLON {
  81650. /** @hidden */
  81651. export interface IShaderProcessor {
  81652. attributeProcessor?: (attribute: string) => string;
  81653. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81654. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81655. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81656. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81657. lineProcessor?: (line: string, isFragment: boolean) => string;
  81658. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81659. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81660. }
  81661. }
  81662. declare module BABYLON {
  81663. /** @hidden */
  81664. export interface ProcessingOptions {
  81665. defines: string[];
  81666. indexParameters: any;
  81667. isFragment: boolean;
  81668. shouldUseHighPrecisionShader: boolean;
  81669. supportsUniformBuffers: boolean;
  81670. shadersRepository: string;
  81671. includesShadersStore: {
  81672. [key: string]: string;
  81673. };
  81674. processor?: IShaderProcessor;
  81675. version: string;
  81676. platformName: string;
  81677. lookForClosingBracketForUniformBuffer?: boolean;
  81678. }
  81679. }
  81680. declare module BABYLON {
  81681. /** @hidden */
  81682. export class ShaderCodeNode {
  81683. line: string;
  81684. children: ShaderCodeNode[];
  81685. additionalDefineKey?: string;
  81686. additionalDefineValue?: string;
  81687. isValid(preprocessors: {
  81688. [key: string]: string;
  81689. }): boolean;
  81690. process(preprocessors: {
  81691. [key: string]: string;
  81692. }, options: ProcessingOptions): string;
  81693. }
  81694. }
  81695. declare module BABYLON {
  81696. /** @hidden */
  81697. export class ShaderCodeCursor {
  81698. private _lines;
  81699. lineIndex: number;
  81700. get currentLine(): string;
  81701. get canRead(): boolean;
  81702. set lines(value: string[]);
  81703. }
  81704. }
  81705. declare module BABYLON {
  81706. /** @hidden */
  81707. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81708. process(preprocessors: {
  81709. [key: string]: string;
  81710. }, options: ProcessingOptions): string;
  81711. }
  81712. }
  81713. declare module BABYLON {
  81714. /** @hidden */
  81715. export class ShaderDefineExpression {
  81716. isTrue(preprocessors: {
  81717. [key: string]: string;
  81718. }): boolean;
  81719. private static _OperatorPriority;
  81720. private static _Stack;
  81721. static postfixToInfix(postfix: string[]): string;
  81722. static infixToPostfix(infix: string): string[];
  81723. }
  81724. }
  81725. declare module BABYLON {
  81726. /** @hidden */
  81727. export class ShaderCodeTestNode extends ShaderCodeNode {
  81728. testExpression: ShaderDefineExpression;
  81729. isValid(preprocessors: {
  81730. [key: string]: string;
  81731. }): boolean;
  81732. }
  81733. }
  81734. declare module BABYLON {
  81735. /** @hidden */
  81736. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81737. define: string;
  81738. not: boolean;
  81739. constructor(define: string, not?: boolean);
  81740. isTrue(preprocessors: {
  81741. [key: string]: string;
  81742. }): boolean;
  81743. }
  81744. }
  81745. declare module BABYLON {
  81746. /** @hidden */
  81747. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81748. leftOperand: ShaderDefineExpression;
  81749. rightOperand: ShaderDefineExpression;
  81750. isTrue(preprocessors: {
  81751. [key: string]: string;
  81752. }): boolean;
  81753. }
  81754. }
  81755. declare module BABYLON {
  81756. /** @hidden */
  81757. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81758. leftOperand: ShaderDefineExpression;
  81759. rightOperand: ShaderDefineExpression;
  81760. isTrue(preprocessors: {
  81761. [key: string]: string;
  81762. }): boolean;
  81763. }
  81764. }
  81765. declare module BABYLON {
  81766. /** @hidden */
  81767. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81768. define: string;
  81769. operand: string;
  81770. testValue: string;
  81771. constructor(define: string, operand: string, testValue: string);
  81772. isTrue(preprocessors: {
  81773. [key: string]: string;
  81774. }): boolean;
  81775. }
  81776. }
  81777. declare module BABYLON {
  81778. /**
  81779. * Class used to enable access to offline support
  81780. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81781. */
  81782. export interface IOfflineProvider {
  81783. /**
  81784. * Gets a boolean indicating if scene must be saved in the database
  81785. */
  81786. enableSceneOffline: boolean;
  81787. /**
  81788. * Gets a boolean indicating if textures must be saved in the database
  81789. */
  81790. enableTexturesOffline: boolean;
  81791. /**
  81792. * Open the offline support and make it available
  81793. * @param successCallback defines the callback to call on success
  81794. * @param errorCallback defines the callback to call on error
  81795. */
  81796. open(successCallback: () => void, errorCallback: () => void): void;
  81797. /**
  81798. * Loads an image from the offline support
  81799. * @param url defines the url to load from
  81800. * @param image defines the target DOM image
  81801. */
  81802. loadImage(url: string, image: HTMLImageElement): void;
  81803. /**
  81804. * Loads a file from offline support
  81805. * @param url defines the URL to load from
  81806. * @param sceneLoaded defines a callback to call on success
  81807. * @param progressCallBack defines a callback to call when progress changed
  81808. * @param errorCallback defines a callback to call on error
  81809. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81810. */
  81811. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81812. }
  81813. }
  81814. declare module BABYLON {
  81815. /**
  81816. * Class used to help managing file picking and drag'n'drop
  81817. * File Storage
  81818. */
  81819. export class FilesInputStore {
  81820. /**
  81821. * List of files ready to be loaded
  81822. */
  81823. static FilesToLoad: {
  81824. [key: string]: File;
  81825. };
  81826. }
  81827. }
  81828. declare module BABYLON {
  81829. /**
  81830. * Class used to define a retry strategy when error happens while loading assets
  81831. */
  81832. export class RetryStrategy {
  81833. /**
  81834. * Function used to defines an exponential back off strategy
  81835. * @param maxRetries defines the maximum number of retries (3 by default)
  81836. * @param baseInterval defines the interval between retries
  81837. * @returns the strategy function to use
  81838. */
  81839. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81840. }
  81841. }
  81842. declare module BABYLON {
  81843. /**
  81844. * @ignore
  81845. * Application error to support additional information when loading a file
  81846. */
  81847. export abstract class BaseError extends Error {
  81848. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81849. }
  81850. }
  81851. declare module BABYLON {
  81852. /** @ignore */
  81853. export class LoadFileError extends BaseError {
  81854. request?: WebRequest;
  81855. file?: File;
  81856. /**
  81857. * Creates a new LoadFileError
  81858. * @param message defines the message of the error
  81859. * @param request defines the optional web request
  81860. * @param file defines the optional file
  81861. */
  81862. constructor(message: string, object?: WebRequest | File);
  81863. }
  81864. /** @ignore */
  81865. export class RequestFileError extends BaseError {
  81866. request: WebRequest;
  81867. /**
  81868. * Creates a new LoadFileError
  81869. * @param message defines the message of the error
  81870. * @param request defines the optional web request
  81871. */
  81872. constructor(message: string, request: WebRequest);
  81873. }
  81874. /** @ignore */
  81875. export class ReadFileError extends BaseError {
  81876. file: File;
  81877. /**
  81878. * Creates a new ReadFileError
  81879. * @param message defines the message of the error
  81880. * @param file defines the optional file
  81881. */
  81882. constructor(message: string, file: File);
  81883. }
  81884. /**
  81885. * @hidden
  81886. */
  81887. export class FileTools {
  81888. /**
  81889. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81890. */
  81891. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81892. /**
  81893. * Gets or sets the base URL to use to load assets
  81894. */
  81895. static BaseUrl: string;
  81896. /**
  81897. * Default behaviour for cors in the application.
  81898. * It can be a string if the expected behavior is identical in the entire app.
  81899. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81900. */
  81901. static CorsBehavior: string | ((url: string | string[]) => string);
  81902. /**
  81903. * Gets or sets a function used to pre-process url before using them to load assets
  81904. */
  81905. static PreprocessUrl: (url: string) => string;
  81906. /**
  81907. * Removes unwanted characters from an url
  81908. * @param url defines the url to clean
  81909. * @returns the cleaned url
  81910. */
  81911. private static _CleanUrl;
  81912. /**
  81913. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81914. * @param url define the url we are trying
  81915. * @param element define the dom element where to configure the cors policy
  81916. */
  81917. static SetCorsBehavior(url: string | string[], element: {
  81918. crossOrigin: string | null;
  81919. }): void;
  81920. /**
  81921. * Loads an image as an HTMLImageElement.
  81922. * @param input url string, ArrayBuffer, or Blob to load
  81923. * @param onLoad callback called when the image successfully loads
  81924. * @param onError callback called when the image fails to load
  81925. * @param offlineProvider offline provider for caching
  81926. * @param mimeType optional mime type
  81927. * @returns the HTMLImageElement of the loaded image
  81928. */
  81929. 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>;
  81930. /**
  81931. * Reads a file from a File object
  81932. * @param file defines the file to load
  81933. * @param onSuccess defines the callback to call when data is loaded
  81934. * @param onProgress defines the callback to call during loading process
  81935. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81936. * @param onError defines the callback to call when an error occurs
  81937. * @returns a file request object
  81938. */
  81939. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81940. /**
  81941. * Loads a file from a url
  81942. * @param url url to load
  81943. * @param onSuccess callback called when the file successfully loads
  81944. * @param onProgress callback called while file is loading (if the server supports this mode)
  81945. * @param offlineProvider defines the offline provider for caching
  81946. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81947. * @param onError callback called when the file fails to load
  81948. * @returns a file request object
  81949. */
  81950. 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;
  81951. /**
  81952. * Loads a file
  81953. * @param url url to load
  81954. * @param onSuccess callback called when the file successfully loads
  81955. * @param onProgress callback called while file is loading (if the server supports this mode)
  81956. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81957. * @param onError callback called when the file fails to load
  81958. * @param onOpened callback called when the web request is opened
  81959. * @returns a file request object
  81960. */
  81961. 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;
  81962. /**
  81963. * Checks if the loaded document was accessed via `file:`-Protocol.
  81964. * @returns boolean
  81965. */
  81966. static IsFileURL(): boolean;
  81967. }
  81968. }
  81969. declare module BABYLON {
  81970. /** @hidden */
  81971. export class ShaderProcessor {
  81972. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81973. private static _ProcessPrecision;
  81974. private static _ExtractOperation;
  81975. private static _BuildSubExpression;
  81976. private static _BuildExpression;
  81977. private static _MoveCursorWithinIf;
  81978. private static _MoveCursor;
  81979. private static _EvaluatePreProcessors;
  81980. private static _PreparePreProcessors;
  81981. private static _ProcessShaderConversion;
  81982. private static _ProcessIncludes;
  81983. /**
  81984. * Loads a file from a url
  81985. * @param url url to load
  81986. * @param onSuccess callback called when the file successfully loads
  81987. * @param onProgress callback called while file is loading (if the server supports this mode)
  81988. * @param offlineProvider defines the offline provider for caching
  81989. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81990. * @param onError callback called when the file fails to load
  81991. * @returns a file request object
  81992. * @hidden
  81993. */
  81994. 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;
  81995. }
  81996. }
  81997. declare module BABYLON {
  81998. /**
  81999. * @hidden
  82000. */
  82001. export interface IColor4Like {
  82002. r: float;
  82003. g: float;
  82004. b: float;
  82005. a: float;
  82006. }
  82007. /**
  82008. * @hidden
  82009. */
  82010. export interface IColor3Like {
  82011. r: float;
  82012. g: float;
  82013. b: float;
  82014. }
  82015. /**
  82016. * @hidden
  82017. */
  82018. export interface IVector4Like {
  82019. x: float;
  82020. y: float;
  82021. z: float;
  82022. w: float;
  82023. }
  82024. /**
  82025. * @hidden
  82026. */
  82027. export interface IVector3Like {
  82028. x: float;
  82029. y: float;
  82030. z: float;
  82031. }
  82032. /**
  82033. * @hidden
  82034. */
  82035. export interface IVector2Like {
  82036. x: float;
  82037. y: float;
  82038. }
  82039. /**
  82040. * @hidden
  82041. */
  82042. export interface IMatrixLike {
  82043. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82044. updateFlag: int;
  82045. }
  82046. /**
  82047. * @hidden
  82048. */
  82049. export interface IViewportLike {
  82050. x: float;
  82051. y: float;
  82052. width: float;
  82053. height: float;
  82054. }
  82055. /**
  82056. * @hidden
  82057. */
  82058. export interface IPlaneLike {
  82059. normal: IVector3Like;
  82060. d: float;
  82061. normalize(): void;
  82062. }
  82063. }
  82064. declare module BABYLON {
  82065. /**
  82066. * Interface used to define common properties for effect fallbacks
  82067. */
  82068. export interface IEffectFallbacks {
  82069. /**
  82070. * Removes the defines that should be removed when falling back.
  82071. * @param currentDefines defines the current define statements for the shader.
  82072. * @param effect defines the current effect we try to compile
  82073. * @returns The resulting defines with defines of the current rank removed.
  82074. */
  82075. reduce(currentDefines: string, effect: Effect): string;
  82076. /**
  82077. * Removes the fallback from the bound mesh.
  82078. */
  82079. unBindMesh(): void;
  82080. /**
  82081. * Checks to see if more fallbacks are still availible.
  82082. */
  82083. hasMoreFallbacks: boolean;
  82084. }
  82085. }
  82086. declare module BABYLON {
  82087. /**
  82088. * Class used to evalaute queries containing `and` and `or` operators
  82089. */
  82090. export class AndOrNotEvaluator {
  82091. /**
  82092. * Evaluate a query
  82093. * @param query defines the query to evaluate
  82094. * @param evaluateCallback defines the callback used to filter result
  82095. * @returns true if the query matches
  82096. */
  82097. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82098. private static _HandleParenthesisContent;
  82099. private static _SimplifyNegation;
  82100. }
  82101. }
  82102. declare module BABYLON {
  82103. /**
  82104. * Class used to store custom tags
  82105. */
  82106. export class Tags {
  82107. /**
  82108. * Adds support for tags on the given object
  82109. * @param obj defines the object to use
  82110. */
  82111. static EnableFor(obj: any): void;
  82112. /**
  82113. * Removes tags support
  82114. * @param obj defines the object to use
  82115. */
  82116. static DisableFor(obj: any): void;
  82117. /**
  82118. * Gets a boolean indicating if the given object has tags
  82119. * @param obj defines the object to use
  82120. * @returns a boolean
  82121. */
  82122. static HasTags(obj: any): boolean;
  82123. /**
  82124. * Gets the tags available on a given object
  82125. * @param obj defines the object to use
  82126. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82127. * @returns the tags
  82128. */
  82129. static GetTags(obj: any, asString?: boolean): any;
  82130. /**
  82131. * Adds tags to an object
  82132. * @param obj defines the object to use
  82133. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82134. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82135. */
  82136. static AddTagsTo(obj: any, tagsString: string): void;
  82137. /**
  82138. * @hidden
  82139. */
  82140. static _AddTagTo(obj: any, tag: string): void;
  82141. /**
  82142. * Removes specific tags from a specific object
  82143. * @param obj defines the object to use
  82144. * @param tagsString defines the tags to remove
  82145. */
  82146. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82147. /**
  82148. * @hidden
  82149. */
  82150. static _RemoveTagFrom(obj: any, tag: string): void;
  82151. /**
  82152. * Defines if tags hosted on an object match a given query
  82153. * @param obj defines the object to use
  82154. * @param tagsQuery defines the tag query
  82155. * @returns a boolean
  82156. */
  82157. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82158. }
  82159. }
  82160. declare module BABYLON {
  82161. /**
  82162. * Scalar computation library
  82163. */
  82164. export class Scalar {
  82165. /**
  82166. * Two pi constants convenient for computation.
  82167. */
  82168. static TwoPi: number;
  82169. /**
  82170. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82171. * @param a number
  82172. * @param b number
  82173. * @param epsilon (default = 1.401298E-45)
  82174. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82175. */
  82176. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82177. /**
  82178. * Returns a string : the upper case translation of the number i to hexadecimal.
  82179. * @param i number
  82180. * @returns the upper case translation of the number i to hexadecimal.
  82181. */
  82182. static ToHex(i: number): string;
  82183. /**
  82184. * Returns -1 if value is negative and +1 is value is positive.
  82185. * @param value the value
  82186. * @returns the value itself if it's equal to zero.
  82187. */
  82188. static Sign(value: number): number;
  82189. /**
  82190. * Returns the value itself if it's between min and max.
  82191. * Returns min if the value is lower than min.
  82192. * Returns max if the value is greater than max.
  82193. * @param value the value to clmap
  82194. * @param min the min value to clamp to (default: 0)
  82195. * @param max the max value to clamp to (default: 1)
  82196. * @returns the clamped value
  82197. */
  82198. static Clamp(value: number, min?: number, max?: number): number;
  82199. /**
  82200. * the log2 of value.
  82201. * @param value the value to compute log2 of
  82202. * @returns the log2 of value.
  82203. */
  82204. static Log2(value: number): number;
  82205. /**
  82206. * Loops the value, so that it is never larger than length and never smaller than 0.
  82207. *
  82208. * This is similar to the modulo operator but it works with floating point numbers.
  82209. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82210. * With t = 5 and length = 2.5, the result would be 0.0.
  82211. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82212. * @param value the value
  82213. * @param length the length
  82214. * @returns the looped value
  82215. */
  82216. static Repeat(value: number, length: number): number;
  82217. /**
  82218. * Normalize the value between 0.0 and 1.0 using min and max values
  82219. * @param value value to normalize
  82220. * @param min max to normalize between
  82221. * @param max min to normalize between
  82222. * @returns the normalized value
  82223. */
  82224. static Normalize(value: number, min: number, max: number): number;
  82225. /**
  82226. * Denormalize the value from 0.0 and 1.0 using min and max values
  82227. * @param normalized value to denormalize
  82228. * @param min max to denormalize between
  82229. * @param max min to denormalize between
  82230. * @returns the denormalized value
  82231. */
  82232. static Denormalize(normalized: number, min: number, max: number): number;
  82233. /**
  82234. * Calculates the shortest difference between two given angles given in degrees.
  82235. * @param current current angle in degrees
  82236. * @param target target angle in degrees
  82237. * @returns the delta
  82238. */
  82239. static DeltaAngle(current: number, target: number): number;
  82240. /**
  82241. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82242. * @param tx value
  82243. * @param length length
  82244. * @returns The returned value will move back and forth between 0 and length
  82245. */
  82246. static PingPong(tx: number, length: number): number;
  82247. /**
  82248. * Interpolates between min and max with smoothing at the limits.
  82249. *
  82250. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82251. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82252. * @param from from
  82253. * @param to to
  82254. * @param tx value
  82255. * @returns the smooth stepped value
  82256. */
  82257. static SmoothStep(from: number, to: number, tx: number): number;
  82258. /**
  82259. * Moves a value current towards target.
  82260. *
  82261. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82262. * Negative values of maxDelta pushes the value away from target.
  82263. * @param current current value
  82264. * @param target target value
  82265. * @param maxDelta max distance to move
  82266. * @returns resulting value
  82267. */
  82268. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82269. /**
  82270. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82271. *
  82272. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82273. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82274. * @param current current value
  82275. * @param target target value
  82276. * @param maxDelta max distance to move
  82277. * @returns resulting angle
  82278. */
  82279. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82280. /**
  82281. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82282. * @param start start value
  82283. * @param end target value
  82284. * @param amount amount to lerp between
  82285. * @returns the lerped value
  82286. */
  82287. static Lerp(start: number, end: number, amount: number): number;
  82288. /**
  82289. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82290. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82291. * @param start start value
  82292. * @param end target value
  82293. * @param amount amount to lerp between
  82294. * @returns the lerped value
  82295. */
  82296. static LerpAngle(start: number, end: number, amount: number): number;
  82297. /**
  82298. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82299. * @param a start value
  82300. * @param b target value
  82301. * @param value value between a and b
  82302. * @returns the inverseLerp value
  82303. */
  82304. static InverseLerp(a: number, b: number, value: number): number;
  82305. /**
  82306. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82307. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82308. * @param value1 spline value
  82309. * @param tangent1 spline value
  82310. * @param value2 spline value
  82311. * @param tangent2 spline value
  82312. * @param amount input value
  82313. * @returns hermite result
  82314. */
  82315. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82316. /**
  82317. * Returns a random float number between and min and max values
  82318. * @param min min value of random
  82319. * @param max max value of random
  82320. * @returns random value
  82321. */
  82322. static RandomRange(min: number, max: number): number;
  82323. /**
  82324. * This function returns percentage of a number in a given range.
  82325. *
  82326. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82327. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82328. * @param number to convert to percentage
  82329. * @param min min range
  82330. * @param max max range
  82331. * @returns the percentage
  82332. */
  82333. static RangeToPercent(number: number, min: number, max: number): number;
  82334. /**
  82335. * This function returns number that corresponds to the percentage in a given range.
  82336. *
  82337. * PercentToRange(0.34,0,100) will return 34.
  82338. * @param percent to convert to number
  82339. * @param min min range
  82340. * @param max max range
  82341. * @returns the number
  82342. */
  82343. static PercentToRange(percent: number, min: number, max: number): number;
  82344. /**
  82345. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82346. * @param angle The angle to normalize in radian.
  82347. * @return The converted angle.
  82348. */
  82349. static NormalizeRadians(angle: number): number;
  82350. }
  82351. }
  82352. declare module BABYLON {
  82353. /**
  82354. * Constant used to convert a value to gamma space
  82355. * @ignorenaming
  82356. */
  82357. export const ToGammaSpace: number;
  82358. /**
  82359. * Constant used to convert a value to linear space
  82360. * @ignorenaming
  82361. */
  82362. export const ToLinearSpace = 2.2;
  82363. /**
  82364. * Constant used to define the minimal number value in Babylon.js
  82365. * @ignorenaming
  82366. */
  82367. let Epsilon: number;
  82368. }
  82369. declare module BABYLON {
  82370. /**
  82371. * Class used to represent a viewport on screen
  82372. */
  82373. export class Viewport {
  82374. /** viewport left coordinate */
  82375. x: number;
  82376. /** viewport top coordinate */
  82377. y: number;
  82378. /**viewport width */
  82379. width: number;
  82380. /** viewport height */
  82381. height: number;
  82382. /**
  82383. * Creates a Viewport object located at (x, y) and sized (width, height)
  82384. * @param x defines viewport left coordinate
  82385. * @param y defines viewport top coordinate
  82386. * @param width defines the viewport width
  82387. * @param height defines the viewport height
  82388. */
  82389. constructor(
  82390. /** viewport left coordinate */
  82391. x: number,
  82392. /** viewport top coordinate */
  82393. y: number,
  82394. /**viewport width */
  82395. width: number,
  82396. /** viewport height */
  82397. height: number);
  82398. /**
  82399. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82400. * @param renderWidth defines the rendering width
  82401. * @param renderHeight defines the rendering height
  82402. * @returns a new Viewport
  82403. */
  82404. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82405. /**
  82406. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82407. * @param renderWidth defines the rendering width
  82408. * @param renderHeight defines the rendering height
  82409. * @param ref defines the target viewport
  82410. * @returns the current viewport
  82411. */
  82412. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82413. /**
  82414. * Returns a new Viewport copied from the current one
  82415. * @returns a new Viewport
  82416. */
  82417. clone(): Viewport;
  82418. }
  82419. }
  82420. declare module BABYLON {
  82421. /**
  82422. * Class containing a set of static utilities functions for arrays.
  82423. */
  82424. export class ArrayTools {
  82425. /**
  82426. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82427. * @param size the number of element to construct and put in the array
  82428. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82429. * @returns a new array filled with new objects
  82430. */
  82431. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82432. }
  82433. }
  82434. declare module BABYLON {
  82435. /**
  82436. * Represents a plane by the equation ax + by + cz + d = 0
  82437. */
  82438. export class Plane {
  82439. private static _TmpMatrix;
  82440. /**
  82441. * Normal of the plane (a,b,c)
  82442. */
  82443. normal: Vector3;
  82444. /**
  82445. * d component of the plane
  82446. */
  82447. d: number;
  82448. /**
  82449. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82450. * @param a a component of the plane
  82451. * @param b b component of the plane
  82452. * @param c c component of the plane
  82453. * @param d d component of the plane
  82454. */
  82455. constructor(a: number, b: number, c: number, d: number);
  82456. /**
  82457. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82458. */
  82459. asArray(): number[];
  82460. /**
  82461. * @returns a new plane copied from the current Plane.
  82462. */
  82463. clone(): Plane;
  82464. /**
  82465. * @returns the string "Plane".
  82466. */
  82467. getClassName(): string;
  82468. /**
  82469. * @returns the Plane hash code.
  82470. */
  82471. getHashCode(): number;
  82472. /**
  82473. * Normalize the current Plane in place.
  82474. * @returns the updated Plane.
  82475. */
  82476. normalize(): Plane;
  82477. /**
  82478. * Applies a transformation the plane and returns the result
  82479. * @param transformation the transformation matrix to be applied to the plane
  82480. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82481. */
  82482. transform(transformation: DeepImmutable<Matrix>): Plane;
  82483. /**
  82484. * Compute the dot product between the point and the plane normal
  82485. * @param point point to calculate the dot product with
  82486. * @returns the dot product (float) of the point coordinates and the plane normal.
  82487. */
  82488. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82489. /**
  82490. * Updates the current Plane from the plane defined by the three given points.
  82491. * @param point1 one of the points used to contruct the plane
  82492. * @param point2 one of the points used to contruct the plane
  82493. * @param point3 one of the points used to contruct the plane
  82494. * @returns the updated Plane.
  82495. */
  82496. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82497. /**
  82498. * Checks if the plane is facing a given direction
  82499. * @param direction the direction to check if the plane is facing
  82500. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82501. * @returns True is the vector "direction" is the same side than the plane normal.
  82502. */
  82503. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82504. /**
  82505. * Calculates the distance to a point
  82506. * @param point point to calculate distance to
  82507. * @returns the signed distance (float) from the given point to the Plane.
  82508. */
  82509. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82510. /**
  82511. * Creates a plane from an array
  82512. * @param array the array to create a plane from
  82513. * @returns a new Plane from the given array.
  82514. */
  82515. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82516. /**
  82517. * Creates a plane from three points
  82518. * @param point1 point used to create the plane
  82519. * @param point2 point used to create the plane
  82520. * @param point3 point used to create the plane
  82521. * @returns a new Plane defined by the three given points.
  82522. */
  82523. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82524. /**
  82525. * Creates a plane from an origin point and a normal
  82526. * @param origin origin of the plane to be constructed
  82527. * @param normal normal of the plane to be constructed
  82528. * @returns a new Plane the normal vector to this plane at the given origin point.
  82529. * Note : the vector "normal" is updated because normalized.
  82530. */
  82531. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82532. /**
  82533. * Calculates the distance from a plane and a point
  82534. * @param origin origin of the plane to be constructed
  82535. * @param normal normal of the plane to be constructed
  82536. * @param point point to calculate distance to
  82537. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82538. */
  82539. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82540. }
  82541. }
  82542. declare module BABYLON {
  82543. /** @hidden */
  82544. export class PerformanceConfigurator {
  82545. /** @hidden */
  82546. static MatrixUse64Bits: boolean;
  82547. /** @hidden */
  82548. static MatrixTrackPrecisionChange: boolean;
  82549. /** @hidden */
  82550. static MatrixCurrentType: any;
  82551. /** @hidden */
  82552. static MatrixTrackedMatrices: Array<any> | null;
  82553. /** @hidden */
  82554. static SetMatrixPrecision(use64bits: boolean): void;
  82555. }
  82556. }
  82557. declare module BABYLON {
  82558. /**
  82559. * Class representing a vector containing 2 coordinates
  82560. */
  82561. export class Vector2 {
  82562. /** defines the first coordinate */
  82563. x: number;
  82564. /** defines the second coordinate */
  82565. y: number;
  82566. /**
  82567. * Creates a new Vector2 from the given x and y coordinates
  82568. * @param x defines the first coordinate
  82569. * @param y defines the second coordinate
  82570. */
  82571. constructor(
  82572. /** defines the first coordinate */
  82573. x?: number,
  82574. /** defines the second coordinate */
  82575. y?: number);
  82576. /**
  82577. * Gets a string with the Vector2 coordinates
  82578. * @returns a string with the Vector2 coordinates
  82579. */
  82580. toString(): string;
  82581. /**
  82582. * Gets class name
  82583. * @returns the string "Vector2"
  82584. */
  82585. getClassName(): string;
  82586. /**
  82587. * Gets current vector hash code
  82588. * @returns the Vector2 hash code as a number
  82589. */
  82590. getHashCode(): number;
  82591. /**
  82592. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82593. * @param array defines the source array
  82594. * @param index defines the offset in source array
  82595. * @returns the current Vector2
  82596. */
  82597. toArray(array: FloatArray, index?: number): Vector2;
  82598. /**
  82599. * Update the current vector from an array
  82600. * @param array defines the destination array
  82601. * @param index defines the offset in the destination array
  82602. * @returns the current Vector3
  82603. */
  82604. fromArray(array: FloatArray, index?: number): Vector2;
  82605. /**
  82606. * Copy the current vector to an array
  82607. * @returns a new array with 2 elements: the Vector2 coordinates.
  82608. */
  82609. asArray(): number[];
  82610. /**
  82611. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82612. * @param source defines the source Vector2
  82613. * @returns the current updated Vector2
  82614. */
  82615. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82616. /**
  82617. * Sets the Vector2 coordinates with the given floats
  82618. * @param x defines the first coordinate
  82619. * @param y defines the second coordinate
  82620. * @returns the current updated Vector2
  82621. */
  82622. copyFromFloats(x: number, y: number): Vector2;
  82623. /**
  82624. * Sets the Vector2 coordinates with the given floats
  82625. * @param x defines the first coordinate
  82626. * @param y defines the second coordinate
  82627. * @returns the current updated Vector2
  82628. */
  82629. set(x: number, y: number): Vector2;
  82630. /**
  82631. * Add another vector with the current one
  82632. * @param otherVector defines the other vector
  82633. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82634. */
  82635. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82636. /**
  82637. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82638. * @param otherVector defines the other vector
  82639. * @param result defines the target vector
  82640. * @returns the unmodified current Vector2
  82641. */
  82642. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82643. /**
  82644. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82645. * @param otherVector defines the other vector
  82646. * @returns the current updated Vector2
  82647. */
  82648. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82649. /**
  82650. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82651. * @param otherVector defines the other vector
  82652. * @returns a new Vector2
  82653. */
  82654. addVector3(otherVector: Vector3): Vector2;
  82655. /**
  82656. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82657. * @param otherVector defines the other vector
  82658. * @returns a new Vector2
  82659. */
  82660. subtract(otherVector: Vector2): Vector2;
  82661. /**
  82662. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82663. * @param otherVector defines the other vector
  82664. * @param result defines the target vector
  82665. * @returns the unmodified current Vector2
  82666. */
  82667. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82668. /**
  82669. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82670. * @param otherVector defines the other vector
  82671. * @returns the current updated Vector2
  82672. */
  82673. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82674. /**
  82675. * Multiplies in place the current Vector2 coordinates by the given ones
  82676. * @param otherVector defines the other vector
  82677. * @returns the current updated Vector2
  82678. */
  82679. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82680. /**
  82681. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82682. * @param otherVector defines the other vector
  82683. * @returns a new Vector2
  82684. */
  82685. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82686. /**
  82687. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82688. * @param otherVector defines the other vector
  82689. * @param result defines the target vector
  82690. * @returns the unmodified current Vector2
  82691. */
  82692. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82693. /**
  82694. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82695. * @param x defines the first coordinate
  82696. * @param y defines the second coordinate
  82697. * @returns a new Vector2
  82698. */
  82699. multiplyByFloats(x: number, y: number): Vector2;
  82700. /**
  82701. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82702. * @param otherVector defines the other vector
  82703. * @returns a new Vector2
  82704. */
  82705. divide(otherVector: Vector2): Vector2;
  82706. /**
  82707. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82708. * @param otherVector defines the other vector
  82709. * @param result defines the target vector
  82710. * @returns the unmodified current Vector2
  82711. */
  82712. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82713. /**
  82714. * Divides the current Vector2 coordinates by the given ones
  82715. * @param otherVector defines the other vector
  82716. * @returns the current updated Vector2
  82717. */
  82718. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82719. /**
  82720. * Gets a new Vector2 with current Vector2 negated coordinates
  82721. * @returns a new Vector2
  82722. */
  82723. negate(): Vector2;
  82724. /**
  82725. * Negate this vector in place
  82726. * @returns this
  82727. */
  82728. negateInPlace(): Vector2;
  82729. /**
  82730. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82731. * @param result defines the Vector3 object where to store the result
  82732. * @returns the current Vector2
  82733. */
  82734. negateToRef(result: Vector2): Vector2;
  82735. /**
  82736. * Multiply the Vector2 coordinates by scale
  82737. * @param scale defines the scaling factor
  82738. * @returns the current updated Vector2
  82739. */
  82740. scaleInPlace(scale: number): Vector2;
  82741. /**
  82742. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82743. * @param scale defines the scaling factor
  82744. * @returns a new Vector2
  82745. */
  82746. scale(scale: number): Vector2;
  82747. /**
  82748. * Scale the current Vector2 values by a factor to a given Vector2
  82749. * @param scale defines the scale factor
  82750. * @param result defines the Vector2 object where to store the result
  82751. * @returns the unmodified current Vector2
  82752. */
  82753. scaleToRef(scale: number, result: Vector2): Vector2;
  82754. /**
  82755. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82756. * @param scale defines the scale factor
  82757. * @param result defines the Vector2 object where to store the result
  82758. * @returns the unmodified current Vector2
  82759. */
  82760. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82761. /**
  82762. * Gets a boolean if two vectors are equals
  82763. * @param otherVector defines the other vector
  82764. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82765. */
  82766. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82767. /**
  82768. * Gets a boolean if two vectors are equals (using an epsilon value)
  82769. * @param otherVector defines the other vector
  82770. * @param epsilon defines the minimal distance to consider equality
  82771. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82772. */
  82773. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82774. /**
  82775. * Gets a new Vector2 from current Vector2 floored values
  82776. * @returns a new Vector2
  82777. */
  82778. floor(): Vector2;
  82779. /**
  82780. * Gets a new Vector2 from current Vector2 floored values
  82781. * @returns a new Vector2
  82782. */
  82783. fract(): Vector2;
  82784. /**
  82785. * Gets the length of the vector
  82786. * @returns the vector length (float)
  82787. */
  82788. length(): number;
  82789. /**
  82790. * Gets the vector squared length
  82791. * @returns the vector squared length (float)
  82792. */
  82793. lengthSquared(): number;
  82794. /**
  82795. * Normalize the vector
  82796. * @returns the current updated Vector2
  82797. */
  82798. normalize(): Vector2;
  82799. /**
  82800. * Gets a new Vector2 copied from the Vector2
  82801. * @returns a new Vector2
  82802. */
  82803. clone(): Vector2;
  82804. /**
  82805. * Gets a new Vector2(0, 0)
  82806. * @returns a new Vector2
  82807. */
  82808. static Zero(): Vector2;
  82809. /**
  82810. * Gets a new Vector2(1, 1)
  82811. * @returns a new Vector2
  82812. */
  82813. static One(): Vector2;
  82814. /**
  82815. * Gets a new Vector2 set from the given index element of the given array
  82816. * @param array defines the data source
  82817. * @param offset defines the offset in the data source
  82818. * @returns a new Vector2
  82819. */
  82820. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82821. /**
  82822. * Sets "result" from the given index element of the given array
  82823. * @param array defines the data source
  82824. * @param offset defines the offset in the data source
  82825. * @param result defines the target vector
  82826. */
  82827. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82828. /**
  82829. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82830. * @param value1 defines 1st point of control
  82831. * @param value2 defines 2nd point of control
  82832. * @param value3 defines 3rd point of control
  82833. * @param value4 defines 4th point of control
  82834. * @param amount defines the interpolation factor
  82835. * @returns a new Vector2
  82836. */
  82837. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82838. /**
  82839. * 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".
  82840. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82841. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82842. * @param value defines the value to clamp
  82843. * @param min defines the lower limit
  82844. * @param max defines the upper limit
  82845. * @returns a new Vector2
  82846. */
  82847. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82848. /**
  82849. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82850. * @param value1 defines the 1st control point
  82851. * @param tangent1 defines the outgoing tangent
  82852. * @param value2 defines the 2nd control point
  82853. * @param tangent2 defines the incoming tangent
  82854. * @param amount defines the interpolation factor
  82855. * @returns a new Vector2
  82856. */
  82857. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82858. /**
  82859. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82860. * @param start defines the start vector
  82861. * @param end defines the end vector
  82862. * @param amount defines the interpolation factor
  82863. * @returns a new Vector2
  82864. */
  82865. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82866. /**
  82867. * Gets the dot product of the vector "left" and the vector "right"
  82868. * @param left defines first vector
  82869. * @param right defines second vector
  82870. * @returns the dot product (float)
  82871. */
  82872. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82873. /**
  82874. * Returns a new Vector2 equal to the normalized given vector
  82875. * @param vector defines the vector to normalize
  82876. * @returns a new Vector2
  82877. */
  82878. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82879. /**
  82880. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82881. * @param left defines 1st vector
  82882. * @param right defines 2nd vector
  82883. * @returns a new Vector2
  82884. */
  82885. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82886. /**
  82887. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82888. * @param left defines 1st vector
  82889. * @param right defines 2nd vector
  82890. * @returns a new Vector2
  82891. */
  82892. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82893. /**
  82894. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82895. * @param vector defines the vector to transform
  82896. * @param transformation defines the matrix to apply
  82897. * @returns a new Vector2
  82898. */
  82899. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82900. /**
  82901. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82902. * @param vector defines the vector to transform
  82903. * @param transformation defines the matrix to apply
  82904. * @param result defines the target vector
  82905. */
  82906. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82907. /**
  82908. * Determines if a given vector is included in a triangle
  82909. * @param p defines the vector to test
  82910. * @param p0 defines 1st triangle point
  82911. * @param p1 defines 2nd triangle point
  82912. * @param p2 defines 3rd triangle point
  82913. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82914. */
  82915. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82916. /**
  82917. * Gets the distance between the vectors "value1" and "value2"
  82918. * @param value1 defines first vector
  82919. * @param value2 defines second vector
  82920. * @returns the distance between vectors
  82921. */
  82922. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82923. /**
  82924. * Returns the squared distance between the vectors "value1" and "value2"
  82925. * @param value1 defines first vector
  82926. * @param value2 defines second vector
  82927. * @returns the squared distance between vectors
  82928. */
  82929. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82930. /**
  82931. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82932. * @param value1 defines first vector
  82933. * @param value2 defines second vector
  82934. * @returns a new Vector2
  82935. */
  82936. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82937. /**
  82938. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82939. * @param p defines the middle point
  82940. * @param segA defines one point of the segment
  82941. * @param segB defines the other point of the segment
  82942. * @returns the shortest distance
  82943. */
  82944. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82945. }
  82946. /**
  82947. * Class used to store (x,y,z) vector representation
  82948. * A Vector3 is the main object used in 3D geometry
  82949. * It can represent etiher the coordinates of a point the space, either a direction
  82950. * Reminder: js uses a left handed forward facing system
  82951. */
  82952. export class Vector3 {
  82953. private static _UpReadOnly;
  82954. private static _ZeroReadOnly;
  82955. /** @hidden */
  82956. _x: number;
  82957. /** @hidden */
  82958. _y: number;
  82959. /** @hidden */
  82960. _z: number;
  82961. /** @hidden */
  82962. _isDirty: boolean;
  82963. /** Gets or sets the x coordinate */
  82964. get x(): number;
  82965. set x(value: number);
  82966. /** Gets or sets the y coordinate */
  82967. get y(): number;
  82968. set y(value: number);
  82969. /** Gets or sets the z coordinate */
  82970. get z(): number;
  82971. set z(value: number);
  82972. /**
  82973. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82974. * @param x defines the first coordinates (on X axis)
  82975. * @param y defines the second coordinates (on Y axis)
  82976. * @param z defines the third coordinates (on Z axis)
  82977. */
  82978. constructor(x?: number, y?: number, z?: number);
  82979. /**
  82980. * Creates a string representation of the Vector3
  82981. * @returns a string with the Vector3 coordinates.
  82982. */
  82983. toString(): string;
  82984. /**
  82985. * Gets the class name
  82986. * @returns the string "Vector3"
  82987. */
  82988. getClassName(): string;
  82989. /**
  82990. * Creates the Vector3 hash code
  82991. * @returns a number which tends to be unique between Vector3 instances
  82992. */
  82993. getHashCode(): number;
  82994. /**
  82995. * Creates an array containing three elements : the coordinates of the Vector3
  82996. * @returns a new array of numbers
  82997. */
  82998. asArray(): number[];
  82999. /**
  83000. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83001. * @param array defines the destination array
  83002. * @param index defines the offset in the destination array
  83003. * @returns the current Vector3
  83004. */
  83005. toArray(array: FloatArray, index?: number): Vector3;
  83006. /**
  83007. * Update the current vector from an array
  83008. * @param array defines the destination array
  83009. * @param index defines the offset in the destination array
  83010. * @returns the current Vector3
  83011. */
  83012. fromArray(array: FloatArray, index?: number): Vector3;
  83013. /**
  83014. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83015. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83016. */
  83017. toQuaternion(): Quaternion;
  83018. /**
  83019. * Adds the given vector to the current Vector3
  83020. * @param otherVector defines the second operand
  83021. * @returns the current updated Vector3
  83022. */
  83023. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83024. /**
  83025. * Adds the given coordinates to the current Vector3
  83026. * @param x defines the x coordinate of the operand
  83027. * @param y defines the y coordinate of the operand
  83028. * @param z defines the z coordinate of the operand
  83029. * @returns the current updated Vector3
  83030. */
  83031. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83032. /**
  83033. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83034. * @param otherVector defines the second operand
  83035. * @returns the resulting Vector3
  83036. */
  83037. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83038. /**
  83039. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83040. * @param otherVector defines the second operand
  83041. * @param result defines the Vector3 object where to store the result
  83042. * @returns the current Vector3
  83043. */
  83044. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83045. /**
  83046. * Subtract the given vector from the current Vector3
  83047. * @param otherVector defines the second operand
  83048. * @returns the current updated Vector3
  83049. */
  83050. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83051. /**
  83052. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83053. * @param otherVector defines the second operand
  83054. * @returns the resulting Vector3
  83055. */
  83056. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83057. /**
  83058. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83059. * @param otherVector defines the second operand
  83060. * @param result defines the Vector3 object where to store the result
  83061. * @returns the current Vector3
  83062. */
  83063. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83064. /**
  83065. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83066. * @param x defines the x coordinate of the operand
  83067. * @param y defines the y coordinate of the operand
  83068. * @param z defines the z coordinate of the operand
  83069. * @returns the resulting Vector3
  83070. */
  83071. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83072. /**
  83073. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83074. * @param x defines the x coordinate of the operand
  83075. * @param y defines the y coordinate of the operand
  83076. * @param z defines the z coordinate of the operand
  83077. * @param result defines the Vector3 object where to store the result
  83078. * @returns the current Vector3
  83079. */
  83080. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83081. /**
  83082. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83083. * @returns a new Vector3
  83084. */
  83085. negate(): Vector3;
  83086. /**
  83087. * Negate this vector in place
  83088. * @returns this
  83089. */
  83090. negateInPlace(): Vector3;
  83091. /**
  83092. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83093. * @param result defines the Vector3 object where to store the result
  83094. * @returns the current Vector3
  83095. */
  83096. negateToRef(result: Vector3): Vector3;
  83097. /**
  83098. * Multiplies the Vector3 coordinates by the float "scale"
  83099. * @param scale defines the multiplier factor
  83100. * @returns the current updated Vector3
  83101. */
  83102. scaleInPlace(scale: number): Vector3;
  83103. /**
  83104. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83105. * @param scale defines the multiplier factor
  83106. * @returns a new Vector3
  83107. */
  83108. scale(scale: number): Vector3;
  83109. /**
  83110. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83111. * @param scale defines the multiplier factor
  83112. * @param result defines the Vector3 object where to store the result
  83113. * @returns the current Vector3
  83114. */
  83115. scaleToRef(scale: number, result: Vector3): Vector3;
  83116. /**
  83117. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83118. * @param scale defines the scale factor
  83119. * @param result defines the Vector3 object where to store the result
  83120. * @returns the unmodified current Vector3
  83121. */
  83122. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83123. /**
  83124. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83125. * @param origin defines the origin of the projection ray
  83126. * @param plane defines the plane to project to
  83127. * @returns the projected vector3
  83128. */
  83129. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83130. /**
  83131. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83132. * @param origin defines the origin of the projection ray
  83133. * @param plane defines the plane to project to
  83134. * @param result defines the Vector3 where to store the result
  83135. */
  83136. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83137. /**
  83138. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83139. * @param otherVector defines the second operand
  83140. * @returns true if both vectors are equals
  83141. */
  83142. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83143. /**
  83144. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83145. * @param otherVector defines the second operand
  83146. * @param epsilon defines the minimal distance to define values as equals
  83147. * @returns true if both vectors are distant less than epsilon
  83148. */
  83149. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83150. /**
  83151. * Returns true if the current Vector3 coordinates equals the given floats
  83152. * @param x defines the x coordinate of the operand
  83153. * @param y defines the y coordinate of the operand
  83154. * @param z defines the z coordinate of the operand
  83155. * @returns true if both vectors are equals
  83156. */
  83157. equalsToFloats(x: number, y: number, z: number): boolean;
  83158. /**
  83159. * Multiplies the current Vector3 coordinates by the given ones
  83160. * @param otherVector defines the second operand
  83161. * @returns the current updated Vector3
  83162. */
  83163. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83164. /**
  83165. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83166. * @param otherVector defines the second operand
  83167. * @returns the new Vector3
  83168. */
  83169. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83170. /**
  83171. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83172. * @param otherVector defines the second operand
  83173. * @param result defines the Vector3 object where to store the result
  83174. * @returns the current Vector3
  83175. */
  83176. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83177. /**
  83178. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83179. * @param x defines the x coordinate of the operand
  83180. * @param y defines the y coordinate of the operand
  83181. * @param z defines the z coordinate of the operand
  83182. * @returns the new Vector3
  83183. */
  83184. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83185. /**
  83186. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83187. * @param otherVector defines the second operand
  83188. * @returns the new Vector3
  83189. */
  83190. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83191. /**
  83192. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83193. * @param otherVector defines the second operand
  83194. * @param result defines the Vector3 object where to store the result
  83195. * @returns the current Vector3
  83196. */
  83197. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83198. /**
  83199. * Divides the current Vector3 coordinates by the given ones.
  83200. * @param otherVector defines the second operand
  83201. * @returns the current updated Vector3
  83202. */
  83203. divideInPlace(otherVector: Vector3): Vector3;
  83204. /**
  83205. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83206. * @param other defines the second operand
  83207. * @returns the current updated Vector3
  83208. */
  83209. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83210. /**
  83211. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83212. * @param other defines the second operand
  83213. * @returns the current updated Vector3
  83214. */
  83215. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83216. /**
  83217. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83218. * @param x defines the x coordinate of the operand
  83219. * @param y defines the y coordinate of the operand
  83220. * @param z defines the z coordinate of the operand
  83221. * @returns the current updated Vector3
  83222. */
  83223. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83224. /**
  83225. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83226. * @param x defines the x coordinate of the operand
  83227. * @param y defines the y coordinate of the operand
  83228. * @param z defines the z coordinate of the operand
  83229. * @returns the current updated Vector3
  83230. */
  83231. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83232. /**
  83233. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83234. * Check if is non uniform within a certain amount of decimal places to account for this
  83235. * @param epsilon the amount the values can differ
  83236. * @returns if the the vector is non uniform to a certain number of decimal places
  83237. */
  83238. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83239. /**
  83240. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83241. */
  83242. get isNonUniform(): boolean;
  83243. /**
  83244. * Gets a new Vector3 from current Vector3 floored values
  83245. * @returns a new Vector3
  83246. */
  83247. floor(): Vector3;
  83248. /**
  83249. * Gets a new Vector3 from current Vector3 floored values
  83250. * @returns a new Vector3
  83251. */
  83252. fract(): Vector3;
  83253. /**
  83254. * Gets the length of the Vector3
  83255. * @returns the length of the Vector3
  83256. */
  83257. length(): number;
  83258. /**
  83259. * Gets the squared length of the Vector3
  83260. * @returns squared length of the Vector3
  83261. */
  83262. lengthSquared(): number;
  83263. /**
  83264. * Normalize the current Vector3.
  83265. * Please note that this is an in place operation.
  83266. * @returns the current updated Vector3
  83267. */
  83268. normalize(): Vector3;
  83269. /**
  83270. * Reorders the x y z properties of the vector in place
  83271. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83272. * @returns the current updated vector
  83273. */
  83274. reorderInPlace(order: string): this;
  83275. /**
  83276. * Rotates the vector around 0,0,0 by a quaternion
  83277. * @param quaternion the rotation quaternion
  83278. * @param result vector to store the result
  83279. * @returns the resulting vector
  83280. */
  83281. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83282. /**
  83283. * Rotates a vector around a given point
  83284. * @param quaternion the rotation quaternion
  83285. * @param point the point to rotate around
  83286. * @param result vector to store the result
  83287. * @returns the resulting vector
  83288. */
  83289. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83290. /**
  83291. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83292. * The cross product is then orthogonal to both current and "other"
  83293. * @param other defines the right operand
  83294. * @returns the cross product
  83295. */
  83296. cross(other: Vector3): Vector3;
  83297. /**
  83298. * Normalize the current Vector3 with the given input length.
  83299. * Please note that this is an in place operation.
  83300. * @param len the length of the vector
  83301. * @returns the current updated Vector3
  83302. */
  83303. normalizeFromLength(len: number): Vector3;
  83304. /**
  83305. * Normalize the current Vector3 to a new vector
  83306. * @returns the new Vector3
  83307. */
  83308. normalizeToNew(): Vector3;
  83309. /**
  83310. * Normalize the current Vector3 to the reference
  83311. * @param reference define the Vector3 to update
  83312. * @returns the updated Vector3
  83313. */
  83314. normalizeToRef(reference: Vector3): Vector3;
  83315. /**
  83316. * Creates a new Vector3 copied from the current Vector3
  83317. * @returns the new Vector3
  83318. */
  83319. clone(): Vector3;
  83320. /**
  83321. * Copies the given vector coordinates to the current Vector3 ones
  83322. * @param source defines the source Vector3
  83323. * @returns the current updated Vector3
  83324. */
  83325. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83326. /**
  83327. * Copies the given floats to the current Vector3 coordinates
  83328. * @param x defines the x coordinate of the operand
  83329. * @param y defines the y coordinate of the operand
  83330. * @param z defines the z coordinate of the operand
  83331. * @returns the current updated Vector3
  83332. */
  83333. copyFromFloats(x: number, y: number, z: number): Vector3;
  83334. /**
  83335. * Copies the given floats to the current Vector3 coordinates
  83336. * @param x defines the x coordinate of the operand
  83337. * @param y defines the y coordinate of the operand
  83338. * @param z defines the z coordinate of the operand
  83339. * @returns the current updated Vector3
  83340. */
  83341. set(x: number, y: number, z: number): Vector3;
  83342. /**
  83343. * Copies the given float to the current Vector3 coordinates
  83344. * @param v defines the x, y and z coordinates of the operand
  83345. * @returns the current updated Vector3
  83346. */
  83347. setAll(v: number): Vector3;
  83348. /**
  83349. * Get the clip factor between two vectors
  83350. * @param vector0 defines the first operand
  83351. * @param vector1 defines the second operand
  83352. * @param axis defines the axis to use
  83353. * @param size defines the size along the axis
  83354. * @returns the clip factor
  83355. */
  83356. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83357. /**
  83358. * Get angle between two vectors
  83359. * @param vector0 angle between vector0 and vector1
  83360. * @param vector1 angle between vector0 and vector1
  83361. * @param normal direction of the normal
  83362. * @return the angle between vector0 and vector1
  83363. */
  83364. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83365. /**
  83366. * Returns a new Vector3 set from the index "offset" of the given array
  83367. * @param array defines the source array
  83368. * @param offset defines the offset in the source array
  83369. * @returns the new Vector3
  83370. */
  83371. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83372. /**
  83373. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83374. * @param array defines the source array
  83375. * @param offset defines the offset in the source array
  83376. * @returns the new Vector3
  83377. * @deprecated Please use FromArray instead.
  83378. */
  83379. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83380. /**
  83381. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83382. * @param array defines the source array
  83383. * @param offset defines the offset in the source array
  83384. * @param result defines the Vector3 where to store the result
  83385. */
  83386. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83387. /**
  83388. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83389. * @param array defines the source array
  83390. * @param offset defines the offset in the source array
  83391. * @param result defines the Vector3 where to store the result
  83392. * @deprecated Please use FromArrayToRef instead.
  83393. */
  83394. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83395. /**
  83396. * Sets the given vector "result" with the given floats.
  83397. * @param x defines the x coordinate of the source
  83398. * @param y defines the y coordinate of the source
  83399. * @param z defines the z coordinate of the source
  83400. * @param result defines the Vector3 where to store the result
  83401. */
  83402. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83403. /**
  83404. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83405. * @returns a new empty Vector3
  83406. */
  83407. static Zero(): Vector3;
  83408. /**
  83409. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83410. * @returns a new unit Vector3
  83411. */
  83412. static One(): Vector3;
  83413. /**
  83414. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83415. * @returns a new up Vector3
  83416. */
  83417. static Up(): Vector3;
  83418. /**
  83419. * Gets a up Vector3 that must not be updated
  83420. */
  83421. static get UpReadOnly(): DeepImmutable<Vector3>;
  83422. /**
  83423. * Gets a zero Vector3 that must not be updated
  83424. */
  83425. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83426. /**
  83427. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83428. * @returns a new down Vector3
  83429. */
  83430. static Down(): Vector3;
  83431. /**
  83432. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83433. * @param rightHandedSystem is the scene right-handed (negative z)
  83434. * @returns a new forward Vector3
  83435. */
  83436. static Forward(rightHandedSystem?: boolean): Vector3;
  83437. /**
  83438. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83439. * @param rightHandedSystem is the scene right-handed (negative-z)
  83440. * @returns a new forward Vector3
  83441. */
  83442. static Backward(rightHandedSystem?: boolean): Vector3;
  83443. /**
  83444. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83445. * @returns a new right Vector3
  83446. */
  83447. static Right(): Vector3;
  83448. /**
  83449. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83450. * @returns a new left Vector3
  83451. */
  83452. static Left(): Vector3;
  83453. /**
  83454. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83455. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83456. * @param vector defines the Vector3 to transform
  83457. * @param transformation defines the transformation matrix
  83458. * @returns the transformed Vector3
  83459. */
  83460. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83461. /**
  83462. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83463. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83464. * @param vector defines the Vector3 to transform
  83465. * @param transformation defines the transformation matrix
  83466. * @param result defines the Vector3 where to store the result
  83467. */
  83468. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83469. /**
  83470. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83471. * This method computes tranformed coordinates only, not transformed direction vectors
  83472. * @param x define the x coordinate of the source vector
  83473. * @param y define the y coordinate of the source vector
  83474. * @param z define the z coordinate of the source vector
  83475. * @param transformation defines the transformation matrix
  83476. * @param result defines the Vector3 where to store the result
  83477. */
  83478. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83479. /**
  83480. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83481. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83482. * @param vector defines the Vector3 to transform
  83483. * @param transformation defines the transformation matrix
  83484. * @returns the new Vector3
  83485. */
  83486. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83487. /**
  83488. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83489. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83490. * @param vector defines the Vector3 to transform
  83491. * @param transformation defines the transformation matrix
  83492. * @param result defines the Vector3 where to store the result
  83493. */
  83494. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83495. /**
  83496. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83497. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83498. * @param x define the x coordinate of the source vector
  83499. * @param y define the y coordinate of the source vector
  83500. * @param z define the z coordinate of the source vector
  83501. * @param transformation defines the transformation matrix
  83502. * @param result defines the Vector3 where to store the result
  83503. */
  83504. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83505. /**
  83506. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83507. * @param value1 defines the first control point
  83508. * @param value2 defines the second control point
  83509. * @param value3 defines the third control point
  83510. * @param value4 defines the fourth control point
  83511. * @param amount defines the amount on the spline to use
  83512. * @returns the new Vector3
  83513. */
  83514. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83515. /**
  83516. * 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"
  83517. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83518. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83519. * @param value defines the current value
  83520. * @param min defines the lower range value
  83521. * @param max defines the upper range value
  83522. * @returns the new Vector3
  83523. */
  83524. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83525. /**
  83526. * 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"
  83527. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83528. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83529. * @param value defines the current value
  83530. * @param min defines the lower range value
  83531. * @param max defines the upper range value
  83532. * @param result defines the Vector3 where to store the result
  83533. */
  83534. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83535. /**
  83536. * Checks if a given vector is inside a specific range
  83537. * @param v defines the vector to test
  83538. * @param min defines the minimum range
  83539. * @param max defines the maximum range
  83540. */
  83541. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83542. /**
  83543. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83544. * @param value1 defines the first control point
  83545. * @param tangent1 defines the first tangent vector
  83546. * @param value2 defines the second control point
  83547. * @param tangent2 defines the second tangent vector
  83548. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83549. * @returns the new Vector3
  83550. */
  83551. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83552. /**
  83553. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83554. * @param start defines the start value
  83555. * @param end defines the end value
  83556. * @param amount max defines amount between both (between 0 and 1)
  83557. * @returns the new Vector3
  83558. */
  83559. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83560. /**
  83561. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83562. * @param start defines the start value
  83563. * @param end defines the end value
  83564. * @param amount max defines amount between both (between 0 and 1)
  83565. * @param result defines the Vector3 where to store the result
  83566. */
  83567. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83568. /**
  83569. * Returns the dot product (float) between the vectors "left" and "right"
  83570. * @param left defines the left operand
  83571. * @param right defines the right operand
  83572. * @returns the dot product
  83573. */
  83574. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83575. /**
  83576. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83577. * The cross product is then orthogonal to both "left" and "right"
  83578. * @param left defines the left operand
  83579. * @param right defines the right operand
  83580. * @returns the cross product
  83581. */
  83582. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83583. /**
  83584. * Sets the given vector "result" with the cross product of "left" and "right"
  83585. * The cross product is then orthogonal to both "left" and "right"
  83586. * @param left defines the left operand
  83587. * @param right defines the right operand
  83588. * @param result defines the Vector3 where to store the result
  83589. */
  83590. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83591. /**
  83592. * Returns a new Vector3 as the normalization of the given vector
  83593. * @param vector defines the Vector3 to normalize
  83594. * @returns the new Vector3
  83595. */
  83596. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83597. /**
  83598. * Sets the given vector "result" with the normalization of the given first vector
  83599. * @param vector defines the Vector3 to normalize
  83600. * @param result defines the Vector3 where to store the result
  83601. */
  83602. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83603. /**
  83604. * Project a Vector3 onto screen space
  83605. * @param vector defines the Vector3 to project
  83606. * @param world defines the world matrix to use
  83607. * @param transform defines the transform (view x projection) matrix to use
  83608. * @param viewport defines the screen viewport to use
  83609. * @returns the new Vector3
  83610. */
  83611. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83612. /** @hidden */
  83613. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83614. /**
  83615. * Unproject from screen space to object space
  83616. * @param source defines the screen space Vector3 to use
  83617. * @param viewportWidth defines the current width of the viewport
  83618. * @param viewportHeight defines the current height of the viewport
  83619. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83620. * @param transform defines the transform (view x projection) matrix to use
  83621. * @returns the new Vector3
  83622. */
  83623. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83624. /**
  83625. * Unproject from screen space to object space
  83626. * @param source defines the screen space Vector3 to use
  83627. * @param viewportWidth defines the current width of the viewport
  83628. * @param viewportHeight defines the current height of the viewport
  83629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83630. * @param view defines the view matrix to use
  83631. * @param projection defines the projection matrix to use
  83632. * @returns the new Vector3
  83633. */
  83634. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83635. /**
  83636. * Unproject from screen space to object space
  83637. * @param source defines the screen space Vector3 to use
  83638. * @param viewportWidth defines the current width of the viewport
  83639. * @param viewportHeight defines the current height of the viewport
  83640. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83641. * @param view defines the view matrix to use
  83642. * @param projection defines the projection matrix to use
  83643. * @param result defines the Vector3 where to store the result
  83644. */
  83645. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83646. /**
  83647. * Unproject from screen space to object space
  83648. * @param sourceX defines the screen space x coordinate to use
  83649. * @param sourceY defines the screen space y coordinate to use
  83650. * @param sourceZ defines the screen space z coordinate to use
  83651. * @param viewportWidth defines the current width of the viewport
  83652. * @param viewportHeight defines the current height of the viewport
  83653. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83654. * @param view defines the view matrix to use
  83655. * @param projection defines the projection matrix to use
  83656. * @param result defines the Vector3 where to store the result
  83657. */
  83658. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83659. /**
  83660. * Gets the minimal coordinate values between two Vector3
  83661. * @param left defines the first operand
  83662. * @param right defines the second operand
  83663. * @returns the new Vector3
  83664. */
  83665. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83666. /**
  83667. * Gets the maximal coordinate values between two Vector3
  83668. * @param left defines the first operand
  83669. * @param right defines the second operand
  83670. * @returns the new Vector3
  83671. */
  83672. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83673. /**
  83674. * Returns the distance between the vectors "value1" and "value2"
  83675. * @param value1 defines the first operand
  83676. * @param value2 defines the second operand
  83677. * @returns the distance
  83678. */
  83679. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83680. /**
  83681. * Returns the squared distance between the vectors "value1" and "value2"
  83682. * @param value1 defines the first operand
  83683. * @param value2 defines the second operand
  83684. * @returns the squared distance
  83685. */
  83686. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83687. /**
  83688. * Returns a new Vector3 located at the center between "value1" and "value2"
  83689. * @param value1 defines the first operand
  83690. * @param value2 defines the second operand
  83691. * @returns the new Vector3
  83692. */
  83693. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83694. /**
  83695. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83696. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83697. * to something in order to rotate it from its local system to the given target system
  83698. * Note: axis1, axis2 and axis3 are normalized during this operation
  83699. * @param axis1 defines the first axis
  83700. * @param axis2 defines the second axis
  83701. * @param axis3 defines the third axis
  83702. * @returns a new Vector3
  83703. */
  83704. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83705. /**
  83706. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83707. * @param axis1 defines the first axis
  83708. * @param axis2 defines the second axis
  83709. * @param axis3 defines the third axis
  83710. * @param ref defines the Vector3 where to store the result
  83711. */
  83712. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83713. }
  83714. /**
  83715. * Vector4 class created for EulerAngle class conversion to Quaternion
  83716. */
  83717. export class Vector4 {
  83718. /** x value of the vector */
  83719. x: number;
  83720. /** y value of the vector */
  83721. y: number;
  83722. /** z value of the vector */
  83723. z: number;
  83724. /** w value of the vector */
  83725. w: number;
  83726. /**
  83727. * Creates a Vector4 object from the given floats.
  83728. * @param x x value of the vector
  83729. * @param y y value of the vector
  83730. * @param z z value of the vector
  83731. * @param w w value of the vector
  83732. */
  83733. constructor(
  83734. /** x value of the vector */
  83735. x: number,
  83736. /** y value of the vector */
  83737. y: number,
  83738. /** z value of the vector */
  83739. z: number,
  83740. /** w value of the vector */
  83741. w: number);
  83742. /**
  83743. * Returns the string with the Vector4 coordinates.
  83744. * @returns a string containing all the vector values
  83745. */
  83746. toString(): string;
  83747. /**
  83748. * Returns the string "Vector4".
  83749. * @returns "Vector4"
  83750. */
  83751. getClassName(): string;
  83752. /**
  83753. * Returns the Vector4 hash code.
  83754. * @returns a unique hash code
  83755. */
  83756. getHashCode(): number;
  83757. /**
  83758. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83759. * @returns the resulting array
  83760. */
  83761. asArray(): number[];
  83762. /**
  83763. * Populates the given array from the given index with the Vector4 coordinates.
  83764. * @param array array to populate
  83765. * @param index index of the array to start at (default: 0)
  83766. * @returns the Vector4.
  83767. */
  83768. toArray(array: FloatArray, index?: number): Vector4;
  83769. /**
  83770. * Update the current vector from an array
  83771. * @param array defines the destination array
  83772. * @param index defines the offset in the destination array
  83773. * @returns the current Vector3
  83774. */
  83775. fromArray(array: FloatArray, index?: number): Vector4;
  83776. /**
  83777. * Adds the given vector to the current Vector4.
  83778. * @param otherVector the vector to add
  83779. * @returns the updated Vector4.
  83780. */
  83781. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83782. /**
  83783. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83784. * @param otherVector the vector to add
  83785. * @returns the resulting vector
  83786. */
  83787. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83788. /**
  83789. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83790. * @param otherVector the vector to add
  83791. * @param result the vector to store the result
  83792. * @returns the current Vector4.
  83793. */
  83794. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83795. /**
  83796. * Subtract in place the given vector from the current Vector4.
  83797. * @param otherVector the vector to subtract
  83798. * @returns the updated Vector4.
  83799. */
  83800. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83801. /**
  83802. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83803. * @param otherVector the vector to add
  83804. * @returns the new vector with the result
  83805. */
  83806. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83807. /**
  83808. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83809. * @param otherVector the vector to subtract
  83810. * @param result the vector to store the result
  83811. * @returns the current Vector4.
  83812. */
  83813. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83814. /**
  83815. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83816. */
  83817. /**
  83818. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83819. * @param x value to subtract
  83820. * @param y value to subtract
  83821. * @param z value to subtract
  83822. * @param w value to subtract
  83823. * @returns new vector containing the result
  83824. */
  83825. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83826. /**
  83827. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83828. * @param x value to subtract
  83829. * @param y value to subtract
  83830. * @param z value to subtract
  83831. * @param w value to subtract
  83832. * @param result the vector to store the result in
  83833. * @returns the current Vector4.
  83834. */
  83835. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83836. /**
  83837. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83838. * @returns a new vector with the negated values
  83839. */
  83840. negate(): Vector4;
  83841. /**
  83842. * Negate this vector in place
  83843. * @returns this
  83844. */
  83845. negateInPlace(): Vector4;
  83846. /**
  83847. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83848. * @param result defines the Vector3 object where to store the result
  83849. * @returns the current Vector4
  83850. */
  83851. negateToRef(result: Vector4): Vector4;
  83852. /**
  83853. * Multiplies the current Vector4 coordinates by scale (float).
  83854. * @param scale the number to scale with
  83855. * @returns the updated Vector4.
  83856. */
  83857. scaleInPlace(scale: number): Vector4;
  83858. /**
  83859. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83860. * @param scale the number to scale with
  83861. * @returns a new vector with the result
  83862. */
  83863. scale(scale: number): Vector4;
  83864. /**
  83865. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83866. * @param scale the number to scale with
  83867. * @param result a vector to store the result in
  83868. * @returns the current Vector4.
  83869. */
  83870. scaleToRef(scale: number, result: Vector4): Vector4;
  83871. /**
  83872. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83873. * @param scale defines the scale factor
  83874. * @param result defines the Vector4 object where to store the result
  83875. * @returns the unmodified current Vector4
  83876. */
  83877. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83878. /**
  83879. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83880. * @param otherVector the vector to compare against
  83881. * @returns true if they are equal
  83882. */
  83883. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83884. /**
  83885. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83886. * @param otherVector vector to compare against
  83887. * @param epsilon (Default: very small number)
  83888. * @returns true if they are equal
  83889. */
  83890. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83891. /**
  83892. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83893. * @param x x value to compare against
  83894. * @param y y value to compare against
  83895. * @param z z value to compare against
  83896. * @param w w value to compare against
  83897. * @returns true if equal
  83898. */
  83899. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83900. /**
  83901. * Multiplies in place the current Vector4 by the given one.
  83902. * @param otherVector vector to multiple with
  83903. * @returns the updated Vector4.
  83904. */
  83905. multiplyInPlace(otherVector: Vector4): Vector4;
  83906. /**
  83907. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83908. * @param otherVector vector to multiple with
  83909. * @returns resulting new vector
  83910. */
  83911. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83912. /**
  83913. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83914. * @param otherVector vector to multiple with
  83915. * @param result vector to store the result
  83916. * @returns the current Vector4.
  83917. */
  83918. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83919. /**
  83920. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83921. * @param x x value multiply with
  83922. * @param y y value multiply with
  83923. * @param z z value multiply with
  83924. * @param w w value multiply with
  83925. * @returns resulting new vector
  83926. */
  83927. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83928. /**
  83929. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83930. * @param otherVector vector to devide with
  83931. * @returns resulting new vector
  83932. */
  83933. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83934. /**
  83935. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83936. * @param otherVector vector to devide with
  83937. * @param result vector to store the result
  83938. * @returns the current Vector4.
  83939. */
  83940. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83941. /**
  83942. * Divides the current Vector3 coordinates by the given ones.
  83943. * @param otherVector vector to devide with
  83944. * @returns the updated Vector3.
  83945. */
  83946. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83947. /**
  83948. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83949. * @param other defines the second operand
  83950. * @returns the current updated Vector4
  83951. */
  83952. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83953. /**
  83954. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83955. * @param other defines the second operand
  83956. * @returns the current updated Vector4
  83957. */
  83958. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83959. /**
  83960. * Gets a new Vector4 from current Vector4 floored values
  83961. * @returns a new Vector4
  83962. */
  83963. floor(): Vector4;
  83964. /**
  83965. * Gets a new Vector4 from current Vector3 floored values
  83966. * @returns a new Vector4
  83967. */
  83968. fract(): Vector4;
  83969. /**
  83970. * Returns the Vector4 length (float).
  83971. * @returns the length
  83972. */
  83973. length(): number;
  83974. /**
  83975. * Returns the Vector4 squared length (float).
  83976. * @returns the length squared
  83977. */
  83978. lengthSquared(): number;
  83979. /**
  83980. * Normalizes in place the Vector4.
  83981. * @returns the updated Vector4.
  83982. */
  83983. normalize(): Vector4;
  83984. /**
  83985. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83986. * @returns this converted to a new vector3
  83987. */
  83988. toVector3(): Vector3;
  83989. /**
  83990. * Returns a new Vector4 copied from the current one.
  83991. * @returns the new cloned vector
  83992. */
  83993. clone(): Vector4;
  83994. /**
  83995. * Updates the current Vector4 with the given one coordinates.
  83996. * @param source the source vector to copy from
  83997. * @returns the updated Vector4.
  83998. */
  83999. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84000. /**
  84001. * Updates the current Vector4 coordinates with the given floats.
  84002. * @param x float to copy from
  84003. * @param y float to copy from
  84004. * @param z float to copy from
  84005. * @param w float to copy from
  84006. * @returns the updated Vector4.
  84007. */
  84008. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84009. /**
  84010. * Updates the current Vector4 coordinates with the given floats.
  84011. * @param x float to set from
  84012. * @param y float to set from
  84013. * @param z float to set from
  84014. * @param w float to set from
  84015. * @returns the updated Vector4.
  84016. */
  84017. set(x: number, y: number, z: number, w: number): Vector4;
  84018. /**
  84019. * Copies the given float to the current Vector3 coordinates
  84020. * @param v defines the x, y, z and w coordinates of the operand
  84021. * @returns the current updated Vector3
  84022. */
  84023. setAll(v: number): Vector4;
  84024. /**
  84025. * Returns a new Vector4 set from the starting index of the given array.
  84026. * @param array the array to pull values from
  84027. * @param offset the offset into the array to start at
  84028. * @returns the new vector
  84029. */
  84030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84031. /**
  84032. * Updates the given vector "result" from the starting index of the given array.
  84033. * @param array the array to pull values from
  84034. * @param offset the offset into the array to start at
  84035. * @param result the vector to store the result in
  84036. */
  84037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84038. /**
  84039. * Updates the given vector "result" from the starting index of the given Float32Array.
  84040. * @param array the array to pull values from
  84041. * @param offset the offset into the array to start at
  84042. * @param result the vector to store the result in
  84043. */
  84044. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84045. /**
  84046. * Updates the given vector "result" coordinates from the given floats.
  84047. * @param x float to set from
  84048. * @param y float to set from
  84049. * @param z float to set from
  84050. * @param w float to set from
  84051. * @param result the vector to the floats in
  84052. */
  84053. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84054. /**
  84055. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84056. * @returns the new vector
  84057. */
  84058. static Zero(): Vector4;
  84059. /**
  84060. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84061. * @returns the new vector
  84062. */
  84063. static One(): Vector4;
  84064. /**
  84065. * Returns a new normalized Vector4 from the given one.
  84066. * @param vector the vector to normalize
  84067. * @returns the vector
  84068. */
  84069. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84070. /**
  84071. * Updates the given vector "result" from the normalization of the given one.
  84072. * @param vector the vector to normalize
  84073. * @param result the vector to store the result in
  84074. */
  84075. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84076. /**
  84077. * Returns a vector with the minimum values from the left and right vectors
  84078. * @param left left vector to minimize
  84079. * @param right right vector to minimize
  84080. * @returns a new vector with the minimum of the left and right vector values
  84081. */
  84082. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84083. /**
  84084. * Returns a vector with the maximum values from the left and right vectors
  84085. * @param left left vector to maximize
  84086. * @param right right vector to maximize
  84087. * @returns a new vector with the maximum of the left and right vector values
  84088. */
  84089. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84090. /**
  84091. * Returns the distance (float) between the vectors "value1" and "value2".
  84092. * @param value1 value to calulate the distance between
  84093. * @param value2 value to calulate the distance between
  84094. * @return the distance between the two vectors
  84095. */
  84096. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84097. /**
  84098. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84099. * @param value1 value to calulate the distance between
  84100. * @param value2 value to calulate the distance between
  84101. * @return the distance between the two vectors squared
  84102. */
  84103. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84104. /**
  84105. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84106. * @param value1 value to calulate the center between
  84107. * @param value2 value to calulate the center between
  84108. * @return the center between the two vectors
  84109. */
  84110. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84111. /**
  84112. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84113. * This methods computes transformed normalized direction vectors only.
  84114. * @param vector the vector to transform
  84115. * @param transformation the transformation matrix to apply
  84116. * @returns the new vector
  84117. */
  84118. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84119. /**
  84120. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84121. * This methods computes transformed normalized direction vectors only.
  84122. * @param vector the vector to transform
  84123. * @param transformation the transformation matrix to apply
  84124. * @param result the vector to store the result in
  84125. */
  84126. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84127. /**
  84128. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84129. * This methods computes transformed normalized direction vectors only.
  84130. * @param x value to transform
  84131. * @param y value to transform
  84132. * @param z value to transform
  84133. * @param w value to transform
  84134. * @param transformation the transformation matrix to apply
  84135. * @param result the vector to store the results in
  84136. */
  84137. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84138. /**
  84139. * Creates a new Vector4 from a Vector3
  84140. * @param source defines the source data
  84141. * @param w defines the 4th component (default is 0)
  84142. * @returns a new Vector4
  84143. */
  84144. static FromVector3(source: Vector3, w?: number): Vector4;
  84145. }
  84146. /**
  84147. * Class used to store quaternion data
  84148. * @see https://en.wikipedia.org/wiki/Quaternion
  84149. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84150. */
  84151. export class Quaternion {
  84152. /** @hidden */
  84153. _x: number;
  84154. /** @hidden */
  84155. _y: number;
  84156. /** @hidden */
  84157. _z: number;
  84158. /** @hidden */
  84159. _w: number;
  84160. /** @hidden */
  84161. _isDirty: boolean;
  84162. /** Gets or sets the x coordinate */
  84163. get x(): number;
  84164. set x(value: number);
  84165. /** Gets or sets the y coordinate */
  84166. get y(): number;
  84167. set y(value: number);
  84168. /** Gets or sets the z coordinate */
  84169. get z(): number;
  84170. set z(value: number);
  84171. /** Gets or sets the w coordinate */
  84172. get w(): number;
  84173. set w(value: number);
  84174. /**
  84175. * Creates a new Quaternion from the given floats
  84176. * @param x defines the first component (0 by default)
  84177. * @param y defines the second component (0 by default)
  84178. * @param z defines the third component (0 by default)
  84179. * @param w defines the fourth component (1.0 by default)
  84180. */
  84181. constructor(x?: number, y?: number, z?: number, w?: number);
  84182. /**
  84183. * Gets a string representation for the current quaternion
  84184. * @returns a string with the Quaternion coordinates
  84185. */
  84186. toString(): string;
  84187. /**
  84188. * Gets the class name of the quaternion
  84189. * @returns the string "Quaternion"
  84190. */
  84191. getClassName(): string;
  84192. /**
  84193. * Gets a hash code for this quaternion
  84194. * @returns the quaternion hash code
  84195. */
  84196. getHashCode(): number;
  84197. /**
  84198. * Copy the quaternion to an array
  84199. * @returns a new array populated with 4 elements from the quaternion coordinates
  84200. */
  84201. asArray(): number[];
  84202. /**
  84203. * Check if two quaternions are equals
  84204. * @param otherQuaternion defines the second operand
  84205. * @return true if the current quaternion and the given one coordinates are strictly equals
  84206. */
  84207. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84208. /**
  84209. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84210. * @param otherQuaternion defines the other quaternion
  84211. * @param epsilon defines the minimal distance to consider equality
  84212. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84213. */
  84214. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84215. /**
  84216. * Clone the current quaternion
  84217. * @returns a new quaternion copied from the current one
  84218. */
  84219. clone(): Quaternion;
  84220. /**
  84221. * Copy a quaternion to the current one
  84222. * @param other defines the other quaternion
  84223. * @returns the updated current quaternion
  84224. */
  84225. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84226. /**
  84227. * Updates the current quaternion with the given float coordinates
  84228. * @param x defines the x coordinate
  84229. * @param y defines the y coordinate
  84230. * @param z defines the z coordinate
  84231. * @param w defines the w coordinate
  84232. * @returns the updated current quaternion
  84233. */
  84234. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84235. /**
  84236. * Updates the current quaternion from the given float coordinates
  84237. * @param x defines the x coordinate
  84238. * @param y defines the y coordinate
  84239. * @param z defines the z coordinate
  84240. * @param w defines the w coordinate
  84241. * @returns the updated current quaternion
  84242. */
  84243. set(x: number, y: number, z: number, w: number): Quaternion;
  84244. /**
  84245. * Adds two quaternions
  84246. * @param other defines the second operand
  84247. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84248. */
  84249. add(other: DeepImmutable<Quaternion>): Quaternion;
  84250. /**
  84251. * Add a quaternion to the current one
  84252. * @param other defines the quaternion to add
  84253. * @returns the current quaternion
  84254. */
  84255. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84256. /**
  84257. * Subtract two quaternions
  84258. * @param other defines the second operand
  84259. * @returns a new quaternion as the subtraction result of the given one from the current one
  84260. */
  84261. subtract(other: Quaternion): Quaternion;
  84262. /**
  84263. * Multiplies the current quaternion by a scale factor
  84264. * @param value defines the scale factor
  84265. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84266. */
  84267. scale(value: number): Quaternion;
  84268. /**
  84269. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84270. * @param scale defines the scale factor
  84271. * @param result defines the Quaternion object where to store the result
  84272. * @returns the unmodified current quaternion
  84273. */
  84274. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84275. /**
  84276. * Multiplies in place the current quaternion by a scale factor
  84277. * @param value defines the scale factor
  84278. * @returns the current modified quaternion
  84279. */
  84280. scaleInPlace(value: number): Quaternion;
  84281. /**
  84282. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84283. * @param scale defines the scale factor
  84284. * @param result defines the Quaternion object where to store the result
  84285. * @returns the unmodified current quaternion
  84286. */
  84287. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84288. /**
  84289. * Multiplies two quaternions
  84290. * @param q1 defines the second operand
  84291. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84292. */
  84293. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84294. /**
  84295. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84296. * @param q1 defines the second operand
  84297. * @param result defines the target quaternion
  84298. * @returns the current quaternion
  84299. */
  84300. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84301. /**
  84302. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84303. * @param q1 defines the second operand
  84304. * @returns the currentupdated quaternion
  84305. */
  84306. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84307. /**
  84308. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84309. * @param ref defines the target quaternion
  84310. * @returns the current quaternion
  84311. */
  84312. conjugateToRef(ref: Quaternion): Quaternion;
  84313. /**
  84314. * Conjugates in place (1-q) the current quaternion
  84315. * @returns the current updated quaternion
  84316. */
  84317. conjugateInPlace(): Quaternion;
  84318. /**
  84319. * Conjugates in place (1-q) the current quaternion
  84320. * @returns a new quaternion
  84321. */
  84322. conjugate(): Quaternion;
  84323. /**
  84324. * Gets length of current quaternion
  84325. * @returns the quaternion length (float)
  84326. */
  84327. length(): number;
  84328. /**
  84329. * Normalize in place the current quaternion
  84330. * @returns the current updated quaternion
  84331. */
  84332. normalize(): Quaternion;
  84333. /**
  84334. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84335. * @param order is a reserved parameter and is ignored for now
  84336. * @returns a new Vector3 containing the Euler angles
  84337. */
  84338. toEulerAngles(order?: string): Vector3;
  84339. /**
  84340. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84341. * @param result defines the vector which will be filled with the Euler angles
  84342. * @returns the current unchanged quaternion
  84343. */
  84344. toEulerAnglesToRef(result: Vector3): Quaternion;
  84345. /**
  84346. * Updates the given rotation matrix with the current quaternion values
  84347. * @param result defines the target matrix
  84348. * @returns the current unchanged quaternion
  84349. */
  84350. toRotationMatrix(result: Matrix): Quaternion;
  84351. /**
  84352. * Updates the current quaternion from the given rotation matrix values
  84353. * @param matrix defines the source matrix
  84354. * @returns the current updated quaternion
  84355. */
  84356. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84357. /**
  84358. * Creates a new quaternion from a rotation matrix
  84359. * @param matrix defines the source matrix
  84360. * @returns a new quaternion created from the given rotation matrix values
  84361. */
  84362. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84363. /**
  84364. * Updates the given quaternion with the given rotation matrix values
  84365. * @param matrix defines the source matrix
  84366. * @param result defines the target quaternion
  84367. */
  84368. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84369. /**
  84370. * Returns the dot product (float) between the quaternions "left" and "right"
  84371. * @param left defines the left operand
  84372. * @param right defines the right operand
  84373. * @returns the dot product
  84374. */
  84375. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84376. /**
  84377. * Checks if the two quaternions are close to each other
  84378. * @param quat0 defines the first quaternion to check
  84379. * @param quat1 defines the second quaternion to check
  84380. * @returns true if the two quaternions are close to each other
  84381. */
  84382. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84383. /**
  84384. * Creates an empty quaternion
  84385. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84386. */
  84387. static Zero(): Quaternion;
  84388. /**
  84389. * Inverse a given quaternion
  84390. * @param q defines the source quaternion
  84391. * @returns a new quaternion as the inverted current quaternion
  84392. */
  84393. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84394. /**
  84395. * Inverse a given quaternion
  84396. * @param q defines the source quaternion
  84397. * @param result the quaternion the result will be stored in
  84398. * @returns the result quaternion
  84399. */
  84400. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84401. /**
  84402. * Creates an identity quaternion
  84403. * @returns the identity quaternion
  84404. */
  84405. static Identity(): Quaternion;
  84406. /**
  84407. * Gets a boolean indicating if the given quaternion is identity
  84408. * @param quaternion defines the quaternion to check
  84409. * @returns true if the quaternion is identity
  84410. */
  84411. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84412. /**
  84413. * Creates a quaternion from a rotation around an axis
  84414. * @param axis defines the axis to use
  84415. * @param angle defines the angle to use
  84416. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84417. */
  84418. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84419. /**
  84420. * Creates a rotation around an axis and stores it into the given quaternion
  84421. * @param axis defines the axis to use
  84422. * @param angle defines the angle to use
  84423. * @param result defines the target quaternion
  84424. * @returns the target quaternion
  84425. */
  84426. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84427. /**
  84428. * Creates a new quaternion from data stored into an array
  84429. * @param array defines the data source
  84430. * @param offset defines the offset in the source array where the data starts
  84431. * @returns a new quaternion
  84432. */
  84433. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84434. /**
  84435. * Updates the given quaternion "result" from the starting index of the given array.
  84436. * @param array the array to pull values from
  84437. * @param offset the offset into the array to start at
  84438. * @param result the quaternion to store the result in
  84439. */
  84440. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84441. /**
  84442. * Create a quaternion from Euler rotation angles
  84443. * @param x Pitch
  84444. * @param y Yaw
  84445. * @param z Roll
  84446. * @returns the new Quaternion
  84447. */
  84448. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84449. /**
  84450. * Updates a quaternion from Euler rotation angles
  84451. * @param x Pitch
  84452. * @param y Yaw
  84453. * @param z Roll
  84454. * @param result the quaternion to store the result
  84455. * @returns the updated quaternion
  84456. */
  84457. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84458. /**
  84459. * Create a quaternion from Euler rotation vector
  84460. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84461. * @returns the new Quaternion
  84462. */
  84463. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84464. /**
  84465. * Updates a quaternion from Euler rotation vector
  84466. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84467. * @param result the quaternion to store the result
  84468. * @returns the updated quaternion
  84469. */
  84470. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84471. /**
  84472. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84473. * @param yaw defines the rotation around Y axis
  84474. * @param pitch defines the rotation around X axis
  84475. * @param roll defines the rotation around Z axis
  84476. * @returns the new quaternion
  84477. */
  84478. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84479. /**
  84480. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84481. * @param yaw defines the rotation around Y axis
  84482. * @param pitch defines the rotation around X axis
  84483. * @param roll defines the rotation around Z axis
  84484. * @param result defines the target quaternion
  84485. */
  84486. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84487. /**
  84488. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84489. * @param alpha defines the rotation around first axis
  84490. * @param beta defines the rotation around second axis
  84491. * @param gamma defines the rotation around third axis
  84492. * @returns the new quaternion
  84493. */
  84494. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84495. /**
  84496. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84497. * @param alpha defines the rotation around first axis
  84498. * @param beta defines the rotation around second axis
  84499. * @param gamma defines the rotation around third axis
  84500. * @param result defines the target quaternion
  84501. */
  84502. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84503. /**
  84504. * 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)
  84505. * @param axis1 defines the first axis
  84506. * @param axis2 defines the second axis
  84507. * @param axis3 defines the third axis
  84508. * @returns the new quaternion
  84509. */
  84510. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84511. /**
  84512. * 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
  84513. * @param axis1 defines the first axis
  84514. * @param axis2 defines the second axis
  84515. * @param axis3 defines the third axis
  84516. * @param ref defines the target quaternion
  84517. */
  84518. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84519. /**
  84520. * Interpolates between two quaternions
  84521. * @param left defines first quaternion
  84522. * @param right defines second quaternion
  84523. * @param amount defines the gradient to use
  84524. * @returns the new interpolated quaternion
  84525. */
  84526. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84527. /**
  84528. * Interpolates between two quaternions and stores it into a target quaternion
  84529. * @param left defines first quaternion
  84530. * @param right defines second quaternion
  84531. * @param amount defines the gradient to use
  84532. * @param result defines the target quaternion
  84533. */
  84534. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84535. /**
  84536. * Interpolate between two quaternions using Hermite interpolation
  84537. * @param value1 defines first quaternion
  84538. * @param tangent1 defines the incoming tangent
  84539. * @param value2 defines second quaternion
  84540. * @param tangent2 defines the outgoing tangent
  84541. * @param amount defines the target quaternion
  84542. * @returns the new interpolated quaternion
  84543. */
  84544. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84545. }
  84546. /**
  84547. * Class used to store matrix data (4x4)
  84548. */
  84549. export class Matrix {
  84550. /**
  84551. * Gets the precision of matrix computations
  84552. */
  84553. static get Use64Bits(): boolean;
  84554. private static _updateFlagSeed;
  84555. private static _identityReadOnly;
  84556. private _isIdentity;
  84557. private _isIdentityDirty;
  84558. private _isIdentity3x2;
  84559. private _isIdentity3x2Dirty;
  84560. /**
  84561. * Gets the update flag of the matrix which is an unique number for the matrix.
  84562. * It will be incremented every time the matrix data change.
  84563. * You can use it to speed the comparison between two versions of the same matrix.
  84564. */
  84565. updateFlag: number;
  84566. private readonly _m;
  84567. /**
  84568. * Gets the internal data of the matrix
  84569. */
  84570. get m(): DeepImmutable<Float32Array | Array<number>>;
  84571. /** @hidden */
  84572. _markAsUpdated(): void;
  84573. /** @hidden */
  84574. private _updateIdentityStatus;
  84575. /**
  84576. * Creates an empty matrix (filled with zeros)
  84577. */
  84578. constructor();
  84579. /**
  84580. * Check if the current matrix is identity
  84581. * @returns true is the matrix is the identity matrix
  84582. */
  84583. isIdentity(): boolean;
  84584. /**
  84585. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84586. * @returns true is the matrix is the identity matrix
  84587. */
  84588. isIdentityAs3x2(): boolean;
  84589. /**
  84590. * Gets the determinant of the matrix
  84591. * @returns the matrix determinant
  84592. */
  84593. determinant(): number;
  84594. /**
  84595. * Returns the matrix as a Float32Array or Array<number>
  84596. * @returns the matrix underlying array
  84597. */
  84598. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84599. /**
  84600. * Returns the matrix as a Float32Array or Array<number>
  84601. * @returns the matrix underlying array.
  84602. */
  84603. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84604. /**
  84605. * Inverts the current matrix in place
  84606. * @returns the current inverted matrix
  84607. */
  84608. invert(): Matrix;
  84609. /**
  84610. * Sets all the matrix elements to zero
  84611. * @returns the current matrix
  84612. */
  84613. reset(): Matrix;
  84614. /**
  84615. * Adds the current matrix with a second one
  84616. * @param other defines the matrix to add
  84617. * @returns a new matrix as the addition of the current matrix and the given one
  84618. */
  84619. add(other: DeepImmutable<Matrix>): Matrix;
  84620. /**
  84621. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84622. * @param other defines the matrix to add
  84623. * @param result defines the target matrix
  84624. * @returns the current matrix
  84625. */
  84626. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84627. /**
  84628. * Adds in place the given matrix to the current matrix
  84629. * @param other defines the second operand
  84630. * @returns the current updated matrix
  84631. */
  84632. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84633. /**
  84634. * Sets the given matrix to the current inverted Matrix
  84635. * @param other defines the target matrix
  84636. * @returns the unmodified current matrix
  84637. */
  84638. invertToRef(other: Matrix): Matrix;
  84639. /**
  84640. * add a value at the specified position in the current Matrix
  84641. * @param index the index of the value within the matrix. between 0 and 15.
  84642. * @param value the value to be added
  84643. * @returns the current updated matrix
  84644. */
  84645. addAtIndex(index: number, value: number): Matrix;
  84646. /**
  84647. * mutiply the specified position in the current Matrix by a value
  84648. * @param index the index of the value within the matrix. between 0 and 15.
  84649. * @param value the value to be added
  84650. * @returns the current updated matrix
  84651. */
  84652. multiplyAtIndex(index: number, value: number): Matrix;
  84653. /**
  84654. * Inserts the translation vector (using 3 floats) in the current matrix
  84655. * @param x defines the 1st component of the translation
  84656. * @param y defines the 2nd component of the translation
  84657. * @param z defines the 3rd component of the translation
  84658. * @returns the current updated matrix
  84659. */
  84660. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84661. /**
  84662. * Adds the translation vector (using 3 floats) in the current matrix
  84663. * @param x defines the 1st component of the translation
  84664. * @param y defines the 2nd component of the translation
  84665. * @param z defines the 3rd component of the translation
  84666. * @returns the current updated matrix
  84667. */
  84668. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84669. /**
  84670. * Inserts the translation vector in the current matrix
  84671. * @param vector3 defines the translation to insert
  84672. * @returns the current updated matrix
  84673. */
  84674. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84675. /**
  84676. * Gets the translation value of the current matrix
  84677. * @returns a new Vector3 as the extracted translation from the matrix
  84678. */
  84679. getTranslation(): Vector3;
  84680. /**
  84681. * Fill a Vector3 with the extracted translation from the matrix
  84682. * @param result defines the Vector3 where to store the translation
  84683. * @returns the current matrix
  84684. */
  84685. getTranslationToRef(result: Vector3): Matrix;
  84686. /**
  84687. * Remove rotation and scaling part from the matrix
  84688. * @returns the updated matrix
  84689. */
  84690. removeRotationAndScaling(): Matrix;
  84691. /**
  84692. * Multiply two matrices
  84693. * @param other defines the second operand
  84694. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84695. */
  84696. multiply(other: DeepImmutable<Matrix>): Matrix;
  84697. /**
  84698. * Copy the current matrix from the given one
  84699. * @param other defines the source matrix
  84700. * @returns the current updated matrix
  84701. */
  84702. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84703. /**
  84704. * Populates the given array from the starting index with the current matrix values
  84705. * @param array defines the target array
  84706. * @param offset defines the offset in the target array where to start storing values
  84707. * @returns the current matrix
  84708. */
  84709. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84710. /**
  84711. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84712. * @param other defines the second operand
  84713. * @param result defines the matrix where to store the multiplication
  84714. * @returns the current matrix
  84715. */
  84716. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84717. /**
  84718. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84719. * @param other defines the second operand
  84720. * @param result defines the array where to store the multiplication
  84721. * @param offset defines the offset in the target array where to start storing values
  84722. * @returns the current matrix
  84723. */
  84724. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84725. /**
  84726. * Check equality between this matrix and a second one
  84727. * @param value defines the second matrix to compare
  84728. * @returns true is the current matrix and the given one values are strictly equal
  84729. */
  84730. equals(value: DeepImmutable<Matrix>): boolean;
  84731. /**
  84732. * Clone the current matrix
  84733. * @returns a new matrix from the current matrix
  84734. */
  84735. clone(): Matrix;
  84736. /**
  84737. * Returns the name of the current matrix class
  84738. * @returns the string "Matrix"
  84739. */
  84740. getClassName(): string;
  84741. /**
  84742. * Gets the hash code of the current matrix
  84743. * @returns the hash code
  84744. */
  84745. getHashCode(): number;
  84746. /**
  84747. * Decomposes the current Matrix into a translation, rotation and scaling components
  84748. * @param scale defines the scale vector3 given as a reference to update
  84749. * @param rotation defines the rotation quaternion given as a reference to update
  84750. * @param translation defines the translation vector3 given as a reference to update
  84751. * @returns true if operation was successful
  84752. */
  84753. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84754. /**
  84755. * Gets specific row of the matrix
  84756. * @param index defines the number of the row to get
  84757. * @returns the index-th row of the current matrix as a new Vector4
  84758. */
  84759. getRow(index: number): Nullable<Vector4>;
  84760. /**
  84761. * Sets the index-th row of the current matrix to the vector4 values
  84762. * @param index defines the number of the row to set
  84763. * @param row defines the target vector4
  84764. * @returns the updated current matrix
  84765. */
  84766. setRow(index: number, row: Vector4): Matrix;
  84767. /**
  84768. * Compute the transpose of the matrix
  84769. * @returns the new transposed matrix
  84770. */
  84771. transpose(): Matrix;
  84772. /**
  84773. * Compute the transpose of the matrix and store it in a given matrix
  84774. * @param result defines the target matrix
  84775. * @returns the current matrix
  84776. */
  84777. transposeToRef(result: Matrix): Matrix;
  84778. /**
  84779. * Sets the index-th row of the current matrix with the given 4 x float values
  84780. * @param index defines the row index
  84781. * @param x defines the x component to set
  84782. * @param y defines the y component to set
  84783. * @param z defines the z component to set
  84784. * @param w defines the w component to set
  84785. * @returns the updated current matrix
  84786. */
  84787. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84788. /**
  84789. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84790. * @param scale defines the scale factor
  84791. * @returns a new matrix
  84792. */
  84793. scale(scale: number): Matrix;
  84794. /**
  84795. * Scale the current matrix values by a factor to a given result matrix
  84796. * @param scale defines the scale factor
  84797. * @param result defines the matrix to store the result
  84798. * @returns the current matrix
  84799. */
  84800. scaleToRef(scale: number, result: Matrix): Matrix;
  84801. /**
  84802. * Scale the current matrix values by a factor and add the result to a given matrix
  84803. * @param scale defines the scale factor
  84804. * @param result defines the Matrix to store the result
  84805. * @returns the current matrix
  84806. */
  84807. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84808. /**
  84809. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84810. * @param ref matrix to store the result
  84811. */
  84812. toNormalMatrix(ref: Matrix): void;
  84813. /**
  84814. * Gets only rotation part of the current matrix
  84815. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84816. */
  84817. getRotationMatrix(): Matrix;
  84818. /**
  84819. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84820. * @param result defines the target matrix to store data to
  84821. * @returns the current matrix
  84822. */
  84823. getRotationMatrixToRef(result: Matrix): Matrix;
  84824. /**
  84825. * Toggles model matrix from being right handed to left handed in place and vice versa
  84826. */
  84827. toggleModelMatrixHandInPlace(): void;
  84828. /**
  84829. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84830. */
  84831. toggleProjectionMatrixHandInPlace(): void;
  84832. /**
  84833. * Creates a matrix from an array
  84834. * @param array defines the source array
  84835. * @param offset defines an offset in the source array
  84836. * @returns a new Matrix set from the starting index of the given array
  84837. */
  84838. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84839. /**
  84840. * Copy the content of an array into a given matrix
  84841. * @param array defines the source array
  84842. * @param offset defines an offset in the source array
  84843. * @param result defines the target matrix
  84844. */
  84845. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84846. /**
  84847. * Stores an array into a matrix after having multiplied each component by a given factor
  84848. * @param array defines the source array
  84849. * @param offset defines the offset in the source array
  84850. * @param scale defines the scaling factor
  84851. * @param result defines the target matrix
  84852. */
  84853. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84854. /**
  84855. * Gets an identity matrix that must not be updated
  84856. */
  84857. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84858. /**
  84859. * Stores a list of values (16) inside a given matrix
  84860. * @param initialM11 defines 1st value of 1st row
  84861. * @param initialM12 defines 2nd value of 1st row
  84862. * @param initialM13 defines 3rd value of 1st row
  84863. * @param initialM14 defines 4th value of 1st row
  84864. * @param initialM21 defines 1st value of 2nd row
  84865. * @param initialM22 defines 2nd value of 2nd row
  84866. * @param initialM23 defines 3rd value of 2nd row
  84867. * @param initialM24 defines 4th value of 2nd row
  84868. * @param initialM31 defines 1st value of 3rd row
  84869. * @param initialM32 defines 2nd value of 3rd row
  84870. * @param initialM33 defines 3rd value of 3rd row
  84871. * @param initialM34 defines 4th value of 3rd row
  84872. * @param initialM41 defines 1st value of 4th row
  84873. * @param initialM42 defines 2nd value of 4th row
  84874. * @param initialM43 defines 3rd value of 4th row
  84875. * @param initialM44 defines 4th value of 4th row
  84876. * @param result defines the target matrix
  84877. */
  84878. 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;
  84879. /**
  84880. * Creates new matrix from a list of values (16)
  84881. * @param initialM11 defines 1st value of 1st row
  84882. * @param initialM12 defines 2nd value of 1st row
  84883. * @param initialM13 defines 3rd value of 1st row
  84884. * @param initialM14 defines 4th value of 1st row
  84885. * @param initialM21 defines 1st value of 2nd row
  84886. * @param initialM22 defines 2nd value of 2nd row
  84887. * @param initialM23 defines 3rd value of 2nd row
  84888. * @param initialM24 defines 4th value of 2nd row
  84889. * @param initialM31 defines 1st value of 3rd row
  84890. * @param initialM32 defines 2nd value of 3rd row
  84891. * @param initialM33 defines 3rd value of 3rd row
  84892. * @param initialM34 defines 4th value of 3rd row
  84893. * @param initialM41 defines 1st value of 4th row
  84894. * @param initialM42 defines 2nd value of 4th row
  84895. * @param initialM43 defines 3rd value of 4th row
  84896. * @param initialM44 defines 4th value of 4th row
  84897. * @returns the new matrix
  84898. */
  84899. 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;
  84900. /**
  84901. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84902. * @param scale defines the scale vector3
  84903. * @param rotation defines the rotation quaternion
  84904. * @param translation defines the translation vector3
  84905. * @returns a new matrix
  84906. */
  84907. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84908. /**
  84909. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84910. * @param scale defines the scale vector3
  84911. * @param rotation defines the rotation quaternion
  84912. * @param translation defines the translation vector3
  84913. * @param result defines the target matrix
  84914. */
  84915. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84916. /**
  84917. * Creates a new identity matrix
  84918. * @returns a new identity matrix
  84919. */
  84920. static Identity(): Matrix;
  84921. /**
  84922. * Creates a new identity matrix and stores the result in a given matrix
  84923. * @param result defines the target matrix
  84924. */
  84925. static IdentityToRef(result: Matrix): void;
  84926. /**
  84927. * Creates a new zero matrix
  84928. * @returns a new zero matrix
  84929. */
  84930. static Zero(): Matrix;
  84931. /**
  84932. * Creates a new rotation matrix for "angle" radians around the X axis
  84933. * @param angle defines the angle (in radians) to use
  84934. * @return the new matrix
  84935. */
  84936. static RotationX(angle: number): Matrix;
  84937. /**
  84938. * Creates a new matrix as the invert of a given matrix
  84939. * @param source defines the source matrix
  84940. * @returns the new matrix
  84941. */
  84942. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84943. /**
  84944. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84945. * @param angle defines the angle (in radians) to use
  84946. * @param result defines the target matrix
  84947. */
  84948. static RotationXToRef(angle: number, result: Matrix): void;
  84949. /**
  84950. * Creates a new rotation matrix for "angle" radians around the Y axis
  84951. * @param angle defines the angle (in radians) to use
  84952. * @return the new matrix
  84953. */
  84954. static RotationY(angle: number): Matrix;
  84955. /**
  84956. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84957. * @param angle defines the angle (in radians) to use
  84958. * @param result defines the target matrix
  84959. */
  84960. static RotationYToRef(angle: number, result: Matrix): void;
  84961. /**
  84962. * Creates a new rotation matrix for "angle" radians around the Z axis
  84963. * @param angle defines the angle (in radians) to use
  84964. * @return the new matrix
  84965. */
  84966. static RotationZ(angle: number): Matrix;
  84967. /**
  84968. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84969. * @param angle defines the angle (in radians) to use
  84970. * @param result defines the target matrix
  84971. */
  84972. static RotationZToRef(angle: number, result: Matrix): void;
  84973. /**
  84974. * Creates a new rotation matrix for "angle" radians around the given axis
  84975. * @param axis defines the axis to use
  84976. * @param angle defines the angle (in radians) to use
  84977. * @return the new matrix
  84978. */
  84979. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84980. /**
  84981. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84982. * @param axis defines the axis to use
  84983. * @param angle defines the angle (in radians) to use
  84984. * @param result defines the target matrix
  84985. */
  84986. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84987. /**
  84988. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84989. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84990. * @param from defines the vector to align
  84991. * @param to defines the vector to align to
  84992. * @param result defines the target matrix
  84993. */
  84994. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84995. /**
  84996. * Creates a rotation matrix
  84997. * @param yaw defines the yaw angle in radians (Y axis)
  84998. * @param pitch defines the pitch angle in radians (X axis)
  84999. * @param roll defines the roll angle in radians (Z axis)
  85000. * @returns the new rotation matrix
  85001. */
  85002. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85003. /**
  85004. * Creates a rotation matrix and stores it in a given matrix
  85005. * @param yaw defines the yaw angle in radians (Y axis)
  85006. * @param pitch defines the pitch angle in radians (X axis)
  85007. * @param roll defines the roll angle in radians (Z axis)
  85008. * @param result defines the target matrix
  85009. */
  85010. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85011. /**
  85012. * Creates a scaling matrix
  85013. * @param x defines the scale factor on X axis
  85014. * @param y defines the scale factor on Y axis
  85015. * @param z defines the scale factor on Z axis
  85016. * @returns the new matrix
  85017. */
  85018. static Scaling(x: number, y: number, z: number): Matrix;
  85019. /**
  85020. * Creates a scaling matrix and stores it in a given matrix
  85021. * @param x defines the scale factor on X axis
  85022. * @param y defines the scale factor on Y axis
  85023. * @param z defines the scale factor on Z axis
  85024. * @param result defines the target matrix
  85025. */
  85026. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85027. /**
  85028. * Creates a translation matrix
  85029. * @param x defines the translation on X axis
  85030. * @param y defines the translation on Y axis
  85031. * @param z defines the translationon Z axis
  85032. * @returns the new matrix
  85033. */
  85034. static Translation(x: number, y: number, z: number): Matrix;
  85035. /**
  85036. * Creates a translation matrix and stores it in a given matrix
  85037. * @param x defines the translation on X axis
  85038. * @param y defines the translation on Y axis
  85039. * @param z defines the translationon Z axis
  85040. * @param result defines the target matrix
  85041. */
  85042. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85043. /**
  85044. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85045. * @param startValue defines the start value
  85046. * @param endValue defines the end value
  85047. * @param gradient defines the gradient factor
  85048. * @returns the new matrix
  85049. */
  85050. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85051. /**
  85052. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85053. * @param startValue defines the start value
  85054. * @param endValue defines the end value
  85055. * @param gradient defines the gradient factor
  85056. * @param result defines the Matrix object where to store data
  85057. */
  85058. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85059. /**
  85060. * Builds a new matrix whose values are computed by:
  85061. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85062. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85063. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85064. * @param startValue defines the first matrix
  85065. * @param endValue defines the second matrix
  85066. * @param gradient defines the gradient between the two matrices
  85067. * @returns the new matrix
  85068. */
  85069. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85070. /**
  85071. * Update a matrix to values which are computed by:
  85072. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85073. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85074. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85075. * @param startValue defines the first matrix
  85076. * @param endValue defines the second matrix
  85077. * @param gradient defines the gradient between the two matrices
  85078. * @param result defines the target matrix
  85079. */
  85080. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85081. /**
  85082. * 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"
  85083. * This function works in left handed mode
  85084. * @param eye defines the final position of the entity
  85085. * @param target defines where the entity should look at
  85086. * @param up defines the up vector for the entity
  85087. * @returns the new matrix
  85088. */
  85089. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85090. /**
  85091. * 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".
  85092. * This function works in left handed mode
  85093. * @param eye defines the final position of the entity
  85094. * @param target defines where the entity should look at
  85095. * @param up defines the up vector for the entity
  85096. * @param result defines the target matrix
  85097. */
  85098. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85099. /**
  85100. * 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"
  85101. * This function works in right handed mode
  85102. * @param eye defines the final position of the entity
  85103. * @param target defines where the entity should look at
  85104. * @param up defines the up vector for the entity
  85105. * @returns the new matrix
  85106. */
  85107. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85108. /**
  85109. * 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".
  85110. * This function works in right handed mode
  85111. * @param eye defines the final position of the entity
  85112. * @param target defines where the entity should look at
  85113. * @param up defines the up vector for the entity
  85114. * @param result defines the target matrix
  85115. */
  85116. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85117. /**
  85118. * Create a left-handed orthographic projection matrix
  85119. * @param width defines the viewport width
  85120. * @param height defines the viewport height
  85121. * @param znear defines the near clip plane
  85122. * @param zfar defines the far clip plane
  85123. * @returns a new matrix as a left-handed orthographic projection matrix
  85124. */
  85125. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85126. /**
  85127. * Store a left-handed orthographic projection to a given matrix
  85128. * @param width defines the viewport width
  85129. * @param height defines the viewport height
  85130. * @param znear defines the near clip plane
  85131. * @param zfar defines the far clip plane
  85132. * @param result defines the target matrix
  85133. */
  85134. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85135. /**
  85136. * Create a left-handed orthographic projection matrix
  85137. * @param left defines the viewport left coordinate
  85138. * @param right defines the viewport right coordinate
  85139. * @param bottom defines the viewport bottom coordinate
  85140. * @param top defines the viewport top coordinate
  85141. * @param znear defines the near clip plane
  85142. * @param zfar defines the far clip plane
  85143. * @returns a new matrix as a left-handed orthographic projection matrix
  85144. */
  85145. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85146. /**
  85147. * Stores a left-handed orthographic projection into a given matrix
  85148. * @param left defines the viewport left coordinate
  85149. * @param right defines the viewport right coordinate
  85150. * @param bottom defines the viewport bottom coordinate
  85151. * @param top defines the viewport top coordinate
  85152. * @param znear defines the near clip plane
  85153. * @param zfar defines the far clip plane
  85154. * @param result defines the target matrix
  85155. */
  85156. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85157. /**
  85158. * Creates a right-handed orthographic projection matrix
  85159. * @param left defines the viewport left coordinate
  85160. * @param right defines the viewport right coordinate
  85161. * @param bottom defines the viewport bottom coordinate
  85162. * @param top defines the viewport top coordinate
  85163. * @param znear defines the near clip plane
  85164. * @param zfar defines the far clip plane
  85165. * @returns a new matrix as a right-handed orthographic projection matrix
  85166. */
  85167. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85168. /**
  85169. * Stores a right-handed orthographic projection into a given matrix
  85170. * @param left defines the viewport left coordinate
  85171. * @param right defines the viewport right coordinate
  85172. * @param bottom defines the viewport bottom coordinate
  85173. * @param top defines the viewport top coordinate
  85174. * @param znear defines the near clip plane
  85175. * @param zfar defines the far clip plane
  85176. * @param result defines the target matrix
  85177. */
  85178. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85179. /**
  85180. * Creates a left-handed perspective projection matrix
  85181. * @param width defines the viewport width
  85182. * @param height defines the viewport height
  85183. * @param znear defines the near clip plane
  85184. * @param zfar defines the far clip plane
  85185. * @returns a new matrix as a left-handed perspective projection matrix
  85186. */
  85187. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85188. /**
  85189. * Creates a left-handed perspective projection matrix
  85190. * @param fov defines the horizontal field of view
  85191. * @param aspect defines the aspect ratio
  85192. * @param znear defines the near clip plane
  85193. * @param zfar defines the far clip plane
  85194. * @returns a new matrix as a left-handed perspective projection matrix
  85195. */
  85196. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85197. /**
  85198. * Stores a left-handed perspective projection into a given matrix
  85199. * @param fov defines the horizontal field of view
  85200. * @param aspect defines the aspect ratio
  85201. * @param znear defines the near clip plane
  85202. * @param zfar defines the far clip plane
  85203. * @param result defines the target matrix
  85204. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85205. */
  85206. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85207. /**
  85208. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85209. * @param fov defines the horizontal field of view
  85210. * @param aspect defines the aspect ratio
  85211. * @param znear defines the near clip plane
  85212. * @param zfar not used as infinity is used as far clip
  85213. * @param result defines the target matrix
  85214. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85215. */
  85216. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85217. /**
  85218. * Creates a right-handed perspective projection matrix
  85219. * @param fov defines the horizontal field of view
  85220. * @param aspect defines the aspect ratio
  85221. * @param znear defines the near clip plane
  85222. * @param zfar defines the far clip plane
  85223. * @returns a new matrix as a right-handed perspective projection matrix
  85224. */
  85225. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85226. /**
  85227. * Stores a right-handed perspective projection into a given matrix
  85228. * @param fov defines the horizontal field of view
  85229. * @param aspect defines the aspect ratio
  85230. * @param znear defines the near clip plane
  85231. * @param zfar defines the far clip plane
  85232. * @param result defines the target matrix
  85233. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85234. */
  85235. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85236. /**
  85237. * Stores a right-handed perspective projection into a given matrix
  85238. * @param fov defines the horizontal field of view
  85239. * @param aspect defines the aspect ratio
  85240. * @param znear defines the near clip plane
  85241. * @param zfar not used as infinity is used as far clip
  85242. * @param result defines the target matrix
  85243. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85244. */
  85245. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85246. /**
  85247. * Stores a perspective projection for WebVR info a given matrix
  85248. * @param fov defines the field of view
  85249. * @param znear defines the near clip plane
  85250. * @param zfar defines the far clip plane
  85251. * @param result defines the target matrix
  85252. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85253. */
  85254. static PerspectiveFovWebVRToRef(fov: {
  85255. upDegrees: number;
  85256. downDegrees: number;
  85257. leftDegrees: number;
  85258. rightDegrees: number;
  85259. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85260. /**
  85261. * Computes a complete transformation matrix
  85262. * @param viewport defines the viewport to use
  85263. * @param world defines the world matrix
  85264. * @param view defines the view matrix
  85265. * @param projection defines the projection matrix
  85266. * @param zmin defines the near clip plane
  85267. * @param zmax defines the far clip plane
  85268. * @returns the transformation matrix
  85269. */
  85270. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85271. /**
  85272. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85273. * @param matrix defines the matrix to use
  85274. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85275. */
  85276. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85277. /**
  85278. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85279. * @param matrix defines the matrix to use
  85280. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85281. */
  85282. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85283. /**
  85284. * Compute the transpose of a given matrix
  85285. * @param matrix defines the matrix to transpose
  85286. * @returns the new matrix
  85287. */
  85288. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85289. /**
  85290. * Compute the transpose of a matrix and store it in a target matrix
  85291. * @param matrix defines the matrix to transpose
  85292. * @param result defines the target matrix
  85293. */
  85294. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85295. /**
  85296. * Computes a reflection matrix from a plane
  85297. * @param plane defines the reflection plane
  85298. * @returns a new matrix
  85299. */
  85300. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85301. /**
  85302. * Computes a reflection matrix from a plane
  85303. * @param plane defines the reflection plane
  85304. * @param result defines the target matrix
  85305. */
  85306. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85307. /**
  85308. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85309. * @param xaxis defines the value of the 1st axis
  85310. * @param yaxis defines the value of the 2nd axis
  85311. * @param zaxis defines the value of the 3rd axis
  85312. * @param result defines the target matrix
  85313. */
  85314. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85315. /**
  85316. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85317. * @param quat defines the quaternion to use
  85318. * @param result defines the target matrix
  85319. */
  85320. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85321. }
  85322. /**
  85323. * @hidden
  85324. */
  85325. export class TmpVectors {
  85326. static Vector2: Vector2[];
  85327. static Vector3: Vector3[];
  85328. static Vector4: Vector4[];
  85329. static Quaternion: Quaternion[];
  85330. static Matrix: Matrix[];
  85331. }
  85332. }
  85333. declare module BABYLON {
  85334. /**
  85335. * Defines potential orientation for back face culling
  85336. */
  85337. export enum Orientation {
  85338. /**
  85339. * Clockwise
  85340. */
  85341. CW = 0,
  85342. /** Counter clockwise */
  85343. CCW = 1
  85344. }
  85345. /** Class used to represent a Bezier curve */
  85346. export class BezierCurve {
  85347. /**
  85348. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85349. * @param t defines the time
  85350. * @param x1 defines the left coordinate on X axis
  85351. * @param y1 defines the left coordinate on Y axis
  85352. * @param x2 defines the right coordinate on X axis
  85353. * @param y2 defines the right coordinate on Y axis
  85354. * @returns the interpolated value
  85355. */
  85356. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85357. }
  85358. /**
  85359. * Defines angle representation
  85360. */
  85361. export class Angle {
  85362. private _radians;
  85363. /**
  85364. * Creates an Angle object of "radians" radians (float).
  85365. * @param radians the angle in radians
  85366. */
  85367. constructor(radians: number);
  85368. /**
  85369. * Get value in degrees
  85370. * @returns the Angle value in degrees (float)
  85371. */
  85372. degrees(): number;
  85373. /**
  85374. * Get value in radians
  85375. * @returns the Angle value in radians (float)
  85376. */
  85377. radians(): number;
  85378. /**
  85379. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85380. * @param a defines first point as the origin
  85381. * @param b defines point
  85382. * @returns a new Angle
  85383. */
  85384. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85385. /**
  85386. * Gets a new Angle object from the given float in radians
  85387. * @param radians defines the angle value in radians
  85388. * @returns a new Angle
  85389. */
  85390. static FromRadians(radians: number): Angle;
  85391. /**
  85392. * Gets a new Angle object from the given float in degrees
  85393. * @param degrees defines the angle value in degrees
  85394. * @returns a new Angle
  85395. */
  85396. static FromDegrees(degrees: number): Angle;
  85397. }
  85398. /**
  85399. * This represents an arc in a 2d space.
  85400. */
  85401. export class Arc2 {
  85402. /** Defines the start point of the arc */
  85403. startPoint: Vector2;
  85404. /** Defines the mid point of the arc */
  85405. midPoint: Vector2;
  85406. /** Defines the end point of the arc */
  85407. endPoint: Vector2;
  85408. /**
  85409. * Defines the center point of the arc.
  85410. */
  85411. centerPoint: Vector2;
  85412. /**
  85413. * Defines the radius of the arc.
  85414. */
  85415. radius: number;
  85416. /**
  85417. * Defines the angle of the arc (from mid point to end point).
  85418. */
  85419. angle: Angle;
  85420. /**
  85421. * Defines the start angle of the arc (from start point to middle point).
  85422. */
  85423. startAngle: Angle;
  85424. /**
  85425. * Defines the orientation of the arc (clock wise/counter clock wise).
  85426. */
  85427. orientation: Orientation;
  85428. /**
  85429. * Creates an Arc object from the three given points : start, middle and end.
  85430. * @param startPoint Defines the start point of the arc
  85431. * @param midPoint Defines the midlle point of the arc
  85432. * @param endPoint Defines the end point of the arc
  85433. */
  85434. constructor(
  85435. /** Defines the start point of the arc */
  85436. startPoint: Vector2,
  85437. /** Defines the mid point of the arc */
  85438. midPoint: Vector2,
  85439. /** Defines the end point of the arc */
  85440. endPoint: Vector2);
  85441. }
  85442. /**
  85443. * Represents a 2D path made up of multiple 2D points
  85444. */
  85445. export class Path2 {
  85446. private _points;
  85447. private _length;
  85448. /**
  85449. * If the path start and end point are the same
  85450. */
  85451. closed: boolean;
  85452. /**
  85453. * Creates a Path2 object from the starting 2D coordinates x and y.
  85454. * @param x the starting points x value
  85455. * @param y the starting points y value
  85456. */
  85457. constructor(x: number, y: number);
  85458. /**
  85459. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85460. * @param x the added points x value
  85461. * @param y the added points y value
  85462. * @returns the updated Path2.
  85463. */
  85464. addLineTo(x: number, y: number): Path2;
  85465. /**
  85466. * 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.
  85467. * @param midX middle point x value
  85468. * @param midY middle point y value
  85469. * @param endX end point x value
  85470. * @param endY end point y value
  85471. * @param numberOfSegments (default: 36)
  85472. * @returns the updated Path2.
  85473. */
  85474. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85475. /**
  85476. * Closes the Path2.
  85477. * @returns the Path2.
  85478. */
  85479. close(): Path2;
  85480. /**
  85481. * Gets the sum of the distance between each sequential point in the path
  85482. * @returns the Path2 total length (float).
  85483. */
  85484. length(): number;
  85485. /**
  85486. * Gets the points which construct the path
  85487. * @returns the Path2 internal array of points.
  85488. */
  85489. getPoints(): Vector2[];
  85490. /**
  85491. * Retreives the point at the distance aways from the starting point
  85492. * @param normalizedLengthPosition the length along the path to retreive the point from
  85493. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85494. */
  85495. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85496. /**
  85497. * Creates a new path starting from an x and y position
  85498. * @param x starting x value
  85499. * @param y starting y value
  85500. * @returns a new Path2 starting at the coordinates (x, y).
  85501. */
  85502. static StartingAt(x: number, y: number): Path2;
  85503. }
  85504. /**
  85505. * Represents a 3D path made up of multiple 3D points
  85506. */
  85507. export class Path3D {
  85508. /**
  85509. * an array of Vector3, the curve axis of the Path3D
  85510. */
  85511. path: Vector3[];
  85512. private _curve;
  85513. private _distances;
  85514. private _tangents;
  85515. private _normals;
  85516. private _binormals;
  85517. private _raw;
  85518. private _alignTangentsWithPath;
  85519. private readonly _pointAtData;
  85520. /**
  85521. * new Path3D(path, normal, raw)
  85522. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85523. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85524. * @param path an array of Vector3, the curve axis of the Path3D
  85525. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85526. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85527. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85528. */
  85529. constructor(
  85530. /**
  85531. * an array of Vector3, the curve axis of the Path3D
  85532. */
  85533. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85534. /**
  85535. * Returns the Path3D array of successive Vector3 designing its curve.
  85536. * @returns the Path3D array of successive Vector3 designing its curve.
  85537. */
  85538. getCurve(): Vector3[];
  85539. /**
  85540. * Returns the Path3D array of successive Vector3 designing its curve.
  85541. * @returns the Path3D array of successive Vector3 designing its curve.
  85542. */
  85543. getPoints(): Vector3[];
  85544. /**
  85545. * @returns the computed length (float) of the path.
  85546. */
  85547. length(): number;
  85548. /**
  85549. * Returns an array populated with tangent vectors on each Path3D curve point.
  85550. * @returns an array populated with tangent vectors on each Path3D curve point.
  85551. */
  85552. getTangents(): Vector3[];
  85553. /**
  85554. * Returns an array populated with normal vectors on each Path3D curve point.
  85555. * @returns an array populated with normal vectors on each Path3D curve point.
  85556. */
  85557. getNormals(): Vector3[];
  85558. /**
  85559. * Returns an array populated with binormal vectors on each Path3D curve point.
  85560. * @returns an array populated with binormal vectors on each Path3D curve point.
  85561. */
  85562. getBinormals(): Vector3[];
  85563. /**
  85564. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85565. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85566. */
  85567. getDistances(): number[];
  85568. /**
  85569. * Returns an interpolated point along this path
  85570. * @param position the position of the point along this path, from 0.0 to 1.0
  85571. * @returns a new Vector3 as the point
  85572. */
  85573. getPointAt(position: number): Vector3;
  85574. /**
  85575. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85576. * @param position the position of the point along this path, from 0.0 to 1.0
  85577. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85578. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85579. */
  85580. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85581. /**
  85582. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85583. * @param position the position of the point along this path, from 0.0 to 1.0
  85584. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85585. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85586. */
  85587. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85588. /**
  85589. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85590. * @param position the position of the point along this path, from 0.0 to 1.0
  85591. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85592. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85593. */
  85594. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85595. /**
  85596. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85597. * @param position the position of the point along this path, from 0.0 to 1.0
  85598. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85599. */
  85600. getDistanceAt(position: number): number;
  85601. /**
  85602. * Returns the array index of the previous point of an interpolated point along this path
  85603. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85604. * @returns the array index
  85605. */
  85606. getPreviousPointIndexAt(position: number): number;
  85607. /**
  85608. * 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)
  85609. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85610. * @returns the sub position
  85611. */
  85612. getSubPositionAt(position: number): number;
  85613. /**
  85614. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85615. * @param target the vector of which to get the closest position to
  85616. * @returns the position of the closest virtual point on this path to the target vector
  85617. */
  85618. getClosestPositionTo(target: Vector3): number;
  85619. /**
  85620. * Returns a sub path (slice) of this path
  85621. * @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
  85622. * @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
  85623. * @returns a sub path (slice) of this path
  85624. */
  85625. slice(start?: number, end?: number): Path3D;
  85626. /**
  85627. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85628. * @param path path which all values are copied into the curves points
  85629. * @param firstNormal which should be projected onto the curve
  85630. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85631. * @returns the same object updated.
  85632. */
  85633. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85634. private _compute;
  85635. private _getFirstNonNullVector;
  85636. private _getLastNonNullVector;
  85637. private _normalVector;
  85638. /**
  85639. * Updates the point at data for an interpolated point along this curve
  85640. * @param position the position of the point along this curve, from 0.0 to 1.0
  85641. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85642. * @returns the (updated) point at data
  85643. */
  85644. private _updatePointAtData;
  85645. /**
  85646. * Updates the point at data from the specified parameters
  85647. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85648. * @param point the interpolated point
  85649. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85650. */
  85651. private _setPointAtData;
  85652. /**
  85653. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85654. */
  85655. private _updateInterpolationMatrix;
  85656. }
  85657. /**
  85658. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85659. * A Curve3 is designed from a series of successive Vector3.
  85660. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85661. */
  85662. export class Curve3 {
  85663. private _points;
  85664. private _length;
  85665. /**
  85666. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85667. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85668. * @param v1 (Vector3) the control point
  85669. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85670. * @param nbPoints (integer) the wanted number of points in the curve
  85671. * @returns the created Curve3
  85672. */
  85673. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85674. /**
  85675. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85676. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85677. * @param v1 (Vector3) the first control point
  85678. * @param v2 (Vector3) the second control point
  85679. * @param v3 (Vector3) the end point of the Cubic Bezier
  85680. * @param nbPoints (integer) the wanted number of points in the curve
  85681. * @returns the created Curve3
  85682. */
  85683. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85684. /**
  85685. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85686. * @param p1 (Vector3) the origin point of the Hermite Spline
  85687. * @param t1 (Vector3) the tangent vector at the origin point
  85688. * @param p2 (Vector3) the end point of the Hermite Spline
  85689. * @param t2 (Vector3) the tangent vector at the end point
  85690. * @param nbPoints (integer) the wanted number of points in the curve
  85691. * @returns the created Curve3
  85692. */
  85693. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85694. /**
  85695. * Returns a Curve3 object along a CatmullRom Spline curve :
  85696. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85697. * @param nbPoints (integer) the wanted number of points between each curve control points
  85698. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85699. * @returns the created Curve3
  85700. */
  85701. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85702. /**
  85703. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85704. * A Curve3 is designed from a series of successive Vector3.
  85705. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85706. * @param points points which make up the curve
  85707. */
  85708. constructor(points: Vector3[]);
  85709. /**
  85710. * @returns the Curve3 stored array of successive Vector3
  85711. */
  85712. getPoints(): Vector3[];
  85713. /**
  85714. * @returns the computed length (float) of the curve.
  85715. */
  85716. length(): number;
  85717. /**
  85718. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85719. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85720. * curveA and curveB keep unchanged.
  85721. * @param curve the curve to continue from this curve
  85722. * @returns the newly constructed curve
  85723. */
  85724. continue(curve: DeepImmutable<Curve3>): Curve3;
  85725. private _computeLength;
  85726. }
  85727. }
  85728. declare module BABYLON {
  85729. /**
  85730. * This represents the main contract an easing function should follow.
  85731. * Easing functions are used throughout the animation system.
  85732. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85733. */
  85734. export interface IEasingFunction {
  85735. /**
  85736. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85737. * of the easing function.
  85738. * The link below provides some of the most common examples of easing functions.
  85739. * @see https://easings.net/
  85740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85741. * @returns the corresponding value on the curve defined by the easing function
  85742. */
  85743. ease(gradient: number): number;
  85744. }
  85745. /**
  85746. * Base class used for every default easing function.
  85747. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85748. */
  85749. export class EasingFunction implements IEasingFunction {
  85750. /**
  85751. * Interpolation follows the mathematical formula associated with the easing function.
  85752. */
  85753. static readonly EASINGMODE_EASEIN: number;
  85754. /**
  85755. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85756. */
  85757. static readonly EASINGMODE_EASEOUT: number;
  85758. /**
  85759. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85760. */
  85761. static readonly EASINGMODE_EASEINOUT: number;
  85762. private _easingMode;
  85763. /**
  85764. * Sets the easing mode of the current function.
  85765. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85766. */
  85767. setEasingMode(easingMode: number): void;
  85768. /**
  85769. * Gets the current easing mode.
  85770. * @returns the easing mode
  85771. */
  85772. getEasingMode(): number;
  85773. /**
  85774. * @hidden
  85775. */
  85776. easeInCore(gradient: number): number;
  85777. /**
  85778. * Given an input gradient between 0 and 1, this returns the corresponding value
  85779. * of the easing function.
  85780. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85781. * @returns the corresponding value on the curve defined by the easing function
  85782. */
  85783. ease(gradient: number): number;
  85784. }
  85785. /**
  85786. * Easing function with a circle shape (see link below).
  85787. * @see https://easings.net/#easeInCirc
  85788. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85789. */
  85790. export class CircleEase extends EasingFunction implements IEasingFunction {
  85791. /** @hidden */
  85792. easeInCore(gradient: number): number;
  85793. }
  85794. /**
  85795. * Easing function with a ease back shape (see link below).
  85796. * @see https://easings.net/#easeInBack
  85797. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85798. */
  85799. export class BackEase extends EasingFunction implements IEasingFunction {
  85800. /** Defines the amplitude of the function */
  85801. amplitude: number;
  85802. /**
  85803. * Instantiates a back ease easing
  85804. * @see https://easings.net/#easeInBack
  85805. * @param amplitude Defines the amplitude of the function
  85806. */
  85807. constructor(
  85808. /** Defines the amplitude of the function */
  85809. amplitude?: number);
  85810. /** @hidden */
  85811. easeInCore(gradient: number): number;
  85812. }
  85813. /**
  85814. * Easing function with a bouncing shape (see link below).
  85815. * @see https://easings.net/#easeInBounce
  85816. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85817. */
  85818. export class BounceEase extends EasingFunction implements IEasingFunction {
  85819. /** Defines the number of bounces */
  85820. bounces: number;
  85821. /** Defines the amplitude of the bounce */
  85822. bounciness: number;
  85823. /**
  85824. * Instantiates a bounce easing
  85825. * @see https://easings.net/#easeInBounce
  85826. * @param bounces Defines the number of bounces
  85827. * @param bounciness Defines the amplitude of the bounce
  85828. */
  85829. constructor(
  85830. /** Defines the number of bounces */
  85831. bounces?: number,
  85832. /** Defines the amplitude of the bounce */
  85833. bounciness?: number);
  85834. /** @hidden */
  85835. easeInCore(gradient: number): number;
  85836. }
  85837. /**
  85838. * Easing function with a power of 3 shape (see link below).
  85839. * @see https://easings.net/#easeInCubic
  85840. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85841. */
  85842. export class CubicEase extends EasingFunction implements IEasingFunction {
  85843. /** @hidden */
  85844. easeInCore(gradient: number): number;
  85845. }
  85846. /**
  85847. * Easing function with an elastic shape (see link below).
  85848. * @see https://easings.net/#easeInElastic
  85849. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85850. */
  85851. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85852. /** Defines the number of oscillations*/
  85853. oscillations: number;
  85854. /** Defines the amplitude of the oscillations*/
  85855. springiness: number;
  85856. /**
  85857. * Instantiates an elastic easing function
  85858. * @see https://easings.net/#easeInElastic
  85859. * @param oscillations Defines the number of oscillations
  85860. * @param springiness Defines the amplitude of the oscillations
  85861. */
  85862. constructor(
  85863. /** Defines the number of oscillations*/
  85864. oscillations?: number,
  85865. /** Defines the amplitude of the oscillations*/
  85866. springiness?: number);
  85867. /** @hidden */
  85868. easeInCore(gradient: number): number;
  85869. }
  85870. /**
  85871. * Easing function with an exponential shape (see link below).
  85872. * @see https://easings.net/#easeInExpo
  85873. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85874. */
  85875. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85876. /** Defines the exponent of the function */
  85877. exponent: number;
  85878. /**
  85879. * Instantiates an exponential easing function
  85880. * @see https://easings.net/#easeInExpo
  85881. * @param exponent Defines the exponent of the function
  85882. */
  85883. constructor(
  85884. /** Defines the exponent of the function */
  85885. exponent?: number);
  85886. /** @hidden */
  85887. easeInCore(gradient: number): number;
  85888. }
  85889. /**
  85890. * Easing function with a power shape (see link below).
  85891. * @see https://easings.net/#easeInQuad
  85892. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85893. */
  85894. export class PowerEase extends EasingFunction implements IEasingFunction {
  85895. /** Defines the power of the function */
  85896. power: number;
  85897. /**
  85898. * Instantiates an power base easing function
  85899. * @see https://easings.net/#easeInQuad
  85900. * @param power Defines the power of the function
  85901. */
  85902. constructor(
  85903. /** Defines the power of the function */
  85904. power?: number);
  85905. /** @hidden */
  85906. easeInCore(gradient: number): number;
  85907. }
  85908. /**
  85909. * Easing function with a power of 2 shape (see link below).
  85910. * @see https://easings.net/#easeInQuad
  85911. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85912. */
  85913. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85914. /** @hidden */
  85915. easeInCore(gradient: number): number;
  85916. }
  85917. /**
  85918. * Easing function with a power of 4 shape (see link below).
  85919. * @see https://easings.net/#easeInQuart
  85920. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85921. */
  85922. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85923. /** @hidden */
  85924. easeInCore(gradient: number): number;
  85925. }
  85926. /**
  85927. * Easing function with a power of 5 shape (see link below).
  85928. * @see https://easings.net/#easeInQuint
  85929. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85930. */
  85931. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85932. /** @hidden */
  85933. easeInCore(gradient: number): number;
  85934. }
  85935. /**
  85936. * Easing function with a sin shape (see link below).
  85937. * @see https://easings.net/#easeInSine
  85938. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85939. */
  85940. export class SineEase extends EasingFunction implements IEasingFunction {
  85941. /** @hidden */
  85942. easeInCore(gradient: number): number;
  85943. }
  85944. /**
  85945. * Easing function with a bezier shape (see link below).
  85946. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85947. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85948. */
  85949. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85950. /** Defines the x component of the start tangent in the bezier curve */
  85951. x1: number;
  85952. /** Defines the y component of the start tangent in the bezier curve */
  85953. y1: number;
  85954. /** Defines the x component of the end tangent in the bezier curve */
  85955. x2: number;
  85956. /** Defines the y component of the end tangent in the bezier curve */
  85957. y2: number;
  85958. /**
  85959. * Instantiates a bezier function
  85960. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85961. * @param x1 Defines the x component of the start tangent in the bezier curve
  85962. * @param y1 Defines the y component of the start tangent in the bezier curve
  85963. * @param x2 Defines the x component of the end tangent in the bezier curve
  85964. * @param y2 Defines the y component of the end tangent in the bezier curve
  85965. */
  85966. constructor(
  85967. /** Defines the x component of the start tangent in the bezier curve */
  85968. x1?: number,
  85969. /** Defines the y component of the start tangent in the bezier curve */
  85970. y1?: number,
  85971. /** Defines the x component of the end tangent in the bezier curve */
  85972. x2?: number,
  85973. /** Defines the y component of the end tangent in the bezier curve */
  85974. y2?: number);
  85975. /** @hidden */
  85976. easeInCore(gradient: number): number;
  85977. }
  85978. }
  85979. declare module BABYLON {
  85980. /**
  85981. * Class used to hold a RBG color
  85982. */
  85983. export class Color3 {
  85984. /**
  85985. * Defines the red component (between 0 and 1, default is 0)
  85986. */
  85987. r: number;
  85988. /**
  85989. * Defines the green component (between 0 and 1, default is 0)
  85990. */
  85991. g: number;
  85992. /**
  85993. * Defines the blue component (between 0 and 1, default is 0)
  85994. */
  85995. b: number;
  85996. /**
  85997. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85998. * @param r defines the red component (between 0 and 1, default is 0)
  85999. * @param g defines the green component (between 0 and 1, default is 0)
  86000. * @param b defines the blue component (between 0 and 1, default is 0)
  86001. */
  86002. constructor(
  86003. /**
  86004. * Defines the red component (between 0 and 1, default is 0)
  86005. */
  86006. r?: number,
  86007. /**
  86008. * Defines the green component (between 0 and 1, default is 0)
  86009. */
  86010. g?: number,
  86011. /**
  86012. * Defines the blue component (between 0 and 1, default is 0)
  86013. */
  86014. b?: number);
  86015. /**
  86016. * Creates a string with the Color3 current values
  86017. * @returns the string representation of the Color3 object
  86018. */
  86019. toString(): string;
  86020. /**
  86021. * Returns the string "Color3"
  86022. * @returns "Color3"
  86023. */
  86024. getClassName(): string;
  86025. /**
  86026. * Compute the Color3 hash code
  86027. * @returns an unique number that can be used to hash Color3 objects
  86028. */
  86029. getHashCode(): number;
  86030. /**
  86031. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86032. * @param array defines the array where to store the r,g,b components
  86033. * @param index defines an optional index in the target array to define where to start storing values
  86034. * @returns the current Color3 object
  86035. */
  86036. toArray(array: FloatArray, index?: number): Color3;
  86037. /**
  86038. * Update the current color with values stored in an array from the starting index of the given array
  86039. * @param array defines the source array
  86040. * @param offset defines an offset in the source array
  86041. * @returns the current Color3 object
  86042. */
  86043. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86044. /**
  86045. * Returns a new Color4 object from the current Color3 and the given alpha
  86046. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86047. * @returns a new Color4 object
  86048. */
  86049. toColor4(alpha?: number): Color4;
  86050. /**
  86051. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86052. * @returns the new array
  86053. */
  86054. asArray(): number[];
  86055. /**
  86056. * Returns the luminance value
  86057. * @returns a float value
  86058. */
  86059. toLuminance(): number;
  86060. /**
  86061. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86062. * @param otherColor defines the second operand
  86063. * @returns the new Color3 object
  86064. */
  86065. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86066. /**
  86067. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86068. * @param otherColor defines the second operand
  86069. * @param result defines the Color3 object where to store the result
  86070. * @returns the current Color3
  86071. */
  86072. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86073. /**
  86074. * Determines equality between Color3 objects
  86075. * @param otherColor defines the second operand
  86076. * @returns true if the rgb values are equal to the given ones
  86077. */
  86078. equals(otherColor: DeepImmutable<Color3>): boolean;
  86079. /**
  86080. * Determines equality between the current Color3 object and a set of r,b,g values
  86081. * @param r defines the red component to check
  86082. * @param g defines the green component to check
  86083. * @param b defines the blue component to check
  86084. * @returns true if the rgb values are equal to the given ones
  86085. */
  86086. equalsFloats(r: number, g: number, b: number): boolean;
  86087. /**
  86088. * Multiplies in place each rgb value by scale
  86089. * @param scale defines the scaling factor
  86090. * @returns the updated Color3
  86091. */
  86092. scale(scale: number): Color3;
  86093. /**
  86094. * Multiplies the rgb values by scale and stores the result into "result"
  86095. * @param scale defines the scaling factor
  86096. * @param result defines the Color3 object where to store the result
  86097. * @returns the unmodified current Color3
  86098. */
  86099. scaleToRef(scale: number, result: Color3): Color3;
  86100. /**
  86101. * Scale the current Color3 values by a factor and add the result to a given Color3
  86102. * @param scale defines the scale factor
  86103. * @param result defines color to store the result into
  86104. * @returns the unmodified current Color3
  86105. */
  86106. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86107. /**
  86108. * Clamps the rgb values by the min and max values and stores the result into "result"
  86109. * @param min defines minimum clamping value (default is 0)
  86110. * @param max defines maximum clamping value (default is 1)
  86111. * @param result defines color to store the result into
  86112. * @returns the original Color3
  86113. */
  86114. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86115. /**
  86116. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86117. * @param otherColor defines the second operand
  86118. * @returns the new Color3
  86119. */
  86120. add(otherColor: DeepImmutable<Color3>): Color3;
  86121. /**
  86122. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86123. * @param otherColor defines the second operand
  86124. * @param result defines Color3 object to store the result into
  86125. * @returns the unmodified current Color3
  86126. */
  86127. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86128. /**
  86129. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86130. * @param otherColor defines the second operand
  86131. * @returns the new Color3
  86132. */
  86133. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86134. /**
  86135. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86136. * @param otherColor defines the second operand
  86137. * @param result defines Color3 object to store the result into
  86138. * @returns the unmodified current Color3
  86139. */
  86140. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86141. /**
  86142. * Copy the current object
  86143. * @returns a new Color3 copied the current one
  86144. */
  86145. clone(): Color3;
  86146. /**
  86147. * Copies the rgb values from the source in the current Color3
  86148. * @param source defines the source Color3 object
  86149. * @returns the updated Color3 object
  86150. */
  86151. copyFrom(source: DeepImmutable<Color3>): Color3;
  86152. /**
  86153. * Updates the Color3 rgb values from the given floats
  86154. * @param r defines the red component to read from
  86155. * @param g defines the green component to read from
  86156. * @param b defines the blue component to read from
  86157. * @returns the current Color3 object
  86158. */
  86159. copyFromFloats(r: number, g: number, b: number): Color3;
  86160. /**
  86161. * Updates the Color3 rgb values from the given floats
  86162. * @param r defines the red component to read from
  86163. * @param g defines the green component to read from
  86164. * @param b defines the blue component to read from
  86165. * @returns the current Color3 object
  86166. */
  86167. set(r: number, g: number, b: number): Color3;
  86168. /**
  86169. * Compute the Color3 hexadecimal code as a string
  86170. * @returns a string containing the hexadecimal representation of the Color3 object
  86171. */
  86172. toHexString(): string;
  86173. /**
  86174. * Computes a new Color3 converted from the current one to linear space
  86175. * @returns a new Color3 object
  86176. */
  86177. toLinearSpace(): Color3;
  86178. /**
  86179. * Converts current color in rgb space to HSV values
  86180. * @returns a new color3 representing the HSV values
  86181. */
  86182. toHSV(): Color3;
  86183. /**
  86184. * Converts current color in rgb space to HSV values
  86185. * @param result defines the Color3 where to store the HSV values
  86186. */
  86187. toHSVToRef(result: Color3): void;
  86188. /**
  86189. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86190. * @param convertedColor defines the Color3 object where to store the linear space version
  86191. * @returns the unmodified Color3
  86192. */
  86193. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86194. /**
  86195. * Computes a new Color3 converted from the current one to gamma space
  86196. * @returns a new Color3 object
  86197. */
  86198. toGammaSpace(): Color3;
  86199. /**
  86200. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86201. * @param convertedColor defines the Color3 object where to store the gamma space version
  86202. * @returns the unmodified Color3
  86203. */
  86204. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86205. private static _BlackReadOnly;
  86206. /**
  86207. * Convert Hue, saturation and value to a Color3 (RGB)
  86208. * @param hue defines the hue
  86209. * @param saturation defines the saturation
  86210. * @param value defines the value
  86211. * @param result defines the Color3 where to store the RGB values
  86212. */
  86213. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86214. /**
  86215. * Creates a new Color3 from the string containing valid hexadecimal values
  86216. * @param hex defines a string containing valid hexadecimal values
  86217. * @returns a new Color3 object
  86218. */
  86219. static FromHexString(hex: string): Color3;
  86220. /**
  86221. * Creates a new Color3 from the starting index of the given array
  86222. * @param array defines the source array
  86223. * @param offset defines an offset in the source array
  86224. * @returns a new Color3 object
  86225. */
  86226. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86227. /**
  86228. * Creates a new Color3 from the starting index element of the given array
  86229. * @param array defines the source array to read from
  86230. * @param offset defines the offset in the source array
  86231. * @param result defines the target Color3 object
  86232. */
  86233. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86234. /**
  86235. * Creates a new Color3 from integer values (< 256)
  86236. * @param r defines the red component to read from (value between 0 and 255)
  86237. * @param g defines the green component to read from (value between 0 and 255)
  86238. * @param b defines the blue component to read from (value between 0 and 255)
  86239. * @returns a new Color3 object
  86240. */
  86241. static FromInts(r: number, g: number, b: number): Color3;
  86242. /**
  86243. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86244. * @param start defines the start Color3 value
  86245. * @param end defines the end Color3 value
  86246. * @param amount defines the gradient value between start and end
  86247. * @returns a new Color3 object
  86248. */
  86249. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86250. /**
  86251. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86252. * @param left defines the start value
  86253. * @param right defines the end value
  86254. * @param amount defines the gradient factor
  86255. * @param result defines the Color3 object where to store the result
  86256. */
  86257. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86258. /**
  86259. * Returns a Color3 value containing a red color
  86260. * @returns a new Color3 object
  86261. */
  86262. static Red(): Color3;
  86263. /**
  86264. * Returns a Color3 value containing a green color
  86265. * @returns a new Color3 object
  86266. */
  86267. static Green(): Color3;
  86268. /**
  86269. * Returns a Color3 value containing a blue color
  86270. * @returns a new Color3 object
  86271. */
  86272. static Blue(): Color3;
  86273. /**
  86274. * Returns a Color3 value containing a black color
  86275. * @returns a new Color3 object
  86276. */
  86277. static Black(): Color3;
  86278. /**
  86279. * Gets a Color3 value containing a black color that must not be updated
  86280. */
  86281. static get BlackReadOnly(): DeepImmutable<Color3>;
  86282. /**
  86283. * Returns a Color3 value containing a white color
  86284. * @returns a new Color3 object
  86285. */
  86286. static White(): Color3;
  86287. /**
  86288. * Returns a Color3 value containing a purple color
  86289. * @returns a new Color3 object
  86290. */
  86291. static Purple(): Color3;
  86292. /**
  86293. * Returns a Color3 value containing a magenta color
  86294. * @returns a new Color3 object
  86295. */
  86296. static Magenta(): Color3;
  86297. /**
  86298. * Returns a Color3 value containing a yellow color
  86299. * @returns a new Color3 object
  86300. */
  86301. static Yellow(): Color3;
  86302. /**
  86303. * Returns a Color3 value containing a gray color
  86304. * @returns a new Color3 object
  86305. */
  86306. static Gray(): Color3;
  86307. /**
  86308. * Returns a Color3 value containing a teal color
  86309. * @returns a new Color3 object
  86310. */
  86311. static Teal(): Color3;
  86312. /**
  86313. * Returns a Color3 value containing a random color
  86314. * @returns a new Color3 object
  86315. */
  86316. static Random(): Color3;
  86317. }
  86318. /**
  86319. * Class used to hold a RBGA color
  86320. */
  86321. export class Color4 {
  86322. /**
  86323. * Defines the red component (between 0 and 1, default is 0)
  86324. */
  86325. r: number;
  86326. /**
  86327. * Defines the green component (between 0 and 1, default is 0)
  86328. */
  86329. g: number;
  86330. /**
  86331. * Defines the blue component (between 0 and 1, default is 0)
  86332. */
  86333. b: number;
  86334. /**
  86335. * Defines the alpha component (between 0 and 1, default is 1)
  86336. */
  86337. a: number;
  86338. /**
  86339. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86340. * @param r defines the red component (between 0 and 1, default is 0)
  86341. * @param g defines the green component (between 0 and 1, default is 0)
  86342. * @param b defines the blue component (between 0 and 1, default is 0)
  86343. * @param a defines the alpha component (between 0 and 1, default is 1)
  86344. */
  86345. constructor(
  86346. /**
  86347. * Defines the red component (between 0 and 1, default is 0)
  86348. */
  86349. r?: number,
  86350. /**
  86351. * Defines the green component (between 0 and 1, default is 0)
  86352. */
  86353. g?: number,
  86354. /**
  86355. * Defines the blue component (between 0 and 1, default is 0)
  86356. */
  86357. b?: number,
  86358. /**
  86359. * Defines the alpha component (between 0 and 1, default is 1)
  86360. */
  86361. a?: number);
  86362. /**
  86363. * Adds in place the given Color4 values to the current Color4 object
  86364. * @param right defines the second operand
  86365. * @returns the current updated Color4 object
  86366. */
  86367. addInPlace(right: DeepImmutable<Color4>): Color4;
  86368. /**
  86369. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86370. * @returns the new array
  86371. */
  86372. asArray(): number[];
  86373. /**
  86374. * Stores from the starting index in the given array the Color4 successive values
  86375. * @param array defines the array where to store the r,g,b components
  86376. * @param index defines an optional index in the target array to define where to start storing values
  86377. * @returns the current Color4 object
  86378. */
  86379. toArray(array: number[], index?: number): Color4;
  86380. /**
  86381. * Update the current color with values stored in an array from the starting index of the given array
  86382. * @param array defines the source array
  86383. * @param offset defines an offset in the source array
  86384. * @returns the current Color4 object
  86385. */
  86386. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86387. /**
  86388. * Determines equality between Color4 objects
  86389. * @param otherColor defines the second operand
  86390. * @returns true if the rgba values are equal to the given ones
  86391. */
  86392. equals(otherColor: DeepImmutable<Color4>): boolean;
  86393. /**
  86394. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86395. * @param right defines the second operand
  86396. * @returns a new Color4 object
  86397. */
  86398. add(right: DeepImmutable<Color4>): Color4;
  86399. /**
  86400. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86401. * @param right defines the second operand
  86402. * @returns a new Color4 object
  86403. */
  86404. subtract(right: DeepImmutable<Color4>): Color4;
  86405. /**
  86406. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86407. * @param right defines the second operand
  86408. * @param result defines the Color4 object where to store the result
  86409. * @returns the current Color4 object
  86410. */
  86411. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86412. /**
  86413. * Creates a new Color4 with the current Color4 values multiplied by scale
  86414. * @param scale defines the scaling factor to apply
  86415. * @returns a new Color4 object
  86416. */
  86417. scale(scale: number): Color4;
  86418. /**
  86419. * Multiplies the current Color4 values by scale and stores the result in "result"
  86420. * @param scale defines the scaling factor to apply
  86421. * @param result defines the Color4 object where to store the result
  86422. * @returns the current unmodified Color4
  86423. */
  86424. scaleToRef(scale: number, result: Color4): Color4;
  86425. /**
  86426. * Scale the current Color4 values by a factor and add the result to a given Color4
  86427. * @param scale defines the scale factor
  86428. * @param result defines the Color4 object where to store the result
  86429. * @returns the unmodified current Color4
  86430. */
  86431. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86432. /**
  86433. * Clamps the rgb values by the min and max values and stores the result into "result"
  86434. * @param min defines minimum clamping value (default is 0)
  86435. * @param max defines maximum clamping value (default is 1)
  86436. * @param result defines color to store the result into.
  86437. * @returns the cuurent Color4
  86438. */
  86439. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86440. /**
  86441. * Multipy an Color4 value by another and return a new Color4 object
  86442. * @param color defines the Color4 value to multiply by
  86443. * @returns a new Color4 object
  86444. */
  86445. multiply(color: Color4): Color4;
  86446. /**
  86447. * Multipy a Color4 value by another and push the result in a reference value
  86448. * @param color defines the Color4 value to multiply by
  86449. * @param result defines the Color4 to fill the result in
  86450. * @returns the result Color4
  86451. */
  86452. multiplyToRef(color: Color4, result: Color4): Color4;
  86453. /**
  86454. * Creates a string with the Color4 current values
  86455. * @returns the string representation of the Color4 object
  86456. */
  86457. toString(): string;
  86458. /**
  86459. * Returns the string "Color4"
  86460. * @returns "Color4"
  86461. */
  86462. getClassName(): string;
  86463. /**
  86464. * Compute the Color4 hash code
  86465. * @returns an unique number that can be used to hash Color4 objects
  86466. */
  86467. getHashCode(): number;
  86468. /**
  86469. * Creates a new Color4 copied from the current one
  86470. * @returns a new Color4 object
  86471. */
  86472. clone(): Color4;
  86473. /**
  86474. * Copies the given Color4 values into the current one
  86475. * @param source defines the source Color4 object
  86476. * @returns the current updated Color4 object
  86477. */
  86478. copyFrom(source: Color4): Color4;
  86479. /**
  86480. * Copies the given float values into the current one
  86481. * @param r defines the red component to read from
  86482. * @param g defines the green component to read from
  86483. * @param b defines the blue component to read from
  86484. * @param a defines the alpha component to read from
  86485. * @returns the current updated Color4 object
  86486. */
  86487. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86488. /**
  86489. * Copies the given float values into the current one
  86490. * @param r defines the red component to read from
  86491. * @param g defines the green component to read from
  86492. * @param b defines the blue component to read from
  86493. * @param a defines the alpha component to read from
  86494. * @returns the current updated Color4 object
  86495. */
  86496. set(r: number, g: number, b: number, a: number): Color4;
  86497. /**
  86498. * Compute the Color4 hexadecimal code as a string
  86499. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86500. * @returns a string containing the hexadecimal representation of the Color4 object
  86501. */
  86502. toHexString(returnAsColor3?: boolean): string;
  86503. /**
  86504. * Computes a new Color4 converted from the current one to linear space
  86505. * @returns a new Color4 object
  86506. */
  86507. toLinearSpace(): Color4;
  86508. /**
  86509. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86510. * @param convertedColor defines the Color4 object where to store the linear space version
  86511. * @returns the unmodified Color4
  86512. */
  86513. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86514. /**
  86515. * Computes a new Color4 converted from the current one to gamma space
  86516. * @returns a new Color4 object
  86517. */
  86518. toGammaSpace(): Color4;
  86519. /**
  86520. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86521. * @param convertedColor defines the Color4 object where to store the gamma space version
  86522. * @returns the unmodified Color4
  86523. */
  86524. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86525. /**
  86526. * Creates a new Color4 from the string containing valid hexadecimal values
  86527. * @param hex defines a string containing valid hexadecimal values
  86528. * @returns a new Color4 object
  86529. */
  86530. static FromHexString(hex: string): Color4;
  86531. /**
  86532. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86533. * @param left defines the start value
  86534. * @param right defines the end value
  86535. * @param amount defines the gradient factor
  86536. * @returns a new Color4 object
  86537. */
  86538. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86539. /**
  86540. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86541. * @param left defines the start value
  86542. * @param right defines the end value
  86543. * @param amount defines the gradient factor
  86544. * @param result defines the Color4 object where to store data
  86545. */
  86546. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86547. /**
  86548. * Creates a new Color4 from a Color3 and an alpha value
  86549. * @param color3 defines the source Color3 to read from
  86550. * @param alpha defines the alpha component (1.0 by default)
  86551. * @returns a new Color4 object
  86552. */
  86553. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86554. /**
  86555. * Creates a new Color4 from the starting index element of the given array
  86556. * @param array defines the source array to read from
  86557. * @param offset defines the offset in the source array
  86558. * @returns a new Color4 object
  86559. */
  86560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86561. /**
  86562. * Creates a new Color4 from the starting index element of the given array
  86563. * @param array defines the source array to read from
  86564. * @param offset defines the offset in the source array
  86565. * @param result defines the target Color4 object
  86566. */
  86567. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86568. /**
  86569. * Creates a new Color3 from integer values (< 256)
  86570. * @param r defines the red component to read from (value between 0 and 255)
  86571. * @param g defines the green component to read from (value between 0 and 255)
  86572. * @param b defines the blue component to read from (value between 0 and 255)
  86573. * @param a defines the alpha component to read from (value between 0 and 255)
  86574. * @returns a new Color3 object
  86575. */
  86576. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86577. /**
  86578. * Check the content of a given array and convert it to an array containing RGBA data
  86579. * If the original array was already containing count * 4 values then it is returned directly
  86580. * @param colors defines the array to check
  86581. * @param count defines the number of RGBA data to expect
  86582. * @returns an array containing count * 4 values (RGBA)
  86583. */
  86584. static CheckColors4(colors: number[], count: number): number[];
  86585. }
  86586. /**
  86587. * @hidden
  86588. */
  86589. export class TmpColors {
  86590. static Color3: Color3[];
  86591. static Color4: Color4[];
  86592. }
  86593. }
  86594. declare module BABYLON {
  86595. /**
  86596. * Defines an interface which represents an animation key frame
  86597. */
  86598. export interface IAnimationKey {
  86599. /**
  86600. * Frame of the key frame
  86601. */
  86602. frame: number;
  86603. /**
  86604. * Value at the specifies key frame
  86605. */
  86606. value: any;
  86607. /**
  86608. * The input tangent for the cubic hermite spline
  86609. */
  86610. inTangent?: any;
  86611. /**
  86612. * The output tangent for the cubic hermite spline
  86613. */
  86614. outTangent?: any;
  86615. /**
  86616. * The animation interpolation type
  86617. */
  86618. interpolation?: AnimationKeyInterpolation;
  86619. }
  86620. /**
  86621. * Enum for the animation key frame interpolation type
  86622. */
  86623. export enum AnimationKeyInterpolation {
  86624. /**
  86625. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86626. */
  86627. STEP = 1
  86628. }
  86629. }
  86630. declare module BABYLON {
  86631. /**
  86632. * Represents the range of an animation
  86633. */
  86634. export class AnimationRange {
  86635. /**The name of the animation range**/
  86636. name: string;
  86637. /**The starting frame of the animation */
  86638. from: number;
  86639. /**The ending frame of the animation*/
  86640. to: number;
  86641. /**
  86642. * Initializes the range of an animation
  86643. * @param name The name of the animation range
  86644. * @param from The starting frame of the animation
  86645. * @param to The ending frame of the animation
  86646. */
  86647. constructor(
  86648. /**The name of the animation range**/
  86649. name: string,
  86650. /**The starting frame of the animation */
  86651. from: number,
  86652. /**The ending frame of the animation*/
  86653. to: number);
  86654. /**
  86655. * Makes a copy of the animation range
  86656. * @returns A copy of the animation range
  86657. */
  86658. clone(): AnimationRange;
  86659. }
  86660. }
  86661. declare module BABYLON {
  86662. /**
  86663. * Composed of a frame, and an action function
  86664. */
  86665. export class AnimationEvent {
  86666. /** The frame for which the event is triggered **/
  86667. frame: number;
  86668. /** The event to perform when triggered **/
  86669. action: (currentFrame: number) => void;
  86670. /** Specifies if the event should be triggered only once**/
  86671. onlyOnce?: boolean | undefined;
  86672. /**
  86673. * Specifies if the animation event is done
  86674. */
  86675. isDone: boolean;
  86676. /**
  86677. * Initializes the animation event
  86678. * @param frame The frame for which the event is triggered
  86679. * @param action The event to perform when triggered
  86680. * @param onlyOnce Specifies if the event should be triggered only once
  86681. */
  86682. constructor(
  86683. /** The frame for which the event is triggered **/
  86684. frame: number,
  86685. /** The event to perform when triggered **/
  86686. action: (currentFrame: number) => void,
  86687. /** Specifies if the event should be triggered only once**/
  86688. onlyOnce?: boolean | undefined);
  86689. /** @hidden */
  86690. _clone(): AnimationEvent;
  86691. }
  86692. }
  86693. declare module BABYLON {
  86694. /**
  86695. * Interface used to define a behavior
  86696. */
  86697. export interface Behavior<T> {
  86698. /** gets or sets behavior's name */
  86699. name: string;
  86700. /**
  86701. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86702. */
  86703. init(): void;
  86704. /**
  86705. * Called when the behavior is attached to a target
  86706. * @param target defines the target where the behavior is attached to
  86707. */
  86708. attach(target: T): void;
  86709. /**
  86710. * Called when the behavior is detached from its target
  86711. */
  86712. detach(): void;
  86713. }
  86714. /**
  86715. * Interface implemented by classes supporting behaviors
  86716. */
  86717. export interface IBehaviorAware<T> {
  86718. /**
  86719. * Attach a behavior
  86720. * @param behavior defines the behavior to attach
  86721. * @returns the current host
  86722. */
  86723. addBehavior(behavior: Behavior<T>): T;
  86724. /**
  86725. * Remove a behavior from the current object
  86726. * @param behavior defines the behavior to detach
  86727. * @returns the current host
  86728. */
  86729. removeBehavior(behavior: Behavior<T>): T;
  86730. /**
  86731. * Gets a behavior using its name to search
  86732. * @param name defines the name to search
  86733. * @returns the behavior or null if not found
  86734. */
  86735. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86736. }
  86737. }
  86738. declare module BABYLON {
  86739. /**
  86740. * Defines an array and its length.
  86741. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86742. */
  86743. export interface ISmartArrayLike<T> {
  86744. /**
  86745. * The data of the array.
  86746. */
  86747. data: Array<T>;
  86748. /**
  86749. * The active length of the array.
  86750. */
  86751. length: number;
  86752. }
  86753. /**
  86754. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86755. */
  86756. export class SmartArray<T> implements ISmartArrayLike<T> {
  86757. /**
  86758. * The full set of data from the array.
  86759. */
  86760. data: Array<T>;
  86761. /**
  86762. * The active length of the array.
  86763. */
  86764. length: number;
  86765. protected _id: number;
  86766. /**
  86767. * Instantiates a Smart Array.
  86768. * @param capacity defines the default capacity of the array.
  86769. */
  86770. constructor(capacity: number);
  86771. /**
  86772. * Pushes a value at the end of the active data.
  86773. * @param value defines the object to push in the array.
  86774. */
  86775. push(value: T): void;
  86776. /**
  86777. * Iterates over the active data and apply the lambda to them.
  86778. * @param func defines the action to apply on each value.
  86779. */
  86780. forEach(func: (content: T) => void): void;
  86781. /**
  86782. * Sorts the full sets of data.
  86783. * @param compareFn defines the comparison function to apply.
  86784. */
  86785. sort(compareFn: (a: T, b: T) => number): void;
  86786. /**
  86787. * Resets the active data to an empty array.
  86788. */
  86789. reset(): void;
  86790. /**
  86791. * Releases all the data from the array as well as the array.
  86792. */
  86793. dispose(): void;
  86794. /**
  86795. * Concats the active data with a given array.
  86796. * @param array defines the data to concatenate with.
  86797. */
  86798. concat(array: any): void;
  86799. /**
  86800. * Returns the position of a value in the active data.
  86801. * @param value defines the value to find the index for
  86802. * @returns the index if found in the active data otherwise -1
  86803. */
  86804. indexOf(value: T): number;
  86805. /**
  86806. * Returns whether an element is part of the active data.
  86807. * @param value defines the value to look for
  86808. * @returns true if found in the active data otherwise false
  86809. */
  86810. contains(value: T): boolean;
  86811. private static _GlobalId;
  86812. }
  86813. /**
  86814. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86815. * The data in this array can only be present once
  86816. */
  86817. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86818. private _duplicateId;
  86819. /**
  86820. * Pushes a value at the end of the active data.
  86821. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86822. * @param value defines the object to push in the array.
  86823. */
  86824. push(value: T): void;
  86825. /**
  86826. * Pushes a value at the end of the active data.
  86827. * If the data is already present, it won t be added again
  86828. * @param value defines the object to push in the array.
  86829. * @returns true if added false if it was already present
  86830. */
  86831. pushNoDuplicate(value: T): boolean;
  86832. /**
  86833. * Resets the active data to an empty array.
  86834. */
  86835. reset(): void;
  86836. /**
  86837. * Concats the active data with a given array.
  86838. * This ensures no dupplicate will be present in the result.
  86839. * @param array defines the data to concatenate with.
  86840. */
  86841. concatWithNoDuplicate(array: any): void;
  86842. }
  86843. }
  86844. declare module BABYLON {
  86845. /**
  86846. * @ignore
  86847. * This is a list of all the different input types that are available in the application.
  86848. * Fo instance: ArcRotateCameraGamepadInput...
  86849. */
  86850. export var CameraInputTypes: {};
  86851. /**
  86852. * This is the contract to implement in order to create a new input class.
  86853. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86854. */
  86855. export interface ICameraInput<TCamera extends Camera> {
  86856. /**
  86857. * Defines the camera the input is attached to.
  86858. */
  86859. camera: Nullable<TCamera>;
  86860. /**
  86861. * Gets the class name of the current intput.
  86862. * @returns the class name
  86863. */
  86864. getClassName(): string;
  86865. /**
  86866. * Get the friendly name associated with the input class.
  86867. * @returns the input friendly name
  86868. */
  86869. getSimpleName(): string;
  86870. /**
  86871. * Attach the input controls to a specific dom element to get the input from.
  86872. * @param element Defines the element the controls should be listened from
  86873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86874. */
  86875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86876. /**
  86877. * Detach the current controls from the specified dom element.
  86878. * @param element Defines the element to stop listening the inputs from
  86879. */
  86880. detachControl(element: Nullable<HTMLElement>): void;
  86881. /**
  86882. * Update the current camera state depending on the inputs that have been used this frame.
  86883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86884. */
  86885. checkInputs?: () => void;
  86886. }
  86887. /**
  86888. * Represents a map of input types to input instance or input index to input instance.
  86889. */
  86890. export interface CameraInputsMap<TCamera extends Camera> {
  86891. /**
  86892. * Accessor to the input by input type.
  86893. */
  86894. [name: string]: ICameraInput<TCamera>;
  86895. /**
  86896. * Accessor to the input by input index.
  86897. */
  86898. [idx: number]: ICameraInput<TCamera>;
  86899. }
  86900. /**
  86901. * This represents the input manager used within a camera.
  86902. * It helps dealing with all the different kind of input attached to a camera.
  86903. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86904. */
  86905. export class CameraInputsManager<TCamera extends Camera> {
  86906. /**
  86907. * Defines the list of inputs attahed to the camera.
  86908. */
  86909. attached: CameraInputsMap<TCamera>;
  86910. /**
  86911. * Defines the dom element the camera is collecting inputs from.
  86912. * This is null if the controls have not been attached.
  86913. */
  86914. attachedElement: Nullable<HTMLElement>;
  86915. /**
  86916. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86917. */
  86918. noPreventDefault: boolean;
  86919. /**
  86920. * Defined the camera the input manager belongs to.
  86921. */
  86922. camera: TCamera;
  86923. /**
  86924. * Update the current camera state depending on the inputs that have been used this frame.
  86925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86926. */
  86927. checkInputs: () => void;
  86928. /**
  86929. * Instantiate a new Camera Input Manager.
  86930. * @param camera Defines the camera the input manager blongs to
  86931. */
  86932. constructor(camera: TCamera);
  86933. /**
  86934. * Add an input method to a camera
  86935. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86936. * @param input camera input method
  86937. */
  86938. add(input: ICameraInput<TCamera>): void;
  86939. /**
  86940. * Remove a specific input method from a camera
  86941. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86942. * @param inputToRemove camera input method
  86943. */
  86944. remove(inputToRemove: ICameraInput<TCamera>): void;
  86945. /**
  86946. * Remove a specific input type from a camera
  86947. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86948. * @param inputType the type of the input to remove
  86949. */
  86950. removeByType(inputType: string): void;
  86951. private _addCheckInputs;
  86952. /**
  86953. * Attach the input controls to the currently attached dom element to listen the events from.
  86954. * @param input Defines the input to attach
  86955. */
  86956. attachInput(input: ICameraInput<TCamera>): void;
  86957. /**
  86958. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86959. * @param element Defines the dom element to collect the events from
  86960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86961. */
  86962. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86963. /**
  86964. * Detach the current manager inputs controls from a specific dom element.
  86965. * @param element Defines the dom element to collect the events from
  86966. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86967. */
  86968. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86969. /**
  86970. * Rebuild the dynamic inputCheck function from the current list of
  86971. * defined inputs in the manager.
  86972. */
  86973. rebuildInputCheck(): void;
  86974. /**
  86975. * Remove all attached input methods from a camera
  86976. */
  86977. clear(): void;
  86978. /**
  86979. * Serialize the current input manager attached to a camera.
  86980. * This ensures than once parsed,
  86981. * the input associated to the camera will be identical to the current ones
  86982. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86983. */
  86984. serialize(serializedCamera: any): void;
  86985. /**
  86986. * Parses an input manager serialized JSON to restore the previous list of inputs
  86987. * and states associated to a camera.
  86988. * @param parsedCamera Defines the JSON to parse
  86989. */
  86990. parse(parsedCamera: any): void;
  86991. }
  86992. }
  86993. declare module BABYLON {
  86994. /**
  86995. * Class used to store data that will be store in GPU memory
  86996. */
  86997. export class Buffer {
  86998. private _engine;
  86999. private _buffer;
  87000. /** @hidden */
  87001. _data: Nullable<DataArray>;
  87002. private _updatable;
  87003. private _instanced;
  87004. private _divisor;
  87005. /**
  87006. * Gets the byte stride.
  87007. */
  87008. readonly byteStride: number;
  87009. /**
  87010. * Constructor
  87011. * @param engine the engine
  87012. * @param data the data to use for this buffer
  87013. * @param updatable whether the data is updatable
  87014. * @param stride the stride (optional)
  87015. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87016. * @param instanced whether the buffer is instanced (optional)
  87017. * @param useBytes set to true if the stride in in bytes (optional)
  87018. * @param divisor sets an optional divisor for instances (1 by default)
  87019. */
  87020. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87021. /**
  87022. * Create a new VertexBuffer based on the current buffer
  87023. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87024. * @param offset defines offset in the buffer (0 by default)
  87025. * @param size defines the size in floats of attributes (position is 3 for instance)
  87026. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87027. * @param instanced defines if the vertex buffer contains indexed data
  87028. * @param useBytes defines if the offset and stride are in bytes *
  87029. * @param divisor sets an optional divisor for instances (1 by default)
  87030. * @returns the new vertex buffer
  87031. */
  87032. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87033. /**
  87034. * Gets a boolean indicating if the Buffer is updatable?
  87035. * @returns true if the buffer is updatable
  87036. */
  87037. isUpdatable(): boolean;
  87038. /**
  87039. * Gets current buffer's data
  87040. * @returns a DataArray or null
  87041. */
  87042. getData(): Nullable<DataArray>;
  87043. /**
  87044. * Gets underlying native buffer
  87045. * @returns underlying native buffer
  87046. */
  87047. getBuffer(): Nullable<DataBuffer>;
  87048. /**
  87049. * Gets the stride in float32 units (i.e. byte stride / 4).
  87050. * May not be an integer if the byte stride is not divisible by 4.
  87051. * @returns the stride in float32 units
  87052. * @deprecated Please use byteStride instead.
  87053. */
  87054. getStrideSize(): number;
  87055. /**
  87056. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87057. * @param data defines the data to store
  87058. */
  87059. create(data?: Nullable<DataArray>): void;
  87060. /** @hidden */
  87061. _rebuild(): void;
  87062. /**
  87063. * Update current buffer data
  87064. * @param data defines the data to store
  87065. */
  87066. update(data: DataArray): void;
  87067. /**
  87068. * Updates the data directly.
  87069. * @param data the new data
  87070. * @param offset the new offset
  87071. * @param vertexCount the vertex count (optional)
  87072. * @param useBytes set to true if the offset is in bytes
  87073. */
  87074. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87075. /**
  87076. * Release all resources
  87077. */
  87078. dispose(): void;
  87079. }
  87080. /**
  87081. * Specialized buffer used to store vertex data
  87082. */
  87083. export class VertexBuffer {
  87084. /** @hidden */
  87085. _buffer: Buffer;
  87086. private _kind;
  87087. private _size;
  87088. private _ownsBuffer;
  87089. private _instanced;
  87090. private _instanceDivisor;
  87091. /**
  87092. * The byte type.
  87093. */
  87094. static readonly BYTE: number;
  87095. /**
  87096. * The unsigned byte type.
  87097. */
  87098. static readonly UNSIGNED_BYTE: number;
  87099. /**
  87100. * The short type.
  87101. */
  87102. static readonly SHORT: number;
  87103. /**
  87104. * The unsigned short type.
  87105. */
  87106. static readonly UNSIGNED_SHORT: number;
  87107. /**
  87108. * The integer type.
  87109. */
  87110. static readonly INT: number;
  87111. /**
  87112. * The unsigned integer type.
  87113. */
  87114. static readonly UNSIGNED_INT: number;
  87115. /**
  87116. * The float type.
  87117. */
  87118. static readonly FLOAT: number;
  87119. /**
  87120. * Gets or sets the instance divisor when in instanced mode
  87121. */
  87122. get instanceDivisor(): number;
  87123. set instanceDivisor(value: number);
  87124. /**
  87125. * Gets the byte stride.
  87126. */
  87127. readonly byteStride: number;
  87128. /**
  87129. * Gets the byte offset.
  87130. */
  87131. readonly byteOffset: number;
  87132. /**
  87133. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87134. */
  87135. readonly normalized: boolean;
  87136. /**
  87137. * Gets the data type of each component in the array.
  87138. */
  87139. readonly type: number;
  87140. /**
  87141. * Constructor
  87142. * @param engine the engine
  87143. * @param data the data to use for this vertex buffer
  87144. * @param kind the vertex buffer kind
  87145. * @param updatable whether the data is updatable
  87146. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87147. * @param stride the stride (optional)
  87148. * @param instanced whether the buffer is instanced (optional)
  87149. * @param offset the offset of the data (optional)
  87150. * @param size the number of components (optional)
  87151. * @param type the type of the component (optional)
  87152. * @param normalized whether the data contains normalized data (optional)
  87153. * @param useBytes set to true if stride and offset are in bytes (optional)
  87154. * @param divisor defines the instance divisor to use (1 by default)
  87155. */
  87156. 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);
  87157. /** @hidden */
  87158. _rebuild(): void;
  87159. /**
  87160. * Returns the kind of the VertexBuffer (string)
  87161. * @returns a string
  87162. */
  87163. getKind(): string;
  87164. /**
  87165. * Gets a boolean indicating if the VertexBuffer is updatable?
  87166. * @returns true if the buffer is updatable
  87167. */
  87168. isUpdatable(): boolean;
  87169. /**
  87170. * Gets current buffer's data
  87171. * @returns a DataArray or null
  87172. */
  87173. getData(): Nullable<DataArray>;
  87174. /**
  87175. * Gets underlying native buffer
  87176. * @returns underlying native buffer
  87177. */
  87178. getBuffer(): Nullable<DataBuffer>;
  87179. /**
  87180. * Gets the stride in float32 units (i.e. byte stride / 4).
  87181. * May not be an integer if the byte stride is not divisible by 4.
  87182. * @returns the stride in float32 units
  87183. * @deprecated Please use byteStride instead.
  87184. */
  87185. getStrideSize(): number;
  87186. /**
  87187. * Returns the offset as a multiple of the type byte length.
  87188. * @returns the offset in bytes
  87189. * @deprecated Please use byteOffset instead.
  87190. */
  87191. getOffset(): number;
  87192. /**
  87193. * Returns the number of components per vertex attribute (integer)
  87194. * @returns the size in float
  87195. */
  87196. getSize(): number;
  87197. /**
  87198. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87199. * @returns true if this buffer is instanced
  87200. */
  87201. getIsInstanced(): boolean;
  87202. /**
  87203. * Returns the instancing divisor, zero for non-instanced (integer).
  87204. * @returns a number
  87205. */
  87206. getInstanceDivisor(): number;
  87207. /**
  87208. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87209. * @param data defines the data to store
  87210. */
  87211. create(data?: DataArray): void;
  87212. /**
  87213. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87214. * This function will create a new buffer if the current one is not updatable
  87215. * @param data defines the data to store
  87216. */
  87217. update(data: DataArray): void;
  87218. /**
  87219. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87220. * Returns the directly updated WebGLBuffer.
  87221. * @param data the new data
  87222. * @param offset the new offset
  87223. * @param useBytes set to true if the offset is in bytes
  87224. */
  87225. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87226. /**
  87227. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87228. */
  87229. dispose(): void;
  87230. /**
  87231. * Enumerates each value of this vertex buffer as numbers.
  87232. * @param count the number of values to enumerate
  87233. * @param callback the callback function called for each value
  87234. */
  87235. forEach(count: number, callback: (value: number, index: number) => void): void;
  87236. /**
  87237. * Positions
  87238. */
  87239. static readonly PositionKind: string;
  87240. /**
  87241. * Normals
  87242. */
  87243. static readonly NormalKind: string;
  87244. /**
  87245. * Tangents
  87246. */
  87247. static readonly TangentKind: string;
  87248. /**
  87249. * Texture coordinates
  87250. */
  87251. static readonly UVKind: string;
  87252. /**
  87253. * Texture coordinates 2
  87254. */
  87255. static readonly UV2Kind: string;
  87256. /**
  87257. * Texture coordinates 3
  87258. */
  87259. static readonly UV3Kind: string;
  87260. /**
  87261. * Texture coordinates 4
  87262. */
  87263. static readonly UV4Kind: string;
  87264. /**
  87265. * Texture coordinates 5
  87266. */
  87267. static readonly UV5Kind: string;
  87268. /**
  87269. * Texture coordinates 6
  87270. */
  87271. static readonly UV6Kind: string;
  87272. /**
  87273. * Colors
  87274. */
  87275. static readonly ColorKind: string;
  87276. /**
  87277. * Matrix indices (for bones)
  87278. */
  87279. static readonly MatricesIndicesKind: string;
  87280. /**
  87281. * Matrix weights (for bones)
  87282. */
  87283. static readonly MatricesWeightsKind: string;
  87284. /**
  87285. * Additional matrix indices (for bones)
  87286. */
  87287. static readonly MatricesIndicesExtraKind: string;
  87288. /**
  87289. * Additional matrix weights (for bones)
  87290. */
  87291. static readonly MatricesWeightsExtraKind: string;
  87292. /**
  87293. * Deduces the stride given a kind.
  87294. * @param kind The kind string to deduce
  87295. * @returns The deduced stride
  87296. */
  87297. static DeduceStride(kind: string): number;
  87298. /**
  87299. * Gets the byte length of the given type.
  87300. * @param type the type
  87301. * @returns the number of bytes
  87302. */
  87303. static GetTypeByteLength(type: number): number;
  87304. /**
  87305. * Enumerates each value of the given parameters as numbers.
  87306. * @param data the data to enumerate
  87307. * @param byteOffset the byte offset of the data
  87308. * @param byteStride the byte stride of the data
  87309. * @param componentCount the number of components per element
  87310. * @param componentType the type of the component
  87311. * @param count the number of values to enumerate
  87312. * @param normalized whether the data is normalized
  87313. * @param callback the callback function called for each value
  87314. */
  87315. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87316. private static _GetFloatValue;
  87317. }
  87318. }
  87319. declare module BABYLON {
  87320. /**
  87321. * The options Interface for creating a Capsule Mesh
  87322. */
  87323. export interface ICreateCapsuleOptions {
  87324. /** The Orientation of the capsule. Default : Vector3.Up() */
  87325. orientation?: Vector3;
  87326. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87327. subdivisions: number;
  87328. /** Number of cylindrical segments on the capsule. */
  87329. tessellation: number;
  87330. /** Height or Length of the capsule. */
  87331. height: number;
  87332. /** Radius of the capsule. */
  87333. radius: number;
  87334. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87335. capSubdivisions: number;
  87336. /** Overwrite for the top radius. */
  87337. radiusTop?: number;
  87338. /** Overwrite for the bottom radius. */
  87339. radiusBottom?: number;
  87340. /** Overwrite for the top capSubdivisions. */
  87341. topCapSubdivisions?: number;
  87342. /** Overwrite for the bottom capSubdivisions. */
  87343. bottomCapSubdivisions?: number;
  87344. }
  87345. /**
  87346. * Class containing static functions to help procedurally build meshes
  87347. */
  87348. export class CapsuleBuilder {
  87349. /**
  87350. * Creates a capsule or a pill mesh
  87351. * @param name defines the name of the mesh
  87352. * @param options The constructors options.
  87353. * @param scene The scene the mesh is scoped to.
  87354. * @returns Capsule Mesh
  87355. */
  87356. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87357. }
  87358. }
  87359. declare module BABYLON {
  87360. /**
  87361. * @hidden
  87362. */
  87363. export class IntersectionInfo {
  87364. bu: Nullable<number>;
  87365. bv: Nullable<number>;
  87366. distance: number;
  87367. faceId: number;
  87368. subMeshId: number;
  87369. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87370. }
  87371. }
  87372. declare module BABYLON {
  87373. /**
  87374. * Class used to store bounding sphere information
  87375. */
  87376. export class BoundingSphere {
  87377. /**
  87378. * Gets the center of the bounding sphere in local space
  87379. */
  87380. readonly center: Vector3;
  87381. /**
  87382. * Radius of the bounding sphere in local space
  87383. */
  87384. radius: number;
  87385. /**
  87386. * Gets the center of the bounding sphere in world space
  87387. */
  87388. readonly centerWorld: Vector3;
  87389. /**
  87390. * Radius of the bounding sphere in world space
  87391. */
  87392. radiusWorld: number;
  87393. /**
  87394. * Gets the minimum vector in local space
  87395. */
  87396. readonly minimum: Vector3;
  87397. /**
  87398. * Gets the maximum vector in local space
  87399. */
  87400. readonly maximum: Vector3;
  87401. private _worldMatrix;
  87402. private static readonly TmpVector3;
  87403. /**
  87404. * Creates a new bounding sphere
  87405. * @param min defines the minimum vector (in local space)
  87406. * @param max defines the maximum vector (in local space)
  87407. * @param worldMatrix defines the new world matrix
  87408. */
  87409. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87410. /**
  87411. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87412. * @param min defines the new minimum vector (in local space)
  87413. * @param max defines the new maximum vector (in local space)
  87414. * @param worldMatrix defines the new world matrix
  87415. */
  87416. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87417. /**
  87418. * Scale the current bounding sphere by applying a scale factor
  87419. * @param factor defines the scale factor to apply
  87420. * @returns the current bounding box
  87421. */
  87422. scale(factor: number): BoundingSphere;
  87423. /**
  87424. * Gets the world matrix of the bounding box
  87425. * @returns a matrix
  87426. */
  87427. getWorldMatrix(): DeepImmutable<Matrix>;
  87428. /** @hidden */
  87429. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87430. /**
  87431. * Tests if the bounding sphere is intersecting the frustum planes
  87432. * @param frustumPlanes defines the frustum planes to test
  87433. * @returns true if there is an intersection
  87434. */
  87435. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87436. /**
  87437. * Tests if the bounding sphere center is in between the frustum planes.
  87438. * Used for optimistic fast inclusion.
  87439. * @param frustumPlanes defines the frustum planes to test
  87440. * @returns true if the sphere center is in between the frustum planes
  87441. */
  87442. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87443. /**
  87444. * Tests if a point is inside the bounding sphere
  87445. * @param point defines the point to test
  87446. * @returns true if the point is inside the bounding sphere
  87447. */
  87448. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87449. /**
  87450. * Checks if two sphere intersct
  87451. * @param sphere0 sphere 0
  87452. * @param sphere1 sphere 1
  87453. * @returns true if the speres intersect
  87454. */
  87455. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87456. }
  87457. }
  87458. declare module BABYLON {
  87459. /**
  87460. * Class used to store bounding box information
  87461. */
  87462. export class BoundingBox implements ICullable {
  87463. /**
  87464. * Gets the 8 vectors representing the bounding box in local space
  87465. */
  87466. readonly vectors: Vector3[];
  87467. /**
  87468. * Gets the center of the bounding box in local space
  87469. */
  87470. readonly center: Vector3;
  87471. /**
  87472. * Gets the center of the bounding box in world space
  87473. */
  87474. readonly centerWorld: Vector3;
  87475. /**
  87476. * Gets the extend size in local space
  87477. */
  87478. readonly extendSize: Vector3;
  87479. /**
  87480. * Gets the extend size in world space
  87481. */
  87482. readonly extendSizeWorld: Vector3;
  87483. /**
  87484. * Gets the OBB (object bounding box) directions
  87485. */
  87486. readonly directions: Vector3[];
  87487. /**
  87488. * Gets the 8 vectors representing the bounding box in world space
  87489. */
  87490. readonly vectorsWorld: Vector3[];
  87491. /**
  87492. * Gets the minimum vector in world space
  87493. */
  87494. readonly minimumWorld: Vector3;
  87495. /**
  87496. * Gets the maximum vector in world space
  87497. */
  87498. readonly maximumWorld: Vector3;
  87499. /**
  87500. * Gets the minimum vector in local space
  87501. */
  87502. readonly minimum: Vector3;
  87503. /**
  87504. * Gets the maximum vector in local space
  87505. */
  87506. readonly maximum: Vector3;
  87507. private _worldMatrix;
  87508. private static readonly TmpVector3;
  87509. /**
  87510. * @hidden
  87511. */
  87512. _tag: number;
  87513. /**
  87514. * Creates a new bounding box
  87515. * @param min defines the minimum vector (in local space)
  87516. * @param max defines the maximum vector (in local space)
  87517. * @param worldMatrix defines the new world matrix
  87518. */
  87519. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87520. /**
  87521. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87522. * @param min defines the new minimum vector (in local space)
  87523. * @param max defines the new maximum vector (in local space)
  87524. * @param worldMatrix defines the new world matrix
  87525. */
  87526. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87527. /**
  87528. * Scale the current bounding box by applying a scale factor
  87529. * @param factor defines the scale factor to apply
  87530. * @returns the current bounding box
  87531. */
  87532. scale(factor: number): BoundingBox;
  87533. /**
  87534. * Gets the world matrix of the bounding box
  87535. * @returns a matrix
  87536. */
  87537. getWorldMatrix(): DeepImmutable<Matrix>;
  87538. /** @hidden */
  87539. _update(world: DeepImmutable<Matrix>): void;
  87540. /**
  87541. * Tests if the bounding box is intersecting the frustum planes
  87542. * @param frustumPlanes defines the frustum planes to test
  87543. * @returns true if there is an intersection
  87544. */
  87545. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87546. /**
  87547. * Tests if the bounding box is entirely inside the frustum planes
  87548. * @param frustumPlanes defines the frustum planes to test
  87549. * @returns true if there is an inclusion
  87550. */
  87551. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87552. /**
  87553. * Tests if a point is inside the bounding box
  87554. * @param point defines the point to test
  87555. * @returns true if the point is inside the bounding box
  87556. */
  87557. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87558. /**
  87559. * Tests if the bounding box intersects with a bounding sphere
  87560. * @param sphere defines the sphere to test
  87561. * @returns true if there is an intersection
  87562. */
  87563. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87564. /**
  87565. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87566. * @param min defines the min vector to use
  87567. * @param max defines the max vector to use
  87568. * @returns true if there is an intersection
  87569. */
  87570. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87571. /**
  87572. * Tests if two bounding boxes are intersections
  87573. * @param box0 defines the first box to test
  87574. * @param box1 defines the second box to test
  87575. * @returns true if there is an intersection
  87576. */
  87577. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87578. /**
  87579. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87580. * @param minPoint defines the minimum vector of the bounding box
  87581. * @param maxPoint defines the maximum vector of the bounding box
  87582. * @param sphereCenter defines the sphere center
  87583. * @param sphereRadius defines the sphere radius
  87584. * @returns true if there is an intersection
  87585. */
  87586. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87587. /**
  87588. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87589. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87590. * @param frustumPlanes defines the frustum planes to test
  87591. * @return true if there is an inclusion
  87592. */
  87593. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87594. /**
  87595. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87596. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87597. * @param frustumPlanes defines the frustum planes to test
  87598. * @return true if there is an intersection
  87599. */
  87600. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87601. }
  87602. }
  87603. declare module BABYLON {
  87604. /** @hidden */
  87605. export class Collider {
  87606. /** Define if a collision was found */
  87607. collisionFound: boolean;
  87608. /**
  87609. * Define last intersection point in local space
  87610. */
  87611. intersectionPoint: Vector3;
  87612. /**
  87613. * Define last collided mesh
  87614. */
  87615. collidedMesh: Nullable<AbstractMesh>;
  87616. private _collisionPoint;
  87617. private _planeIntersectionPoint;
  87618. private _tempVector;
  87619. private _tempVector2;
  87620. private _tempVector3;
  87621. private _tempVector4;
  87622. private _edge;
  87623. private _baseToVertex;
  87624. private _destinationPoint;
  87625. private _slidePlaneNormal;
  87626. private _displacementVector;
  87627. /** @hidden */
  87628. _radius: Vector3;
  87629. /** @hidden */
  87630. _retry: number;
  87631. private _velocity;
  87632. private _basePoint;
  87633. private _epsilon;
  87634. /** @hidden */
  87635. _velocityWorldLength: number;
  87636. /** @hidden */
  87637. _basePointWorld: Vector3;
  87638. private _velocityWorld;
  87639. private _normalizedVelocity;
  87640. /** @hidden */
  87641. _initialVelocity: Vector3;
  87642. /** @hidden */
  87643. _initialPosition: Vector3;
  87644. private _nearestDistance;
  87645. private _collisionMask;
  87646. get collisionMask(): number;
  87647. set collisionMask(mask: number);
  87648. /**
  87649. * Gets the plane normal used to compute the sliding response (in local space)
  87650. */
  87651. get slidePlaneNormal(): Vector3;
  87652. /** @hidden */
  87653. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87654. /** @hidden */
  87655. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87656. /** @hidden */
  87657. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87658. /** @hidden */
  87659. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87660. /** @hidden */
  87661. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87662. /** @hidden */
  87663. _getResponse(pos: Vector3, vel: Vector3): void;
  87664. }
  87665. }
  87666. declare module BABYLON {
  87667. /**
  87668. * Interface for cullable objects
  87669. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87670. */
  87671. export interface ICullable {
  87672. /**
  87673. * Checks if the object or part of the object is in the frustum
  87674. * @param frustumPlanes Camera near/planes
  87675. * @returns true if the object is in frustum otherwise false
  87676. */
  87677. isInFrustum(frustumPlanes: Plane[]): boolean;
  87678. /**
  87679. * Checks if a cullable object (mesh...) is in the camera frustum
  87680. * Unlike isInFrustum this cheks the full bounding box
  87681. * @param frustumPlanes Camera near/planes
  87682. * @returns true if the object is in frustum otherwise false
  87683. */
  87684. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87685. }
  87686. /**
  87687. * Info for a bounding data of a mesh
  87688. */
  87689. export class BoundingInfo implements ICullable {
  87690. /**
  87691. * Bounding box for the mesh
  87692. */
  87693. readonly boundingBox: BoundingBox;
  87694. /**
  87695. * Bounding sphere for the mesh
  87696. */
  87697. readonly boundingSphere: BoundingSphere;
  87698. private _isLocked;
  87699. private static readonly TmpVector3;
  87700. /**
  87701. * Constructs bounding info
  87702. * @param minimum min vector of the bounding box/sphere
  87703. * @param maximum max vector of the bounding box/sphere
  87704. * @param worldMatrix defines the new world matrix
  87705. */
  87706. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87707. /**
  87708. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87709. * @param min defines the new minimum vector (in local space)
  87710. * @param max defines the new maximum vector (in local space)
  87711. * @param worldMatrix defines the new world matrix
  87712. */
  87713. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87714. /**
  87715. * min vector of the bounding box/sphere
  87716. */
  87717. get minimum(): Vector3;
  87718. /**
  87719. * max vector of the bounding box/sphere
  87720. */
  87721. get maximum(): Vector3;
  87722. /**
  87723. * If the info is locked and won't be updated to avoid perf overhead
  87724. */
  87725. get isLocked(): boolean;
  87726. set isLocked(value: boolean);
  87727. /**
  87728. * Updates the bounding sphere and box
  87729. * @param world world matrix to be used to update
  87730. */
  87731. update(world: DeepImmutable<Matrix>): void;
  87732. /**
  87733. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87734. * @param center New center of the bounding info
  87735. * @param extend New extend of the bounding info
  87736. * @returns the current bounding info
  87737. */
  87738. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87739. /**
  87740. * Scale the current bounding info by applying a scale factor
  87741. * @param factor defines the scale factor to apply
  87742. * @returns the current bounding info
  87743. */
  87744. scale(factor: number): BoundingInfo;
  87745. /**
  87746. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87747. * @param frustumPlanes defines the frustum to test
  87748. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87749. * @returns true if the bounding info is in the frustum planes
  87750. */
  87751. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87752. /**
  87753. * Gets the world distance between the min and max points of the bounding box
  87754. */
  87755. get diagonalLength(): number;
  87756. /**
  87757. * Checks if a cullable object (mesh...) is in the camera frustum
  87758. * Unlike isInFrustum this cheks the full bounding box
  87759. * @param frustumPlanes Camera near/planes
  87760. * @returns true if the object is in frustum otherwise false
  87761. */
  87762. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87763. /** @hidden */
  87764. _checkCollision(collider: Collider): boolean;
  87765. /**
  87766. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87767. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87768. * @param point the point to check intersection with
  87769. * @returns if the point intersects
  87770. */
  87771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87772. /**
  87773. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87774. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87775. * @param boundingInfo the bounding info to check intersection with
  87776. * @param precise if the intersection should be done using OBB
  87777. * @returns if the bounding info intersects
  87778. */
  87779. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87780. }
  87781. }
  87782. declare module BABYLON {
  87783. /**
  87784. * Extracts minimum and maximum values from a list of indexed positions
  87785. * @param positions defines the positions to use
  87786. * @param indices defines the indices to the positions
  87787. * @param indexStart defines the start index
  87788. * @param indexCount defines the end index
  87789. * @param bias defines bias value to add to the result
  87790. * @return minimum and maximum values
  87791. */
  87792. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87793. minimum: Vector3;
  87794. maximum: Vector3;
  87795. };
  87796. /**
  87797. * Extracts minimum and maximum values from a list of positions
  87798. * @param positions defines the positions to use
  87799. * @param start defines the start index in the positions array
  87800. * @param count defines the number of positions to handle
  87801. * @param bias defines bias value to add to the result
  87802. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87803. * @return minimum and maximum values
  87804. */
  87805. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87806. minimum: Vector3;
  87807. maximum: Vector3;
  87808. };
  87809. }
  87810. declare module BABYLON {
  87811. /** @hidden */
  87812. export class WebGLDataBuffer extends DataBuffer {
  87813. private _buffer;
  87814. constructor(resource: WebGLBuffer);
  87815. get underlyingResource(): any;
  87816. }
  87817. }
  87818. declare module BABYLON {
  87819. /** @hidden */
  87820. export class WebGLPipelineContext implements IPipelineContext {
  87821. engine: ThinEngine;
  87822. program: Nullable<WebGLProgram>;
  87823. context?: WebGLRenderingContext;
  87824. vertexShader?: WebGLShader;
  87825. fragmentShader?: WebGLShader;
  87826. isParallelCompiled: boolean;
  87827. onCompiled?: () => void;
  87828. transformFeedback?: WebGLTransformFeedback | null;
  87829. vertexCompilationError: Nullable<string>;
  87830. fragmentCompilationError: Nullable<string>;
  87831. programLinkError: Nullable<string>;
  87832. programValidationError: Nullable<string>;
  87833. get isAsync(): boolean;
  87834. get isReady(): boolean;
  87835. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87836. _getVertexShaderCode(): string | null;
  87837. _getFragmentShaderCode(): string | null;
  87838. }
  87839. }
  87840. declare module BABYLON {
  87841. interface ThinEngine {
  87842. /**
  87843. * Create an uniform buffer
  87844. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87845. * @param elements defines the content of the uniform buffer
  87846. * @returns the webGL uniform buffer
  87847. */
  87848. createUniformBuffer(elements: FloatArray): DataBuffer;
  87849. /**
  87850. * Create a dynamic uniform buffer
  87851. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87852. * @param elements defines the content of the uniform buffer
  87853. * @returns the webGL uniform buffer
  87854. */
  87855. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87856. /**
  87857. * Update an existing uniform buffer
  87858. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87859. * @param uniformBuffer defines the target uniform buffer
  87860. * @param elements defines the content to update
  87861. * @param offset defines the offset in the uniform buffer where update should start
  87862. * @param count defines the size of the data to update
  87863. */
  87864. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87865. /**
  87866. * Bind an uniform buffer to the current webGL context
  87867. * @param buffer defines the buffer to bind
  87868. */
  87869. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87870. /**
  87871. * Bind a buffer to the current webGL context at a given location
  87872. * @param buffer defines the buffer to bind
  87873. * @param location defines the index where to bind the buffer
  87874. */
  87875. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87876. /**
  87877. * Bind a specific block at a given index in a specific shader program
  87878. * @param pipelineContext defines the pipeline context to use
  87879. * @param blockName defines the block name
  87880. * @param index defines the index where to bind the block
  87881. */
  87882. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87883. }
  87884. }
  87885. declare module BABYLON {
  87886. /**
  87887. * Uniform buffer objects.
  87888. *
  87889. * Handles blocks of uniform on the GPU.
  87890. *
  87891. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87892. *
  87893. * For more information, please refer to :
  87894. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87895. */
  87896. export class UniformBuffer {
  87897. private _engine;
  87898. private _buffer;
  87899. private _data;
  87900. private _bufferData;
  87901. private _dynamic?;
  87902. private _uniformLocations;
  87903. private _uniformSizes;
  87904. private _uniformLocationPointer;
  87905. private _needSync;
  87906. private _noUBO;
  87907. private _currentEffect;
  87908. /** @hidden */
  87909. _alreadyBound: boolean;
  87910. private static _MAX_UNIFORM_SIZE;
  87911. private static _tempBuffer;
  87912. /**
  87913. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87914. * This is dynamic to allow compat with webgl 1 and 2.
  87915. * You will need to pass the name of the uniform as well as the value.
  87916. */
  87917. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87918. /**
  87919. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87920. * This is dynamic to allow compat with webgl 1 and 2.
  87921. * You will need to pass the name of the uniform as well as the value.
  87922. */
  87923. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87924. /**
  87925. * Lambda to Update a single float in a uniform buffer.
  87926. * This is dynamic to allow compat with webgl 1 and 2.
  87927. * You will need to pass the name of the uniform as well as the value.
  87928. */
  87929. updateFloat: (name: string, x: number) => void;
  87930. /**
  87931. * Lambda to Update a vec2 of float in a uniform buffer.
  87932. * This is dynamic to allow compat with webgl 1 and 2.
  87933. * You will need to pass the name of the uniform as well as the value.
  87934. */
  87935. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87936. /**
  87937. * Lambda to Update a vec3 of float in a uniform buffer.
  87938. * This is dynamic to allow compat with webgl 1 and 2.
  87939. * You will need to pass the name of the uniform as well as the value.
  87940. */
  87941. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87942. /**
  87943. * Lambda to Update a vec4 of float in a uniform buffer.
  87944. * This is dynamic to allow compat with webgl 1 and 2.
  87945. * You will need to pass the name of the uniform as well as the value.
  87946. */
  87947. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87948. /**
  87949. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87950. * This is dynamic to allow compat with webgl 1 and 2.
  87951. * You will need to pass the name of the uniform as well as the value.
  87952. */
  87953. updateMatrix: (name: string, mat: Matrix) => void;
  87954. /**
  87955. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87956. * This is dynamic to allow compat with webgl 1 and 2.
  87957. * You will need to pass the name of the uniform as well as the value.
  87958. */
  87959. updateVector3: (name: string, vector: Vector3) => void;
  87960. /**
  87961. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87962. * This is dynamic to allow compat with webgl 1 and 2.
  87963. * You will need to pass the name of the uniform as well as the value.
  87964. */
  87965. updateVector4: (name: string, vector: Vector4) => void;
  87966. /**
  87967. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87968. * This is dynamic to allow compat with webgl 1 and 2.
  87969. * You will need to pass the name of the uniform as well as the value.
  87970. */
  87971. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87972. /**
  87973. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87974. * This is dynamic to allow compat with webgl 1 and 2.
  87975. * You will need to pass the name of the uniform as well as the value.
  87976. */
  87977. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87978. /**
  87979. * Instantiates a new Uniform buffer objects.
  87980. *
  87981. * Handles blocks of uniform on the GPU.
  87982. *
  87983. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87984. *
  87985. * For more information, please refer to :
  87986. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87987. * @param engine Define the engine the buffer is associated with
  87988. * @param data Define the data contained in the buffer
  87989. * @param dynamic Define if the buffer is updatable
  87990. */
  87991. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87992. /**
  87993. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87994. * or just falling back on setUniformXXX calls.
  87995. */
  87996. get useUbo(): boolean;
  87997. /**
  87998. * Indicates if the WebGL underlying uniform buffer is in sync
  87999. * with the javascript cache data.
  88000. */
  88001. get isSync(): boolean;
  88002. /**
  88003. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88004. * Also, a dynamic UniformBuffer will disable cache verification and always
  88005. * update the underlying WebGL uniform buffer to the GPU.
  88006. * @returns if Dynamic, otherwise false
  88007. */
  88008. isDynamic(): boolean;
  88009. /**
  88010. * The data cache on JS side.
  88011. * @returns the underlying data as a float array
  88012. */
  88013. getData(): Float32Array;
  88014. /**
  88015. * The underlying WebGL Uniform buffer.
  88016. * @returns the webgl buffer
  88017. */
  88018. getBuffer(): Nullable<DataBuffer>;
  88019. /**
  88020. * std140 layout specifies how to align data within an UBO structure.
  88021. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88022. * for specs.
  88023. */
  88024. private _fillAlignment;
  88025. /**
  88026. * Adds an uniform in the buffer.
  88027. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88028. * for the layout to be correct !
  88029. * @param name Name of the uniform, as used in the uniform block in the shader.
  88030. * @param size Data size, or data directly.
  88031. */
  88032. addUniform(name: string, size: number | number[]): void;
  88033. /**
  88034. * Adds a Matrix 4x4 to the uniform buffer.
  88035. * @param name Name of the uniform, as used in the uniform block in the shader.
  88036. * @param mat A 4x4 matrix.
  88037. */
  88038. addMatrix(name: string, mat: Matrix): void;
  88039. /**
  88040. * Adds a vec2 to the uniform buffer.
  88041. * @param name Name of the uniform, as used in the uniform block in the shader.
  88042. * @param x Define the x component value of the vec2
  88043. * @param y Define the y component value of the vec2
  88044. */
  88045. addFloat2(name: string, x: number, y: number): void;
  88046. /**
  88047. * Adds a vec3 to the uniform buffer.
  88048. * @param name Name of the uniform, as used in the uniform block in the shader.
  88049. * @param x Define the x component value of the vec3
  88050. * @param y Define the y component value of the vec3
  88051. * @param z Define the z component value of the vec3
  88052. */
  88053. addFloat3(name: string, x: number, y: number, z: number): void;
  88054. /**
  88055. * Adds a vec3 to the uniform buffer.
  88056. * @param name Name of the uniform, as used in the uniform block in the shader.
  88057. * @param color Define the vec3 from a Color
  88058. */
  88059. addColor3(name: string, color: Color3): void;
  88060. /**
  88061. * Adds a vec4 to the uniform buffer.
  88062. * @param name Name of the uniform, as used in the uniform block in the shader.
  88063. * @param color Define the rgb components from a Color
  88064. * @param alpha Define the a component of the vec4
  88065. */
  88066. addColor4(name: string, color: Color3, alpha: number): void;
  88067. /**
  88068. * Adds a vec3 to the uniform buffer.
  88069. * @param name Name of the uniform, as used in the uniform block in the shader.
  88070. * @param vector Define the vec3 components from a Vector
  88071. */
  88072. addVector3(name: string, vector: Vector3): void;
  88073. /**
  88074. * Adds a Matrix 3x3 to the uniform buffer.
  88075. * @param name Name of the uniform, as used in the uniform block in the shader.
  88076. */
  88077. addMatrix3x3(name: string): void;
  88078. /**
  88079. * Adds a Matrix 2x2 to the uniform buffer.
  88080. * @param name Name of the uniform, as used in the uniform block in the shader.
  88081. */
  88082. addMatrix2x2(name: string): void;
  88083. /**
  88084. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88085. */
  88086. create(): void;
  88087. /** @hidden */
  88088. _rebuild(): void;
  88089. /**
  88090. * Updates the WebGL Uniform Buffer on the GPU.
  88091. * If the `dynamic` flag is set to true, no cache comparison is done.
  88092. * Otherwise, the buffer will be updated only if the cache differs.
  88093. */
  88094. update(): void;
  88095. /**
  88096. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88097. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88098. * @param data Define the flattened data
  88099. * @param size Define the size of the data.
  88100. */
  88101. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88102. private _valueCache;
  88103. private _cacheMatrix;
  88104. private _updateMatrix3x3ForUniform;
  88105. private _updateMatrix3x3ForEffect;
  88106. private _updateMatrix2x2ForEffect;
  88107. private _updateMatrix2x2ForUniform;
  88108. private _updateFloatForEffect;
  88109. private _updateFloatForUniform;
  88110. private _updateFloat2ForEffect;
  88111. private _updateFloat2ForUniform;
  88112. private _updateFloat3ForEffect;
  88113. private _updateFloat3ForUniform;
  88114. private _updateFloat4ForEffect;
  88115. private _updateFloat4ForUniform;
  88116. private _updateMatrixForEffect;
  88117. private _updateMatrixForUniform;
  88118. private _updateVector3ForEffect;
  88119. private _updateVector3ForUniform;
  88120. private _updateVector4ForEffect;
  88121. private _updateVector4ForUniform;
  88122. private _updateColor3ForEffect;
  88123. private _updateColor3ForUniform;
  88124. private _updateColor4ForEffect;
  88125. private _updateColor4ForUniform;
  88126. /**
  88127. * Sets a sampler uniform on the effect.
  88128. * @param name Define the name of the sampler.
  88129. * @param texture Define the texture to set in the sampler
  88130. */
  88131. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88132. /**
  88133. * Directly updates the value of the uniform in the cache AND on the GPU.
  88134. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88135. * @param data Define the flattened data
  88136. */
  88137. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88138. /**
  88139. * Binds this uniform buffer to an effect.
  88140. * @param effect Define the effect to bind the buffer to
  88141. * @param name Name of the uniform block in the shader.
  88142. */
  88143. bindToEffect(effect: Effect, name: string): void;
  88144. /**
  88145. * Disposes the uniform buffer.
  88146. */
  88147. dispose(): void;
  88148. }
  88149. }
  88150. declare module BABYLON {
  88151. /**
  88152. * Enum that determines the text-wrapping mode to use.
  88153. */
  88154. export enum InspectableType {
  88155. /**
  88156. * Checkbox for booleans
  88157. */
  88158. Checkbox = 0,
  88159. /**
  88160. * Sliders for numbers
  88161. */
  88162. Slider = 1,
  88163. /**
  88164. * Vector3
  88165. */
  88166. Vector3 = 2,
  88167. /**
  88168. * Quaternions
  88169. */
  88170. Quaternion = 3,
  88171. /**
  88172. * Color3
  88173. */
  88174. Color3 = 4,
  88175. /**
  88176. * String
  88177. */
  88178. String = 5
  88179. }
  88180. /**
  88181. * Interface used to define custom inspectable properties.
  88182. * This interface is used by the inspector to display custom property grids
  88183. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88184. */
  88185. export interface IInspectable {
  88186. /**
  88187. * Gets the label to display
  88188. */
  88189. label: string;
  88190. /**
  88191. * Gets the name of the property to edit
  88192. */
  88193. propertyName: string;
  88194. /**
  88195. * Gets the type of the editor to use
  88196. */
  88197. type: InspectableType;
  88198. /**
  88199. * Gets the minimum value of the property when using in "slider" mode
  88200. */
  88201. min?: number;
  88202. /**
  88203. * Gets the maximum value of the property when using in "slider" mode
  88204. */
  88205. max?: number;
  88206. /**
  88207. * Gets the setp to use when using in "slider" mode
  88208. */
  88209. step?: number;
  88210. }
  88211. }
  88212. declare module BABYLON {
  88213. /**
  88214. * Class used to provide helper for timing
  88215. */
  88216. export class TimingTools {
  88217. /**
  88218. * Polyfill for setImmediate
  88219. * @param action defines the action to execute after the current execution block
  88220. */
  88221. static SetImmediate(action: () => void): void;
  88222. }
  88223. }
  88224. declare module BABYLON {
  88225. /**
  88226. * Class used to enable instatition of objects by class name
  88227. */
  88228. export class InstantiationTools {
  88229. /**
  88230. * Use this object to register external classes like custom textures or material
  88231. * to allow the laoders to instantiate them
  88232. */
  88233. static RegisteredExternalClasses: {
  88234. [key: string]: Object;
  88235. };
  88236. /**
  88237. * Tries to instantiate a new object from a given class name
  88238. * @param className defines the class name to instantiate
  88239. * @returns the new object or null if the system was not able to do the instantiation
  88240. */
  88241. static Instantiate(className: string): any;
  88242. }
  88243. }
  88244. declare module BABYLON {
  88245. /**
  88246. * Define options used to create a depth texture
  88247. */
  88248. export class DepthTextureCreationOptions {
  88249. /** Specifies whether or not a stencil should be allocated in the texture */
  88250. generateStencil?: boolean;
  88251. /** Specifies whether or not bilinear filtering is enable on the texture */
  88252. bilinearFiltering?: boolean;
  88253. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88254. comparisonFunction?: number;
  88255. /** Specifies if the created texture is a cube texture */
  88256. isCube?: boolean;
  88257. }
  88258. }
  88259. declare module BABYLON {
  88260. interface ThinEngine {
  88261. /**
  88262. * Creates a depth stencil cube texture.
  88263. * This is only available in WebGL 2.
  88264. * @param size The size of face edge in the cube texture.
  88265. * @param options The options defining the cube texture.
  88266. * @returns The cube texture
  88267. */
  88268. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88269. /**
  88270. * Creates a cube texture
  88271. * @param rootUrl defines the url where the files to load is located
  88272. * @param scene defines the current scene
  88273. * @param files defines the list of files to load (1 per face)
  88274. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88275. * @param onLoad defines an optional callback raised when the texture is loaded
  88276. * @param onError defines an optional callback raised if there is an issue to load the texture
  88277. * @param format defines the format of the data
  88278. * @param forcedExtension defines the extension to use to pick the right loader
  88279. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88280. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88281. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88282. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88283. * @returns the cube texture as an InternalTexture
  88284. */
  88285. 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;
  88286. /**
  88287. * Creates a cube texture
  88288. * @param rootUrl defines the url where the files to load is located
  88289. * @param scene defines the current scene
  88290. * @param files defines the list of files to load (1 per face)
  88291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88292. * @param onLoad defines an optional callback raised when the texture is loaded
  88293. * @param onError defines an optional callback raised if there is an issue to load the texture
  88294. * @param format defines the format of the data
  88295. * @param forcedExtension defines the extension to use to pick the right loader
  88296. * @returns the cube texture as an InternalTexture
  88297. */
  88298. 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;
  88299. /**
  88300. * Creates a cube texture
  88301. * @param rootUrl defines the url where the files to load is located
  88302. * @param scene defines the current scene
  88303. * @param files defines the list of files to load (1 per face)
  88304. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88305. * @param onLoad defines an optional callback raised when the texture is loaded
  88306. * @param onError defines an optional callback raised if there is an issue to load the texture
  88307. * @param format defines the format of the data
  88308. * @param forcedExtension defines the extension to use to pick the right loader
  88309. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88310. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88311. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88312. * @returns the cube texture as an InternalTexture
  88313. */
  88314. 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;
  88315. /** @hidden */
  88316. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88317. /** @hidden */
  88318. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88319. /** @hidden */
  88320. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88321. /** @hidden */
  88322. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88323. /**
  88324. * @hidden
  88325. */
  88326. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88327. }
  88328. }
  88329. declare module BABYLON {
  88330. /**
  88331. * Class for creating a cube texture
  88332. */
  88333. export class CubeTexture extends BaseTexture {
  88334. private _delayedOnLoad;
  88335. /**
  88336. * Observable triggered once the texture has been loaded.
  88337. */
  88338. onLoadObservable: Observable<CubeTexture>;
  88339. /**
  88340. * The url of the texture
  88341. */
  88342. url: string;
  88343. /**
  88344. * Gets or sets the center of the bounding box associated with the cube texture.
  88345. * It must define where the camera used to render the texture was set
  88346. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88347. */
  88348. boundingBoxPosition: Vector3;
  88349. private _boundingBoxSize;
  88350. /**
  88351. * Gets or sets the size of the bounding box associated with the cube texture
  88352. * When defined, the cubemap will switch to local mode
  88353. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88354. * @example https://www.babylonjs-playground.com/#RNASML
  88355. */
  88356. set boundingBoxSize(value: Vector3);
  88357. /**
  88358. * Returns the bounding box size
  88359. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88360. */
  88361. get boundingBoxSize(): Vector3;
  88362. protected _rotationY: number;
  88363. /**
  88364. * Sets texture matrix rotation angle around Y axis in radians.
  88365. */
  88366. set rotationY(value: number);
  88367. /**
  88368. * Gets texture matrix rotation angle around Y axis radians.
  88369. */
  88370. get rotationY(): number;
  88371. /**
  88372. * Are mip maps generated for this texture or not.
  88373. */
  88374. get noMipmap(): boolean;
  88375. private _noMipmap;
  88376. private _files;
  88377. protected _forcedExtension: Nullable<string>;
  88378. private _extensions;
  88379. private _textureMatrix;
  88380. private _format;
  88381. private _createPolynomials;
  88382. /**
  88383. * Creates a cube texture from an array of image urls
  88384. * @param files defines an array of image urls
  88385. * @param scene defines the hosting scene
  88386. * @param noMipmap specifies if mip maps are not used
  88387. * @returns a cube texture
  88388. */
  88389. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88390. /**
  88391. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88392. * @param url defines the url of the prefiltered texture
  88393. * @param scene defines the scene the texture is attached to
  88394. * @param forcedExtension defines the extension of the file if different from the url
  88395. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88396. * @return the prefiltered texture
  88397. */
  88398. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88399. /**
  88400. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88401. * as prefiltered data.
  88402. * @param rootUrl defines the url of the texture or the root name of the six images
  88403. * @param null defines the scene or engine the texture is attached to
  88404. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88405. * @param noMipmap defines if mipmaps should be created or not
  88406. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88407. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88408. * @param onError defines a callback triggered in case of error during load
  88409. * @param format defines the internal format to use for the texture once loaded
  88410. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88411. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88412. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88415. * @return the cube texture
  88416. */
  88417. 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);
  88418. /**
  88419. * Get the current class name of the texture useful for serialization or dynamic coding.
  88420. * @returns "CubeTexture"
  88421. */
  88422. getClassName(): string;
  88423. /**
  88424. * Update the url (and optional buffer) of this texture if url was null during construction.
  88425. * @param url the url of the texture
  88426. * @param forcedExtension defines the extension to use
  88427. * @param onLoad callback called when the texture is loaded (defaults to null)
  88428. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88429. */
  88430. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88431. /**
  88432. * Delays loading of the cube texture
  88433. * @param forcedExtension defines the extension to use
  88434. */
  88435. delayLoad(forcedExtension?: string): void;
  88436. /**
  88437. * Returns the reflection texture matrix
  88438. * @returns the reflection texture matrix
  88439. */
  88440. getReflectionTextureMatrix(): Matrix;
  88441. /**
  88442. * Sets the reflection texture matrix
  88443. * @param value Reflection texture matrix
  88444. */
  88445. setReflectionTextureMatrix(value: Matrix): void;
  88446. /**
  88447. * Parses text to create a cube texture
  88448. * @param parsedTexture define the serialized text to read from
  88449. * @param scene defines the hosting scene
  88450. * @param rootUrl defines the root url of the cube texture
  88451. * @returns a cube texture
  88452. */
  88453. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88454. /**
  88455. * Makes a clone, or deep copy, of the cube texture
  88456. * @returns a new cube texture
  88457. */
  88458. clone(): CubeTexture;
  88459. }
  88460. }
  88461. declare module BABYLON {
  88462. /**
  88463. * Manages the defines for the Material
  88464. */
  88465. export class MaterialDefines {
  88466. /** @hidden */
  88467. protected _keys: string[];
  88468. private _isDirty;
  88469. /** @hidden */
  88470. _renderId: number;
  88471. /** @hidden */
  88472. _areLightsDirty: boolean;
  88473. /** @hidden */
  88474. _areLightsDisposed: boolean;
  88475. /** @hidden */
  88476. _areAttributesDirty: boolean;
  88477. /** @hidden */
  88478. _areTexturesDirty: boolean;
  88479. /** @hidden */
  88480. _areFresnelDirty: boolean;
  88481. /** @hidden */
  88482. _areMiscDirty: boolean;
  88483. /** @hidden */
  88484. _arePrePassDirty: boolean;
  88485. /** @hidden */
  88486. _areImageProcessingDirty: boolean;
  88487. /** @hidden */
  88488. _normals: boolean;
  88489. /** @hidden */
  88490. _uvs: boolean;
  88491. /** @hidden */
  88492. _needNormals: boolean;
  88493. /** @hidden */
  88494. _needUVs: boolean;
  88495. [id: string]: any;
  88496. /**
  88497. * Specifies if the material needs to be re-calculated
  88498. */
  88499. get isDirty(): boolean;
  88500. /**
  88501. * Marks the material to indicate that it has been re-calculated
  88502. */
  88503. markAsProcessed(): void;
  88504. /**
  88505. * Marks the material to indicate that it needs to be re-calculated
  88506. */
  88507. markAsUnprocessed(): void;
  88508. /**
  88509. * Marks the material to indicate all of its defines need to be re-calculated
  88510. */
  88511. markAllAsDirty(): void;
  88512. /**
  88513. * Marks the material to indicate that image processing needs to be re-calculated
  88514. */
  88515. markAsImageProcessingDirty(): void;
  88516. /**
  88517. * Marks the material to indicate the lights need to be re-calculated
  88518. * @param disposed Defines whether the light is dirty due to dispose or not
  88519. */
  88520. markAsLightDirty(disposed?: boolean): void;
  88521. /**
  88522. * Marks the attribute state as changed
  88523. */
  88524. markAsAttributesDirty(): void;
  88525. /**
  88526. * Marks the texture state as changed
  88527. */
  88528. markAsTexturesDirty(): void;
  88529. /**
  88530. * Marks the fresnel state as changed
  88531. */
  88532. markAsFresnelDirty(): void;
  88533. /**
  88534. * Marks the misc state as changed
  88535. */
  88536. markAsMiscDirty(): void;
  88537. /**
  88538. * Marks the prepass state as changed
  88539. */
  88540. markAsPrePassDirty(): void;
  88541. /**
  88542. * Rebuilds the material defines
  88543. */
  88544. rebuild(): void;
  88545. /**
  88546. * Specifies if two material defines are equal
  88547. * @param other - A material define instance to compare to
  88548. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88549. */
  88550. isEqual(other: MaterialDefines): boolean;
  88551. /**
  88552. * Clones this instance's defines to another instance
  88553. * @param other - material defines to clone values to
  88554. */
  88555. cloneTo(other: MaterialDefines): void;
  88556. /**
  88557. * Resets the material define values
  88558. */
  88559. reset(): void;
  88560. /**
  88561. * Converts the material define values to a string
  88562. * @returns - String of material define information
  88563. */
  88564. toString(): string;
  88565. }
  88566. }
  88567. declare module BABYLON {
  88568. /**
  88569. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88570. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88571. * 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;
  88572. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88573. */
  88574. export class ColorCurves {
  88575. private _dirty;
  88576. private _tempColor;
  88577. private _globalCurve;
  88578. private _highlightsCurve;
  88579. private _midtonesCurve;
  88580. private _shadowsCurve;
  88581. private _positiveCurve;
  88582. private _negativeCurve;
  88583. private _globalHue;
  88584. private _globalDensity;
  88585. private _globalSaturation;
  88586. private _globalExposure;
  88587. /**
  88588. * Gets the global Hue value.
  88589. * 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).
  88590. */
  88591. get globalHue(): number;
  88592. /**
  88593. * Sets the global Hue value.
  88594. * 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).
  88595. */
  88596. set globalHue(value: number);
  88597. /**
  88598. * Gets the global Density value.
  88599. * 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.
  88600. * Values less than zero provide a filter of opposite hue.
  88601. */
  88602. get globalDensity(): number;
  88603. /**
  88604. * Sets the global Density value.
  88605. * 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.
  88606. * Values less than zero provide a filter of opposite hue.
  88607. */
  88608. set globalDensity(value: number);
  88609. /**
  88610. * Gets the global Saturation value.
  88611. * 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.
  88612. */
  88613. get globalSaturation(): number;
  88614. /**
  88615. * Sets the global Saturation value.
  88616. * 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.
  88617. */
  88618. set globalSaturation(value: number);
  88619. /**
  88620. * Gets the global Exposure value.
  88621. * 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.
  88622. */
  88623. get globalExposure(): number;
  88624. /**
  88625. * Sets the global Exposure value.
  88626. * 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.
  88627. */
  88628. set globalExposure(value: number);
  88629. private _highlightsHue;
  88630. private _highlightsDensity;
  88631. private _highlightsSaturation;
  88632. private _highlightsExposure;
  88633. /**
  88634. * Gets the highlights Hue value.
  88635. * 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).
  88636. */
  88637. get highlightsHue(): number;
  88638. /**
  88639. * Sets the highlights Hue value.
  88640. * 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).
  88641. */
  88642. set highlightsHue(value: number);
  88643. /**
  88644. * Gets the highlights Density value.
  88645. * 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.
  88646. * Values less than zero provide a filter of opposite hue.
  88647. */
  88648. get highlightsDensity(): number;
  88649. /**
  88650. * Sets the highlights Density value.
  88651. * 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.
  88652. * Values less than zero provide a filter of opposite hue.
  88653. */
  88654. set highlightsDensity(value: number);
  88655. /**
  88656. * Gets the highlights Saturation value.
  88657. * 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.
  88658. */
  88659. get highlightsSaturation(): number;
  88660. /**
  88661. * Sets the highlights Saturation value.
  88662. * 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.
  88663. */
  88664. set highlightsSaturation(value: number);
  88665. /**
  88666. * Gets the highlights Exposure value.
  88667. * 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.
  88668. */
  88669. get highlightsExposure(): number;
  88670. /**
  88671. * Sets the highlights Exposure value.
  88672. * 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.
  88673. */
  88674. set highlightsExposure(value: number);
  88675. private _midtonesHue;
  88676. private _midtonesDensity;
  88677. private _midtonesSaturation;
  88678. private _midtonesExposure;
  88679. /**
  88680. * Gets the midtones Hue value.
  88681. * 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).
  88682. */
  88683. get midtonesHue(): number;
  88684. /**
  88685. * Sets the midtones Hue value.
  88686. * 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).
  88687. */
  88688. set midtonesHue(value: number);
  88689. /**
  88690. * Gets the midtones Density value.
  88691. * 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.
  88692. * Values less than zero provide a filter of opposite hue.
  88693. */
  88694. get midtonesDensity(): number;
  88695. /**
  88696. * Sets the midtones Density value.
  88697. * 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.
  88698. * Values less than zero provide a filter of opposite hue.
  88699. */
  88700. set midtonesDensity(value: number);
  88701. /**
  88702. * Gets the midtones Saturation value.
  88703. * 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.
  88704. */
  88705. get midtonesSaturation(): number;
  88706. /**
  88707. * Sets the midtones Saturation value.
  88708. * 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.
  88709. */
  88710. set midtonesSaturation(value: number);
  88711. /**
  88712. * Gets the midtones Exposure value.
  88713. * 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.
  88714. */
  88715. get midtonesExposure(): number;
  88716. /**
  88717. * Sets the midtones Exposure value.
  88718. * 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.
  88719. */
  88720. set midtonesExposure(value: number);
  88721. private _shadowsHue;
  88722. private _shadowsDensity;
  88723. private _shadowsSaturation;
  88724. private _shadowsExposure;
  88725. /**
  88726. * Gets the shadows Hue value.
  88727. * 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).
  88728. */
  88729. get shadowsHue(): number;
  88730. /**
  88731. * Sets the shadows Hue value.
  88732. * 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).
  88733. */
  88734. set shadowsHue(value: number);
  88735. /**
  88736. * Gets the shadows Density value.
  88737. * 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.
  88738. * Values less than zero provide a filter of opposite hue.
  88739. */
  88740. get shadowsDensity(): number;
  88741. /**
  88742. * Sets the shadows Density value.
  88743. * 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.
  88744. * Values less than zero provide a filter of opposite hue.
  88745. */
  88746. set shadowsDensity(value: number);
  88747. /**
  88748. * Gets the shadows Saturation value.
  88749. * 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.
  88750. */
  88751. get shadowsSaturation(): number;
  88752. /**
  88753. * Sets the shadows Saturation value.
  88754. * 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.
  88755. */
  88756. set shadowsSaturation(value: number);
  88757. /**
  88758. * Gets the shadows Exposure value.
  88759. * 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.
  88760. */
  88761. get shadowsExposure(): number;
  88762. /**
  88763. * Sets the shadows Exposure value.
  88764. * 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.
  88765. */
  88766. set shadowsExposure(value: number);
  88767. /**
  88768. * Returns the class name
  88769. * @returns The class name
  88770. */
  88771. getClassName(): string;
  88772. /**
  88773. * Binds the color curves to the shader.
  88774. * @param colorCurves The color curve to bind
  88775. * @param effect The effect to bind to
  88776. * @param positiveUniform The positive uniform shader parameter
  88777. * @param neutralUniform The neutral uniform shader parameter
  88778. * @param negativeUniform The negative uniform shader parameter
  88779. */
  88780. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88781. /**
  88782. * Prepare the list of uniforms associated with the ColorCurves effects.
  88783. * @param uniformsList The list of uniforms used in the effect
  88784. */
  88785. static PrepareUniforms(uniformsList: string[]): void;
  88786. /**
  88787. * Returns color grading data based on a hue, density, saturation and exposure value.
  88788. * @param filterHue The hue of the color filter.
  88789. * @param filterDensity The density of the color filter.
  88790. * @param saturation The saturation.
  88791. * @param exposure The exposure.
  88792. * @param result The result data container.
  88793. */
  88794. private getColorGradingDataToRef;
  88795. /**
  88796. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88797. * @param value The input slider value in range [-100,100].
  88798. * @returns Adjusted value.
  88799. */
  88800. private static applyColorGradingSliderNonlinear;
  88801. /**
  88802. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88803. * @param hue The hue (H) input.
  88804. * @param saturation The saturation (S) input.
  88805. * @param brightness The brightness (B) input.
  88806. * @result An RGBA color represented as Vector4.
  88807. */
  88808. private static fromHSBToRef;
  88809. /**
  88810. * Returns a value clamped between min and max
  88811. * @param value The value to clamp
  88812. * @param min The minimum of value
  88813. * @param max The maximum of value
  88814. * @returns The clamped value.
  88815. */
  88816. private static clamp;
  88817. /**
  88818. * Clones the current color curve instance.
  88819. * @return The cloned curves
  88820. */
  88821. clone(): ColorCurves;
  88822. /**
  88823. * Serializes the current color curve instance to a json representation.
  88824. * @return a JSON representation
  88825. */
  88826. serialize(): any;
  88827. /**
  88828. * Parses the color curve from a json representation.
  88829. * @param source the JSON source to parse
  88830. * @return The parsed curves
  88831. */
  88832. static Parse(source: any): ColorCurves;
  88833. }
  88834. }
  88835. declare module BABYLON {
  88836. /**
  88837. * Interface to follow in your material defines to integrate easily the
  88838. * Image proccessing functions.
  88839. * @hidden
  88840. */
  88841. export interface IImageProcessingConfigurationDefines {
  88842. IMAGEPROCESSING: boolean;
  88843. VIGNETTE: boolean;
  88844. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88845. VIGNETTEBLENDMODEOPAQUE: boolean;
  88846. TONEMAPPING: boolean;
  88847. TONEMAPPING_ACES: boolean;
  88848. CONTRAST: boolean;
  88849. EXPOSURE: boolean;
  88850. COLORCURVES: boolean;
  88851. COLORGRADING: boolean;
  88852. COLORGRADING3D: boolean;
  88853. SAMPLER3DGREENDEPTH: boolean;
  88854. SAMPLER3DBGRMAP: boolean;
  88855. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88856. }
  88857. /**
  88858. * @hidden
  88859. */
  88860. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88861. IMAGEPROCESSING: boolean;
  88862. VIGNETTE: boolean;
  88863. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88864. VIGNETTEBLENDMODEOPAQUE: boolean;
  88865. TONEMAPPING: boolean;
  88866. TONEMAPPING_ACES: boolean;
  88867. CONTRAST: boolean;
  88868. COLORCURVES: boolean;
  88869. COLORGRADING: boolean;
  88870. COLORGRADING3D: boolean;
  88871. SAMPLER3DGREENDEPTH: boolean;
  88872. SAMPLER3DBGRMAP: boolean;
  88873. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88874. EXPOSURE: boolean;
  88875. constructor();
  88876. }
  88877. /**
  88878. * This groups together the common properties used for image processing either in direct forward pass
  88879. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88880. * or not.
  88881. */
  88882. export class ImageProcessingConfiguration {
  88883. /**
  88884. * Default tone mapping applied in BabylonJS.
  88885. */
  88886. static readonly TONEMAPPING_STANDARD: number;
  88887. /**
  88888. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88889. * to other engines rendering to increase portability.
  88890. */
  88891. static readonly TONEMAPPING_ACES: number;
  88892. /**
  88893. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88894. */
  88895. colorCurves: Nullable<ColorCurves>;
  88896. private _colorCurvesEnabled;
  88897. /**
  88898. * Gets wether the color curves effect is enabled.
  88899. */
  88900. get colorCurvesEnabled(): boolean;
  88901. /**
  88902. * Sets wether the color curves effect is enabled.
  88903. */
  88904. set colorCurvesEnabled(value: boolean);
  88905. private _colorGradingTexture;
  88906. /**
  88907. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88908. */
  88909. get colorGradingTexture(): Nullable<BaseTexture>;
  88910. /**
  88911. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88912. */
  88913. set colorGradingTexture(value: Nullable<BaseTexture>);
  88914. private _colorGradingEnabled;
  88915. /**
  88916. * Gets wether the color grading effect is enabled.
  88917. */
  88918. get colorGradingEnabled(): boolean;
  88919. /**
  88920. * Sets wether the color grading effect is enabled.
  88921. */
  88922. set colorGradingEnabled(value: boolean);
  88923. private _colorGradingWithGreenDepth;
  88924. /**
  88925. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88926. */
  88927. get colorGradingWithGreenDepth(): boolean;
  88928. /**
  88929. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88930. */
  88931. set colorGradingWithGreenDepth(value: boolean);
  88932. private _colorGradingBGR;
  88933. /**
  88934. * Gets wether the color grading texture contains BGR values.
  88935. */
  88936. get colorGradingBGR(): boolean;
  88937. /**
  88938. * Sets wether the color grading texture contains BGR values.
  88939. */
  88940. set colorGradingBGR(value: boolean);
  88941. /** @hidden */
  88942. _exposure: number;
  88943. /**
  88944. * Gets the Exposure used in the effect.
  88945. */
  88946. get exposure(): number;
  88947. /**
  88948. * Sets the Exposure used in the effect.
  88949. */
  88950. set exposure(value: number);
  88951. private _toneMappingEnabled;
  88952. /**
  88953. * Gets wether the tone mapping effect is enabled.
  88954. */
  88955. get toneMappingEnabled(): boolean;
  88956. /**
  88957. * Sets wether the tone mapping effect is enabled.
  88958. */
  88959. set toneMappingEnabled(value: boolean);
  88960. private _toneMappingType;
  88961. /**
  88962. * Gets the type of tone mapping effect.
  88963. */
  88964. get toneMappingType(): number;
  88965. /**
  88966. * Sets the type of tone mapping effect used in BabylonJS.
  88967. */
  88968. set toneMappingType(value: number);
  88969. protected _contrast: number;
  88970. /**
  88971. * Gets the contrast used in the effect.
  88972. */
  88973. get contrast(): number;
  88974. /**
  88975. * Sets the contrast used in the effect.
  88976. */
  88977. set contrast(value: number);
  88978. /**
  88979. * Vignette stretch size.
  88980. */
  88981. vignetteStretch: number;
  88982. /**
  88983. * Vignette centre X Offset.
  88984. */
  88985. vignetteCentreX: number;
  88986. /**
  88987. * Vignette centre Y Offset.
  88988. */
  88989. vignetteCentreY: number;
  88990. /**
  88991. * Vignette weight or intensity of the vignette effect.
  88992. */
  88993. vignetteWeight: number;
  88994. /**
  88995. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88996. * if vignetteEnabled is set to true.
  88997. */
  88998. vignetteColor: Color4;
  88999. /**
  89000. * Camera field of view used by the Vignette effect.
  89001. */
  89002. vignetteCameraFov: number;
  89003. private _vignetteBlendMode;
  89004. /**
  89005. * Gets the vignette blend mode allowing different kind of effect.
  89006. */
  89007. get vignetteBlendMode(): number;
  89008. /**
  89009. * Sets the vignette blend mode allowing different kind of effect.
  89010. */
  89011. set vignetteBlendMode(value: number);
  89012. private _vignetteEnabled;
  89013. /**
  89014. * Gets wether the vignette effect is enabled.
  89015. */
  89016. get vignetteEnabled(): boolean;
  89017. /**
  89018. * Sets wether the vignette effect is enabled.
  89019. */
  89020. set vignetteEnabled(value: boolean);
  89021. private _applyByPostProcess;
  89022. /**
  89023. * Gets wether the image processing is applied through a post process or not.
  89024. */
  89025. get applyByPostProcess(): boolean;
  89026. /**
  89027. * Sets wether the image processing is applied through a post process or not.
  89028. */
  89029. set applyByPostProcess(value: boolean);
  89030. private _isEnabled;
  89031. /**
  89032. * Gets wether the image processing is enabled or not.
  89033. */
  89034. get isEnabled(): boolean;
  89035. /**
  89036. * Sets wether the image processing is enabled or not.
  89037. */
  89038. set isEnabled(value: boolean);
  89039. /**
  89040. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89041. */
  89042. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89043. /**
  89044. * Method called each time the image processing information changes requires to recompile the effect.
  89045. */
  89046. protected _updateParameters(): void;
  89047. /**
  89048. * Gets the current class name.
  89049. * @return "ImageProcessingConfiguration"
  89050. */
  89051. getClassName(): string;
  89052. /**
  89053. * Prepare the list of uniforms associated with the Image Processing effects.
  89054. * @param uniforms The list of uniforms used in the effect
  89055. * @param defines the list of defines currently in use
  89056. */
  89057. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89058. /**
  89059. * Prepare the list of samplers associated with the Image Processing effects.
  89060. * @param samplersList The list of uniforms used in the effect
  89061. * @param defines the list of defines currently in use
  89062. */
  89063. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89064. /**
  89065. * Prepare the list of defines associated to the shader.
  89066. * @param defines the list of defines to complete
  89067. * @param forPostProcess Define if we are currently in post process mode or not
  89068. */
  89069. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89070. /**
  89071. * Returns true if all the image processing information are ready.
  89072. * @returns True if ready, otherwise, false
  89073. */
  89074. isReady(): boolean;
  89075. /**
  89076. * Binds the image processing to the shader.
  89077. * @param effect The effect to bind to
  89078. * @param overrideAspectRatio Override the aspect ratio of the effect
  89079. */
  89080. bind(effect: Effect, overrideAspectRatio?: number): void;
  89081. /**
  89082. * Clones the current image processing instance.
  89083. * @return The cloned image processing
  89084. */
  89085. clone(): ImageProcessingConfiguration;
  89086. /**
  89087. * Serializes the current image processing instance to a json representation.
  89088. * @return a JSON representation
  89089. */
  89090. serialize(): any;
  89091. /**
  89092. * Parses the image processing from a json representation.
  89093. * @param source the JSON source to parse
  89094. * @return The parsed image processing
  89095. */
  89096. static Parse(source: any): ImageProcessingConfiguration;
  89097. private static _VIGNETTEMODE_MULTIPLY;
  89098. private static _VIGNETTEMODE_OPAQUE;
  89099. /**
  89100. * Used to apply the vignette as a mix with the pixel color.
  89101. */
  89102. static get VIGNETTEMODE_MULTIPLY(): number;
  89103. /**
  89104. * Used to apply the vignette as a replacement of the pixel color.
  89105. */
  89106. static get VIGNETTEMODE_OPAQUE(): number;
  89107. }
  89108. }
  89109. declare module BABYLON {
  89110. /** @hidden */
  89111. export var postprocessVertexShader: {
  89112. name: string;
  89113. shader: string;
  89114. };
  89115. }
  89116. declare module BABYLON {
  89117. /**
  89118. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89119. */
  89120. export type RenderTargetTextureSize = number | {
  89121. width: number;
  89122. height: number;
  89123. layers?: number;
  89124. };
  89125. interface ThinEngine {
  89126. /**
  89127. * Creates a new render target texture
  89128. * @param size defines the size of the texture
  89129. * @param options defines the options used to create the texture
  89130. * @returns a new render target texture stored in an InternalTexture
  89131. */
  89132. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89133. /**
  89134. * Creates a depth stencil texture.
  89135. * This is only available in WebGL 2 or with the depth texture extension available.
  89136. * @param size The size of face edge in the texture.
  89137. * @param options The options defining the texture.
  89138. * @returns The texture
  89139. */
  89140. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89141. /** @hidden */
  89142. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89143. }
  89144. }
  89145. declare module BABYLON {
  89146. /**
  89147. * Defines the kind of connection point for node based material
  89148. */
  89149. export enum NodeMaterialBlockConnectionPointTypes {
  89150. /** Float */
  89151. Float = 1,
  89152. /** Int */
  89153. Int = 2,
  89154. /** Vector2 */
  89155. Vector2 = 4,
  89156. /** Vector3 */
  89157. Vector3 = 8,
  89158. /** Vector4 */
  89159. Vector4 = 16,
  89160. /** Color3 */
  89161. Color3 = 32,
  89162. /** Color4 */
  89163. Color4 = 64,
  89164. /** Matrix */
  89165. Matrix = 128,
  89166. /** Custom object */
  89167. Object = 256,
  89168. /** Detect type based on connection */
  89169. AutoDetect = 1024,
  89170. /** Output type that will be defined by input type */
  89171. BasedOnInput = 2048
  89172. }
  89173. }
  89174. declare module BABYLON {
  89175. /**
  89176. * Enum used to define the target of a block
  89177. */
  89178. export enum NodeMaterialBlockTargets {
  89179. /** Vertex shader */
  89180. Vertex = 1,
  89181. /** Fragment shader */
  89182. Fragment = 2,
  89183. /** Neutral */
  89184. Neutral = 4,
  89185. /** Vertex and Fragment */
  89186. VertexAndFragment = 3
  89187. }
  89188. }
  89189. declare module BABYLON {
  89190. /**
  89191. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89192. */
  89193. export enum NodeMaterialBlockConnectionPointMode {
  89194. /** Value is an uniform */
  89195. Uniform = 0,
  89196. /** Value is a mesh attribute */
  89197. Attribute = 1,
  89198. /** Value is a varying between vertex and fragment shaders */
  89199. Varying = 2,
  89200. /** Mode is undefined */
  89201. Undefined = 3
  89202. }
  89203. }
  89204. declare module BABYLON {
  89205. /**
  89206. * Enum used to define system values e.g. values automatically provided by the system
  89207. */
  89208. export enum NodeMaterialSystemValues {
  89209. /** World */
  89210. World = 1,
  89211. /** View */
  89212. View = 2,
  89213. /** Projection */
  89214. Projection = 3,
  89215. /** ViewProjection */
  89216. ViewProjection = 4,
  89217. /** WorldView */
  89218. WorldView = 5,
  89219. /** WorldViewProjection */
  89220. WorldViewProjection = 6,
  89221. /** CameraPosition */
  89222. CameraPosition = 7,
  89223. /** Fog Color */
  89224. FogColor = 8,
  89225. /** Delta time */
  89226. DeltaTime = 9
  89227. }
  89228. }
  89229. declare module BABYLON {
  89230. /** Defines supported spaces */
  89231. export enum Space {
  89232. /** Local (object) space */
  89233. LOCAL = 0,
  89234. /** World space */
  89235. WORLD = 1,
  89236. /** Bone space */
  89237. BONE = 2
  89238. }
  89239. /** Defines the 3 main axes */
  89240. export class Axis {
  89241. /** X axis */
  89242. static X: Vector3;
  89243. /** Y axis */
  89244. static Y: Vector3;
  89245. /** Z axis */
  89246. static Z: Vector3;
  89247. }
  89248. }
  89249. declare module BABYLON {
  89250. /**
  89251. * Represents a camera frustum
  89252. */
  89253. export class Frustum {
  89254. /**
  89255. * Gets the planes representing the frustum
  89256. * @param transform matrix to be applied to the returned planes
  89257. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89258. */
  89259. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89260. /**
  89261. * Gets the near frustum plane transformed by the transform matrix
  89262. * @param transform transformation matrix to be applied to the resulting frustum plane
  89263. * @param frustumPlane the resuling frustum plane
  89264. */
  89265. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89266. /**
  89267. * Gets the far frustum plane transformed by the transform matrix
  89268. * @param transform transformation matrix to be applied to the resulting frustum plane
  89269. * @param frustumPlane the resuling frustum plane
  89270. */
  89271. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89272. /**
  89273. * Gets the left frustum plane transformed by the transform matrix
  89274. * @param transform transformation matrix to be applied to the resulting frustum plane
  89275. * @param frustumPlane the resuling frustum plane
  89276. */
  89277. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89278. /**
  89279. * Gets the right frustum plane transformed by the transform matrix
  89280. * @param transform transformation matrix to be applied to the resulting frustum plane
  89281. * @param frustumPlane the resuling frustum plane
  89282. */
  89283. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89284. /**
  89285. * Gets the top frustum plane transformed by the transform matrix
  89286. * @param transform transformation matrix to be applied to the resulting frustum plane
  89287. * @param frustumPlane the resuling frustum plane
  89288. */
  89289. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89290. /**
  89291. * Gets the bottom frustum plane transformed by the transform matrix
  89292. * @param transform transformation matrix to be applied to the resulting frustum plane
  89293. * @param frustumPlane the resuling frustum plane
  89294. */
  89295. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89296. /**
  89297. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89298. * @param transform transformation matrix to be applied to the resulting frustum planes
  89299. * @param frustumPlanes the resuling frustum planes
  89300. */
  89301. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89302. }
  89303. }
  89304. declare module BABYLON {
  89305. /**
  89306. * Interface for the size containing width and height
  89307. */
  89308. export interface ISize {
  89309. /**
  89310. * Width
  89311. */
  89312. width: number;
  89313. /**
  89314. * Heighht
  89315. */
  89316. height: number;
  89317. }
  89318. /**
  89319. * Size containing widht and height
  89320. */
  89321. export class Size implements ISize {
  89322. /**
  89323. * Width
  89324. */
  89325. width: number;
  89326. /**
  89327. * Height
  89328. */
  89329. height: number;
  89330. /**
  89331. * Creates a Size object from the given width and height (floats).
  89332. * @param width width of the new size
  89333. * @param height height of the new size
  89334. */
  89335. constructor(width: number, height: number);
  89336. /**
  89337. * Returns a string with the Size width and height
  89338. * @returns a string with the Size width and height
  89339. */
  89340. toString(): string;
  89341. /**
  89342. * "Size"
  89343. * @returns the string "Size"
  89344. */
  89345. getClassName(): string;
  89346. /**
  89347. * Returns the Size hash code.
  89348. * @returns a hash code for a unique width and height
  89349. */
  89350. getHashCode(): number;
  89351. /**
  89352. * Updates the current size from the given one.
  89353. * @param src the given size
  89354. */
  89355. copyFrom(src: Size): void;
  89356. /**
  89357. * Updates in place the current Size from the given floats.
  89358. * @param width width of the new size
  89359. * @param height height of the new size
  89360. * @returns the updated Size.
  89361. */
  89362. copyFromFloats(width: number, height: number): Size;
  89363. /**
  89364. * Updates in place the current Size from the given floats.
  89365. * @param width width to set
  89366. * @param height height to set
  89367. * @returns the updated Size.
  89368. */
  89369. set(width: number, height: number): Size;
  89370. /**
  89371. * Multiplies the width and height by numbers
  89372. * @param w factor to multiple the width by
  89373. * @param h factor to multiple the height by
  89374. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89375. */
  89376. multiplyByFloats(w: number, h: number): Size;
  89377. /**
  89378. * Clones the size
  89379. * @returns a new Size copied from the given one.
  89380. */
  89381. clone(): Size;
  89382. /**
  89383. * True if the current Size and the given one width and height are strictly equal.
  89384. * @param other the other size to compare against
  89385. * @returns True if the current Size and the given one width and height are strictly equal.
  89386. */
  89387. equals(other: Size): boolean;
  89388. /**
  89389. * The surface of the Size : width * height (float).
  89390. */
  89391. get surface(): number;
  89392. /**
  89393. * Create a new size of zero
  89394. * @returns a new Size set to (0.0, 0.0)
  89395. */
  89396. static Zero(): Size;
  89397. /**
  89398. * Sums the width and height of two sizes
  89399. * @param otherSize size to add to this size
  89400. * @returns a new Size set as the addition result of the current Size and the given one.
  89401. */
  89402. add(otherSize: Size): Size;
  89403. /**
  89404. * Subtracts the width and height of two
  89405. * @param otherSize size to subtract to this size
  89406. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89407. */
  89408. subtract(otherSize: Size): Size;
  89409. /**
  89410. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89411. * @param start starting size to lerp between
  89412. * @param end end size to lerp between
  89413. * @param amount amount to lerp between the start and end values
  89414. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89415. */
  89416. static Lerp(start: Size, end: Size, amount: number): Size;
  89417. }
  89418. }
  89419. declare module BABYLON {
  89420. /**
  89421. * Contains position and normal vectors for a vertex
  89422. */
  89423. export class PositionNormalVertex {
  89424. /** the position of the vertex (defaut: 0,0,0) */
  89425. position: Vector3;
  89426. /** the normal of the vertex (defaut: 0,1,0) */
  89427. normal: Vector3;
  89428. /**
  89429. * Creates a PositionNormalVertex
  89430. * @param position the position of the vertex (defaut: 0,0,0)
  89431. * @param normal the normal of the vertex (defaut: 0,1,0)
  89432. */
  89433. constructor(
  89434. /** the position of the vertex (defaut: 0,0,0) */
  89435. position?: Vector3,
  89436. /** the normal of the vertex (defaut: 0,1,0) */
  89437. normal?: Vector3);
  89438. /**
  89439. * Clones the PositionNormalVertex
  89440. * @returns the cloned PositionNormalVertex
  89441. */
  89442. clone(): PositionNormalVertex;
  89443. }
  89444. /**
  89445. * Contains position, normal and uv vectors for a vertex
  89446. */
  89447. export class PositionNormalTextureVertex {
  89448. /** the position of the vertex (defaut: 0,0,0) */
  89449. position: Vector3;
  89450. /** the normal of the vertex (defaut: 0,1,0) */
  89451. normal: Vector3;
  89452. /** the uv of the vertex (default: 0,0) */
  89453. uv: Vector2;
  89454. /**
  89455. * Creates a PositionNormalTextureVertex
  89456. * @param position the position of the vertex (defaut: 0,0,0)
  89457. * @param normal the normal of the vertex (defaut: 0,1,0)
  89458. * @param uv the uv of the vertex (default: 0,0)
  89459. */
  89460. constructor(
  89461. /** the position of the vertex (defaut: 0,0,0) */
  89462. position?: Vector3,
  89463. /** the normal of the vertex (defaut: 0,1,0) */
  89464. normal?: Vector3,
  89465. /** the uv of the vertex (default: 0,0) */
  89466. uv?: Vector2);
  89467. /**
  89468. * Clones the PositionNormalTextureVertex
  89469. * @returns the cloned PositionNormalTextureVertex
  89470. */
  89471. clone(): PositionNormalTextureVertex;
  89472. }
  89473. }
  89474. declare module BABYLON {
  89475. /**
  89476. * Enum defining the type of animations supported by InputBlock
  89477. */
  89478. export enum AnimatedInputBlockTypes {
  89479. /** No animation */
  89480. None = 0,
  89481. /** Time based animation. Will only work for floats */
  89482. Time = 1
  89483. }
  89484. }
  89485. declare module BABYLON {
  89486. /**
  89487. * Interface describing all the common properties and methods a shadow light needs to implement.
  89488. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89489. * as well as binding the different shadow properties to the effects.
  89490. */
  89491. export interface IShadowLight extends Light {
  89492. /**
  89493. * The light id in the scene (used in scene.findLighById for instance)
  89494. */
  89495. id: string;
  89496. /**
  89497. * The position the shdow will be casted from.
  89498. */
  89499. position: Vector3;
  89500. /**
  89501. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89502. */
  89503. direction: Vector3;
  89504. /**
  89505. * The transformed position. Position of the light in world space taking parenting in account.
  89506. */
  89507. transformedPosition: Vector3;
  89508. /**
  89509. * The transformed direction. Direction of the light in world space taking parenting in account.
  89510. */
  89511. transformedDirection: Vector3;
  89512. /**
  89513. * The friendly name of the light in the scene.
  89514. */
  89515. name: string;
  89516. /**
  89517. * Defines the shadow projection clipping minimum z value.
  89518. */
  89519. shadowMinZ: number;
  89520. /**
  89521. * Defines the shadow projection clipping maximum z value.
  89522. */
  89523. shadowMaxZ: number;
  89524. /**
  89525. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89526. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89527. */
  89528. computeTransformedInformation(): boolean;
  89529. /**
  89530. * Gets the scene the light belongs to.
  89531. * @returns The scene
  89532. */
  89533. getScene(): Scene;
  89534. /**
  89535. * Callback defining a custom Projection Matrix Builder.
  89536. * This can be used to override the default projection matrix computation.
  89537. */
  89538. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89539. /**
  89540. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89541. * @param matrix The materix to updated with the projection information
  89542. * @param viewMatrix The transform matrix of the light
  89543. * @param renderList The list of mesh to render in the map
  89544. * @returns The current light
  89545. */
  89546. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89547. /**
  89548. * Gets the current depth scale used in ESM.
  89549. * @returns The scale
  89550. */
  89551. getDepthScale(): number;
  89552. /**
  89553. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89554. * @returns true if a cube texture needs to be use
  89555. */
  89556. needCube(): boolean;
  89557. /**
  89558. * Detects if the projection matrix requires to be recomputed this frame.
  89559. * @returns true if it requires to be recomputed otherwise, false.
  89560. */
  89561. needProjectionMatrixCompute(): boolean;
  89562. /**
  89563. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89564. */
  89565. forceProjectionMatrixCompute(): void;
  89566. /**
  89567. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89568. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89569. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89570. */
  89571. getShadowDirection(faceIndex?: number): Vector3;
  89572. /**
  89573. * Gets the minZ used for shadow according to both the scene and the light.
  89574. * @param activeCamera The camera we are returning the min for
  89575. * @returns the depth min z
  89576. */
  89577. getDepthMinZ(activeCamera: Camera): number;
  89578. /**
  89579. * Gets the maxZ used for shadow according to both the scene and the light.
  89580. * @param activeCamera The camera we are returning the max for
  89581. * @returns the depth max z
  89582. */
  89583. getDepthMaxZ(activeCamera: Camera): number;
  89584. }
  89585. /**
  89586. * Base implementation IShadowLight
  89587. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89588. */
  89589. export abstract class ShadowLight extends Light implements IShadowLight {
  89590. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89591. protected _position: Vector3;
  89592. protected _setPosition(value: Vector3): void;
  89593. /**
  89594. * Sets the position the shadow will be casted from. Also use as the light position for both
  89595. * point and spot lights.
  89596. */
  89597. get position(): Vector3;
  89598. /**
  89599. * Sets the position the shadow will be casted from. Also use as the light position for both
  89600. * point and spot lights.
  89601. */
  89602. set position(value: Vector3);
  89603. protected _direction: Vector3;
  89604. protected _setDirection(value: Vector3): void;
  89605. /**
  89606. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89607. * Also use as the light direction on spot and directional lights.
  89608. */
  89609. get direction(): Vector3;
  89610. /**
  89611. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89612. * Also use as the light direction on spot and directional lights.
  89613. */
  89614. set direction(value: Vector3);
  89615. protected _shadowMinZ: number;
  89616. /**
  89617. * Gets the shadow projection clipping minimum z value.
  89618. */
  89619. get shadowMinZ(): number;
  89620. /**
  89621. * Sets the shadow projection clipping minimum z value.
  89622. */
  89623. set shadowMinZ(value: number);
  89624. protected _shadowMaxZ: number;
  89625. /**
  89626. * Sets the shadow projection clipping maximum z value.
  89627. */
  89628. get shadowMaxZ(): number;
  89629. /**
  89630. * Gets the shadow projection clipping maximum z value.
  89631. */
  89632. set shadowMaxZ(value: number);
  89633. /**
  89634. * Callback defining a custom Projection Matrix Builder.
  89635. * This can be used to override the default projection matrix computation.
  89636. */
  89637. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89638. /**
  89639. * The transformed position. Position of the light in world space taking parenting in account.
  89640. */
  89641. transformedPosition: Vector3;
  89642. /**
  89643. * The transformed direction. Direction of the light in world space taking parenting in account.
  89644. */
  89645. transformedDirection: Vector3;
  89646. private _needProjectionMatrixCompute;
  89647. /**
  89648. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89649. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89650. */
  89651. computeTransformedInformation(): boolean;
  89652. /**
  89653. * Return the depth scale used for the shadow map.
  89654. * @returns the depth scale.
  89655. */
  89656. getDepthScale(): number;
  89657. /**
  89658. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89659. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89660. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89661. */
  89662. getShadowDirection(faceIndex?: number): Vector3;
  89663. /**
  89664. * Returns the ShadowLight absolute position in the World.
  89665. * @returns the position vector in world space
  89666. */
  89667. getAbsolutePosition(): Vector3;
  89668. /**
  89669. * Sets the ShadowLight direction toward the passed target.
  89670. * @param target The point to target in local space
  89671. * @returns the updated ShadowLight direction
  89672. */
  89673. setDirectionToTarget(target: Vector3): Vector3;
  89674. /**
  89675. * Returns the light rotation in euler definition.
  89676. * @returns the x y z rotation in local space.
  89677. */
  89678. getRotation(): Vector3;
  89679. /**
  89680. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89681. * @returns true if a cube texture needs to be use
  89682. */
  89683. needCube(): boolean;
  89684. /**
  89685. * Detects if the projection matrix requires to be recomputed this frame.
  89686. * @returns true if it requires to be recomputed otherwise, false.
  89687. */
  89688. needProjectionMatrixCompute(): boolean;
  89689. /**
  89690. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89691. */
  89692. forceProjectionMatrixCompute(): void;
  89693. /** @hidden */
  89694. _initCache(): void;
  89695. /** @hidden */
  89696. _isSynchronized(): boolean;
  89697. /**
  89698. * Computes the world matrix of the node
  89699. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89700. * @returns the world matrix
  89701. */
  89702. computeWorldMatrix(force?: boolean): Matrix;
  89703. /**
  89704. * Gets the minZ used for shadow according to both the scene and the light.
  89705. * @param activeCamera The camera we are returning the min for
  89706. * @returns the depth min z
  89707. */
  89708. getDepthMinZ(activeCamera: Camera): number;
  89709. /**
  89710. * Gets the maxZ used for shadow according to both the scene and the light.
  89711. * @param activeCamera The camera we are returning the max for
  89712. * @returns the depth max z
  89713. */
  89714. getDepthMaxZ(activeCamera: Camera): number;
  89715. /**
  89716. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89717. * @param matrix The materix to updated with the projection information
  89718. * @param viewMatrix The transform matrix of the light
  89719. * @param renderList The list of mesh to render in the map
  89720. * @returns The current light
  89721. */
  89722. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89723. }
  89724. }
  89725. declare module BABYLON {
  89726. /** @hidden */
  89727. export var packingFunctions: {
  89728. name: string;
  89729. shader: string;
  89730. };
  89731. }
  89732. declare module BABYLON {
  89733. /** @hidden */
  89734. export var bayerDitherFunctions: {
  89735. name: string;
  89736. shader: string;
  89737. };
  89738. }
  89739. declare module BABYLON {
  89740. /** @hidden */
  89741. export var shadowMapFragmentDeclaration: {
  89742. name: string;
  89743. shader: string;
  89744. };
  89745. }
  89746. declare module BABYLON {
  89747. /** @hidden */
  89748. export var clipPlaneFragmentDeclaration: {
  89749. name: string;
  89750. shader: string;
  89751. };
  89752. }
  89753. declare module BABYLON {
  89754. /** @hidden */
  89755. export var clipPlaneFragment: {
  89756. name: string;
  89757. shader: string;
  89758. };
  89759. }
  89760. declare module BABYLON {
  89761. /** @hidden */
  89762. export var shadowMapFragment: {
  89763. name: string;
  89764. shader: string;
  89765. };
  89766. }
  89767. declare module BABYLON {
  89768. /** @hidden */
  89769. export var shadowMapPixelShader: {
  89770. name: string;
  89771. shader: string;
  89772. };
  89773. }
  89774. declare module BABYLON {
  89775. /** @hidden */
  89776. export var bonesDeclaration: {
  89777. name: string;
  89778. shader: string;
  89779. };
  89780. }
  89781. declare module BABYLON {
  89782. /** @hidden */
  89783. export var morphTargetsVertexGlobalDeclaration: {
  89784. name: string;
  89785. shader: string;
  89786. };
  89787. }
  89788. declare module BABYLON {
  89789. /** @hidden */
  89790. export var morphTargetsVertexDeclaration: {
  89791. name: string;
  89792. shader: string;
  89793. };
  89794. }
  89795. declare module BABYLON {
  89796. /** @hidden */
  89797. export var instancesDeclaration: {
  89798. name: string;
  89799. shader: string;
  89800. };
  89801. }
  89802. declare module BABYLON {
  89803. /** @hidden */
  89804. export var helperFunctions: {
  89805. name: string;
  89806. shader: string;
  89807. };
  89808. }
  89809. declare module BABYLON {
  89810. /** @hidden */
  89811. export var shadowMapVertexDeclaration: {
  89812. name: string;
  89813. shader: string;
  89814. };
  89815. }
  89816. declare module BABYLON {
  89817. /** @hidden */
  89818. export var clipPlaneVertexDeclaration: {
  89819. name: string;
  89820. shader: string;
  89821. };
  89822. }
  89823. declare module BABYLON {
  89824. /** @hidden */
  89825. export var morphTargetsVertex: {
  89826. name: string;
  89827. shader: string;
  89828. };
  89829. }
  89830. declare module BABYLON {
  89831. /** @hidden */
  89832. export var instancesVertex: {
  89833. name: string;
  89834. shader: string;
  89835. };
  89836. }
  89837. declare module BABYLON {
  89838. /** @hidden */
  89839. export var bonesVertex: {
  89840. name: string;
  89841. shader: string;
  89842. };
  89843. }
  89844. declare module BABYLON {
  89845. /** @hidden */
  89846. export var shadowMapVertexNormalBias: {
  89847. name: string;
  89848. shader: string;
  89849. };
  89850. }
  89851. declare module BABYLON {
  89852. /** @hidden */
  89853. export var shadowMapVertexMetric: {
  89854. name: string;
  89855. shader: string;
  89856. };
  89857. }
  89858. declare module BABYLON {
  89859. /** @hidden */
  89860. export var clipPlaneVertex: {
  89861. name: string;
  89862. shader: string;
  89863. };
  89864. }
  89865. declare module BABYLON {
  89866. /** @hidden */
  89867. export var shadowMapVertexShader: {
  89868. name: string;
  89869. shader: string;
  89870. };
  89871. }
  89872. declare module BABYLON {
  89873. /** @hidden */
  89874. export var depthBoxBlurPixelShader: {
  89875. name: string;
  89876. shader: string;
  89877. };
  89878. }
  89879. declare module BABYLON {
  89880. /** @hidden */
  89881. export var shadowMapFragmentSoftTransparentShadow: {
  89882. name: string;
  89883. shader: string;
  89884. };
  89885. }
  89886. declare module BABYLON {
  89887. /**
  89888. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89889. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89890. */
  89891. export class EffectFallbacks implements IEffectFallbacks {
  89892. private _defines;
  89893. private _currentRank;
  89894. private _maxRank;
  89895. private _mesh;
  89896. /**
  89897. * Removes the fallback from the bound mesh.
  89898. */
  89899. unBindMesh(): void;
  89900. /**
  89901. * Adds a fallback on the specified property.
  89902. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89903. * @param define The name of the define in the shader
  89904. */
  89905. addFallback(rank: number, define: string): void;
  89906. /**
  89907. * Sets the mesh to use CPU skinning when needing to fallback.
  89908. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89909. * @param mesh The mesh to use the fallbacks.
  89910. */
  89911. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89912. /**
  89913. * Checks to see if more fallbacks are still availible.
  89914. */
  89915. get hasMoreFallbacks(): boolean;
  89916. /**
  89917. * Removes the defines that should be removed when falling back.
  89918. * @param currentDefines defines the current define statements for the shader.
  89919. * @param effect defines the current effect we try to compile
  89920. * @returns The resulting defines with defines of the current rank removed.
  89921. */
  89922. reduce(currentDefines: string, effect: Effect): string;
  89923. }
  89924. }
  89925. declare module BABYLON {
  89926. /**
  89927. * Interface used to define Action
  89928. */
  89929. export interface IAction {
  89930. /**
  89931. * Trigger for the action
  89932. */
  89933. trigger: number;
  89934. /** Options of the trigger */
  89935. triggerOptions: any;
  89936. /**
  89937. * Gets the trigger parameters
  89938. * @returns the trigger parameters
  89939. */
  89940. getTriggerParameter(): any;
  89941. /**
  89942. * Internal only - executes current action event
  89943. * @hidden
  89944. */
  89945. _executeCurrent(evt?: ActionEvent): void;
  89946. /**
  89947. * Serialize placeholder for child classes
  89948. * @param parent of child
  89949. * @returns the serialized object
  89950. */
  89951. serialize(parent: any): any;
  89952. /**
  89953. * Internal only
  89954. * @hidden
  89955. */
  89956. _prepare(): void;
  89957. /**
  89958. * Internal only - manager for action
  89959. * @hidden
  89960. */
  89961. _actionManager: Nullable<AbstractActionManager>;
  89962. /**
  89963. * Adds action to chain of actions, may be a DoNothingAction
  89964. * @param action defines the next action to execute
  89965. * @returns The action passed in
  89966. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89967. */
  89968. then(action: IAction): IAction;
  89969. }
  89970. /**
  89971. * The action to be carried out following a trigger
  89972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89973. */
  89974. export class Action implements IAction {
  89975. /** the trigger, with or without parameters, for the action */
  89976. triggerOptions: any;
  89977. /**
  89978. * Trigger for the action
  89979. */
  89980. trigger: number;
  89981. /**
  89982. * Internal only - manager for action
  89983. * @hidden
  89984. */
  89985. _actionManager: ActionManager;
  89986. private _nextActiveAction;
  89987. private _child;
  89988. private _condition?;
  89989. private _triggerParameter;
  89990. /**
  89991. * An event triggered prior to action being executed.
  89992. */
  89993. onBeforeExecuteObservable: Observable<Action>;
  89994. /**
  89995. * Creates a new Action
  89996. * @param triggerOptions the trigger, with or without parameters, for the action
  89997. * @param condition an optional determinant of action
  89998. */
  89999. constructor(
  90000. /** the trigger, with or without parameters, for the action */
  90001. triggerOptions: any, condition?: Condition);
  90002. /**
  90003. * Internal only
  90004. * @hidden
  90005. */
  90006. _prepare(): void;
  90007. /**
  90008. * Gets the trigger parameters
  90009. * @returns the trigger parameters
  90010. */
  90011. getTriggerParameter(): any;
  90012. /**
  90013. * Internal only - executes current action event
  90014. * @hidden
  90015. */
  90016. _executeCurrent(evt?: ActionEvent): void;
  90017. /**
  90018. * Execute placeholder for child classes
  90019. * @param evt optional action event
  90020. */
  90021. execute(evt?: ActionEvent): void;
  90022. /**
  90023. * Skips to next active action
  90024. */
  90025. skipToNextActiveAction(): void;
  90026. /**
  90027. * Adds action to chain of actions, may be a DoNothingAction
  90028. * @param action defines the next action to execute
  90029. * @returns The action passed in
  90030. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90031. */
  90032. then(action: Action): Action;
  90033. /**
  90034. * Internal only
  90035. * @hidden
  90036. */
  90037. _getProperty(propertyPath: string): string;
  90038. /**
  90039. * Internal only
  90040. * @hidden
  90041. */
  90042. _getEffectiveTarget(target: any, propertyPath: string): any;
  90043. /**
  90044. * Serialize placeholder for child classes
  90045. * @param parent of child
  90046. * @returns the serialized object
  90047. */
  90048. serialize(parent: any): any;
  90049. /**
  90050. * Internal only called by serialize
  90051. * @hidden
  90052. */
  90053. protected _serialize(serializedAction: any, parent?: any): any;
  90054. /**
  90055. * Internal only
  90056. * @hidden
  90057. */
  90058. static _SerializeValueAsString: (value: any) => string;
  90059. /**
  90060. * Internal only
  90061. * @hidden
  90062. */
  90063. static _GetTargetProperty: (target: Scene | Node) => {
  90064. name: string;
  90065. targetType: string;
  90066. value: string;
  90067. };
  90068. }
  90069. }
  90070. declare module BABYLON {
  90071. /**
  90072. * A Condition applied to an Action
  90073. */
  90074. export class Condition {
  90075. /**
  90076. * Internal only - manager for action
  90077. * @hidden
  90078. */
  90079. _actionManager: ActionManager;
  90080. /**
  90081. * Internal only
  90082. * @hidden
  90083. */
  90084. _evaluationId: number;
  90085. /**
  90086. * Internal only
  90087. * @hidden
  90088. */
  90089. _currentResult: boolean;
  90090. /**
  90091. * Creates a new Condition
  90092. * @param actionManager the manager of the action the condition is applied to
  90093. */
  90094. constructor(actionManager: ActionManager);
  90095. /**
  90096. * Check if the current condition is valid
  90097. * @returns a boolean
  90098. */
  90099. isValid(): boolean;
  90100. /**
  90101. * Internal only
  90102. * @hidden
  90103. */
  90104. _getProperty(propertyPath: string): string;
  90105. /**
  90106. * Internal only
  90107. * @hidden
  90108. */
  90109. _getEffectiveTarget(target: any, propertyPath: string): any;
  90110. /**
  90111. * Serialize placeholder for child classes
  90112. * @returns the serialized object
  90113. */
  90114. serialize(): any;
  90115. /**
  90116. * Internal only
  90117. * @hidden
  90118. */
  90119. protected _serialize(serializedCondition: any): any;
  90120. }
  90121. /**
  90122. * Defines specific conditional operators as extensions of Condition
  90123. */
  90124. export class ValueCondition extends Condition {
  90125. /** path to specify the property of the target the conditional operator uses */
  90126. propertyPath: string;
  90127. /** the value compared by the conditional operator against the current value of the property */
  90128. value: any;
  90129. /** the conditional operator, default ValueCondition.IsEqual */
  90130. operator: number;
  90131. /**
  90132. * Internal only
  90133. * @hidden
  90134. */
  90135. private static _IsEqual;
  90136. /**
  90137. * Internal only
  90138. * @hidden
  90139. */
  90140. private static _IsDifferent;
  90141. /**
  90142. * Internal only
  90143. * @hidden
  90144. */
  90145. private static _IsGreater;
  90146. /**
  90147. * Internal only
  90148. * @hidden
  90149. */
  90150. private static _IsLesser;
  90151. /**
  90152. * returns the number for IsEqual
  90153. */
  90154. static get IsEqual(): number;
  90155. /**
  90156. * Returns the number for IsDifferent
  90157. */
  90158. static get IsDifferent(): number;
  90159. /**
  90160. * Returns the number for IsGreater
  90161. */
  90162. static get IsGreater(): number;
  90163. /**
  90164. * Returns the number for IsLesser
  90165. */
  90166. static get IsLesser(): number;
  90167. /**
  90168. * Internal only The action manager for the condition
  90169. * @hidden
  90170. */
  90171. _actionManager: ActionManager;
  90172. /**
  90173. * Internal only
  90174. * @hidden
  90175. */
  90176. private _target;
  90177. /**
  90178. * Internal only
  90179. * @hidden
  90180. */
  90181. private _effectiveTarget;
  90182. /**
  90183. * Internal only
  90184. * @hidden
  90185. */
  90186. private _property;
  90187. /**
  90188. * Creates a new ValueCondition
  90189. * @param actionManager manager for the action the condition applies to
  90190. * @param target for the action
  90191. * @param propertyPath path to specify the property of the target the conditional operator uses
  90192. * @param value the value compared by the conditional operator against the current value of the property
  90193. * @param operator the conditional operator, default ValueCondition.IsEqual
  90194. */
  90195. constructor(actionManager: ActionManager, target: any,
  90196. /** path to specify the property of the target the conditional operator uses */
  90197. propertyPath: string,
  90198. /** the value compared by the conditional operator against the current value of the property */
  90199. value: any,
  90200. /** the conditional operator, default ValueCondition.IsEqual */
  90201. operator?: number);
  90202. /**
  90203. * Compares the given value with the property value for the specified conditional operator
  90204. * @returns the result of the comparison
  90205. */
  90206. isValid(): boolean;
  90207. /**
  90208. * Serialize the ValueCondition into a JSON compatible object
  90209. * @returns serialization object
  90210. */
  90211. serialize(): any;
  90212. /**
  90213. * Gets the name of the conditional operator for the ValueCondition
  90214. * @param operator the conditional operator
  90215. * @returns the name
  90216. */
  90217. static GetOperatorName(operator: number): string;
  90218. }
  90219. /**
  90220. * Defines a predicate condition as an extension of Condition
  90221. */
  90222. export class PredicateCondition extends Condition {
  90223. /** defines the predicate function used to validate the condition */
  90224. predicate: () => boolean;
  90225. /**
  90226. * Internal only - manager for action
  90227. * @hidden
  90228. */
  90229. _actionManager: ActionManager;
  90230. /**
  90231. * Creates a new PredicateCondition
  90232. * @param actionManager manager for the action the condition applies to
  90233. * @param predicate defines the predicate function used to validate the condition
  90234. */
  90235. constructor(actionManager: ActionManager,
  90236. /** defines the predicate function used to validate the condition */
  90237. predicate: () => boolean);
  90238. /**
  90239. * @returns the validity of the predicate condition
  90240. */
  90241. isValid(): boolean;
  90242. }
  90243. /**
  90244. * Defines a state condition as an extension of Condition
  90245. */
  90246. export class StateCondition extends Condition {
  90247. /** Value to compare with target state */
  90248. value: string;
  90249. /**
  90250. * Internal only - manager for action
  90251. * @hidden
  90252. */
  90253. _actionManager: ActionManager;
  90254. /**
  90255. * Internal only
  90256. * @hidden
  90257. */
  90258. private _target;
  90259. /**
  90260. * Creates a new StateCondition
  90261. * @param actionManager manager for the action the condition applies to
  90262. * @param target of the condition
  90263. * @param value to compare with target state
  90264. */
  90265. constructor(actionManager: ActionManager, target: any,
  90266. /** Value to compare with target state */
  90267. value: string);
  90268. /**
  90269. * Gets a boolean indicating if the current condition is met
  90270. * @returns the validity of the state
  90271. */
  90272. isValid(): boolean;
  90273. /**
  90274. * Serialize the StateCondition into a JSON compatible object
  90275. * @returns serialization object
  90276. */
  90277. serialize(): any;
  90278. }
  90279. }
  90280. declare module BABYLON {
  90281. /**
  90282. * This defines an action responsible to toggle a boolean once triggered.
  90283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90284. */
  90285. export class SwitchBooleanAction extends Action {
  90286. /**
  90287. * The path to the boolean property in the target object
  90288. */
  90289. propertyPath: string;
  90290. private _target;
  90291. private _effectiveTarget;
  90292. private _property;
  90293. /**
  90294. * Instantiate the action
  90295. * @param triggerOptions defines the trigger options
  90296. * @param target defines the object containing the boolean
  90297. * @param propertyPath defines the path to the boolean property in the target object
  90298. * @param condition defines the trigger related conditions
  90299. */
  90300. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90301. /** @hidden */
  90302. _prepare(): void;
  90303. /**
  90304. * Execute the action toggle the boolean value.
  90305. */
  90306. execute(): void;
  90307. /**
  90308. * Serializes the actions and its related information.
  90309. * @param parent defines the object to serialize in
  90310. * @returns the serialized object
  90311. */
  90312. serialize(parent: any): any;
  90313. }
  90314. /**
  90315. * This defines an action responsible to set a the state field of the target
  90316. * to a desired value once triggered.
  90317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90318. */
  90319. export class SetStateAction extends Action {
  90320. /**
  90321. * The value to store in the state field.
  90322. */
  90323. value: string;
  90324. private _target;
  90325. /**
  90326. * Instantiate the action
  90327. * @param triggerOptions defines the trigger options
  90328. * @param target defines the object containing the state property
  90329. * @param value defines the value to store in the state field
  90330. * @param condition defines the trigger related conditions
  90331. */
  90332. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90333. /**
  90334. * Execute the action and store the value on the target state property.
  90335. */
  90336. execute(): void;
  90337. /**
  90338. * Serializes the actions and its related information.
  90339. * @param parent defines the object to serialize in
  90340. * @returns the serialized object
  90341. */
  90342. serialize(parent: any): any;
  90343. }
  90344. /**
  90345. * This defines an action responsible to set a property of the target
  90346. * to a desired value once triggered.
  90347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90348. */
  90349. export class SetValueAction extends Action {
  90350. /**
  90351. * The path of the property to set in the target.
  90352. */
  90353. propertyPath: string;
  90354. /**
  90355. * The value to set in the property
  90356. */
  90357. value: any;
  90358. private _target;
  90359. private _effectiveTarget;
  90360. private _property;
  90361. /**
  90362. * Instantiate the action
  90363. * @param triggerOptions defines the trigger options
  90364. * @param target defines the object containing the property
  90365. * @param propertyPath defines the path of the property to set in the target
  90366. * @param value defines the value to set in the property
  90367. * @param condition defines the trigger related conditions
  90368. */
  90369. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90370. /** @hidden */
  90371. _prepare(): void;
  90372. /**
  90373. * Execute the action and set the targetted property to the desired value.
  90374. */
  90375. execute(): void;
  90376. /**
  90377. * Serializes the actions and its related information.
  90378. * @param parent defines the object to serialize in
  90379. * @returns the serialized object
  90380. */
  90381. serialize(parent: any): any;
  90382. }
  90383. /**
  90384. * This defines an action responsible to increment the target value
  90385. * to a desired value once triggered.
  90386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90387. */
  90388. export class IncrementValueAction extends Action {
  90389. /**
  90390. * The path of the property to increment in the target.
  90391. */
  90392. propertyPath: string;
  90393. /**
  90394. * The value we should increment the property by.
  90395. */
  90396. value: any;
  90397. private _target;
  90398. private _effectiveTarget;
  90399. private _property;
  90400. /**
  90401. * Instantiate the action
  90402. * @param triggerOptions defines the trigger options
  90403. * @param target defines the object containing the property
  90404. * @param propertyPath defines the path of the property to increment in the target
  90405. * @param value defines the value value we should increment the property by
  90406. * @param condition defines the trigger related conditions
  90407. */
  90408. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90409. /** @hidden */
  90410. _prepare(): void;
  90411. /**
  90412. * Execute the action and increment the target of the value amount.
  90413. */
  90414. execute(): void;
  90415. /**
  90416. * Serializes the actions and its related information.
  90417. * @param parent defines the object to serialize in
  90418. * @returns the serialized object
  90419. */
  90420. serialize(parent: any): any;
  90421. }
  90422. /**
  90423. * This defines an action responsible to start an animation once triggered.
  90424. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90425. */
  90426. export class PlayAnimationAction extends Action {
  90427. /**
  90428. * Where the animation should start (animation frame)
  90429. */
  90430. from: number;
  90431. /**
  90432. * Where the animation should stop (animation frame)
  90433. */
  90434. to: number;
  90435. /**
  90436. * Define if the animation should loop or stop after the first play.
  90437. */
  90438. loop?: boolean;
  90439. private _target;
  90440. /**
  90441. * Instantiate the action
  90442. * @param triggerOptions defines the trigger options
  90443. * @param target defines the target animation or animation name
  90444. * @param from defines from where the animation should start (animation frame)
  90445. * @param end defines where the animation should stop (animation frame)
  90446. * @param loop defines if the animation should loop or stop after the first play
  90447. * @param condition defines the trigger related conditions
  90448. */
  90449. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90450. /** @hidden */
  90451. _prepare(): void;
  90452. /**
  90453. * Execute the action and play the animation.
  90454. */
  90455. execute(): void;
  90456. /**
  90457. * Serializes the actions and its related information.
  90458. * @param parent defines the object to serialize in
  90459. * @returns the serialized object
  90460. */
  90461. serialize(parent: any): any;
  90462. }
  90463. /**
  90464. * This defines an action responsible to stop an animation once triggered.
  90465. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90466. */
  90467. export class StopAnimationAction extends Action {
  90468. private _target;
  90469. /**
  90470. * Instantiate the action
  90471. * @param triggerOptions defines the trigger options
  90472. * @param target defines the target animation or animation name
  90473. * @param condition defines the trigger related conditions
  90474. */
  90475. constructor(triggerOptions: any, target: any, condition?: Condition);
  90476. /** @hidden */
  90477. _prepare(): void;
  90478. /**
  90479. * Execute the action and stop the animation.
  90480. */
  90481. execute(): void;
  90482. /**
  90483. * Serializes the actions and its related information.
  90484. * @param parent defines the object to serialize in
  90485. * @returns the serialized object
  90486. */
  90487. serialize(parent: any): any;
  90488. }
  90489. /**
  90490. * This defines an action responsible that does nothing once triggered.
  90491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90492. */
  90493. export class DoNothingAction extends Action {
  90494. /**
  90495. * Instantiate the action
  90496. * @param triggerOptions defines the trigger options
  90497. * @param condition defines the trigger related conditions
  90498. */
  90499. constructor(triggerOptions?: any, condition?: Condition);
  90500. /**
  90501. * Execute the action and do nothing.
  90502. */
  90503. execute(): void;
  90504. /**
  90505. * Serializes the actions and its related information.
  90506. * @param parent defines the object to serialize in
  90507. * @returns the serialized object
  90508. */
  90509. serialize(parent: any): any;
  90510. }
  90511. /**
  90512. * This defines an action responsible to trigger several actions once triggered.
  90513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90514. */
  90515. export class CombineAction extends Action {
  90516. /**
  90517. * The list of aggregated animations to run.
  90518. */
  90519. children: Action[];
  90520. /**
  90521. * Instantiate the action
  90522. * @param triggerOptions defines the trigger options
  90523. * @param children defines the list of aggregated animations to run
  90524. * @param condition defines the trigger related conditions
  90525. */
  90526. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90527. /** @hidden */
  90528. _prepare(): void;
  90529. /**
  90530. * Execute the action and executes all the aggregated actions.
  90531. */
  90532. execute(evt: ActionEvent): void;
  90533. /**
  90534. * Serializes the actions and its related information.
  90535. * @param parent defines the object to serialize in
  90536. * @returns the serialized object
  90537. */
  90538. serialize(parent: any): any;
  90539. }
  90540. /**
  90541. * This defines an action responsible to run code (external event) once triggered.
  90542. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90543. */
  90544. export class ExecuteCodeAction extends Action {
  90545. /**
  90546. * The callback function to run.
  90547. */
  90548. func: (evt: ActionEvent) => void;
  90549. /**
  90550. * Instantiate the action
  90551. * @param triggerOptions defines the trigger options
  90552. * @param func defines the callback function to run
  90553. * @param condition defines the trigger related conditions
  90554. */
  90555. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90556. /**
  90557. * Execute the action and run the attached code.
  90558. */
  90559. execute(evt: ActionEvent): void;
  90560. }
  90561. /**
  90562. * This defines an action responsible to set the parent property of the target once triggered.
  90563. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90564. */
  90565. export class SetParentAction extends Action {
  90566. private _parent;
  90567. private _target;
  90568. /**
  90569. * Instantiate the action
  90570. * @param triggerOptions defines the trigger options
  90571. * @param target defines the target containing the parent property
  90572. * @param parent defines from where the animation should start (animation frame)
  90573. * @param condition defines the trigger related conditions
  90574. */
  90575. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90576. /** @hidden */
  90577. _prepare(): void;
  90578. /**
  90579. * Execute the action and set the parent property.
  90580. */
  90581. execute(): void;
  90582. /**
  90583. * Serializes the actions and its related information.
  90584. * @param parent defines the object to serialize in
  90585. * @returns the serialized object
  90586. */
  90587. serialize(parent: any): any;
  90588. }
  90589. }
  90590. declare module BABYLON {
  90591. /**
  90592. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90593. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90594. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90595. */
  90596. export class ActionManager extends AbstractActionManager {
  90597. /**
  90598. * Nothing
  90599. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90600. */
  90601. static readonly NothingTrigger: number;
  90602. /**
  90603. * On pick
  90604. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90605. */
  90606. static readonly OnPickTrigger: number;
  90607. /**
  90608. * On left pick
  90609. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90610. */
  90611. static readonly OnLeftPickTrigger: number;
  90612. /**
  90613. * On right pick
  90614. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90615. */
  90616. static readonly OnRightPickTrigger: number;
  90617. /**
  90618. * On center pick
  90619. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90620. */
  90621. static readonly OnCenterPickTrigger: number;
  90622. /**
  90623. * On pick down
  90624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90625. */
  90626. static readonly OnPickDownTrigger: number;
  90627. /**
  90628. * On double pick
  90629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90630. */
  90631. static readonly OnDoublePickTrigger: number;
  90632. /**
  90633. * On pick up
  90634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90635. */
  90636. static readonly OnPickUpTrigger: number;
  90637. /**
  90638. * On pick out.
  90639. * This trigger will only be raised if you also declared a OnPickDown
  90640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90641. */
  90642. static readonly OnPickOutTrigger: number;
  90643. /**
  90644. * On long press
  90645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90646. */
  90647. static readonly OnLongPressTrigger: number;
  90648. /**
  90649. * On pointer over
  90650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90651. */
  90652. static readonly OnPointerOverTrigger: number;
  90653. /**
  90654. * On pointer out
  90655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90656. */
  90657. static readonly OnPointerOutTrigger: number;
  90658. /**
  90659. * On every frame
  90660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90661. */
  90662. static readonly OnEveryFrameTrigger: number;
  90663. /**
  90664. * On intersection enter
  90665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90666. */
  90667. static readonly OnIntersectionEnterTrigger: number;
  90668. /**
  90669. * On intersection exit
  90670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90671. */
  90672. static readonly OnIntersectionExitTrigger: number;
  90673. /**
  90674. * On key down
  90675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90676. */
  90677. static readonly OnKeyDownTrigger: number;
  90678. /**
  90679. * On key up
  90680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90681. */
  90682. static readonly OnKeyUpTrigger: number;
  90683. private _scene;
  90684. /**
  90685. * Creates a new action manager
  90686. * @param scene defines the hosting scene
  90687. */
  90688. constructor(scene: Scene);
  90689. /**
  90690. * Releases all associated resources
  90691. */
  90692. dispose(): void;
  90693. /**
  90694. * Gets hosting scene
  90695. * @returns the hosting scene
  90696. */
  90697. getScene(): Scene;
  90698. /**
  90699. * Does this action manager handles actions of any of the given triggers
  90700. * @param triggers defines the triggers to be tested
  90701. * @return a boolean indicating whether one (or more) of the triggers is handled
  90702. */
  90703. hasSpecificTriggers(triggers: number[]): boolean;
  90704. /**
  90705. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90706. * speed.
  90707. * @param triggerA defines the trigger to be tested
  90708. * @param triggerB defines the trigger to be tested
  90709. * @return a boolean indicating whether one (or more) of the triggers is handled
  90710. */
  90711. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90712. /**
  90713. * Does this action manager handles actions of a given trigger
  90714. * @param trigger defines the trigger to be tested
  90715. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90716. * @return whether the trigger is handled
  90717. */
  90718. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90719. /**
  90720. * Does this action manager has pointer triggers
  90721. */
  90722. get hasPointerTriggers(): boolean;
  90723. /**
  90724. * Does this action manager has pick triggers
  90725. */
  90726. get hasPickTriggers(): boolean;
  90727. /**
  90728. * Registers an action to this action manager
  90729. * @param action defines the action to be registered
  90730. * @return the action amended (prepared) after registration
  90731. */
  90732. registerAction(action: IAction): Nullable<IAction>;
  90733. /**
  90734. * Unregisters an action to this action manager
  90735. * @param action defines the action to be unregistered
  90736. * @return a boolean indicating whether the action has been unregistered
  90737. */
  90738. unregisterAction(action: IAction): Boolean;
  90739. /**
  90740. * Process a specific trigger
  90741. * @param trigger defines the trigger to process
  90742. * @param evt defines the event details to be processed
  90743. */
  90744. processTrigger(trigger: number, evt?: IActionEvent): void;
  90745. /** @hidden */
  90746. _getEffectiveTarget(target: any, propertyPath: string): any;
  90747. /** @hidden */
  90748. _getProperty(propertyPath: string): string;
  90749. /**
  90750. * Serialize this manager to a JSON object
  90751. * @param name defines the property name to store this manager
  90752. * @returns a JSON representation of this manager
  90753. */
  90754. serialize(name: string): any;
  90755. /**
  90756. * Creates a new ActionManager from a JSON data
  90757. * @param parsedActions defines the JSON data to read from
  90758. * @param object defines the hosting mesh
  90759. * @param scene defines the hosting scene
  90760. */
  90761. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90762. /**
  90763. * Get a trigger name by index
  90764. * @param trigger defines the trigger index
  90765. * @returns a trigger name
  90766. */
  90767. static GetTriggerName(trigger: number): string;
  90768. }
  90769. }
  90770. declare module BABYLON {
  90771. /**
  90772. * Class used to represent a sprite
  90773. * @see https://doc.babylonjs.com/babylon101/sprites
  90774. */
  90775. export class Sprite implements IAnimatable {
  90776. /** defines the name */
  90777. name: string;
  90778. /** Gets or sets the current world position */
  90779. position: Vector3;
  90780. /** Gets or sets the main color */
  90781. color: Color4;
  90782. /** Gets or sets the width */
  90783. width: number;
  90784. /** Gets or sets the height */
  90785. height: number;
  90786. /** Gets or sets rotation angle */
  90787. angle: number;
  90788. /** Gets or sets the cell index in the sprite sheet */
  90789. cellIndex: number;
  90790. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90791. cellRef: string;
  90792. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90793. invertU: boolean;
  90794. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90795. invertV: boolean;
  90796. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90797. disposeWhenFinishedAnimating: boolean;
  90798. /** Gets the list of attached animations */
  90799. animations: Nullable<Array<Animation>>;
  90800. /** Gets or sets a boolean indicating if the sprite can be picked */
  90801. isPickable: boolean;
  90802. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90803. useAlphaForPicking: boolean;
  90804. /** @hidden */
  90805. _xOffset: number;
  90806. /** @hidden */
  90807. _yOffset: number;
  90808. /** @hidden */
  90809. _xSize: number;
  90810. /** @hidden */
  90811. _ySize: number;
  90812. /**
  90813. * Gets or sets the associated action manager
  90814. */
  90815. actionManager: Nullable<ActionManager>;
  90816. /**
  90817. * An event triggered when the control has been disposed
  90818. */
  90819. onDisposeObservable: Observable<Sprite>;
  90820. private _animationStarted;
  90821. private _loopAnimation;
  90822. private _fromIndex;
  90823. private _toIndex;
  90824. private _delay;
  90825. private _direction;
  90826. private _manager;
  90827. private _time;
  90828. private _onAnimationEnd;
  90829. /**
  90830. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90831. */
  90832. isVisible: boolean;
  90833. /**
  90834. * Gets or sets the sprite size
  90835. */
  90836. get size(): number;
  90837. set size(value: number);
  90838. /**
  90839. * Returns a boolean indicating if the animation is started
  90840. */
  90841. get animationStarted(): boolean;
  90842. /**
  90843. * Gets or sets the unique id of the sprite
  90844. */
  90845. uniqueId: number;
  90846. /**
  90847. * Gets the manager of this sprite
  90848. */
  90849. get manager(): ISpriteManager;
  90850. /**
  90851. * Creates a new Sprite
  90852. * @param name defines the name
  90853. * @param manager defines the manager
  90854. */
  90855. constructor(
  90856. /** defines the name */
  90857. name: string, manager: ISpriteManager);
  90858. /**
  90859. * Returns the string "Sprite"
  90860. * @returns "Sprite"
  90861. */
  90862. getClassName(): string;
  90863. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90864. get fromIndex(): number;
  90865. set fromIndex(value: number);
  90866. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90867. get toIndex(): number;
  90868. set toIndex(value: number);
  90869. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90870. get loopAnimation(): boolean;
  90871. set loopAnimation(value: boolean);
  90872. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90873. get delay(): number;
  90874. set delay(value: number);
  90875. /**
  90876. * Starts an animation
  90877. * @param from defines the initial key
  90878. * @param to defines the end key
  90879. * @param loop defines if the animation must loop
  90880. * @param delay defines the start delay (in ms)
  90881. * @param onAnimationEnd defines a callback to call when animation ends
  90882. */
  90883. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90884. /** Stops current animation (if any) */
  90885. stopAnimation(): void;
  90886. /** @hidden */
  90887. _animate(deltaTime: number): void;
  90888. /** Release associated resources */
  90889. dispose(): void;
  90890. /**
  90891. * Serializes the sprite to a JSON object
  90892. * @returns the JSON object
  90893. */
  90894. serialize(): any;
  90895. /**
  90896. * Parses a JSON object to create a new sprite
  90897. * @param parsedSprite The JSON object to parse
  90898. * @param manager defines the hosting manager
  90899. * @returns the new sprite
  90900. */
  90901. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90902. }
  90903. }
  90904. declare module BABYLON {
  90905. /**
  90906. * Information about the result of picking within a scene
  90907. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90908. */
  90909. export class PickingInfo {
  90910. /** @hidden */
  90911. _pickingUnavailable: boolean;
  90912. /**
  90913. * If the pick collided with an object
  90914. */
  90915. hit: boolean;
  90916. /**
  90917. * Distance away where the pick collided
  90918. */
  90919. distance: number;
  90920. /**
  90921. * The location of pick collision
  90922. */
  90923. pickedPoint: Nullable<Vector3>;
  90924. /**
  90925. * The mesh corresponding the the pick collision
  90926. */
  90927. pickedMesh: Nullable<AbstractMesh>;
  90928. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90929. bu: number;
  90930. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90931. bv: number;
  90932. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90933. faceId: number;
  90934. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90935. subMeshFaceId: number;
  90936. /** Id of the the submesh that was picked */
  90937. subMeshId: number;
  90938. /** If a sprite was picked, this will be the sprite the pick collided with */
  90939. pickedSprite: Nullable<Sprite>;
  90940. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90941. thinInstanceIndex: number;
  90942. /**
  90943. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90944. */
  90945. originMesh: Nullable<AbstractMesh>;
  90946. /**
  90947. * The ray that was used to perform the picking.
  90948. */
  90949. ray: Nullable<Ray>;
  90950. /**
  90951. * Gets the normal correspodning to the face the pick collided with
  90952. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90953. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90954. * @returns The normal correspodning to the face the pick collided with
  90955. */
  90956. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90957. /**
  90958. * Gets the texture coordinates of where the pick occured
  90959. * @returns the vector containing the coordnates of the texture
  90960. */
  90961. getTextureCoordinates(): Nullable<Vector2>;
  90962. }
  90963. }
  90964. declare module BABYLON {
  90965. /**
  90966. * Class representing a ray with position and direction
  90967. */
  90968. export class Ray {
  90969. /** origin point */
  90970. origin: Vector3;
  90971. /** direction */
  90972. direction: Vector3;
  90973. /** length of the ray */
  90974. length: number;
  90975. private static readonly _TmpVector3;
  90976. private _tmpRay;
  90977. /**
  90978. * Creates a new ray
  90979. * @param origin origin point
  90980. * @param direction direction
  90981. * @param length length of the ray
  90982. */
  90983. constructor(
  90984. /** origin point */
  90985. origin: Vector3,
  90986. /** direction */
  90987. direction: Vector3,
  90988. /** length of the ray */
  90989. length?: number);
  90990. /**
  90991. * Checks if the ray intersects a box
  90992. * This does not account for the ray lenght by design to improve perfs.
  90993. * @param minimum bound of the box
  90994. * @param maximum bound of the box
  90995. * @param intersectionTreshold extra extend to be added to the box in all direction
  90996. * @returns if the box was hit
  90997. */
  90998. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90999. /**
  91000. * Checks if the ray intersects a box
  91001. * This does not account for the ray lenght by design to improve perfs.
  91002. * @param box the bounding box to check
  91003. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91004. * @returns if the box was hit
  91005. */
  91006. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91007. /**
  91008. * If the ray hits a sphere
  91009. * @param sphere the bounding sphere to check
  91010. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91011. * @returns true if it hits the sphere
  91012. */
  91013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91014. /**
  91015. * If the ray hits a triange
  91016. * @param vertex0 triangle vertex
  91017. * @param vertex1 triangle vertex
  91018. * @param vertex2 triangle vertex
  91019. * @returns intersection information if hit
  91020. */
  91021. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91022. /**
  91023. * Checks if ray intersects a plane
  91024. * @param plane the plane to check
  91025. * @returns the distance away it was hit
  91026. */
  91027. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91028. /**
  91029. * Calculate the intercept of a ray on a given axis
  91030. * @param axis to check 'x' | 'y' | 'z'
  91031. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91032. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91033. */
  91034. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91035. /**
  91036. * Checks if ray intersects a mesh
  91037. * @param mesh the mesh to check
  91038. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91039. * @returns picking info of the intersecton
  91040. */
  91041. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91042. /**
  91043. * Checks if ray intersects a mesh
  91044. * @param meshes the meshes to check
  91045. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91046. * @param results array to store result in
  91047. * @returns Array of picking infos
  91048. */
  91049. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91050. private _comparePickingInfo;
  91051. private static smallnum;
  91052. private static rayl;
  91053. /**
  91054. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91055. * @param sega the first point of the segment to test the intersection against
  91056. * @param segb the second point of the segment to test the intersection against
  91057. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91058. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91059. */
  91060. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91061. /**
  91062. * Update the ray from viewport position
  91063. * @param x position
  91064. * @param y y position
  91065. * @param viewportWidth viewport width
  91066. * @param viewportHeight viewport height
  91067. * @param world world matrix
  91068. * @param view view matrix
  91069. * @param projection projection matrix
  91070. * @returns this ray updated
  91071. */
  91072. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91073. /**
  91074. * Creates a ray with origin and direction of 0,0,0
  91075. * @returns the new ray
  91076. */
  91077. static Zero(): Ray;
  91078. /**
  91079. * Creates a new ray from screen space and viewport
  91080. * @param x position
  91081. * @param y y position
  91082. * @param viewportWidth viewport width
  91083. * @param viewportHeight viewport height
  91084. * @param world world matrix
  91085. * @param view view matrix
  91086. * @param projection projection matrix
  91087. * @returns new ray
  91088. */
  91089. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91090. /**
  91091. * 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
  91092. * transformed to the given world matrix.
  91093. * @param origin The origin point
  91094. * @param end The end point
  91095. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91096. * @returns the new ray
  91097. */
  91098. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91099. /**
  91100. * Transforms a ray by a matrix
  91101. * @param ray ray to transform
  91102. * @param matrix matrix to apply
  91103. * @returns the resulting new ray
  91104. */
  91105. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91106. /**
  91107. * Transforms a ray by a matrix
  91108. * @param ray ray to transform
  91109. * @param matrix matrix to apply
  91110. * @param result ray to store result in
  91111. */
  91112. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91113. /**
  91114. * Unproject a ray from screen space to object space
  91115. * @param sourceX defines the screen space x coordinate to use
  91116. * @param sourceY defines the screen space y coordinate to use
  91117. * @param viewportWidth defines the current width of the viewport
  91118. * @param viewportHeight defines the current height of the viewport
  91119. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91120. * @param view defines the view matrix to use
  91121. * @param projection defines the projection matrix to use
  91122. */
  91123. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91124. }
  91125. /**
  91126. * Type used to define predicate used to select faces when a mesh intersection is detected
  91127. */
  91128. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91129. interface Scene {
  91130. /** @hidden */
  91131. _tempPickingRay: Nullable<Ray>;
  91132. /** @hidden */
  91133. _cachedRayForTransform: Ray;
  91134. /** @hidden */
  91135. _pickWithRayInverseMatrix: Matrix;
  91136. /** @hidden */
  91137. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91138. /** @hidden */
  91139. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91140. /** @hidden */
  91141. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91142. }
  91143. }
  91144. declare module BABYLON {
  91145. /**
  91146. * Groups all the scene component constants in one place to ease maintenance.
  91147. * @hidden
  91148. */
  91149. export class SceneComponentConstants {
  91150. static readonly NAME_EFFECTLAYER: string;
  91151. static readonly NAME_LAYER: string;
  91152. static readonly NAME_LENSFLARESYSTEM: string;
  91153. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91154. static readonly NAME_PARTICLESYSTEM: string;
  91155. static readonly NAME_GAMEPAD: string;
  91156. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91157. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91158. static readonly NAME_PREPASSRENDERER: string;
  91159. static readonly NAME_DEPTHRENDERER: string;
  91160. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91161. static readonly NAME_SPRITE: string;
  91162. static readonly NAME_SUBSURFACE: string;
  91163. static readonly NAME_OUTLINERENDERER: string;
  91164. static readonly NAME_PROCEDURALTEXTURE: string;
  91165. static readonly NAME_SHADOWGENERATOR: string;
  91166. static readonly NAME_OCTREE: string;
  91167. static readonly NAME_PHYSICSENGINE: string;
  91168. static readonly NAME_AUDIO: string;
  91169. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91170. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91171. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91172. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91173. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91174. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91175. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91176. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91177. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91178. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91179. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91180. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91181. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91182. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91183. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91184. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91185. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91186. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91187. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91188. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91189. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91190. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91191. static readonly STEP_AFTERRENDER_AUDIO: number;
  91192. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91193. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91194. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91195. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91196. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91197. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91198. static readonly STEP_POINTERMOVE_SPRITE: number;
  91199. static readonly STEP_POINTERDOWN_SPRITE: number;
  91200. static readonly STEP_POINTERUP_SPRITE: number;
  91201. }
  91202. /**
  91203. * This represents a scene component.
  91204. *
  91205. * This is used to decouple the dependency the scene is having on the different workloads like
  91206. * layers, post processes...
  91207. */
  91208. export interface ISceneComponent {
  91209. /**
  91210. * The name of the component. Each component must have a unique name.
  91211. */
  91212. name: string;
  91213. /**
  91214. * The scene the component belongs to.
  91215. */
  91216. scene: Scene;
  91217. /**
  91218. * Register the component to one instance of a scene.
  91219. */
  91220. register(): void;
  91221. /**
  91222. * Rebuilds the elements related to this component in case of
  91223. * context lost for instance.
  91224. */
  91225. rebuild(): void;
  91226. /**
  91227. * Disposes the component and the associated ressources.
  91228. */
  91229. dispose(): void;
  91230. }
  91231. /**
  91232. * This represents a SERIALIZABLE scene component.
  91233. *
  91234. * This extends Scene Component to add Serialization methods on top.
  91235. */
  91236. export interface ISceneSerializableComponent extends ISceneComponent {
  91237. /**
  91238. * Adds all the elements from the container to the scene
  91239. * @param container the container holding the elements
  91240. */
  91241. addFromContainer(container: AbstractScene): void;
  91242. /**
  91243. * Removes all the elements in the container from the scene
  91244. * @param container contains the elements to remove
  91245. * @param dispose if the removed element should be disposed (default: false)
  91246. */
  91247. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91248. /**
  91249. * Serializes the component data to the specified json object
  91250. * @param serializationObject The object to serialize to
  91251. */
  91252. serialize(serializationObject: any): void;
  91253. }
  91254. /**
  91255. * Strong typing of a Mesh related stage step action
  91256. */
  91257. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91258. /**
  91259. * Strong typing of a Evaluate Sub Mesh related stage step action
  91260. */
  91261. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91262. /**
  91263. * Strong typing of a Active Mesh related stage step action
  91264. */
  91265. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91266. /**
  91267. * Strong typing of a Camera related stage step action
  91268. */
  91269. export type CameraStageAction = (camera: Camera) => void;
  91270. /**
  91271. * Strong typing of a Camera Frame buffer related stage step action
  91272. */
  91273. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91274. /**
  91275. * Strong typing of a Render Target related stage step action
  91276. */
  91277. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91278. /**
  91279. * Strong typing of a RenderingGroup related stage step action
  91280. */
  91281. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91282. /**
  91283. * Strong typing of a Mesh Render related stage step action
  91284. */
  91285. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91286. /**
  91287. * Strong typing of a simple stage step action
  91288. */
  91289. export type SimpleStageAction = () => void;
  91290. /**
  91291. * Strong typing of a render target action.
  91292. */
  91293. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91294. /**
  91295. * Strong typing of a pointer move action.
  91296. */
  91297. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91298. /**
  91299. * Strong typing of a pointer up/down action.
  91300. */
  91301. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91302. /**
  91303. * Representation of a stage in the scene (Basically a list of ordered steps)
  91304. * @hidden
  91305. */
  91306. export class Stage<T extends Function> extends Array<{
  91307. index: number;
  91308. component: ISceneComponent;
  91309. action: T;
  91310. }> {
  91311. /**
  91312. * Hide ctor from the rest of the world.
  91313. * @param items The items to add.
  91314. */
  91315. private constructor();
  91316. /**
  91317. * Creates a new Stage.
  91318. * @returns A new instance of a Stage
  91319. */
  91320. static Create<T extends Function>(): Stage<T>;
  91321. /**
  91322. * Registers a step in an ordered way in the targeted stage.
  91323. * @param index Defines the position to register the step in
  91324. * @param component Defines the component attached to the step
  91325. * @param action Defines the action to launch during the step
  91326. */
  91327. registerStep(index: number, component: ISceneComponent, action: T): void;
  91328. /**
  91329. * Clears all the steps from the stage.
  91330. */
  91331. clear(): void;
  91332. }
  91333. }
  91334. declare module BABYLON {
  91335. interface Scene {
  91336. /** @hidden */
  91337. _pointerOverSprite: Nullable<Sprite>;
  91338. /** @hidden */
  91339. _pickedDownSprite: Nullable<Sprite>;
  91340. /** @hidden */
  91341. _tempSpritePickingRay: Nullable<Ray>;
  91342. /**
  91343. * All of the sprite managers added to this scene
  91344. * @see https://doc.babylonjs.com/babylon101/sprites
  91345. */
  91346. spriteManagers: Array<ISpriteManager>;
  91347. /**
  91348. * An event triggered when sprites rendering is about to start
  91349. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91350. */
  91351. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91352. /**
  91353. * An event triggered when sprites rendering is done
  91354. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91355. */
  91356. onAfterSpritesRenderingObservable: Observable<Scene>;
  91357. /** @hidden */
  91358. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91359. /** Launch a ray to try to pick a sprite in the scene
  91360. * @param x position on screen
  91361. * @param y position on screen
  91362. * @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
  91363. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91364. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91365. * @returns a PickingInfo
  91366. */
  91367. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91368. /** Use the given ray to pick a sprite in the scene
  91369. * @param ray The ray (in world space) to use to pick meshes
  91370. * @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
  91371. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91372. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91373. * @returns a PickingInfo
  91374. */
  91375. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91376. /** @hidden */
  91377. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91378. /** Launch a ray to try to pick sprites in the scene
  91379. * @param x position on screen
  91380. * @param y position on screen
  91381. * @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
  91382. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91383. * @returns a PickingInfo array
  91384. */
  91385. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91386. /** Use the given ray to pick sprites in the scene
  91387. * @param ray The ray (in world space) to use to pick meshes
  91388. * @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
  91389. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91390. * @returns a PickingInfo array
  91391. */
  91392. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91393. /**
  91394. * Force the sprite under the pointer
  91395. * @param sprite defines the sprite to use
  91396. */
  91397. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91398. /**
  91399. * Gets the sprite under the pointer
  91400. * @returns a Sprite or null if no sprite is under the pointer
  91401. */
  91402. getPointerOverSprite(): Nullable<Sprite>;
  91403. }
  91404. /**
  91405. * Defines the sprite scene component responsible to manage sprites
  91406. * in a given scene.
  91407. */
  91408. export class SpriteSceneComponent implements ISceneComponent {
  91409. /**
  91410. * The component name helpfull to identify the component in the list of scene components.
  91411. */
  91412. readonly name: string;
  91413. /**
  91414. * The scene the component belongs to.
  91415. */
  91416. scene: Scene;
  91417. /** @hidden */
  91418. private _spritePredicate;
  91419. /**
  91420. * Creates a new instance of the component for the given scene
  91421. * @param scene Defines the scene to register the component in
  91422. */
  91423. constructor(scene: Scene);
  91424. /**
  91425. * Registers the component in a given scene
  91426. */
  91427. register(): void;
  91428. /**
  91429. * Rebuilds the elements related to this component in case of
  91430. * context lost for instance.
  91431. */
  91432. rebuild(): void;
  91433. /**
  91434. * Disposes the component and the associated ressources.
  91435. */
  91436. dispose(): void;
  91437. private _pickSpriteButKeepRay;
  91438. private _pointerMove;
  91439. private _pointerDown;
  91440. private _pointerUp;
  91441. }
  91442. }
  91443. declare module BABYLON {
  91444. /** @hidden */
  91445. export var fogFragmentDeclaration: {
  91446. name: string;
  91447. shader: string;
  91448. };
  91449. }
  91450. declare module BABYLON {
  91451. /** @hidden */
  91452. export var fogFragment: {
  91453. name: string;
  91454. shader: string;
  91455. };
  91456. }
  91457. declare module BABYLON {
  91458. /** @hidden */
  91459. export var spritesPixelShader: {
  91460. name: string;
  91461. shader: string;
  91462. };
  91463. }
  91464. declare module BABYLON {
  91465. /** @hidden */
  91466. export var fogVertexDeclaration: {
  91467. name: string;
  91468. shader: string;
  91469. };
  91470. }
  91471. declare module BABYLON {
  91472. /** @hidden */
  91473. export var spritesVertexShader: {
  91474. name: string;
  91475. shader: string;
  91476. };
  91477. }
  91478. declare module BABYLON {
  91479. /**
  91480. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91481. */
  91482. export interface ISpriteManager extends IDisposable {
  91483. /**
  91484. * Gets manager's name
  91485. */
  91486. name: string;
  91487. /**
  91488. * Restricts the camera to viewing objects with the same layerMask.
  91489. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91490. */
  91491. layerMask: number;
  91492. /**
  91493. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91494. */
  91495. isPickable: boolean;
  91496. /**
  91497. * Gets the hosting scene
  91498. */
  91499. scene: Scene;
  91500. /**
  91501. * Specifies the rendering group id for this mesh (0 by default)
  91502. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91503. */
  91504. renderingGroupId: number;
  91505. /**
  91506. * Defines the list of sprites managed by the manager.
  91507. */
  91508. sprites: Array<Sprite>;
  91509. /**
  91510. * Gets or sets the spritesheet texture
  91511. */
  91512. texture: Texture;
  91513. /** Defines the default width of a cell in the spritesheet */
  91514. cellWidth: number;
  91515. /** Defines the default height of a cell in the spritesheet */
  91516. cellHeight: number;
  91517. /**
  91518. * Tests the intersection of a sprite with a specific ray.
  91519. * @param ray The ray we are sending to test the collision
  91520. * @param camera The camera space we are sending rays in
  91521. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91522. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91523. * @returns picking info or null.
  91524. */
  91525. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91526. /**
  91527. * Intersects the sprites with a ray
  91528. * @param ray defines the ray to intersect with
  91529. * @param camera defines the current active camera
  91530. * @param predicate defines a predicate used to select candidate sprites
  91531. * @returns null if no hit or a PickingInfo array
  91532. */
  91533. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91534. /**
  91535. * Renders the list of sprites on screen.
  91536. */
  91537. render(): void;
  91538. }
  91539. /**
  91540. * Class used to manage multiple sprites on the same spritesheet
  91541. * @see https://doc.babylonjs.com/babylon101/sprites
  91542. */
  91543. export class SpriteManager implements ISpriteManager {
  91544. /** defines the manager's name */
  91545. name: string;
  91546. /** Define the Url to load snippets */
  91547. static SnippetUrl: string;
  91548. /** Snippet ID if the manager was created from the snippet server */
  91549. snippetId: string;
  91550. /** Gets the list of sprites */
  91551. sprites: Sprite[];
  91552. /** Gets or sets the rendering group id (0 by default) */
  91553. renderingGroupId: number;
  91554. /** Gets or sets camera layer mask */
  91555. layerMask: number;
  91556. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91557. fogEnabled: boolean;
  91558. /** Gets or sets a boolean indicating if the sprites are pickable */
  91559. isPickable: boolean;
  91560. /** Defines the default width of a cell in the spritesheet */
  91561. cellWidth: number;
  91562. /** Defines the default height of a cell in the spritesheet */
  91563. cellHeight: number;
  91564. /** Associative array from JSON sprite data file */
  91565. private _cellData;
  91566. /** Array of sprite names from JSON sprite data file */
  91567. private _spriteMap;
  91568. /** True when packed cell data from JSON file is ready*/
  91569. private _packedAndReady;
  91570. private _textureContent;
  91571. private _useInstancing;
  91572. /**
  91573. * An event triggered when the manager is disposed.
  91574. */
  91575. onDisposeObservable: Observable<SpriteManager>;
  91576. private _onDisposeObserver;
  91577. /**
  91578. * Callback called when the manager is disposed
  91579. */
  91580. set onDispose(callback: () => void);
  91581. private _capacity;
  91582. private _fromPacked;
  91583. private _spriteTexture;
  91584. private _epsilon;
  91585. private _scene;
  91586. private _vertexData;
  91587. private _buffer;
  91588. private _vertexBuffers;
  91589. private _spriteBuffer;
  91590. private _indexBuffer;
  91591. private _effectBase;
  91592. private _effectFog;
  91593. private _vertexBufferSize;
  91594. /**
  91595. * Gets or sets the unique id of the sprite
  91596. */
  91597. uniqueId: number;
  91598. /**
  91599. * Gets the array of sprites
  91600. */
  91601. get children(): Sprite[];
  91602. /**
  91603. * Gets the hosting scene
  91604. */
  91605. get scene(): Scene;
  91606. /**
  91607. * Gets the capacity of the manager
  91608. */
  91609. get capacity(): number;
  91610. /**
  91611. * Gets or sets the spritesheet texture
  91612. */
  91613. get texture(): Texture;
  91614. set texture(value: Texture);
  91615. private _blendMode;
  91616. /**
  91617. * Blend mode use to render the particle, it can be any of
  91618. * the static Constants.ALPHA_x properties provided in this class.
  91619. * Default value is Constants.ALPHA_COMBINE
  91620. */
  91621. get blendMode(): number;
  91622. set blendMode(blendMode: number);
  91623. /** Disables writing to the depth buffer when rendering the sprites.
  91624. * It can be handy to disable depth writing when using textures without alpha channel
  91625. * and setting some specific blend modes.
  91626. */
  91627. disableDepthWrite: boolean;
  91628. /**
  91629. * Creates a new sprite manager
  91630. * @param name defines the manager's name
  91631. * @param imgUrl defines the sprite sheet url
  91632. * @param capacity defines the maximum allowed number of sprites
  91633. * @param cellSize defines the size of a sprite cell
  91634. * @param scene defines the hosting scene
  91635. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91636. * @param samplingMode defines the smapling mode to use with spritesheet
  91637. * @param fromPacked set to false; do not alter
  91638. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91639. */
  91640. constructor(
  91641. /** defines the manager's name */
  91642. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91643. /**
  91644. * Returns the string "SpriteManager"
  91645. * @returns "SpriteManager"
  91646. */
  91647. getClassName(): string;
  91648. private _makePacked;
  91649. private _appendSpriteVertex;
  91650. private _checkTextureAlpha;
  91651. /**
  91652. * Intersects the sprites with a ray
  91653. * @param ray defines the ray to intersect with
  91654. * @param camera defines the current active camera
  91655. * @param predicate defines a predicate used to select candidate sprites
  91656. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91657. * @returns null if no hit or a PickingInfo
  91658. */
  91659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91660. /**
  91661. * Intersects the sprites with a ray
  91662. * @param ray defines the ray to intersect with
  91663. * @param camera defines the current active camera
  91664. * @param predicate defines a predicate used to select candidate sprites
  91665. * @returns null if no hit or a PickingInfo array
  91666. */
  91667. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91668. /**
  91669. * Render all child sprites
  91670. */
  91671. render(): void;
  91672. /**
  91673. * Release associated resources
  91674. */
  91675. dispose(): void;
  91676. /**
  91677. * Serializes the sprite manager to a JSON object
  91678. * @param serializeTexture defines if the texture must be serialized as well
  91679. * @returns the JSON object
  91680. */
  91681. serialize(serializeTexture?: boolean): any;
  91682. /**
  91683. * Parses a JSON object to create a new sprite manager.
  91684. * @param parsedManager The JSON object to parse
  91685. * @param scene The scene to create the sprite managerin
  91686. * @param rootUrl The root url to use to load external dependencies like texture
  91687. * @returns the new sprite manager
  91688. */
  91689. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91690. /**
  91691. * Creates a sprite manager from a snippet saved in a remote file
  91692. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91693. * @param url defines the url to load from
  91694. * @param scene defines the hosting scene
  91695. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91696. * @returns a promise that will resolve to the new sprite manager
  91697. */
  91698. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91699. /**
  91700. * Creates a sprite manager from a snippet saved by the sprite editor
  91701. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91702. * @param scene defines the hosting scene
  91703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91704. * @returns a promise that will resolve to the new sprite manager
  91705. */
  91706. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91707. }
  91708. }
  91709. declare module BABYLON {
  91710. /** Interface used by value gradients (color, factor, ...) */
  91711. export interface IValueGradient {
  91712. /**
  91713. * Gets or sets the gradient value (between 0 and 1)
  91714. */
  91715. gradient: number;
  91716. }
  91717. /** Class used to store color4 gradient */
  91718. export class ColorGradient implements IValueGradient {
  91719. /**
  91720. * Gets or sets the gradient value (between 0 and 1)
  91721. */
  91722. gradient: number;
  91723. /**
  91724. * Gets or sets first associated color
  91725. */
  91726. color1: Color4;
  91727. /**
  91728. * Gets or sets second associated color
  91729. */
  91730. color2?: Color4 | undefined;
  91731. /**
  91732. * Creates a new color4 gradient
  91733. * @param gradient gets or sets the gradient value (between 0 and 1)
  91734. * @param color1 gets or sets first associated color
  91735. * @param color2 gets or sets first second color
  91736. */
  91737. constructor(
  91738. /**
  91739. * Gets or sets the gradient value (between 0 and 1)
  91740. */
  91741. gradient: number,
  91742. /**
  91743. * Gets or sets first associated color
  91744. */
  91745. color1: Color4,
  91746. /**
  91747. * Gets or sets second associated color
  91748. */
  91749. color2?: Color4 | undefined);
  91750. /**
  91751. * Will get a color picked randomly between color1 and color2.
  91752. * If color2 is undefined then color1 will be used
  91753. * @param result defines the target Color4 to store the result in
  91754. */
  91755. getColorToRef(result: Color4): void;
  91756. }
  91757. /** Class used to store color 3 gradient */
  91758. export class Color3Gradient implements IValueGradient {
  91759. /**
  91760. * Gets or sets the gradient value (between 0 and 1)
  91761. */
  91762. gradient: number;
  91763. /**
  91764. * Gets or sets the associated color
  91765. */
  91766. color: Color3;
  91767. /**
  91768. * Creates a new color3 gradient
  91769. * @param gradient gets or sets the gradient value (between 0 and 1)
  91770. * @param color gets or sets associated color
  91771. */
  91772. constructor(
  91773. /**
  91774. * Gets or sets the gradient value (between 0 and 1)
  91775. */
  91776. gradient: number,
  91777. /**
  91778. * Gets or sets the associated color
  91779. */
  91780. color: Color3);
  91781. }
  91782. /** Class used to store factor gradient */
  91783. export class FactorGradient implements IValueGradient {
  91784. /**
  91785. * Gets or sets the gradient value (between 0 and 1)
  91786. */
  91787. gradient: number;
  91788. /**
  91789. * Gets or sets first associated factor
  91790. */
  91791. factor1: number;
  91792. /**
  91793. * Gets or sets second associated factor
  91794. */
  91795. factor2?: number | undefined;
  91796. /**
  91797. * Creates a new factor gradient
  91798. * @param gradient gets or sets the gradient value (between 0 and 1)
  91799. * @param factor1 gets or sets first associated factor
  91800. * @param factor2 gets or sets second associated factor
  91801. */
  91802. constructor(
  91803. /**
  91804. * Gets or sets the gradient value (between 0 and 1)
  91805. */
  91806. gradient: number,
  91807. /**
  91808. * Gets or sets first associated factor
  91809. */
  91810. factor1: number,
  91811. /**
  91812. * Gets or sets second associated factor
  91813. */
  91814. factor2?: number | undefined);
  91815. /**
  91816. * Will get a number picked randomly between factor1 and factor2.
  91817. * If factor2 is undefined then factor1 will be used
  91818. * @returns the picked number
  91819. */
  91820. getFactor(): number;
  91821. }
  91822. /**
  91823. * Helper used to simplify some generic gradient tasks
  91824. */
  91825. export class GradientHelper {
  91826. /**
  91827. * Gets the current gradient from an array of IValueGradient
  91828. * @param ratio defines the current ratio to get
  91829. * @param gradients defines the array of IValueGradient
  91830. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91831. */
  91832. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91833. }
  91834. }
  91835. declare module BABYLON {
  91836. interface ThinEngine {
  91837. /**
  91838. * Creates a raw texture
  91839. * @param data defines the data to store in the texture
  91840. * @param width defines the width of the texture
  91841. * @param height defines the height of the texture
  91842. * @param format defines the format of the data
  91843. * @param generateMipMaps defines if the engine should generate the mip levels
  91844. * @param invertY defines if data must be stored with Y axis inverted
  91845. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91846. * @param compression defines the compression used (null by default)
  91847. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91848. * @returns the raw texture inside an InternalTexture
  91849. */
  91850. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91851. /**
  91852. * Update a raw texture
  91853. * @param texture defines the texture to update
  91854. * @param data defines the data to store in the texture
  91855. * @param format defines the format of the data
  91856. * @param invertY defines if data must be stored with Y axis inverted
  91857. */
  91858. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91859. /**
  91860. * Update a raw texture
  91861. * @param texture defines the texture to update
  91862. * @param data defines the data to store in the texture
  91863. * @param format defines the format of the data
  91864. * @param invertY defines if data must be stored with Y axis inverted
  91865. * @param compression defines the compression used (null by default)
  91866. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91867. */
  91868. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91869. /**
  91870. * Creates a new raw cube texture
  91871. * @param data defines the array of data to use to create each face
  91872. * @param size defines the size of the textures
  91873. * @param format defines the format of the data
  91874. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91875. * @param generateMipMaps defines if the engine should generate the mip levels
  91876. * @param invertY defines if data must be stored with Y axis inverted
  91877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91878. * @param compression defines the compression used (null by default)
  91879. * @returns the cube texture as an InternalTexture
  91880. */
  91881. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91882. /**
  91883. * Update a raw cube texture
  91884. * @param texture defines the texture to udpdate
  91885. * @param data defines the data to store
  91886. * @param format defines the data format
  91887. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91888. * @param invertY defines if data must be stored with Y axis inverted
  91889. */
  91890. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91891. /**
  91892. * Update a raw cube texture
  91893. * @param texture defines the texture to udpdate
  91894. * @param data defines the data to store
  91895. * @param format defines the data format
  91896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91897. * @param invertY defines if data must be stored with Y axis inverted
  91898. * @param compression defines the compression used (null by default)
  91899. */
  91900. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91901. /**
  91902. * Update a raw cube texture
  91903. * @param texture defines the texture to udpdate
  91904. * @param data defines the data to store
  91905. * @param format defines the data format
  91906. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91907. * @param invertY defines if data must be stored with Y axis inverted
  91908. * @param compression defines the compression used (null by default)
  91909. * @param level defines which level of the texture to update
  91910. */
  91911. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91912. /**
  91913. * Creates a new raw cube texture from a specified url
  91914. * @param url defines the url where the data is located
  91915. * @param scene defines the current scene
  91916. * @param size defines the size of the textures
  91917. * @param format defines the format of the data
  91918. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91919. * @param noMipmap defines if the engine should avoid generating the mip levels
  91920. * @param callback defines a callback used to extract texture data from loaded data
  91921. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91922. * @param onLoad defines a callback called when texture is loaded
  91923. * @param onError defines a callback called if there is an error
  91924. * @returns the cube texture as an InternalTexture
  91925. */
  91926. 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;
  91927. /**
  91928. * Creates a new raw cube texture from a specified url
  91929. * @param url defines the url where the data is located
  91930. * @param scene defines the current scene
  91931. * @param size defines the size of the textures
  91932. * @param format defines the format of the data
  91933. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91934. * @param noMipmap defines if the engine should avoid generating the mip levels
  91935. * @param callback defines a callback used to extract texture data from loaded data
  91936. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91937. * @param onLoad defines a callback called when texture is loaded
  91938. * @param onError defines a callback called if there is an error
  91939. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91940. * @param invertY defines if data must be stored with Y axis inverted
  91941. * @returns the cube texture as an InternalTexture
  91942. */
  91943. 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;
  91944. /**
  91945. * Creates a new raw 3D texture
  91946. * @param data defines the data used to create the texture
  91947. * @param width defines the width of the texture
  91948. * @param height defines the height of the texture
  91949. * @param depth defines the depth of the texture
  91950. * @param format defines the format of the texture
  91951. * @param generateMipMaps defines if the engine must generate mip levels
  91952. * @param invertY defines if data must be stored with Y axis inverted
  91953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91954. * @param compression defines the compressed used (can be null)
  91955. * @param textureType defines the compressed used (can be null)
  91956. * @returns a new raw 3D texture (stored in an InternalTexture)
  91957. */
  91958. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91959. /**
  91960. * Update a raw 3D texture
  91961. * @param texture defines the texture to update
  91962. * @param data defines the data to store
  91963. * @param format defines the data format
  91964. * @param invertY defines if data must be stored with Y axis inverted
  91965. */
  91966. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91967. /**
  91968. * Update a raw 3D texture
  91969. * @param texture defines the texture to update
  91970. * @param data defines the data to store
  91971. * @param format defines the data format
  91972. * @param invertY defines if data must be stored with Y axis inverted
  91973. * @param compression defines the used compression (can be null)
  91974. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91975. */
  91976. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91977. /**
  91978. * Creates a new raw 2D array texture
  91979. * @param data defines the data used to create the texture
  91980. * @param width defines the width of the texture
  91981. * @param height defines the height of the texture
  91982. * @param depth defines the number of layers of the texture
  91983. * @param format defines the format of the texture
  91984. * @param generateMipMaps defines if the engine must generate mip levels
  91985. * @param invertY defines if data must be stored with Y axis inverted
  91986. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91987. * @param compression defines the compressed used (can be null)
  91988. * @param textureType defines the compressed used (can be null)
  91989. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91990. */
  91991. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91992. /**
  91993. * Update a raw 2D array texture
  91994. * @param texture defines the texture to update
  91995. * @param data defines the data to store
  91996. * @param format defines the data format
  91997. * @param invertY defines if data must be stored with Y axis inverted
  91998. */
  91999. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92000. /**
  92001. * Update a raw 2D array texture
  92002. * @param texture defines the texture to update
  92003. * @param data defines the data to store
  92004. * @param format defines the data format
  92005. * @param invertY defines if data must be stored with Y axis inverted
  92006. * @param compression defines the used compression (can be null)
  92007. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92008. */
  92009. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92010. }
  92011. }
  92012. declare module BABYLON {
  92013. /**
  92014. * Raw texture can help creating a texture directly from an array of data.
  92015. * This can be super useful if you either get the data from an uncompressed source or
  92016. * if you wish to create your texture pixel by pixel.
  92017. */
  92018. export class RawTexture extends Texture {
  92019. /**
  92020. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92021. */
  92022. format: number;
  92023. /**
  92024. * Instantiates a new RawTexture.
  92025. * Raw texture can help creating a texture directly from an array of data.
  92026. * This can be super useful if you either get the data from an uncompressed source or
  92027. * if you wish to create your texture pixel by pixel.
  92028. * @param data define the array of data to use to create the texture
  92029. * @param width define the width of the texture
  92030. * @param height define the height of the texture
  92031. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92032. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92033. * @param generateMipMaps define whether mip maps should be generated or not
  92034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92036. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92037. */
  92038. constructor(data: ArrayBufferView, width: number, height: number,
  92039. /**
  92040. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92041. */
  92042. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92043. /**
  92044. * Updates the texture underlying data.
  92045. * @param data Define the new data of the texture
  92046. */
  92047. update(data: ArrayBufferView): void;
  92048. /**
  92049. * Creates a luminance texture from some data.
  92050. * @param data Define the texture data
  92051. * @param width Define the width of the texture
  92052. * @param height Define the height of the texture
  92053. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92057. * @returns the luminance texture
  92058. */
  92059. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92060. /**
  92061. * Creates a luminance alpha texture from some data.
  92062. * @param data Define the texture data
  92063. * @param width Define the width of the texture
  92064. * @param height Define the height of the texture
  92065. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92066. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92067. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92068. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92069. * @returns the luminance alpha texture
  92070. */
  92071. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92072. /**
  92073. * Creates an alpha texture from some data.
  92074. * @param data Define the texture data
  92075. * @param width Define the width of the texture
  92076. * @param height Define the height of the texture
  92077. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92078. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92079. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92080. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92081. * @returns the alpha texture
  92082. */
  92083. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92084. /**
  92085. * Creates a RGB texture from some data.
  92086. * @param data Define the texture data
  92087. * @param width Define the width of the texture
  92088. * @param height Define the height of the texture
  92089. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92090. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92091. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92092. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92093. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92094. * @returns the RGB alpha texture
  92095. */
  92096. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92097. /**
  92098. * Creates a RGBA texture from some data.
  92099. * @param data Define the texture data
  92100. * @param width Define the width of the texture
  92101. * @param height Define the height of the texture
  92102. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92103. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92104. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92105. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92106. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92107. * @returns the RGBA texture
  92108. */
  92109. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92110. /**
  92111. * Creates a R texture from some data.
  92112. * @param data Define the texture data
  92113. * @param width Define the width of the texture
  92114. * @param height Define the height of the texture
  92115. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92116. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92117. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92118. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92119. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92120. * @returns the R texture
  92121. */
  92122. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92123. }
  92124. }
  92125. declare module BABYLON {
  92126. interface ThinEngine {
  92127. /**
  92128. * Update a dynamic index buffer
  92129. * @param indexBuffer defines the target index buffer
  92130. * @param indices defines the data to update
  92131. * @param offset defines the offset in the target index buffer where update should start
  92132. */
  92133. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92134. /**
  92135. * Updates a dynamic vertex buffer.
  92136. * @param vertexBuffer the vertex buffer to update
  92137. * @param data the data used to update the vertex buffer
  92138. * @param byteOffset the byte offset of the data
  92139. * @param byteLength the byte length of the data
  92140. */
  92141. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92142. }
  92143. }
  92144. declare module BABYLON {
  92145. interface AbstractScene {
  92146. /**
  92147. * The list of procedural textures added to the scene
  92148. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92149. */
  92150. proceduralTextures: Array<ProceduralTexture>;
  92151. }
  92152. /**
  92153. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92154. * in a given scene.
  92155. */
  92156. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92157. /**
  92158. * The component name helpfull to identify the component in the list of scene components.
  92159. */
  92160. readonly name: string;
  92161. /**
  92162. * The scene the component belongs to.
  92163. */
  92164. scene: Scene;
  92165. /**
  92166. * Creates a new instance of the component for the given scene
  92167. * @param scene Defines the scene to register the component in
  92168. */
  92169. constructor(scene: Scene);
  92170. /**
  92171. * Registers the component in a given scene
  92172. */
  92173. register(): void;
  92174. /**
  92175. * Rebuilds the elements related to this component in case of
  92176. * context lost for instance.
  92177. */
  92178. rebuild(): void;
  92179. /**
  92180. * Disposes the component and the associated ressources.
  92181. */
  92182. dispose(): void;
  92183. private _beforeClear;
  92184. }
  92185. }
  92186. declare module BABYLON {
  92187. interface ThinEngine {
  92188. /**
  92189. * Creates a new render target cube texture
  92190. * @param size defines the size of the texture
  92191. * @param options defines the options used to create the texture
  92192. * @returns a new render target cube texture stored in an InternalTexture
  92193. */
  92194. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92195. }
  92196. }
  92197. declare module BABYLON {
  92198. /** @hidden */
  92199. export var proceduralVertexShader: {
  92200. name: string;
  92201. shader: string;
  92202. };
  92203. }
  92204. declare module BABYLON {
  92205. /**
  92206. * 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.
  92207. * This is the base class of any Procedural texture and contains most of the shareable code.
  92208. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92209. */
  92210. export class ProceduralTexture extends Texture {
  92211. /**
  92212. * Define if the texture is enabled or not (disabled texture will not render)
  92213. */
  92214. isEnabled: boolean;
  92215. /**
  92216. * Define if the texture must be cleared before rendering (default is true)
  92217. */
  92218. autoClear: boolean;
  92219. /**
  92220. * Callback called when the texture is generated
  92221. */
  92222. onGenerated: () => void;
  92223. /**
  92224. * Event raised when the texture is generated
  92225. */
  92226. onGeneratedObservable: Observable<ProceduralTexture>;
  92227. /**
  92228. * Event raised before the texture is generated
  92229. */
  92230. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92231. /**
  92232. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92233. */
  92234. nodeMaterialSource: Nullable<NodeMaterial>;
  92235. /** @hidden */
  92236. _generateMipMaps: boolean;
  92237. /** @hidden **/
  92238. _effect: Effect;
  92239. /** @hidden */
  92240. _textures: {
  92241. [key: string]: Texture;
  92242. };
  92243. /** @hidden */
  92244. protected _fallbackTexture: Nullable<Texture>;
  92245. private _size;
  92246. private _currentRefreshId;
  92247. private _frameId;
  92248. private _refreshRate;
  92249. private _vertexBuffers;
  92250. private _indexBuffer;
  92251. private _uniforms;
  92252. private _samplers;
  92253. private _fragment;
  92254. private _floats;
  92255. private _ints;
  92256. private _floatsArrays;
  92257. private _colors3;
  92258. private _colors4;
  92259. private _vectors2;
  92260. private _vectors3;
  92261. private _matrices;
  92262. private _fallbackTextureUsed;
  92263. private _fullEngine;
  92264. private _cachedDefines;
  92265. private _contentUpdateId;
  92266. private _contentData;
  92267. /**
  92268. * Instantiates a new procedural texture.
  92269. * 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.
  92270. * This is the base class of any Procedural texture and contains most of the shareable code.
  92271. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92272. * @param name Define the name of the texture
  92273. * @param size Define the size of the texture to create
  92274. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92275. * @param scene Define the scene the texture belongs to
  92276. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92277. * @param generateMipMaps Define if the texture should creates mip maps or not
  92278. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92279. */
  92280. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92281. /**
  92282. * The effect that is created when initializing the post process.
  92283. * @returns The created effect corresponding the the postprocess.
  92284. */
  92285. getEffect(): Effect;
  92286. /**
  92287. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92288. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92289. */
  92290. getContent(): Nullable<ArrayBufferView>;
  92291. private _createIndexBuffer;
  92292. /** @hidden */
  92293. _rebuild(): void;
  92294. /**
  92295. * Resets the texture in order to recreate its associated resources.
  92296. * This can be called in case of context loss
  92297. */
  92298. reset(): void;
  92299. protected _getDefines(): string;
  92300. /**
  92301. * Is the texture ready to be used ? (rendered at least once)
  92302. * @returns true if ready, otherwise, false.
  92303. */
  92304. isReady(): boolean;
  92305. /**
  92306. * Resets the refresh counter of the texture and start bak from scratch.
  92307. * Could be useful to regenerate the texture if it is setup to render only once.
  92308. */
  92309. resetRefreshCounter(): void;
  92310. /**
  92311. * Set the fragment shader to use in order to render the texture.
  92312. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92313. */
  92314. setFragment(fragment: any): void;
  92315. /**
  92316. * Define the refresh rate of the texture or the rendering frequency.
  92317. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92318. */
  92319. get refreshRate(): number;
  92320. set refreshRate(value: number);
  92321. /** @hidden */
  92322. _shouldRender(): boolean;
  92323. /**
  92324. * Get the size the texture is rendering at.
  92325. * @returns the size (on cube texture it is always squared)
  92326. */
  92327. getRenderSize(): RenderTargetTextureSize;
  92328. /**
  92329. * Resize the texture to new value.
  92330. * @param size Define the new size the texture should have
  92331. * @param generateMipMaps Define whether the new texture should create mip maps
  92332. */
  92333. resize(size: number, generateMipMaps: boolean): void;
  92334. private _checkUniform;
  92335. /**
  92336. * Set a texture in the shader program used to render.
  92337. * @param name Define the name of the uniform samplers as defined in the shader
  92338. * @param texture Define the texture to bind to this sampler
  92339. * @return the texture itself allowing "fluent" like uniform updates
  92340. */
  92341. setTexture(name: string, texture: Texture): ProceduralTexture;
  92342. /**
  92343. * Set a float in the shader.
  92344. * @param name Define the name of the uniform as defined in the shader
  92345. * @param value Define the value to give to the uniform
  92346. * @return the texture itself allowing "fluent" like uniform updates
  92347. */
  92348. setFloat(name: string, value: number): ProceduralTexture;
  92349. /**
  92350. * Set a int in the shader.
  92351. * @param name Define the name of the uniform as defined in the shader
  92352. * @param value Define the value to give to the uniform
  92353. * @return the texture itself allowing "fluent" like uniform updates
  92354. */
  92355. setInt(name: string, value: number): ProceduralTexture;
  92356. /**
  92357. * Set an array of floats in the shader.
  92358. * @param name Define the name of the uniform as defined in the shader
  92359. * @param value Define the value to give to the uniform
  92360. * @return the texture itself allowing "fluent" like uniform updates
  92361. */
  92362. setFloats(name: string, value: number[]): ProceduralTexture;
  92363. /**
  92364. * Set a vec3 in the shader from a Color3.
  92365. * @param name Define the name of the uniform as defined in the shader
  92366. * @param value Define the value to give to the uniform
  92367. * @return the texture itself allowing "fluent" like uniform updates
  92368. */
  92369. setColor3(name: string, value: Color3): ProceduralTexture;
  92370. /**
  92371. * Set a vec4 in the shader from a Color4.
  92372. * @param name Define the name of the uniform as defined in the shader
  92373. * @param value Define the value to give to the uniform
  92374. * @return the texture itself allowing "fluent" like uniform updates
  92375. */
  92376. setColor4(name: string, value: Color4): ProceduralTexture;
  92377. /**
  92378. * Set a vec2 in the shader from a Vector2.
  92379. * @param name Define the name of the uniform as defined in the shader
  92380. * @param value Define the value to give to the uniform
  92381. * @return the texture itself allowing "fluent" like uniform updates
  92382. */
  92383. setVector2(name: string, value: Vector2): ProceduralTexture;
  92384. /**
  92385. * Set a vec3 in the shader from a Vector3.
  92386. * @param name Define the name of the uniform as defined in the shader
  92387. * @param value Define the value to give to the uniform
  92388. * @return the texture itself allowing "fluent" like uniform updates
  92389. */
  92390. setVector3(name: string, value: Vector3): ProceduralTexture;
  92391. /**
  92392. * Set a mat4 in the shader from a MAtrix.
  92393. * @param name Define the name of the uniform as defined in the shader
  92394. * @param value Define the value to give to the uniform
  92395. * @return the texture itself allowing "fluent" like uniform updates
  92396. */
  92397. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92398. /**
  92399. * Render the texture to its associated render target.
  92400. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92401. */
  92402. render(useCameraPostProcess?: boolean): void;
  92403. /**
  92404. * Clone the texture.
  92405. * @returns the cloned texture
  92406. */
  92407. clone(): ProceduralTexture;
  92408. /**
  92409. * Dispose the texture and release its asoociated resources.
  92410. */
  92411. dispose(): void;
  92412. }
  92413. }
  92414. declare module BABYLON {
  92415. /**
  92416. * This represents the base class for particle system in Babylon.
  92417. * 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.
  92418. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92419. * @example https://doc.babylonjs.com/babylon101/particles
  92420. */
  92421. export class BaseParticleSystem {
  92422. /**
  92423. * Source color is added to the destination color without alpha affecting the result
  92424. */
  92425. static BLENDMODE_ONEONE: number;
  92426. /**
  92427. * Blend current color and particle color using particle’s alpha
  92428. */
  92429. static BLENDMODE_STANDARD: number;
  92430. /**
  92431. * Add current color and particle color multiplied by particle’s alpha
  92432. */
  92433. static BLENDMODE_ADD: number;
  92434. /**
  92435. * Multiply current color with particle color
  92436. */
  92437. static BLENDMODE_MULTIPLY: number;
  92438. /**
  92439. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92440. */
  92441. static BLENDMODE_MULTIPLYADD: number;
  92442. /**
  92443. * List of animations used by the particle system.
  92444. */
  92445. animations: Animation[];
  92446. /**
  92447. * Gets or sets the unique id of the particle system
  92448. */
  92449. uniqueId: number;
  92450. /**
  92451. * The id of the Particle system.
  92452. */
  92453. id: string;
  92454. /**
  92455. * The friendly name of the Particle system.
  92456. */
  92457. name: string;
  92458. /**
  92459. * Snippet ID if the particle system was created from the snippet server
  92460. */
  92461. snippetId: string;
  92462. /**
  92463. * The rendering group used by the Particle system to chose when to render.
  92464. */
  92465. renderingGroupId: number;
  92466. /**
  92467. * The emitter represents the Mesh or position we are attaching the particle system to.
  92468. */
  92469. emitter: Nullable<AbstractMesh | Vector3>;
  92470. /**
  92471. * The maximum number of particles to emit per frame
  92472. */
  92473. emitRate: number;
  92474. /**
  92475. * If you want to launch only a few particles at once, that can be done, as well.
  92476. */
  92477. manualEmitCount: number;
  92478. /**
  92479. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92480. */
  92481. updateSpeed: number;
  92482. /**
  92483. * The amount of time the particle system is running (depends of the overall update speed).
  92484. */
  92485. targetStopDuration: number;
  92486. /**
  92487. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92488. */
  92489. disposeOnStop: boolean;
  92490. /**
  92491. * Minimum power of emitting particles.
  92492. */
  92493. minEmitPower: number;
  92494. /**
  92495. * Maximum power of emitting particles.
  92496. */
  92497. maxEmitPower: number;
  92498. /**
  92499. * Minimum life time of emitting particles.
  92500. */
  92501. minLifeTime: number;
  92502. /**
  92503. * Maximum life time of emitting particles.
  92504. */
  92505. maxLifeTime: number;
  92506. /**
  92507. * Minimum Size of emitting particles.
  92508. */
  92509. minSize: number;
  92510. /**
  92511. * Maximum Size of emitting particles.
  92512. */
  92513. maxSize: number;
  92514. /**
  92515. * Minimum scale of emitting particles on X axis.
  92516. */
  92517. minScaleX: number;
  92518. /**
  92519. * Maximum scale of emitting particles on X axis.
  92520. */
  92521. maxScaleX: number;
  92522. /**
  92523. * Minimum scale of emitting particles on Y axis.
  92524. */
  92525. minScaleY: number;
  92526. /**
  92527. * Maximum scale of emitting particles on Y axis.
  92528. */
  92529. maxScaleY: number;
  92530. /**
  92531. * Gets or sets the minimal initial rotation in radians.
  92532. */
  92533. minInitialRotation: number;
  92534. /**
  92535. * Gets or sets the maximal initial rotation in radians.
  92536. */
  92537. maxInitialRotation: number;
  92538. /**
  92539. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92540. */
  92541. minAngularSpeed: number;
  92542. /**
  92543. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92544. */
  92545. maxAngularSpeed: number;
  92546. /**
  92547. * The texture used to render each particle. (this can be a spritesheet)
  92548. */
  92549. particleTexture: Nullable<BaseTexture>;
  92550. /**
  92551. * The layer mask we are rendering the particles through.
  92552. */
  92553. layerMask: number;
  92554. /**
  92555. * This can help using your own shader to render the particle system.
  92556. * The according effect will be created
  92557. */
  92558. customShader: any;
  92559. /**
  92560. * By default particle system starts as soon as they are created. This prevents the
  92561. * automatic start to happen and let you decide when to start emitting particles.
  92562. */
  92563. preventAutoStart: boolean;
  92564. private _noiseTexture;
  92565. /**
  92566. * Gets or sets a texture used to add random noise to particle positions
  92567. */
  92568. get noiseTexture(): Nullable<ProceduralTexture>;
  92569. set noiseTexture(value: Nullable<ProceduralTexture>);
  92570. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92571. noiseStrength: Vector3;
  92572. /**
  92573. * Callback triggered when the particle animation is ending.
  92574. */
  92575. onAnimationEnd: Nullable<() => void>;
  92576. /**
  92577. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92578. */
  92579. blendMode: number;
  92580. /**
  92581. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92582. * to override the particles.
  92583. */
  92584. forceDepthWrite: boolean;
  92585. /** 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 */
  92586. preWarmCycles: number;
  92587. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92588. preWarmStepOffset: number;
  92589. /**
  92590. * 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)
  92591. */
  92592. spriteCellChangeSpeed: number;
  92593. /**
  92594. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92595. */
  92596. startSpriteCellID: number;
  92597. /**
  92598. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92599. */
  92600. endSpriteCellID: number;
  92601. /**
  92602. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92603. */
  92604. spriteCellWidth: number;
  92605. /**
  92606. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92607. */
  92608. spriteCellHeight: number;
  92609. /**
  92610. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92611. */
  92612. spriteRandomStartCell: boolean;
  92613. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92614. translationPivot: Vector2;
  92615. /** @hidden */
  92616. protected _isAnimationSheetEnabled: boolean;
  92617. /**
  92618. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92619. */
  92620. beginAnimationOnStart: boolean;
  92621. /**
  92622. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92623. */
  92624. beginAnimationFrom: number;
  92625. /**
  92626. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92627. */
  92628. beginAnimationTo: number;
  92629. /**
  92630. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92631. */
  92632. beginAnimationLoop: boolean;
  92633. /**
  92634. * Gets or sets a world offset applied to all particles
  92635. */
  92636. worldOffset: Vector3;
  92637. /**
  92638. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92639. */
  92640. get isAnimationSheetEnabled(): boolean;
  92641. set isAnimationSheetEnabled(value: boolean);
  92642. /**
  92643. * Get hosting scene
  92644. * @returns the scene
  92645. */
  92646. getScene(): Nullable<Scene>;
  92647. /**
  92648. * You can use gravity if you want to give an orientation to your particles.
  92649. */
  92650. gravity: Vector3;
  92651. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92652. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92653. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92654. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92655. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92656. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92657. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92658. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92659. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92660. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92661. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92662. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92663. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92664. /**
  92665. * Defines the delay in milliseconds before starting the system (0 by default)
  92666. */
  92667. startDelay: number;
  92668. /**
  92669. * Gets the current list of drag gradients.
  92670. * You must use addDragGradient and removeDragGradient to udpate this list
  92671. * @returns the list of drag gradients
  92672. */
  92673. getDragGradients(): Nullable<Array<FactorGradient>>;
  92674. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92675. limitVelocityDamping: number;
  92676. /**
  92677. * Gets the current list of limit velocity gradients.
  92678. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92679. * @returns the list of limit velocity gradients
  92680. */
  92681. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92682. /**
  92683. * Gets the current list of color gradients.
  92684. * You must use addColorGradient and removeColorGradient to udpate this list
  92685. * @returns the list of color gradients
  92686. */
  92687. getColorGradients(): Nullable<Array<ColorGradient>>;
  92688. /**
  92689. * Gets the current list of size gradients.
  92690. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92691. * @returns the list of size gradients
  92692. */
  92693. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92694. /**
  92695. * Gets the current list of color remap gradients.
  92696. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92697. * @returns the list of color remap gradients
  92698. */
  92699. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92700. /**
  92701. * Gets the current list of alpha remap gradients.
  92702. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92703. * @returns the list of alpha remap gradients
  92704. */
  92705. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92706. /**
  92707. * Gets the current list of life time gradients.
  92708. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92709. * @returns the list of life time gradients
  92710. */
  92711. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92712. /**
  92713. * Gets the current list of angular speed gradients.
  92714. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92715. * @returns the list of angular speed gradients
  92716. */
  92717. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92718. /**
  92719. * Gets the current list of velocity gradients.
  92720. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92721. * @returns the list of velocity gradients
  92722. */
  92723. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92724. /**
  92725. * Gets the current list of start size gradients.
  92726. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92727. * @returns the list of start size gradients
  92728. */
  92729. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92730. /**
  92731. * Gets the current list of emit rate gradients.
  92732. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92733. * @returns the list of emit rate gradients
  92734. */
  92735. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92736. /**
  92737. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92739. */
  92740. get direction1(): Vector3;
  92741. set direction1(value: Vector3);
  92742. /**
  92743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92744. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92745. */
  92746. get direction2(): Vector3;
  92747. set direction2(value: Vector3);
  92748. /**
  92749. * 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.
  92750. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92751. */
  92752. get minEmitBox(): Vector3;
  92753. set minEmitBox(value: Vector3);
  92754. /**
  92755. * 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.
  92756. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92757. */
  92758. get maxEmitBox(): Vector3;
  92759. set maxEmitBox(value: Vector3);
  92760. /**
  92761. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92762. */
  92763. color1: Color4;
  92764. /**
  92765. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92766. */
  92767. color2: Color4;
  92768. /**
  92769. * Color the particle will have at the end of its lifetime
  92770. */
  92771. colorDead: Color4;
  92772. /**
  92773. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92774. */
  92775. textureMask: Color4;
  92776. /**
  92777. * The particle emitter type defines the emitter used by the particle system.
  92778. * It can be for example box, sphere, or cone...
  92779. */
  92780. particleEmitterType: IParticleEmitterType;
  92781. /** @hidden */
  92782. _isSubEmitter: boolean;
  92783. /**
  92784. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92785. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92786. */
  92787. billboardMode: number;
  92788. protected _isBillboardBased: boolean;
  92789. /**
  92790. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92791. */
  92792. get isBillboardBased(): boolean;
  92793. set isBillboardBased(value: boolean);
  92794. /**
  92795. * The scene the particle system belongs to.
  92796. */
  92797. protected _scene: Nullable<Scene>;
  92798. /**
  92799. * The engine the particle system belongs to.
  92800. */
  92801. protected _engine: ThinEngine;
  92802. /**
  92803. * Local cache of defines for image processing.
  92804. */
  92805. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92806. /**
  92807. * Default configuration related to image processing available in the standard Material.
  92808. */
  92809. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92810. /**
  92811. * Gets the image processing configuration used either in this material.
  92812. */
  92813. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92814. /**
  92815. * Sets the Default image processing configuration used either in the this material.
  92816. *
  92817. * If sets to null, the scene one is in use.
  92818. */
  92819. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92820. /**
  92821. * Attaches a new image processing configuration to the Standard Material.
  92822. * @param configuration
  92823. */
  92824. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92825. /** @hidden */
  92826. protected _reset(): void;
  92827. /** @hidden */
  92828. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92829. /**
  92830. * Instantiates a particle system.
  92831. * 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.
  92832. * @param name The name of the particle system
  92833. */
  92834. constructor(name: string);
  92835. /**
  92836. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92839. * @returns the emitter
  92840. */
  92841. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92842. /**
  92843. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92844. * @param radius The radius of the hemisphere to emit from
  92845. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92846. * @returns the emitter
  92847. */
  92848. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92849. /**
  92850. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92851. * @param radius The radius of the sphere to emit from
  92852. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92853. * @returns the emitter
  92854. */
  92855. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92856. /**
  92857. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92858. * @param radius The radius of the sphere to emit from
  92859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92861. * @returns the emitter
  92862. */
  92863. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92864. /**
  92865. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92866. * @param radius The radius of the emission cylinder
  92867. * @param height The height of the emission cylinder
  92868. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92869. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92870. * @returns the emitter
  92871. */
  92872. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92873. /**
  92874. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92875. * @param radius The radius of the cylinder to emit from
  92876. * @param height The height of the emission cylinder
  92877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92878. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92879. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92880. * @returns the emitter
  92881. */
  92882. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92883. /**
  92884. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92885. * @param radius The radius of the cone to emit from
  92886. * @param angle The base angle of the cone
  92887. * @returns the emitter
  92888. */
  92889. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92890. /**
  92891. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92892. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92893. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92894. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92895. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92896. * @returns the emitter
  92897. */
  92898. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92899. }
  92900. }
  92901. declare module BABYLON {
  92902. /**
  92903. * Type of sub emitter
  92904. */
  92905. export enum SubEmitterType {
  92906. /**
  92907. * Attached to the particle over it's lifetime
  92908. */
  92909. ATTACHED = 0,
  92910. /**
  92911. * Created when the particle dies
  92912. */
  92913. END = 1
  92914. }
  92915. /**
  92916. * Sub emitter class used to emit particles from an existing particle
  92917. */
  92918. export class SubEmitter {
  92919. /**
  92920. * the particle system to be used by the sub emitter
  92921. */
  92922. particleSystem: ParticleSystem;
  92923. /**
  92924. * Type of the submitter (Default: END)
  92925. */
  92926. type: SubEmitterType;
  92927. /**
  92928. * 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)
  92929. * Note: This only is supported when using an emitter of type Mesh
  92930. */
  92931. inheritDirection: boolean;
  92932. /**
  92933. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92934. */
  92935. inheritedVelocityAmount: number;
  92936. /**
  92937. * Creates a sub emitter
  92938. * @param particleSystem the particle system to be used by the sub emitter
  92939. */
  92940. constructor(
  92941. /**
  92942. * the particle system to be used by the sub emitter
  92943. */
  92944. particleSystem: ParticleSystem);
  92945. /**
  92946. * Clones the sub emitter
  92947. * @returns the cloned sub emitter
  92948. */
  92949. clone(): SubEmitter;
  92950. /**
  92951. * Serialize current object to a JSON object
  92952. * @returns the serialized object
  92953. */
  92954. serialize(): any;
  92955. /** @hidden */
  92956. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92957. /**
  92958. * Creates a new SubEmitter from a serialized JSON version
  92959. * @param serializationObject defines the JSON object to read from
  92960. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92961. * @param rootUrl defines the rootUrl for data loading
  92962. * @returns a new SubEmitter
  92963. */
  92964. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92965. /** Release associated resources */
  92966. dispose(): void;
  92967. }
  92968. }
  92969. declare module BABYLON {
  92970. /** @hidden */
  92971. export var imageProcessingDeclaration: {
  92972. name: string;
  92973. shader: string;
  92974. };
  92975. }
  92976. declare module BABYLON {
  92977. /** @hidden */
  92978. export var imageProcessingFunctions: {
  92979. name: string;
  92980. shader: string;
  92981. };
  92982. }
  92983. declare module BABYLON {
  92984. /** @hidden */
  92985. export var particlesPixelShader: {
  92986. name: string;
  92987. shader: string;
  92988. };
  92989. }
  92990. declare module BABYLON {
  92991. /** @hidden */
  92992. export var particlesVertexShader: {
  92993. name: string;
  92994. shader: string;
  92995. };
  92996. }
  92997. declare module BABYLON {
  92998. /**
  92999. * Interface used to define entities containing multiple clip planes
  93000. */
  93001. export interface IClipPlanesHolder {
  93002. /**
  93003. * Gets or sets the active clipplane 1
  93004. */
  93005. clipPlane: Nullable<Plane>;
  93006. /**
  93007. * Gets or sets the active clipplane 2
  93008. */
  93009. clipPlane2: Nullable<Plane>;
  93010. /**
  93011. * Gets or sets the active clipplane 3
  93012. */
  93013. clipPlane3: Nullable<Plane>;
  93014. /**
  93015. * Gets or sets the active clipplane 4
  93016. */
  93017. clipPlane4: Nullable<Plane>;
  93018. /**
  93019. * Gets or sets the active clipplane 5
  93020. */
  93021. clipPlane5: Nullable<Plane>;
  93022. /**
  93023. * Gets or sets the active clipplane 6
  93024. */
  93025. clipPlane6: Nullable<Plane>;
  93026. }
  93027. }
  93028. declare module BABYLON {
  93029. /**
  93030. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93031. *
  93032. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93033. *
  93034. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93035. */
  93036. export class ThinMaterialHelper {
  93037. /**
  93038. * Binds the clip plane information from the holder to the effect.
  93039. * @param effect The effect we are binding the data to
  93040. * @param holder The entity containing the clip plane information
  93041. */
  93042. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93043. }
  93044. }
  93045. declare module BABYLON {
  93046. interface ThinEngine {
  93047. /**
  93048. * Sets alpha constants used by some alpha blending modes
  93049. * @param r defines the red component
  93050. * @param g defines the green component
  93051. * @param b defines the blue component
  93052. * @param a defines the alpha component
  93053. */
  93054. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93055. /**
  93056. * Sets the current alpha mode
  93057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93059. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93060. */
  93061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93062. /**
  93063. * Gets the current alpha mode
  93064. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93065. * @returns the current alpha mode
  93066. */
  93067. getAlphaMode(): number;
  93068. /**
  93069. * Sets the current alpha equation
  93070. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93071. */
  93072. setAlphaEquation(equation: number): void;
  93073. /**
  93074. * Gets the current alpha equation.
  93075. * @returns the current alpha equation
  93076. */
  93077. getAlphaEquation(): number;
  93078. }
  93079. }
  93080. declare module BABYLON {
  93081. /**
  93082. * This represents a particle system in Babylon.
  93083. * 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.
  93084. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93085. * @example https://doc.babylonjs.com/babylon101/particles
  93086. */
  93087. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93088. /**
  93089. * Billboard mode will only apply to Y axis
  93090. */
  93091. static readonly BILLBOARDMODE_Y: number;
  93092. /**
  93093. * Billboard mode will apply to all axes
  93094. */
  93095. static readonly BILLBOARDMODE_ALL: number;
  93096. /**
  93097. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93098. */
  93099. static readonly BILLBOARDMODE_STRETCHED: number;
  93100. /**
  93101. * This function can be defined to provide custom update for active particles.
  93102. * This function will be called instead of regular update (age, position, color, etc.).
  93103. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93104. */
  93105. updateFunction: (particles: Particle[]) => void;
  93106. private _emitterWorldMatrix;
  93107. /**
  93108. * This function can be defined to specify initial direction for every new particle.
  93109. * It by default use the emitterType defined function
  93110. */
  93111. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93112. /**
  93113. * This function can be defined to specify initial position for every new particle.
  93114. * It by default use the emitterType defined function
  93115. */
  93116. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93117. /**
  93118. * @hidden
  93119. */
  93120. _inheritedVelocityOffset: Vector3;
  93121. /**
  93122. * An event triggered when the system is disposed
  93123. */
  93124. onDisposeObservable: Observable<IParticleSystem>;
  93125. private _onDisposeObserver;
  93126. /**
  93127. * Sets a callback that will be triggered when the system is disposed
  93128. */
  93129. set onDispose(callback: () => void);
  93130. private _particles;
  93131. private _epsilon;
  93132. private _capacity;
  93133. private _stockParticles;
  93134. private _newPartsExcess;
  93135. private _vertexData;
  93136. private _vertexBuffer;
  93137. private _vertexBuffers;
  93138. private _spriteBuffer;
  93139. private _indexBuffer;
  93140. private _effect;
  93141. private _customEffect;
  93142. private _cachedDefines;
  93143. private _scaledColorStep;
  93144. private _colorDiff;
  93145. private _scaledDirection;
  93146. private _scaledGravity;
  93147. private _currentRenderId;
  93148. private _alive;
  93149. private _useInstancing;
  93150. private _started;
  93151. private _stopped;
  93152. private _actualFrame;
  93153. private _scaledUpdateSpeed;
  93154. private _vertexBufferSize;
  93155. /** @hidden */
  93156. _currentEmitRateGradient: Nullable<FactorGradient>;
  93157. /** @hidden */
  93158. _currentEmitRate1: number;
  93159. /** @hidden */
  93160. _currentEmitRate2: number;
  93161. /** @hidden */
  93162. _currentStartSizeGradient: Nullable<FactorGradient>;
  93163. /** @hidden */
  93164. _currentStartSize1: number;
  93165. /** @hidden */
  93166. _currentStartSize2: number;
  93167. private readonly _rawTextureWidth;
  93168. private _rampGradientsTexture;
  93169. private _useRampGradients;
  93170. /** Gets or sets a matrix to use to compute projection */
  93171. defaultProjectionMatrix: Matrix;
  93172. /** Gets or sets a matrix to use to compute view */
  93173. defaultViewMatrix: Matrix;
  93174. /** Gets or sets a boolean indicating that ramp gradients must be used
  93175. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93176. */
  93177. get useRampGradients(): boolean;
  93178. set useRampGradients(value: boolean);
  93179. /**
  93180. * 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.
  93181. * 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: [])
  93182. */
  93183. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93184. private _subEmitters;
  93185. /**
  93186. * @hidden
  93187. * If the particle systems emitter should be disposed when the particle system is disposed
  93188. */
  93189. _disposeEmitterOnDispose: boolean;
  93190. /**
  93191. * The current active Sub-systems, this property is used by the root particle system only.
  93192. */
  93193. activeSubSystems: Array<ParticleSystem>;
  93194. /**
  93195. * Specifies if the particles are updated in emitter local space or world space
  93196. */
  93197. isLocal: boolean;
  93198. private _rootParticleSystem;
  93199. /**
  93200. * Gets the current list of active particles
  93201. */
  93202. get particles(): Particle[];
  93203. /**
  93204. * Gets the number of particles active at the same time.
  93205. * @returns The number of active particles.
  93206. */
  93207. getActiveCount(): number;
  93208. /**
  93209. * Returns the string "ParticleSystem"
  93210. * @returns a string containing the class name
  93211. */
  93212. getClassName(): string;
  93213. /**
  93214. * Gets a boolean indicating that the system is stopping
  93215. * @returns true if the system is currently stopping
  93216. */
  93217. isStopping(): boolean;
  93218. /**
  93219. * Gets the custom effect used to render the particles
  93220. * @param blendMode Blend mode for which the effect should be retrieved
  93221. * @returns The effect
  93222. */
  93223. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93224. /**
  93225. * Sets the custom effect used to render the particles
  93226. * @param effect The effect to set
  93227. * @param blendMode Blend mode for which the effect should be set
  93228. */
  93229. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93230. /** @hidden */
  93231. private _onBeforeDrawParticlesObservable;
  93232. /**
  93233. * Observable that will be called just before the particles are drawn
  93234. */
  93235. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93236. /**
  93237. * Gets the name of the particle vertex shader
  93238. */
  93239. get vertexShaderName(): string;
  93240. /**
  93241. * Instantiates a particle system.
  93242. * 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.
  93243. * @param name The name of the particle system
  93244. * @param capacity The max number of particles alive at the same time
  93245. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93246. * @param customEffect a custom effect used to change the way particles are rendered by default
  93247. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93248. * @param epsilon Offset used to render the particles
  93249. */
  93250. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93251. private _addFactorGradient;
  93252. private _removeFactorGradient;
  93253. /**
  93254. * Adds a new life time gradient
  93255. * @param gradient defines the gradient to use (between 0 and 1)
  93256. * @param factor defines the life time factor to affect to the specified gradient
  93257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93258. * @returns the current particle system
  93259. */
  93260. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93261. /**
  93262. * Remove a specific life time gradient
  93263. * @param gradient defines the gradient to remove
  93264. * @returns the current particle system
  93265. */
  93266. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93267. /**
  93268. * Adds a new size gradient
  93269. * @param gradient defines the gradient to use (between 0 and 1)
  93270. * @param factor defines the size factor to affect to the specified gradient
  93271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93272. * @returns the current particle system
  93273. */
  93274. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93275. /**
  93276. * Remove a specific size gradient
  93277. * @param gradient defines the gradient to remove
  93278. * @returns the current particle system
  93279. */
  93280. removeSizeGradient(gradient: number): IParticleSystem;
  93281. /**
  93282. * Adds a new color remap gradient
  93283. * @param gradient defines the gradient to use (between 0 and 1)
  93284. * @param min defines the color remap minimal range
  93285. * @param max defines the color remap maximal range
  93286. * @returns the current particle system
  93287. */
  93288. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93289. /**
  93290. * Remove a specific color remap gradient
  93291. * @param gradient defines the gradient to remove
  93292. * @returns the current particle system
  93293. */
  93294. removeColorRemapGradient(gradient: number): IParticleSystem;
  93295. /**
  93296. * Adds a new alpha remap gradient
  93297. * @param gradient defines the gradient to use (between 0 and 1)
  93298. * @param min defines the alpha remap minimal range
  93299. * @param max defines the alpha remap maximal range
  93300. * @returns the current particle system
  93301. */
  93302. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93303. /**
  93304. * Remove a specific alpha remap gradient
  93305. * @param gradient defines the gradient to remove
  93306. * @returns the current particle system
  93307. */
  93308. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93309. /**
  93310. * Adds a new angular speed gradient
  93311. * @param gradient defines the gradient to use (between 0 and 1)
  93312. * @param factor defines the angular speed to affect to the specified gradient
  93313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93314. * @returns the current particle system
  93315. */
  93316. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93317. /**
  93318. * Remove a specific angular speed gradient
  93319. * @param gradient defines the gradient to remove
  93320. * @returns the current particle system
  93321. */
  93322. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93323. /**
  93324. * Adds a new velocity gradient
  93325. * @param gradient defines the gradient to use (between 0 and 1)
  93326. * @param factor defines the velocity to affect to the specified gradient
  93327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93328. * @returns the current particle system
  93329. */
  93330. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93331. /**
  93332. * Remove a specific velocity gradient
  93333. * @param gradient defines the gradient to remove
  93334. * @returns the current particle system
  93335. */
  93336. removeVelocityGradient(gradient: number): IParticleSystem;
  93337. /**
  93338. * Adds a new limit velocity gradient
  93339. * @param gradient defines the gradient to use (between 0 and 1)
  93340. * @param factor defines the limit velocity value to affect to the specified gradient
  93341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93342. * @returns the current particle system
  93343. */
  93344. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93345. /**
  93346. * Remove a specific limit velocity gradient
  93347. * @param gradient defines the gradient to remove
  93348. * @returns the current particle system
  93349. */
  93350. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93351. /**
  93352. * Adds a new drag gradient
  93353. * @param gradient defines the gradient to use (between 0 and 1)
  93354. * @param factor defines the drag value to affect to the specified gradient
  93355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93356. * @returns the current particle system
  93357. */
  93358. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93359. /**
  93360. * Remove a specific drag gradient
  93361. * @param gradient defines the gradient to remove
  93362. * @returns the current particle system
  93363. */
  93364. removeDragGradient(gradient: number): IParticleSystem;
  93365. /**
  93366. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93367. * @param gradient defines the gradient to use (between 0 and 1)
  93368. * @param factor defines the emit rate value to affect to the specified gradient
  93369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93370. * @returns the current particle system
  93371. */
  93372. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93373. /**
  93374. * Remove a specific emit rate gradient
  93375. * @param gradient defines the gradient to remove
  93376. * @returns the current particle system
  93377. */
  93378. removeEmitRateGradient(gradient: number): IParticleSystem;
  93379. /**
  93380. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93381. * @param gradient defines the gradient to use (between 0 and 1)
  93382. * @param factor defines the start size value to affect to the specified gradient
  93383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93384. * @returns the current particle system
  93385. */
  93386. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93387. /**
  93388. * Remove a specific start size gradient
  93389. * @param gradient defines the gradient to remove
  93390. * @returns the current particle system
  93391. */
  93392. removeStartSizeGradient(gradient: number): IParticleSystem;
  93393. private _createRampGradientTexture;
  93394. /**
  93395. * Gets the current list of ramp gradients.
  93396. * You must use addRampGradient and removeRampGradient to udpate this list
  93397. * @returns the list of ramp gradients
  93398. */
  93399. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93400. /** Force the system to rebuild all gradients that need to be resync */
  93401. forceRefreshGradients(): void;
  93402. private _syncRampGradientTexture;
  93403. /**
  93404. * Adds a new ramp gradient used to remap particle colors
  93405. * @param gradient defines the gradient to use (between 0 and 1)
  93406. * @param color defines the color to affect to the specified gradient
  93407. * @returns the current particle system
  93408. */
  93409. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93410. /**
  93411. * Remove a specific ramp gradient
  93412. * @param gradient defines the gradient to remove
  93413. * @returns the current particle system
  93414. */
  93415. removeRampGradient(gradient: number): ParticleSystem;
  93416. /**
  93417. * Adds a new color gradient
  93418. * @param gradient defines the gradient to use (between 0 and 1)
  93419. * @param color1 defines the color to affect to the specified gradient
  93420. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93421. * @returns this particle system
  93422. */
  93423. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93424. /**
  93425. * Remove a specific color gradient
  93426. * @param gradient defines the gradient to remove
  93427. * @returns this particle system
  93428. */
  93429. removeColorGradient(gradient: number): IParticleSystem;
  93430. private _fetchR;
  93431. protected _reset(): void;
  93432. private _resetEffect;
  93433. private _createVertexBuffers;
  93434. private _createIndexBuffer;
  93435. /**
  93436. * Gets the maximum number of particles active at the same time.
  93437. * @returns The max number of active particles.
  93438. */
  93439. getCapacity(): number;
  93440. /**
  93441. * Gets whether there are still active particles in the system.
  93442. * @returns True if it is alive, otherwise false.
  93443. */
  93444. isAlive(): boolean;
  93445. /**
  93446. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93447. * @returns True if it has been started, otherwise false.
  93448. */
  93449. isStarted(): boolean;
  93450. private _prepareSubEmitterInternalArray;
  93451. /**
  93452. * Starts the particle system and begins to emit
  93453. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93454. */
  93455. start(delay?: number): void;
  93456. /**
  93457. * Stops the particle system.
  93458. * @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.
  93459. */
  93460. stop(stopSubEmitters?: boolean): void;
  93461. /**
  93462. * Remove all active particles
  93463. */
  93464. reset(): void;
  93465. /**
  93466. * @hidden (for internal use only)
  93467. */
  93468. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93469. /**
  93470. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93471. * Its lifetime will start back at 0.
  93472. */
  93473. recycleParticle: (particle: Particle) => void;
  93474. private _stopSubEmitters;
  93475. private _createParticle;
  93476. private _removeFromRoot;
  93477. private _emitFromParticle;
  93478. private _update;
  93479. /** @hidden */
  93480. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93481. /** @hidden */
  93482. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93483. /**
  93484. * Fill the defines array according to the current settings of the particle system
  93485. * @param defines Array to be updated
  93486. * @param blendMode blend mode to take into account when updating the array
  93487. */
  93488. fillDefines(defines: Array<string>, blendMode: number): void;
  93489. /**
  93490. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93491. * @param uniforms Uniforms array to fill
  93492. * @param attributes Attributes array to fill
  93493. * @param samplers Samplers array to fill
  93494. */
  93495. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93496. /** @hidden */
  93497. private _getEffect;
  93498. /**
  93499. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93500. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93501. */
  93502. animate(preWarmOnly?: boolean): void;
  93503. private _appendParticleVertices;
  93504. /**
  93505. * Rebuilds the particle system.
  93506. */
  93507. rebuild(): void;
  93508. /**
  93509. * Is this system ready to be used/rendered
  93510. * @return true if the system is ready
  93511. */
  93512. isReady(): boolean;
  93513. private _render;
  93514. /**
  93515. * Renders the particle system in its current state.
  93516. * @returns the current number of particles
  93517. */
  93518. render(): number;
  93519. /**
  93520. * Disposes the particle system and free the associated resources
  93521. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93522. */
  93523. dispose(disposeTexture?: boolean): void;
  93524. /**
  93525. * Clones the particle system.
  93526. * @param name The name of the cloned object
  93527. * @param newEmitter The new emitter to use
  93528. * @returns the cloned particle system
  93529. */
  93530. clone(name: string, newEmitter: any): ParticleSystem;
  93531. /**
  93532. * Serializes the particle system to a JSON object
  93533. * @param serializeTexture defines if the texture must be serialized as well
  93534. * @returns the JSON object
  93535. */
  93536. serialize(serializeTexture?: boolean): any;
  93537. /** @hidden */
  93538. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93539. /** @hidden */
  93540. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93541. /**
  93542. * Parses a JSON object to create a particle system.
  93543. * @param parsedParticleSystem The JSON object to parse
  93544. * @param sceneOrEngine The scene or the engine to create the particle system in
  93545. * @param rootUrl The root url to use to load external dependencies like texture
  93546. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93547. * @returns the Parsed particle system
  93548. */
  93549. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93550. }
  93551. }
  93552. declare module BABYLON {
  93553. /**
  93554. * A particle represents one of the element emitted by a particle system.
  93555. * This is mainly define by its coordinates, direction, velocity and age.
  93556. */
  93557. export class Particle {
  93558. /**
  93559. * The particle system the particle belongs to.
  93560. */
  93561. particleSystem: ParticleSystem;
  93562. private static _Count;
  93563. /**
  93564. * Unique ID of the particle
  93565. */
  93566. id: number;
  93567. /**
  93568. * The world position of the particle in the scene.
  93569. */
  93570. position: Vector3;
  93571. /**
  93572. * The world direction of the particle in the scene.
  93573. */
  93574. direction: Vector3;
  93575. /**
  93576. * The color of the particle.
  93577. */
  93578. color: Color4;
  93579. /**
  93580. * The color change of the particle per step.
  93581. */
  93582. colorStep: Color4;
  93583. /**
  93584. * Defines how long will the life of the particle be.
  93585. */
  93586. lifeTime: number;
  93587. /**
  93588. * The current age of the particle.
  93589. */
  93590. age: number;
  93591. /**
  93592. * The current size of the particle.
  93593. */
  93594. size: number;
  93595. /**
  93596. * The current scale of the particle.
  93597. */
  93598. scale: Vector2;
  93599. /**
  93600. * The current angle of the particle.
  93601. */
  93602. angle: number;
  93603. /**
  93604. * Defines how fast is the angle changing.
  93605. */
  93606. angularSpeed: number;
  93607. /**
  93608. * Defines the cell index used by the particle to be rendered from a sprite.
  93609. */
  93610. cellIndex: number;
  93611. /**
  93612. * The information required to support color remapping
  93613. */
  93614. remapData: Vector4;
  93615. /** @hidden */
  93616. _randomCellOffset?: number;
  93617. /** @hidden */
  93618. _initialDirection: Nullable<Vector3>;
  93619. /** @hidden */
  93620. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93621. /** @hidden */
  93622. _initialStartSpriteCellID: number;
  93623. /** @hidden */
  93624. _initialEndSpriteCellID: number;
  93625. /** @hidden */
  93626. _currentColorGradient: Nullable<ColorGradient>;
  93627. /** @hidden */
  93628. _currentColor1: Color4;
  93629. /** @hidden */
  93630. _currentColor2: Color4;
  93631. /** @hidden */
  93632. _currentSizeGradient: Nullable<FactorGradient>;
  93633. /** @hidden */
  93634. _currentSize1: number;
  93635. /** @hidden */
  93636. _currentSize2: number;
  93637. /** @hidden */
  93638. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93639. /** @hidden */
  93640. _currentAngularSpeed1: number;
  93641. /** @hidden */
  93642. _currentAngularSpeed2: number;
  93643. /** @hidden */
  93644. _currentVelocityGradient: Nullable<FactorGradient>;
  93645. /** @hidden */
  93646. _currentVelocity1: number;
  93647. /** @hidden */
  93648. _currentVelocity2: number;
  93649. /** @hidden */
  93650. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93651. /** @hidden */
  93652. _currentLimitVelocity1: number;
  93653. /** @hidden */
  93654. _currentLimitVelocity2: number;
  93655. /** @hidden */
  93656. _currentDragGradient: Nullable<FactorGradient>;
  93657. /** @hidden */
  93658. _currentDrag1: number;
  93659. /** @hidden */
  93660. _currentDrag2: number;
  93661. /** @hidden */
  93662. _randomNoiseCoordinates1: Vector3;
  93663. /** @hidden */
  93664. _randomNoiseCoordinates2: Vector3;
  93665. /** @hidden */
  93666. _localPosition?: Vector3;
  93667. /**
  93668. * Creates a new instance Particle
  93669. * @param particleSystem the particle system the particle belongs to
  93670. */
  93671. constructor(
  93672. /**
  93673. * The particle system the particle belongs to.
  93674. */
  93675. particleSystem: ParticleSystem);
  93676. private updateCellInfoFromSystem;
  93677. /**
  93678. * Defines how the sprite cell index is updated for the particle
  93679. */
  93680. updateCellIndex(): void;
  93681. /** @hidden */
  93682. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93683. /** @hidden */
  93684. _inheritParticleInfoToSubEmitters(): void;
  93685. /** @hidden */
  93686. _reset(): void;
  93687. /**
  93688. * Copy the properties of particle to another one.
  93689. * @param other the particle to copy the information to.
  93690. */
  93691. copyTo(other: Particle): void;
  93692. }
  93693. }
  93694. declare module BABYLON {
  93695. /**
  93696. * Particle emitter represents a volume emitting particles.
  93697. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93698. */
  93699. export interface IParticleEmitterType {
  93700. /**
  93701. * Called by the particle System when the direction is computed for the created particle.
  93702. * @param worldMatrix is the world matrix of the particle system
  93703. * @param directionToUpdate is the direction vector to update with the result
  93704. * @param particle is the particle we are computed the direction for
  93705. * @param isLocal defines if the direction should be set in local space
  93706. */
  93707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93708. /**
  93709. * Called by the particle System when the position is computed for the created particle.
  93710. * @param worldMatrix is the world matrix of the particle system
  93711. * @param positionToUpdate is the position vector to update with the result
  93712. * @param particle is the particle we are computed the position for
  93713. * @param isLocal defines if the position should be set in local space
  93714. */
  93715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93716. /**
  93717. * Clones the current emitter and returns a copy of it
  93718. * @returns the new emitter
  93719. */
  93720. clone(): IParticleEmitterType;
  93721. /**
  93722. * Called by the GPUParticleSystem to setup the update shader
  93723. * @param effect defines the update shader
  93724. */
  93725. applyToShader(effect: Effect): void;
  93726. /**
  93727. * Returns a string to use to update the GPU particles update shader
  93728. * @returns the effect defines string
  93729. */
  93730. getEffectDefines(): string;
  93731. /**
  93732. * Returns a string representing the class name
  93733. * @returns a string containing the class name
  93734. */
  93735. getClassName(): string;
  93736. /**
  93737. * Serializes the particle system to a JSON object.
  93738. * @returns the JSON object
  93739. */
  93740. serialize(): any;
  93741. /**
  93742. * Parse properties from a JSON object
  93743. * @param serializationObject defines the JSON object
  93744. * @param scene defines the hosting scene
  93745. */
  93746. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93747. }
  93748. }
  93749. declare module BABYLON {
  93750. /**
  93751. * Particle emitter emitting particles from the inside of a box.
  93752. * It emits the particles randomly between 2 given directions.
  93753. */
  93754. export class BoxParticleEmitter implements IParticleEmitterType {
  93755. /**
  93756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93757. */
  93758. direction1: Vector3;
  93759. /**
  93760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93761. */
  93762. direction2: Vector3;
  93763. /**
  93764. * 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.
  93765. */
  93766. minEmitBox: Vector3;
  93767. /**
  93768. * 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.
  93769. */
  93770. maxEmitBox: Vector3;
  93771. /**
  93772. * Creates a new instance BoxParticleEmitter
  93773. */
  93774. constructor();
  93775. /**
  93776. * Called by the particle System when the direction is computed for the created particle.
  93777. * @param worldMatrix is the world matrix of the particle system
  93778. * @param directionToUpdate is the direction vector to update with the result
  93779. * @param particle is the particle we are computed the direction for
  93780. * @param isLocal defines if the direction should be set in local space
  93781. */
  93782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93783. /**
  93784. * Called by the particle System when the position is computed for the created particle.
  93785. * @param worldMatrix is the world matrix of the particle system
  93786. * @param positionToUpdate is the position vector to update with the result
  93787. * @param particle is the particle we are computed the position for
  93788. * @param isLocal defines if the position should be set in local space
  93789. */
  93790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93791. /**
  93792. * Clones the current emitter and returns a copy of it
  93793. * @returns the new emitter
  93794. */
  93795. clone(): BoxParticleEmitter;
  93796. /**
  93797. * Called by the GPUParticleSystem to setup the update shader
  93798. * @param effect defines the update shader
  93799. */
  93800. applyToShader(effect: Effect): void;
  93801. /**
  93802. * Returns a string to use to update the GPU particles update shader
  93803. * @returns a string containng the defines string
  93804. */
  93805. getEffectDefines(): string;
  93806. /**
  93807. * Returns the string "BoxParticleEmitter"
  93808. * @returns a string containing the class name
  93809. */
  93810. getClassName(): string;
  93811. /**
  93812. * Serializes the particle system to a JSON object.
  93813. * @returns the JSON object
  93814. */
  93815. serialize(): any;
  93816. /**
  93817. * Parse properties from a JSON object
  93818. * @param serializationObject defines the JSON object
  93819. */
  93820. parse(serializationObject: any): void;
  93821. }
  93822. }
  93823. declare module BABYLON {
  93824. /**
  93825. * Particle emitter emitting particles from the inside of a cone.
  93826. * It emits the particles alongside the cone volume from the base to the particle.
  93827. * The emission direction might be randomized.
  93828. */
  93829. export class ConeParticleEmitter implements IParticleEmitterType {
  93830. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93831. directionRandomizer: number;
  93832. private _radius;
  93833. private _angle;
  93834. private _height;
  93835. /**
  93836. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93837. */
  93838. radiusRange: number;
  93839. /**
  93840. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93841. */
  93842. heightRange: number;
  93843. /**
  93844. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93845. */
  93846. emitFromSpawnPointOnly: boolean;
  93847. /**
  93848. * Gets or sets the radius of the emission cone
  93849. */
  93850. get radius(): number;
  93851. set radius(value: number);
  93852. /**
  93853. * Gets or sets the angle of the emission cone
  93854. */
  93855. get angle(): number;
  93856. set angle(value: number);
  93857. private _buildHeight;
  93858. /**
  93859. * Creates a new instance ConeParticleEmitter
  93860. * @param radius the radius of the emission cone (1 by default)
  93861. * @param angle the cone base angle (PI by default)
  93862. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93863. */
  93864. constructor(radius?: number, angle?: number,
  93865. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93866. directionRandomizer?: number);
  93867. /**
  93868. * Called by the particle System when the direction is computed for the created particle.
  93869. * @param worldMatrix is the world matrix of the particle system
  93870. * @param directionToUpdate is the direction vector to update with the result
  93871. * @param particle is the particle we are computed the direction for
  93872. * @param isLocal defines if the direction should be set in local space
  93873. */
  93874. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93875. /**
  93876. * Called by the particle System when the position is computed for the created particle.
  93877. * @param worldMatrix is the world matrix of the particle system
  93878. * @param positionToUpdate is the position vector to update with the result
  93879. * @param particle is the particle we are computed the position for
  93880. * @param isLocal defines if the position should be set in local space
  93881. */
  93882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93883. /**
  93884. * Clones the current emitter and returns a copy of it
  93885. * @returns the new emitter
  93886. */
  93887. clone(): ConeParticleEmitter;
  93888. /**
  93889. * Called by the GPUParticleSystem to setup the update shader
  93890. * @param effect defines the update shader
  93891. */
  93892. applyToShader(effect: Effect): void;
  93893. /**
  93894. * Returns a string to use to update the GPU particles update shader
  93895. * @returns a string containng the defines string
  93896. */
  93897. getEffectDefines(): string;
  93898. /**
  93899. * Returns the string "ConeParticleEmitter"
  93900. * @returns a string containing the class name
  93901. */
  93902. getClassName(): string;
  93903. /**
  93904. * Serializes the particle system to a JSON object.
  93905. * @returns the JSON object
  93906. */
  93907. serialize(): any;
  93908. /**
  93909. * Parse properties from a JSON object
  93910. * @param serializationObject defines the JSON object
  93911. */
  93912. parse(serializationObject: any): void;
  93913. }
  93914. }
  93915. declare module BABYLON {
  93916. /**
  93917. * Particle emitter emitting particles from the inside of a cylinder.
  93918. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93919. */
  93920. export class CylinderParticleEmitter implements IParticleEmitterType {
  93921. /**
  93922. * The radius of the emission cylinder.
  93923. */
  93924. radius: number;
  93925. /**
  93926. * The height of the emission cylinder.
  93927. */
  93928. height: number;
  93929. /**
  93930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93931. */
  93932. radiusRange: number;
  93933. /**
  93934. * How much to randomize the particle direction [0-1].
  93935. */
  93936. directionRandomizer: number;
  93937. /**
  93938. * Creates a new instance CylinderParticleEmitter
  93939. * @param radius the radius of the emission cylinder (1 by default)
  93940. * @param height the height of the emission cylinder (1 by default)
  93941. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93943. */
  93944. constructor(
  93945. /**
  93946. * The radius of the emission cylinder.
  93947. */
  93948. radius?: number,
  93949. /**
  93950. * The height of the emission cylinder.
  93951. */
  93952. height?: number,
  93953. /**
  93954. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93955. */
  93956. radiusRange?: number,
  93957. /**
  93958. * How much to randomize the particle direction [0-1].
  93959. */
  93960. directionRandomizer?: number);
  93961. /**
  93962. * Called by the particle System when the direction is computed for the created particle.
  93963. * @param worldMatrix is the world matrix of the particle system
  93964. * @param directionToUpdate is the direction vector to update with the result
  93965. * @param particle is the particle we are computed the direction for
  93966. * @param isLocal defines if the direction should be set in local space
  93967. */
  93968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93969. /**
  93970. * Called by the particle System when the position is computed for the created particle.
  93971. * @param worldMatrix is the world matrix of the particle system
  93972. * @param positionToUpdate is the position vector to update with the result
  93973. * @param particle is the particle we are computed the position for
  93974. * @param isLocal defines if the position should be set in local space
  93975. */
  93976. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93977. /**
  93978. * Clones the current emitter and returns a copy of it
  93979. * @returns the new emitter
  93980. */
  93981. clone(): CylinderParticleEmitter;
  93982. /**
  93983. * Called by the GPUParticleSystem to setup the update shader
  93984. * @param effect defines the update shader
  93985. */
  93986. applyToShader(effect: Effect): void;
  93987. /**
  93988. * Returns a string to use to update the GPU particles update shader
  93989. * @returns a string containng the defines string
  93990. */
  93991. getEffectDefines(): string;
  93992. /**
  93993. * Returns the string "CylinderParticleEmitter"
  93994. * @returns a string containing the class name
  93995. */
  93996. getClassName(): string;
  93997. /**
  93998. * Serializes the particle system to a JSON object.
  93999. * @returns the JSON object
  94000. */
  94001. serialize(): any;
  94002. /**
  94003. * Parse properties from a JSON object
  94004. * @param serializationObject defines the JSON object
  94005. */
  94006. parse(serializationObject: any): void;
  94007. }
  94008. /**
  94009. * Particle emitter emitting particles from the inside of a cylinder.
  94010. * It emits the particles randomly between two vectors.
  94011. */
  94012. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94013. /**
  94014. * The min limit of the emission direction.
  94015. */
  94016. direction1: Vector3;
  94017. /**
  94018. * The max limit of the emission direction.
  94019. */
  94020. direction2: Vector3;
  94021. /**
  94022. * Creates a new instance CylinderDirectedParticleEmitter
  94023. * @param radius the radius of the emission cylinder (1 by default)
  94024. * @param height the height of the emission cylinder (1 by default)
  94025. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94026. * @param direction1 the min limit of the emission direction (up vector by default)
  94027. * @param direction2 the max limit of the emission direction (up vector by default)
  94028. */
  94029. constructor(radius?: number, height?: number, radiusRange?: number,
  94030. /**
  94031. * The min limit of the emission direction.
  94032. */
  94033. direction1?: Vector3,
  94034. /**
  94035. * The max limit of the emission direction.
  94036. */
  94037. direction2?: Vector3);
  94038. /**
  94039. * Called by the particle System when the direction is computed for the created particle.
  94040. * @param worldMatrix is the world matrix of the particle system
  94041. * @param directionToUpdate is the direction vector to update with the result
  94042. * @param particle is the particle we are computed the direction for
  94043. */
  94044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94045. /**
  94046. * Clones the current emitter and returns a copy of it
  94047. * @returns the new emitter
  94048. */
  94049. clone(): CylinderDirectedParticleEmitter;
  94050. /**
  94051. * Called by the GPUParticleSystem to setup the update shader
  94052. * @param effect defines the update shader
  94053. */
  94054. applyToShader(effect: Effect): void;
  94055. /**
  94056. * Returns a string to use to update the GPU particles update shader
  94057. * @returns a string containng the defines string
  94058. */
  94059. getEffectDefines(): string;
  94060. /**
  94061. * Returns the string "CylinderDirectedParticleEmitter"
  94062. * @returns a string containing the class name
  94063. */
  94064. getClassName(): string;
  94065. /**
  94066. * Serializes the particle system to a JSON object.
  94067. * @returns the JSON object
  94068. */
  94069. serialize(): any;
  94070. /**
  94071. * Parse properties from a JSON object
  94072. * @param serializationObject defines the JSON object
  94073. */
  94074. parse(serializationObject: any): void;
  94075. }
  94076. }
  94077. declare module BABYLON {
  94078. /**
  94079. * Particle emitter emitting particles from the inside of a hemisphere.
  94080. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94081. */
  94082. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94083. /**
  94084. * The radius of the emission hemisphere.
  94085. */
  94086. radius: number;
  94087. /**
  94088. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94089. */
  94090. radiusRange: number;
  94091. /**
  94092. * How much to randomize the particle direction [0-1].
  94093. */
  94094. directionRandomizer: number;
  94095. /**
  94096. * Creates a new instance HemisphericParticleEmitter
  94097. * @param radius the radius of the emission hemisphere (1 by default)
  94098. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94099. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94100. */
  94101. constructor(
  94102. /**
  94103. * The radius of the emission hemisphere.
  94104. */
  94105. radius?: number,
  94106. /**
  94107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94108. */
  94109. radiusRange?: number,
  94110. /**
  94111. * How much to randomize the particle direction [0-1].
  94112. */
  94113. directionRandomizer?: number);
  94114. /**
  94115. * Called by the particle System when the direction is computed for the created particle.
  94116. * @param worldMatrix is the world matrix of the particle system
  94117. * @param directionToUpdate is the direction vector to update with the result
  94118. * @param particle is the particle we are computed the direction for
  94119. * @param isLocal defines if the direction should be set in local space
  94120. */
  94121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94122. /**
  94123. * Called by the particle System when the position is computed for the created particle.
  94124. * @param worldMatrix is the world matrix of the particle system
  94125. * @param positionToUpdate is the position vector to update with the result
  94126. * @param particle is the particle we are computed the position for
  94127. * @param isLocal defines if the position should be set in local space
  94128. */
  94129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94130. /**
  94131. * Clones the current emitter and returns a copy of it
  94132. * @returns the new emitter
  94133. */
  94134. clone(): HemisphericParticleEmitter;
  94135. /**
  94136. * Called by the GPUParticleSystem to setup the update shader
  94137. * @param effect defines the update shader
  94138. */
  94139. applyToShader(effect: Effect): void;
  94140. /**
  94141. * Returns a string to use to update the GPU particles update shader
  94142. * @returns a string containng the defines string
  94143. */
  94144. getEffectDefines(): string;
  94145. /**
  94146. * Returns the string "HemisphericParticleEmitter"
  94147. * @returns a string containing the class name
  94148. */
  94149. getClassName(): string;
  94150. /**
  94151. * Serializes the particle system to a JSON object.
  94152. * @returns the JSON object
  94153. */
  94154. serialize(): any;
  94155. /**
  94156. * Parse properties from a JSON object
  94157. * @param serializationObject defines the JSON object
  94158. */
  94159. parse(serializationObject: any): void;
  94160. }
  94161. }
  94162. declare module BABYLON {
  94163. /**
  94164. * Particle emitter emitting particles from a point.
  94165. * It emits the particles randomly between 2 given directions.
  94166. */
  94167. export class PointParticleEmitter implements IParticleEmitterType {
  94168. /**
  94169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94170. */
  94171. direction1: Vector3;
  94172. /**
  94173. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94174. */
  94175. direction2: Vector3;
  94176. /**
  94177. * Creates a new instance PointParticleEmitter
  94178. */
  94179. constructor();
  94180. /**
  94181. * Called by the particle System when the direction is computed for the created particle.
  94182. * @param worldMatrix is the world matrix of the particle system
  94183. * @param directionToUpdate is the direction vector to update with the result
  94184. * @param particle is the particle we are computed the direction for
  94185. * @param isLocal defines if the direction should be set in local space
  94186. */
  94187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94188. /**
  94189. * Called by the particle System when the position is computed for the created particle.
  94190. * @param worldMatrix is the world matrix of the particle system
  94191. * @param positionToUpdate is the position vector to update with the result
  94192. * @param particle is the particle we are computed the position for
  94193. * @param isLocal defines if the position should be set in local space
  94194. */
  94195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94196. /**
  94197. * Clones the current emitter and returns a copy of it
  94198. * @returns the new emitter
  94199. */
  94200. clone(): PointParticleEmitter;
  94201. /**
  94202. * Called by the GPUParticleSystem to setup the update shader
  94203. * @param effect defines the update shader
  94204. */
  94205. applyToShader(effect: Effect): void;
  94206. /**
  94207. * Returns a string to use to update the GPU particles update shader
  94208. * @returns a string containng the defines string
  94209. */
  94210. getEffectDefines(): string;
  94211. /**
  94212. * Returns the string "PointParticleEmitter"
  94213. * @returns a string containing the class name
  94214. */
  94215. getClassName(): string;
  94216. /**
  94217. * Serializes the particle system to a JSON object.
  94218. * @returns the JSON object
  94219. */
  94220. serialize(): any;
  94221. /**
  94222. * Parse properties from a JSON object
  94223. * @param serializationObject defines the JSON object
  94224. */
  94225. parse(serializationObject: any): void;
  94226. }
  94227. }
  94228. declare module BABYLON {
  94229. /**
  94230. * Particle emitter emitting particles from the inside of a sphere.
  94231. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94232. */
  94233. export class SphereParticleEmitter implements IParticleEmitterType {
  94234. /**
  94235. * The radius of the emission sphere.
  94236. */
  94237. radius: number;
  94238. /**
  94239. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94240. */
  94241. radiusRange: number;
  94242. /**
  94243. * How much to randomize the particle direction [0-1].
  94244. */
  94245. directionRandomizer: number;
  94246. /**
  94247. * Creates a new instance SphereParticleEmitter
  94248. * @param radius the radius of the emission sphere (1 by default)
  94249. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94250. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94251. */
  94252. constructor(
  94253. /**
  94254. * The radius of the emission sphere.
  94255. */
  94256. radius?: number,
  94257. /**
  94258. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94259. */
  94260. radiusRange?: number,
  94261. /**
  94262. * How much to randomize the particle direction [0-1].
  94263. */
  94264. directionRandomizer?: number);
  94265. /**
  94266. * Called by the particle System when the direction is computed for the created particle.
  94267. * @param worldMatrix is the world matrix of the particle system
  94268. * @param directionToUpdate is the direction vector to update with the result
  94269. * @param particle is the particle we are computed the direction for
  94270. * @param isLocal defines if the direction should be set in local space
  94271. */
  94272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94273. /**
  94274. * Called by the particle System when the position is computed for the created particle.
  94275. * @param worldMatrix is the world matrix of the particle system
  94276. * @param positionToUpdate is the position vector to update with the result
  94277. * @param particle is the particle we are computed the position for
  94278. * @param isLocal defines if the position should be set in local space
  94279. */
  94280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94281. /**
  94282. * Clones the current emitter and returns a copy of it
  94283. * @returns the new emitter
  94284. */
  94285. clone(): SphereParticleEmitter;
  94286. /**
  94287. * Called by the GPUParticleSystem to setup the update shader
  94288. * @param effect defines the update shader
  94289. */
  94290. applyToShader(effect: Effect): void;
  94291. /**
  94292. * Returns a string to use to update the GPU particles update shader
  94293. * @returns a string containng the defines string
  94294. */
  94295. getEffectDefines(): string;
  94296. /**
  94297. * Returns the string "SphereParticleEmitter"
  94298. * @returns a string containing the class name
  94299. */
  94300. getClassName(): string;
  94301. /**
  94302. * Serializes the particle system to a JSON object.
  94303. * @returns the JSON object
  94304. */
  94305. serialize(): any;
  94306. /**
  94307. * Parse properties from a JSON object
  94308. * @param serializationObject defines the JSON object
  94309. */
  94310. parse(serializationObject: any): void;
  94311. }
  94312. /**
  94313. * Particle emitter emitting particles from the inside of a sphere.
  94314. * It emits the particles randomly between two vectors.
  94315. */
  94316. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94317. /**
  94318. * The min limit of the emission direction.
  94319. */
  94320. direction1: Vector3;
  94321. /**
  94322. * The max limit of the emission direction.
  94323. */
  94324. direction2: Vector3;
  94325. /**
  94326. * Creates a new instance SphereDirectedParticleEmitter
  94327. * @param radius the radius of the emission sphere (1 by default)
  94328. * @param direction1 the min limit of the emission direction (up vector by default)
  94329. * @param direction2 the max limit of the emission direction (up vector by default)
  94330. */
  94331. constructor(radius?: number,
  94332. /**
  94333. * The min limit of the emission direction.
  94334. */
  94335. direction1?: Vector3,
  94336. /**
  94337. * The max limit of the emission direction.
  94338. */
  94339. direction2?: Vector3);
  94340. /**
  94341. * Called by the particle System when the direction is computed for the created particle.
  94342. * @param worldMatrix is the world matrix of the particle system
  94343. * @param directionToUpdate is the direction vector to update with the result
  94344. * @param particle is the particle we are computed the direction for
  94345. */
  94346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94347. /**
  94348. * Clones the current emitter and returns a copy of it
  94349. * @returns the new emitter
  94350. */
  94351. clone(): SphereDirectedParticleEmitter;
  94352. /**
  94353. * Called by the GPUParticleSystem to setup the update shader
  94354. * @param effect defines the update shader
  94355. */
  94356. applyToShader(effect: Effect): void;
  94357. /**
  94358. * Returns a string to use to update the GPU particles update shader
  94359. * @returns a string containng the defines string
  94360. */
  94361. getEffectDefines(): string;
  94362. /**
  94363. * Returns the string "SphereDirectedParticleEmitter"
  94364. * @returns a string containing the class name
  94365. */
  94366. getClassName(): string;
  94367. /**
  94368. * Serializes the particle system to a JSON object.
  94369. * @returns the JSON object
  94370. */
  94371. serialize(): any;
  94372. /**
  94373. * Parse properties from a JSON object
  94374. * @param serializationObject defines the JSON object
  94375. */
  94376. parse(serializationObject: any): void;
  94377. }
  94378. }
  94379. declare module BABYLON {
  94380. /**
  94381. * Particle emitter emitting particles from a custom list of positions.
  94382. */
  94383. export class CustomParticleEmitter implements IParticleEmitterType {
  94384. /**
  94385. * Gets or sets the position generator that will create the inital position of each particle.
  94386. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94387. */
  94388. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94389. /**
  94390. * Gets or sets the destination generator that will create the final destination of each particle.
  94391. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94392. */
  94393. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94394. /**
  94395. * Creates a new instance CustomParticleEmitter
  94396. */
  94397. constructor();
  94398. /**
  94399. * Called by the particle System when the direction is computed for the created particle.
  94400. * @param worldMatrix is the world matrix of the particle system
  94401. * @param directionToUpdate is the direction vector to update with the result
  94402. * @param particle is the particle we are computed the direction for
  94403. * @param isLocal defines if the direction should be set in local space
  94404. */
  94405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94406. /**
  94407. * Called by the particle System when the position is computed for the created particle.
  94408. * @param worldMatrix is the world matrix of the particle system
  94409. * @param positionToUpdate is the position vector to update with the result
  94410. * @param particle is the particle we are computed the position for
  94411. * @param isLocal defines if the position should be set in local space
  94412. */
  94413. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94414. /**
  94415. * Clones the current emitter and returns a copy of it
  94416. * @returns the new emitter
  94417. */
  94418. clone(): CustomParticleEmitter;
  94419. /**
  94420. * Called by the GPUParticleSystem to setup the update shader
  94421. * @param effect defines the update shader
  94422. */
  94423. applyToShader(effect: Effect): void;
  94424. /**
  94425. * Returns a string to use to update the GPU particles update shader
  94426. * @returns a string containng the defines string
  94427. */
  94428. getEffectDefines(): string;
  94429. /**
  94430. * Returns the string "PointParticleEmitter"
  94431. * @returns a string containing the class name
  94432. */
  94433. getClassName(): string;
  94434. /**
  94435. * Serializes the particle system to a JSON object.
  94436. * @returns the JSON object
  94437. */
  94438. serialize(): any;
  94439. /**
  94440. * Parse properties from a JSON object
  94441. * @param serializationObject defines the JSON object
  94442. */
  94443. parse(serializationObject: any): void;
  94444. }
  94445. }
  94446. declare module BABYLON {
  94447. /**
  94448. * Particle emitter emitting particles from the inside of a box.
  94449. * It emits the particles randomly between 2 given directions.
  94450. */
  94451. export class MeshParticleEmitter implements IParticleEmitterType {
  94452. private _indices;
  94453. private _positions;
  94454. private _normals;
  94455. private _storedNormal;
  94456. private _mesh;
  94457. /**
  94458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94459. */
  94460. direction1: Vector3;
  94461. /**
  94462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94463. */
  94464. direction2: Vector3;
  94465. /**
  94466. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94467. */
  94468. useMeshNormalsForDirection: boolean;
  94469. /** Defines the mesh to use as source */
  94470. get mesh(): Nullable<AbstractMesh>;
  94471. set mesh(value: Nullable<AbstractMesh>);
  94472. /**
  94473. * Creates a new instance MeshParticleEmitter
  94474. * @param mesh defines the mesh to use as source
  94475. */
  94476. constructor(mesh?: Nullable<AbstractMesh>);
  94477. /**
  94478. * Called by the particle System when the direction is computed for the created particle.
  94479. * @param worldMatrix is the world matrix of the particle system
  94480. * @param directionToUpdate is the direction vector to update with the result
  94481. * @param particle is the particle we are computed the direction for
  94482. * @param isLocal defines if the direction should be set in local space
  94483. */
  94484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94485. /**
  94486. * Called by the particle System when the position is computed for the created particle.
  94487. * @param worldMatrix is the world matrix of the particle system
  94488. * @param positionToUpdate is the position vector to update with the result
  94489. * @param particle is the particle we are computed the position for
  94490. * @param isLocal defines if the position should be set in local space
  94491. */
  94492. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94493. /**
  94494. * Clones the current emitter and returns a copy of it
  94495. * @returns the new emitter
  94496. */
  94497. clone(): MeshParticleEmitter;
  94498. /**
  94499. * Called by the GPUParticleSystem to setup the update shader
  94500. * @param effect defines the update shader
  94501. */
  94502. applyToShader(effect: Effect): void;
  94503. /**
  94504. * Returns a string to use to update the GPU particles update shader
  94505. * @returns a string containng the defines string
  94506. */
  94507. getEffectDefines(): string;
  94508. /**
  94509. * Returns the string "BoxParticleEmitter"
  94510. * @returns a string containing the class name
  94511. */
  94512. getClassName(): string;
  94513. /**
  94514. * Serializes the particle system to a JSON object.
  94515. * @returns the JSON object
  94516. */
  94517. serialize(): any;
  94518. /**
  94519. * Parse properties from a JSON object
  94520. * @param serializationObject defines the JSON object
  94521. * @param scene defines the hosting scene
  94522. */
  94523. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94524. }
  94525. }
  94526. declare module BABYLON {
  94527. /**
  94528. * Interface representing a particle system in Babylon.js.
  94529. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94530. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94531. */
  94532. export interface IParticleSystem {
  94533. /**
  94534. * List of animations used by the particle system.
  94535. */
  94536. animations: Animation[];
  94537. /**
  94538. * The id of the Particle system.
  94539. */
  94540. id: string;
  94541. /**
  94542. * The name of the Particle system.
  94543. */
  94544. name: string;
  94545. /**
  94546. * The emitter represents the Mesh or position we are attaching the particle system to.
  94547. */
  94548. emitter: Nullable<AbstractMesh | Vector3>;
  94549. /**
  94550. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94551. */
  94552. isBillboardBased: boolean;
  94553. /**
  94554. * The rendering group used by the Particle system to chose when to render.
  94555. */
  94556. renderingGroupId: number;
  94557. /**
  94558. * The layer mask we are rendering the particles through.
  94559. */
  94560. layerMask: number;
  94561. /**
  94562. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94563. */
  94564. updateSpeed: number;
  94565. /**
  94566. * The amount of time the particle system is running (depends of the overall update speed).
  94567. */
  94568. targetStopDuration: number;
  94569. /**
  94570. * The texture used to render each particle. (this can be a spritesheet)
  94571. */
  94572. particleTexture: Nullable<BaseTexture>;
  94573. /**
  94574. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94575. */
  94576. blendMode: number;
  94577. /**
  94578. * Minimum life time of emitting particles.
  94579. */
  94580. minLifeTime: number;
  94581. /**
  94582. * Maximum life time of emitting particles.
  94583. */
  94584. maxLifeTime: number;
  94585. /**
  94586. * Minimum Size of emitting particles.
  94587. */
  94588. minSize: number;
  94589. /**
  94590. * Maximum Size of emitting particles.
  94591. */
  94592. maxSize: number;
  94593. /**
  94594. * Minimum scale of emitting particles on X axis.
  94595. */
  94596. minScaleX: number;
  94597. /**
  94598. * Maximum scale of emitting particles on X axis.
  94599. */
  94600. maxScaleX: number;
  94601. /**
  94602. * Minimum scale of emitting particles on Y axis.
  94603. */
  94604. minScaleY: number;
  94605. /**
  94606. * Maximum scale of emitting particles on Y axis.
  94607. */
  94608. maxScaleY: number;
  94609. /**
  94610. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94611. */
  94612. color1: Color4;
  94613. /**
  94614. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94615. */
  94616. color2: Color4;
  94617. /**
  94618. * Color the particle will have at the end of its lifetime.
  94619. */
  94620. colorDead: Color4;
  94621. /**
  94622. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94623. */
  94624. emitRate: number;
  94625. /**
  94626. * You can use gravity if you want to give an orientation to your particles.
  94627. */
  94628. gravity: Vector3;
  94629. /**
  94630. * Minimum power of emitting particles.
  94631. */
  94632. minEmitPower: number;
  94633. /**
  94634. * Maximum power of emitting particles.
  94635. */
  94636. maxEmitPower: number;
  94637. /**
  94638. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94639. */
  94640. minAngularSpeed: number;
  94641. /**
  94642. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94643. */
  94644. maxAngularSpeed: number;
  94645. /**
  94646. * Gets or sets the minimal initial rotation in radians.
  94647. */
  94648. minInitialRotation: number;
  94649. /**
  94650. * Gets or sets the maximal initial rotation in radians.
  94651. */
  94652. maxInitialRotation: number;
  94653. /**
  94654. * The particle emitter type defines the emitter used by the particle system.
  94655. * It can be for example box, sphere, or cone...
  94656. */
  94657. particleEmitterType: Nullable<IParticleEmitterType>;
  94658. /**
  94659. * Defines the delay in milliseconds before starting the system (0 by default)
  94660. */
  94661. startDelay: number;
  94662. /**
  94663. * 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
  94664. */
  94665. preWarmCycles: number;
  94666. /**
  94667. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94668. */
  94669. preWarmStepOffset: number;
  94670. /**
  94671. * 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)
  94672. */
  94673. spriteCellChangeSpeed: number;
  94674. /**
  94675. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94676. */
  94677. startSpriteCellID: number;
  94678. /**
  94679. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94680. */
  94681. endSpriteCellID: number;
  94682. /**
  94683. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94684. */
  94685. spriteCellWidth: number;
  94686. /**
  94687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94688. */
  94689. spriteCellHeight: number;
  94690. /**
  94691. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94692. */
  94693. spriteRandomStartCell: boolean;
  94694. /**
  94695. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94696. */
  94697. isAnimationSheetEnabled: boolean;
  94698. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94699. translationPivot: Vector2;
  94700. /**
  94701. * Gets or sets a texture used to add random noise to particle positions
  94702. */
  94703. noiseTexture: Nullable<BaseTexture>;
  94704. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94705. noiseStrength: Vector3;
  94706. /**
  94707. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94708. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94709. */
  94710. billboardMode: number;
  94711. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94712. limitVelocityDamping: number;
  94713. /**
  94714. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94715. */
  94716. beginAnimationOnStart: boolean;
  94717. /**
  94718. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94719. */
  94720. beginAnimationFrom: number;
  94721. /**
  94722. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94723. */
  94724. beginAnimationTo: number;
  94725. /**
  94726. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94727. */
  94728. beginAnimationLoop: boolean;
  94729. /**
  94730. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94731. */
  94732. disposeOnStop: boolean;
  94733. /**
  94734. * Specifies if the particles are updated in emitter local space or world space
  94735. */
  94736. isLocal: boolean;
  94737. /** Snippet ID if the particle system was created from the snippet server */
  94738. snippetId: string;
  94739. /** Gets or sets a matrix to use to compute projection */
  94740. defaultProjectionMatrix: Matrix;
  94741. /**
  94742. * Gets the maximum number of particles active at the same time.
  94743. * @returns The max number of active particles.
  94744. */
  94745. getCapacity(): number;
  94746. /**
  94747. * Gets the number of particles active at the same time.
  94748. * @returns The number of active particles.
  94749. */
  94750. getActiveCount(): number;
  94751. /**
  94752. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94753. * @returns True if it has been started, otherwise false.
  94754. */
  94755. isStarted(): boolean;
  94756. /**
  94757. * Animates the particle system for this frame.
  94758. */
  94759. animate(): void;
  94760. /**
  94761. * Renders the particle system in its current state.
  94762. * @returns the current number of particles
  94763. */
  94764. render(): number;
  94765. /**
  94766. * Dispose the particle system and frees its associated resources.
  94767. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94768. */
  94769. dispose(disposeTexture?: boolean): void;
  94770. /**
  94771. * An event triggered when the system is disposed
  94772. */
  94773. onDisposeObservable: Observable<IParticleSystem>;
  94774. /**
  94775. * Clones the particle system.
  94776. * @param name The name of the cloned object
  94777. * @param newEmitter The new emitter to use
  94778. * @returns the cloned particle system
  94779. */
  94780. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94781. /**
  94782. * Serializes the particle system to a JSON object
  94783. * @param serializeTexture defines if the texture must be serialized as well
  94784. * @returns the JSON object
  94785. */
  94786. serialize(serializeTexture: boolean): any;
  94787. /**
  94788. * Rebuild the particle system
  94789. */
  94790. rebuild(): void;
  94791. /** Force the system to rebuild all gradients that need to be resync */
  94792. forceRefreshGradients(): void;
  94793. /**
  94794. * Starts the particle system and begins to emit
  94795. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94796. */
  94797. start(delay?: number): void;
  94798. /**
  94799. * Stops the particle system.
  94800. */
  94801. stop(): void;
  94802. /**
  94803. * Remove all active particles
  94804. */
  94805. reset(): void;
  94806. /**
  94807. * Gets a boolean indicating that the system is stopping
  94808. * @returns true if the system is currently stopping
  94809. */
  94810. isStopping(): boolean;
  94811. /**
  94812. * Is this system ready to be used/rendered
  94813. * @return true if the system is ready
  94814. */
  94815. isReady(): boolean;
  94816. /**
  94817. * Returns the string "ParticleSystem"
  94818. * @returns a string containing the class name
  94819. */
  94820. getClassName(): string;
  94821. /**
  94822. * Gets the custom effect used to render the particles
  94823. * @param blendMode Blend mode for which the effect should be retrieved
  94824. * @returns The effect
  94825. */
  94826. getCustomEffect(blendMode: number): Nullable<Effect>;
  94827. /**
  94828. * Sets the custom effect used to render the particles
  94829. * @param effect The effect to set
  94830. * @param blendMode Blend mode for which the effect should be set
  94831. */
  94832. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94833. /**
  94834. * Fill the defines array according to the current settings of the particle system
  94835. * @param defines Array to be updated
  94836. * @param blendMode blend mode to take into account when updating the array
  94837. */
  94838. fillDefines(defines: Array<string>, blendMode: number): void;
  94839. /**
  94840. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94841. * @param uniforms Uniforms array to fill
  94842. * @param attributes Attributes array to fill
  94843. * @param samplers Samplers array to fill
  94844. */
  94845. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94846. /**
  94847. * Observable that will be called just before the particles are drawn
  94848. */
  94849. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94850. /**
  94851. * Gets the name of the particle vertex shader
  94852. */
  94853. vertexShaderName: string;
  94854. /**
  94855. * Adds a new color gradient
  94856. * @param gradient defines the gradient to use (between 0 and 1)
  94857. * @param color1 defines the color to affect to the specified gradient
  94858. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94859. * @returns the current particle system
  94860. */
  94861. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94862. /**
  94863. * Remove a specific color gradient
  94864. * @param gradient defines the gradient to remove
  94865. * @returns the current particle system
  94866. */
  94867. removeColorGradient(gradient: number): IParticleSystem;
  94868. /**
  94869. * Adds a new size gradient
  94870. * @param gradient defines the gradient to use (between 0 and 1)
  94871. * @param factor defines the size factor to affect to the specified gradient
  94872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94873. * @returns the current particle system
  94874. */
  94875. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94876. /**
  94877. * Remove a specific size gradient
  94878. * @param gradient defines the gradient to remove
  94879. * @returns the current particle system
  94880. */
  94881. removeSizeGradient(gradient: number): IParticleSystem;
  94882. /**
  94883. * Gets the current list of color gradients.
  94884. * You must use addColorGradient and removeColorGradient to udpate this list
  94885. * @returns the list of color gradients
  94886. */
  94887. getColorGradients(): Nullable<Array<ColorGradient>>;
  94888. /**
  94889. * Gets the current list of size gradients.
  94890. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94891. * @returns the list of size gradients
  94892. */
  94893. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94894. /**
  94895. * Gets the current list of angular speed gradients.
  94896. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94897. * @returns the list of angular speed gradients
  94898. */
  94899. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94900. /**
  94901. * Adds a new angular speed gradient
  94902. * @param gradient defines the gradient to use (between 0 and 1)
  94903. * @param factor defines the angular speed to affect to the specified gradient
  94904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94905. * @returns the current particle system
  94906. */
  94907. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94908. /**
  94909. * Remove a specific angular speed gradient
  94910. * @param gradient defines the gradient to remove
  94911. * @returns the current particle system
  94912. */
  94913. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94914. /**
  94915. * Gets the current list of velocity gradients.
  94916. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94917. * @returns the list of velocity gradients
  94918. */
  94919. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94920. /**
  94921. * Adds a new velocity gradient
  94922. * @param gradient defines the gradient to use (between 0 and 1)
  94923. * @param factor defines the velocity to affect to the specified gradient
  94924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94925. * @returns the current particle system
  94926. */
  94927. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94928. /**
  94929. * Remove a specific velocity gradient
  94930. * @param gradient defines the gradient to remove
  94931. * @returns the current particle system
  94932. */
  94933. removeVelocityGradient(gradient: number): IParticleSystem;
  94934. /**
  94935. * Gets the current list of limit velocity gradients.
  94936. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94937. * @returns the list of limit velocity gradients
  94938. */
  94939. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94940. /**
  94941. * Adds a new limit velocity gradient
  94942. * @param gradient defines the gradient to use (between 0 and 1)
  94943. * @param factor defines the limit velocity to affect to the specified gradient
  94944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94945. * @returns the current particle system
  94946. */
  94947. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94948. /**
  94949. * Remove a specific limit velocity gradient
  94950. * @param gradient defines the gradient to remove
  94951. * @returns the current particle system
  94952. */
  94953. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94954. /**
  94955. * Adds a new drag gradient
  94956. * @param gradient defines the gradient to use (between 0 and 1)
  94957. * @param factor defines the drag to affect to the specified gradient
  94958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94959. * @returns the current particle system
  94960. */
  94961. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94962. /**
  94963. * Remove a specific drag gradient
  94964. * @param gradient defines the gradient to remove
  94965. * @returns the current particle system
  94966. */
  94967. removeDragGradient(gradient: number): IParticleSystem;
  94968. /**
  94969. * Gets the current list of drag gradients.
  94970. * You must use addDragGradient and removeDragGradient to udpate this list
  94971. * @returns the list of drag gradients
  94972. */
  94973. getDragGradients(): Nullable<Array<FactorGradient>>;
  94974. /**
  94975. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94976. * @param gradient defines the gradient to use (between 0 and 1)
  94977. * @param factor defines the emit rate to affect to the specified gradient
  94978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94979. * @returns the current particle system
  94980. */
  94981. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94982. /**
  94983. * Remove a specific emit rate gradient
  94984. * @param gradient defines the gradient to remove
  94985. * @returns the current particle system
  94986. */
  94987. removeEmitRateGradient(gradient: number): IParticleSystem;
  94988. /**
  94989. * Gets the current list of emit rate gradients.
  94990. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94991. * @returns the list of emit rate gradients
  94992. */
  94993. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94994. /**
  94995. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94996. * @param gradient defines the gradient to use (between 0 and 1)
  94997. * @param factor defines the start size to affect to the specified gradient
  94998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94999. * @returns the current particle system
  95000. */
  95001. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95002. /**
  95003. * Remove a specific start size gradient
  95004. * @param gradient defines the gradient to remove
  95005. * @returns the current particle system
  95006. */
  95007. removeStartSizeGradient(gradient: number): IParticleSystem;
  95008. /**
  95009. * Gets the current list of start size gradients.
  95010. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95011. * @returns the list of start size gradients
  95012. */
  95013. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95014. /**
  95015. * Adds a new life time gradient
  95016. * @param gradient defines the gradient to use (between 0 and 1)
  95017. * @param factor defines the life time factor to affect to the specified gradient
  95018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95019. * @returns the current particle system
  95020. */
  95021. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95022. /**
  95023. * Remove a specific life time gradient
  95024. * @param gradient defines the gradient to remove
  95025. * @returns the current particle system
  95026. */
  95027. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95028. /**
  95029. * Gets the current list of life time gradients.
  95030. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95031. * @returns the list of life time gradients
  95032. */
  95033. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95034. /**
  95035. * Gets the current list of color gradients.
  95036. * You must use addColorGradient and removeColorGradient to udpate this list
  95037. * @returns the list of color gradients
  95038. */
  95039. getColorGradients(): Nullable<Array<ColorGradient>>;
  95040. /**
  95041. * Adds a new ramp gradient used to remap particle colors
  95042. * @param gradient defines the gradient to use (between 0 and 1)
  95043. * @param color defines the color to affect to the specified gradient
  95044. * @returns the current particle system
  95045. */
  95046. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95047. /**
  95048. * Gets the current list of ramp gradients.
  95049. * You must use addRampGradient and removeRampGradient to udpate this list
  95050. * @returns the list of ramp gradients
  95051. */
  95052. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95053. /** Gets or sets a boolean indicating that ramp gradients must be used
  95054. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95055. */
  95056. useRampGradients: boolean;
  95057. /**
  95058. * Adds a new color remap gradient
  95059. * @param gradient defines the gradient to use (between 0 and 1)
  95060. * @param min defines the color remap minimal range
  95061. * @param max defines the color remap maximal range
  95062. * @returns the current particle system
  95063. */
  95064. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95065. /**
  95066. * Gets the current list of color remap gradients.
  95067. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95068. * @returns the list of color remap gradients
  95069. */
  95070. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95071. /**
  95072. * Adds a new alpha remap gradient
  95073. * @param gradient defines the gradient to use (between 0 and 1)
  95074. * @param min defines the alpha remap minimal range
  95075. * @param max defines the alpha remap maximal range
  95076. * @returns the current particle system
  95077. */
  95078. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95079. /**
  95080. * Gets the current list of alpha remap gradients.
  95081. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95082. * @returns the list of alpha remap gradients
  95083. */
  95084. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95085. /**
  95086. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95087. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95088. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95089. * @returns the emitter
  95090. */
  95091. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95092. /**
  95093. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95094. * @param radius The radius of the hemisphere to emit from
  95095. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95096. * @returns the emitter
  95097. */
  95098. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95099. /**
  95100. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95101. * @param radius The radius of the sphere to emit from
  95102. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95103. * @returns the emitter
  95104. */
  95105. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95106. /**
  95107. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95108. * @param radius The radius of the sphere to emit from
  95109. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95110. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95111. * @returns the emitter
  95112. */
  95113. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95114. /**
  95115. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95116. * @param radius The radius of the emission cylinder
  95117. * @param height The height of the emission cylinder
  95118. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95119. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95120. * @returns the emitter
  95121. */
  95122. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95123. /**
  95124. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95125. * @param radius The radius of the cylinder to emit from
  95126. * @param height The height of the emission cylinder
  95127. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95128. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95129. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95130. * @returns the emitter
  95131. */
  95132. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95133. /**
  95134. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95135. * @param radius The radius of the cone to emit from
  95136. * @param angle The base angle of the cone
  95137. * @returns the emitter
  95138. */
  95139. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95140. /**
  95141. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95142. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95143. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95144. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95145. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95146. * @returns the emitter
  95147. */
  95148. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95149. /**
  95150. * Get hosting scene
  95151. * @returns the scene
  95152. */
  95153. getScene(): Nullable<Scene>;
  95154. }
  95155. }
  95156. declare module BABYLON {
  95157. /**
  95158. * 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.
  95159. * @see https://doc.babylonjs.com/how_to/transformnode
  95160. */
  95161. export class TransformNode extends Node {
  95162. /**
  95163. * Object will not rotate to face the camera
  95164. */
  95165. static BILLBOARDMODE_NONE: number;
  95166. /**
  95167. * Object will rotate to face the camera but only on the x axis
  95168. */
  95169. static BILLBOARDMODE_X: number;
  95170. /**
  95171. * Object will rotate to face the camera but only on the y axis
  95172. */
  95173. static BILLBOARDMODE_Y: number;
  95174. /**
  95175. * Object will rotate to face the camera but only on the z axis
  95176. */
  95177. static BILLBOARDMODE_Z: number;
  95178. /**
  95179. * Object will rotate to face the camera
  95180. */
  95181. static BILLBOARDMODE_ALL: number;
  95182. /**
  95183. * Object will rotate to face the camera's position instead of orientation
  95184. */
  95185. static BILLBOARDMODE_USE_POSITION: number;
  95186. private static _TmpRotation;
  95187. private static _TmpScaling;
  95188. private static _TmpTranslation;
  95189. private _forward;
  95190. private _forwardInverted;
  95191. private _up;
  95192. private _right;
  95193. private _rightInverted;
  95194. private _position;
  95195. private _rotation;
  95196. private _rotationQuaternion;
  95197. protected _scaling: Vector3;
  95198. protected _isDirty: boolean;
  95199. private _transformToBoneReferal;
  95200. private _isAbsoluteSynced;
  95201. private _billboardMode;
  95202. /**
  95203. * Gets or sets the billboard mode. Default is 0.
  95204. *
  95205. * | Value | Type | Description |
  95206. * | --- | --- | --- |
  95207. * | 0 | BILLBOARDMODE_NONE | |
  95208. * | 1 | BILLBOARDMODE_X | |
  95209. * | 2 | BILLBOARDMODE_Y | |
  95210. * | 4 | BILLBOARDMODE_Z | |
  95211. * | 7 | BILLBOARDMODE_ALL | |
  95212. *
  95213. */
  95214. get billboardMode(): number;
  95215. set billboardMode(value: number);
  95216. private _preserveParentRotationForBillboard;
  95217. /**
  95218. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95219. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95220. */
  95221. get preserveParentRotationForBillboard(): boolean;
  95222. set preserveParentRotationForBillboard(value: boolean);
  95223. /**
  95224. * 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
  95225. */
  95226. scalingDeterminant: number;
  95227. private _infiniteDistance;
  95228. /**
  95229. * Gets or sets the distance of the object to max, often used by skybox
  95230. */
  95231. get infiniteDistance(): boolean;
  95232. set infiniteDistance(value: boolean);
  95233. /**
  95234. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95235. * By default the system will update normals to compensate
  95236. */
  95237. ignoreNonUniformScaling: boolean;
  95238. /**
  95239. * 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
  95240. */
  95241. reIntegrateRotationIntoRotationQuaternion: boolean;
  95242. /** @hidden */
  95243. _poseMatrix: Nullable<Matrix>;
  95244. /** @hidden */
  95245. _localMatrix: Matrix;
  95246. private _usePivotMatrix;
  95247. private _absolutePosition;
  95248. private _absoluteScaling;
  95249. private _absoluteRotationQuaternion;
  95250. private _pivotMatrix;
  95251. private _pivotMatrixInverse;
  95252. /** @hidden */
  95253. _postMultiplyPivotMatrix: boolean;
  95254. protected _isWorldMatrixFrozen: boolean;
  95255. /** @hidden */
  95256. _indexInSceneTransformNodesArray: number;
  95257. /**
  95258. * An event triggered after the world matrix is updated
  95259. */
  95260. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95261. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95262. /**
  95263. * Gets a string identifying the name of the class
  95264. * @returns "TransformNode" string
  95265. */
  95266. getClassName(): string;
  95267. /**
  95268. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95269. */
  95270. get position(): Vector3;
  95271. set position(newPosition: Vector3);
  95272. /**
  95273. * 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)).
  95274. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95275. */
  95276. get rotation(): Vector3;
  95277. set rotation(newRotation: Vector3);
  95278. /**
  95279. * 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)).
  95280. */
  95281. get scaling(): Vector3;
  95282. set scaling(newScaling: Vector3);
  95283. /**
  95284. * 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).
  95285. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95286. */
  95287. get rotationQuaternion(): Nullable<Quaternion>;
  95288. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95289. /**
  95290. * The forward direction of that transform in world space.
  95291. */
  95292. get forward(): Vector3;
  95293. /**
  95294. * The up direction of that transform in world space.
  95295. */
  95296. get up(): Vector3;
  95297. /**
  95298. * The right direction of that transform in world space.
  95299. */
  95300. get right(): Vector3;
  95301. /**
  95302. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95303. * @param matrix the matrix to copy the pose from
  95304. * @returns this TransformNode.
  95305. */
  95306. updatePoseMatrix(matrix: Matrix): TransformNode;
  95307. /**
  95308. * Returns the mesh Pose matrix.
  95309. * @returns the pose matrix
  95310. */
  95311. getPoseMatrix(): Matrix;
  95312. /** @hidden */
  95313. _isSynchronized(): boolean;
  95314. /** @hidden */
  95315. _initCache(): void;
  95316. /**
  95317. * Flag the transform node as dirty (Forcing it to update everything)
  95318. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95319. * @returns this transform node
  95320. */
  95321. markAsDirty(property: string): TransformNode;
  95322. /**
  95323. * Returns the current mesh absolute position.
  95324. * Returns a Vector3.
  95325. */
  95326. get absolutePosition(): Vector3;
  95327. /**
  95328. * Returns the current mesh absolute scaling.
  95329. * Returns a Vector3.
  95330. */
  95331. get absoluteScaling(): Vector3;
  95332. /**
  95333. * Returns the current mesh absolute rotation.
  95334. * Returns a Quaternion.
  95335. */
  95336. get absoluteRotationQuaternion(): Quaternion;
  95337. /**
  95338. * Sets a new matrix to apply before all other transformation
  95339. * @param matrix defines the transform matrix
  95340. * @returns the current TransformNode
  95341. */
  95342. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95343. /**
  95344. * Sets a new pivot matrix to the current node
  95345. * @param matrix defines the new pivot matrix to use
  95346. * @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
  95347. * @returns the current TransformNode
  95348. */
  95349. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95350. /**
  95351. * Returns the mesh pivot matrix.
  95352. * Default : Identity.
  95353. * @returns the matrix
  95354. */
  95355. getPivotMatrix(): Matrix;
  95356. /**
  95357. * Instantiate (when possible) or clone that node with its hierarchy
  95358. * @param newParent defines the new parent to use for the instance (or clone)
  95359. * @param options defines options to configure how copy is done
  95360. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95361. * @returns an instance (or a clone) of the current node with its hiearchy
  95362. */
  95363. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95364. doNotInstantiate: boolean;
  95365. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95366. /**
  95367. * Prevents the World matrix to be computed any longer
  95368. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95369. * @returns the TransformNode.
  95370. */
  95371. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95372. /**
  95373. * Allows back the World matrix computation.
  95374. * @returns the TransformNode.
  95375. */
  95376. unfreezeWorldMatrix(): this;
  95377. /**
  95378. * True if the World matrix has been frozen.
  95379. */
  95380. get isWorldMatrixFrozen(): boolean;
  95381. /**
  95382. * Retuns the mesh absolute position in the World.
  95383. * @returns a Vector3.
  95384. */
  95385. getAbsolutePosition(): Vector3;
  95386. /**
  95387. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95388. * @param absolutePosition the absolute position to set
  95389. * @returns the TransformNode.
  95390. */
  95391. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95392. /**
  95393. * Sets the mesh position in its local space.
  95394. * @param vector3 the position to set in localspace
  95395. * @returns the TransformNode.
  95396. */
  95397. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95398. /**
  95399. * Returns the mesh position in the local space from the current World matrix values.
  95400. * @returns a new Vector3.
  95401. */
  95402. getPositionExpressedInLocalSpace(): Vector3;
  95403. /**
  95404. * Translates the mesh along the passed Vector3 in its local space.
  95405. * @param vector3 the distance to translate in localspace
  95406. * @returns the TransformNode.
  95407. */
  95408. locallyTranslate(vector3: Vector3): TransformNode;
  95409. private static _lookAtVectorCache;
  95410. /**
  95411. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95412. * @param targetPoint the position (must be in same space as current mesh) to look at
  95413. * @param yawCor optional yaw (y-axis) correction in radians
  95414. * @param pitchCor optional pitch (x-axis) correction in radians
  95415. * @param rollCor optional roll (z-axis) correction in radians
  95416. * @param space the choosen space of the target
  95417. * @returns the TransformNode.
  95418. */
  95419. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95420. /**
  95421. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95422. * This Vector3 is expressed in the World space.
  95423. * @param localAxis axis to rotate
  95424. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95425. */
  95426. getDirection(localAxis: Vector3): Vector3;
  95427. /**
  95428. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95429. * localAxis is expressed in the mesh local space.
  95430. * result is computed in the Wordl space from the mesh World matrix.
  95431. * @param localAxis axis to rotate
  95432. * @param result the resulting transformnode
  95433. * @returns this TransformNode.
  95434. */
  95435. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95436. /**
  95437. * Sets this transform node rotation to the given local axis.
  95438. * @param localAxis the axis in local space
  95439. * @param yawCor optional yaw (y-axis) correction in radians
  95440. * @param pitchCor optional pitch (x-axis) correction in radians
  95441. * @param rollCor optional roll (z-axis) correction in radians
  95442. * @returns this TransformNode
  95443. */
  95444. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95445. /**
  95446. * Sets a new pivot point to the current node
  95447. * @param point defines the new pivot point to use
  95448. * @param space defines if the point is in world or local space (local by default)
  95449. * @returns the current TransformNode
  95450. */
  95451. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95452. /**
  95453. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95454. * @returns the pivot point
  95455. */
  95456. getPivotPoint(): Vector3;
  95457. /**
  95458. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95459. * @param result the vector3 to store the result
  95460. * @returns this TransformNode.
  95461. */
  95462. getPivotPointToRef(result: Vector3): TransformNode;
  95463. /**
  95464. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95465. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95466. */
  95467. getAbsolutePivotPoint(): Vector3;
  95468. /**
  95469. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95470. * @param result vector3 to store the result
  95471. * @returns this TransformNode.
  95472. */
  95473. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95474. /**
  95475. * Defines the passed node as the parent of the current node.
  95476. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95477. * @see https://doc.babylonjs.com/how_to/parenting
  95478. * @param node the node ot set as the parent
  95479. * @returns this TransformNode.
  95480. */
  95481. setParent(node: Nullable<Node>): TransformNode;
  95482. private _nonUniformScaling;
  95483. /**
  95484. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95485. */
  95486. get nonUniformScaling(): boolean;
  95487. /** @hidden */
  95488. _updateNonUniformScalingState(value: boolean): boolean;
  95489. /**
  95490. * Attach the current TransformNode to another TransformNode associated with a bone
  95491. * @param bone Bone affecting the TransformNode
  95492. * @param affectedTransformNode TransformNode associated with the bone
  95493. * @returns this object
  95494. */
  95495. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95496. /**
  95497. * Detach the transform node if its associated with a bone
  95498. * @returns this object
  95499. */
  95500. detachFromBone(): TransformNode;
  95501. private static _rotationAxisCache;
  95502. /**
  95503. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95504. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95505. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95506. * The passed axis is also normalized.
  95507. * @param axis the axis to rotate around
  95508. * @param amount the amount to rotate in radians
  95509. * @param space Space to rotate in (Default: local)
  95510. * @returns the TransformNode.
  95511. */
  95512. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95513. /**
  95514. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95515. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95516. * The passed axis is also normalized. .
  95517. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95518. * @param point the point to rotate around
  95519. * @param axis the axis to rotate around
  95520. * @param amount the amount to rotate in radians
  95521. * @returns the TransformNode
  95522. */
  95523. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95524. /**
  95525. * Translates the mesh along the axis vector for the passed distance in the given space.
  95526. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95527. * @param axis the axis to translate in
  95528. * @param distance the distance to translate
  95529. * @param space Space to rotate in (Default: local)
  95530. * @returns the TransformNode.
  95531. */
  95532. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95533. /**
  95534. * Adds a rotation step to the mesh current rotation.
  95535. * x, y, z are Euler angles expressed in radians.
  95536. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95537. * This means this rotation is made in the mesh local space only.
  95538. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95539. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95540. * ```javascript
  95541. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95542. * ```
  95543. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95544. * 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.
  95545. * @param x Rotation to add
  95546. * @param y Rotation to add
  95547. * @param z Rotation to add
  95548. * @returns the TransformNode.
  95549. */
  95550. addRotation(x: number, y: number, z: number): TransformNode;
  95551. /**
  95552. * @hidden
  95553. */
  95554. protected _getEffectiveParent(): Nullable<Node>;
  95555. /**
  95556. * Computes the world matrix of the node
  95557. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95558. * @returns the world matrix
  95559. */
  95560. computeWorldMatrix(force?: boolean): Matrix;
  95561. /**
  95562. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95563. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95564. */
  95565. resetLocalMatrix(independentOfChildren?: boolean): void;
  95566. protected _afterComputeWorldMatrix(): void;
  95567. /**
  95568. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95569. * @param func callback function to add
  95570. *
  95571. * @returns the TransformNode.
  95572. */
  95573. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95574. /**
  95575. * Removes a registered callback function.
  95576. * @param func callback function to remove
  95577. * @returns the TransformNode.
  95578. */
  95579. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95580. /**
  95581. * Gets the position of the current mesh in camera space
  95582. * @param camera defines the camera to use
  95583. * @returns a position
  95584. */
  95585. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95586. /**
  95587. * Returns the distance from the mesh to the active camera
  95588. * @param camera defines the camera to use
  95589. * @returns the distance
  95590. */
  95591. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95592. /**
  95593. * Clone the current transform node
  95594. * @param name Name of the new clone
  95595. * @param newParent New parent for the clone
  95596. * @param doNotCloneChildren Do not clone children hierarchy
  95597. * @returns the new transform node
  95598. */
  95599. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95600. /**
  95601. * Serializes the objects information.
  95602. * @param currentSerializationObject defines the object to serialize in
  95603. * @returns the serialized object
  95604. */
  95605. serialize(currentSerializationObject?: any): any;
  95606. /**
  95607. * Returns a new TransformNode object parsed from the source provided.
  95608. * @param parsedTransformNode is the source.
  95609. * @param scene the scne the object belongs to
  95610. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95611. * @returns a new TransformNode object parsed from the source provided.
  95612. */
  95613. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95614. /**
  95615. * Get all child-transformNodes of this node
  95616. * @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
  95617. * @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
  95618. * @returns an array of TransformNode
  95619. */
  95620. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95621. /**
  95622. * Releases resources associated with this transform node.
  95623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95625. */
  95626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95627. /**
  95628. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95629. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95630. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95631. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95632. * @returns the current mesh
  95633. */
  95634. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95635. private _syncAbsoluteScalingAndRotation;
  95636. }
  95637. }
  95638. declare module BABYLON {
  95639. /**
  95640. * Class used to override all child animations of a given target
  95641. */
  95642. export class AnimationPropertiesOverride {
  95643. /**
  95644. * Gets or sets a value indicating if animation blending must be used
  95645. */
  95646. enableBlending: boolean;
  95647. /**
  95648. * Gets or sets the blending speed to use when enableBlending is true
  95649. */
  95650. blendingSpeed: number;
  95651. /**
  95652. * Gets or sets the default loop mode to use
  95653. */
  95654. loopMode: number;
  95655. }
  95656. }
  95657. declare module BABYLON {
  95658. /**
  95659. * Class used to store bone information
  95660. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95661. */
  95662. export class Bone extends Node {
  95663. /**
  95664. * defines the bone name
  95665. */
  95666. name: string;
  95667. private static _tmpVecs;
  95668. private static _tmpQuat;
  95669. private static _tmpMats;
  95670. /**
  95671. * Gets the list of child bones
  95672. */
  95673. children: Bone[];
  95674. /** Gets the animations associated with this bone */
  95675. animations: Animation[];
  95676. /**
  95677. * Gets or sets bone length
  95678. */
  95679. length: number;
  95680. /**
  95681. * @hidden Internal only
  95682. * Set this value to map this bone to a different index in the transform matrices
  95683. * Set this value to -1 to exclude the bone from the transform matrices
  95684. */
  95685. _index: Nullable<number>;
  95686. private _skeleton;
  95687. private _localMatrix;
  95688. private _restPose;
  95689. private _bindPose;
  95690. private _baseMatrix;
  95691. private _absoluteTransform;
  95692. private _invertedAbsoluteTransform;
  95693. private _parent;
  95694. private _scalingDeterminant;
  95695. private _worldTransform;
  95696. private _localScaling;
  95697. private _localRotation;
  95698. private _localPosition;
  95699. private _needToDecompose;
  95700. private _needToCompose;
  95701. /** @hidden */
  95702. _linkedTransformNode: Nullable<TransformNode>;
  95703. /** @hidden */
  95704. _waitingTransformNodeId: Nullable<string>;
  95705. /** @hidden */
  95706. get _matrix(): Matrix;
  95707. /** @hidden */
  95708. set _matrix(value: Matrix);
  95709. /**
  95710. * Create a new bone
  95711. * @param name defines the bone name
  95712. * @param skeleton defines the parent skeleton
  95713. * @param parentBone defines the parent (can be null if the bone is the root)
  95714. * @param localMatrix defines the local matrix
  95715. * @param restPose defines the rest pose matrix
  95716. * @param baseMatrix defines the base matrix
  95717. * @param index defines index of the bone in the hiearchy
  95718. */
  95719. constructor(
  95720. /**
  95721. * defines the bone name
  95722. */
  95723. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95724. /**
  95725. * Gets the current object class name.
  95726. * @return the class name
  95727. */
  95728. getClassName(): string;
  95729. /**
  95730. * Gets the parent skeleton
  95731. * @returns a skeleton
  95732. */
  95733. getSkeleton(): Skeleton;
  95734. /**
  95735. * Gets parent bone
  95736. * @returns a bone or null if the bone is the root of the bone hierarchy
  95737. */
  95738. getParent(): Nullable<Bone>;
  95739. /**
  95740. * Returns an array containing the root bones
  95741. * @returns an array containing the root bones
  95742. */
  95743. getChildren(): Array<Bone>;
  95744. /**
  95745. * Gets the node index in matrix array generated for rendering
  95746. * @returns the node index
  95747. */
  95748. getIndex(): number;
  95749. /**
  95750. * Sets the parent bone
  95751. * @param parent defines the parent (can be null if the bone is the root)
  95752. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95753. */
  95754. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95755. /**
  95756. * Gets the local matrix
  95757. * @returns a matrix
  95758. */
  95759. getLocalMatrix(): Matrix;
  95760. /**
  95761. * Gets the base matrix (initial matrix which remains unchanged)
  95762. * @returns a matrix
  95763. */
  95764. getBaseMatrix(): Matrix;
  95765. /**
  95766. * Gets the rest pose matrix
  95767. * @returns a matrix
  95768. */
  95769. getRestPose(): Matrix;
  95770. /**
  95771. * Sets the rest pose matrix
  95772. * @param matrix the local-space rest pose to set for this bone
  95773. */
  95774. setRestPose(matrix: Matrix): void;
  95775. /**
  95776. * Gets the bind pose matrix
  95777. * @returns the bind pose matrix
  95778. */
  95779. getBindPose(): Matrix;
  95780. /**
  95781. * Sets the bind pose matrix
  95782. * @param matrix the local-space bind pose to set for this bone
  95783. */
  95784. setBindPose(matrix: Matrix): void;
  95785. /**
  95786. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95787. */
  95788. getWorldMatrix(): Matrix;
  95789. /**
  95790. * Sets the local matrix to rest pose matrix
  95791. */
  95792. returnToRest(): void;
  95793. /**
  95794. * Gets the inverse of the absolute transform matrix.
  95795. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95796. * @returns a matrix
  95797. */
  95798. getInvertedAbsoluteTransform(): Matrix;
  95799. /**
  95800. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95801. * @returns a matrix
  95802. */
  95803. getAbsoluteTransform(): Matrix;
  95804. /**
  95805. * Links with the given transform node.
  95806. * The local matrix of this bone is copied from the transform node every frame.
  95807. * @param transformNode defines the transform node to link to
  95808. */
  95809. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95810. /**
  95811. * Gets the node used to drive the bone's transformation
  95812. * @returns a transform node or null
  95813. */
  95814. getTransformNode(): Nullable<TransformNode>;
  95815. /** Gets or sets current position (in local space) */
  95816. get position(): Vector3;
  95817. set position(newPosition: Vector3);
  95818. /** Gets or sets current rotation (in local space) */
  95819. get rotation(): Vector3;
  95820. set rotation(newRotation: Vector3);
  95821. /** Gets or sets current rotation quaternion (in local space) */
  95822. get rotationQuaternion(): Quaternion;
  95823. set rotationQuaternion(newRotation: Quaternion);
  95824. /** Gets or sets current scaling (in local space) */
  95825. get scaling(): Vector3;
  95826. set scaling(newScaling: Vector3);
  95827. /**
  95828. * Gets the animation properties override
  95829. */
  95830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95831. private _decompose;
  95832. private _compose;
  95833. /**
  95834. * Update the base and local matrices
  95835. * @param matrix defines the new base or local matrix
  95836. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95837. * @param updateLocalMatrix defines if the local matrix should be updated
  95838. */
  95839. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95840. /** @hidden */
  95841. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95842. /**
  95843. * Flag the bone as dirty (Forcing it to update everything)
  95844. */
  95845. markAsDirty(): void;
  95846. /** @hidden */
  95847. _markAsDirtyAndCompose(): void;
  95848. private _markAsDirtyAndDecompose;
  95849. /**
  95850. * Translate the bone in local or world space
  95851. * @param vec The amount to translate the bone
  95852. * @param space The space that the translation is in
  95853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95854. */
  95855. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95856. /**
  95857. * Set the postion of the bone in local or world space
  95858. * @param position The position to set the bone
  95859. * @param space The space that the position is in
  95860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95861. */
  95862. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95863. /**
  95864. * Set the absolute position of the bone (world space)
  95865. * @param position The position to set the bone
  95866. * @param mesh The mesh that this bone is attached to
  95867. */
  95868. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95869. /**
  95870. * Scale the bone on the x, y and z axes (in local space)
  95871. * @param x The amount to scale the bone on the x axis
  95872. * @param y The amount to scale the bone on the y axis
  95873. * @param z The amount to scale the bone on the z axis
  95874. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95875. */
  95876. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95877. /**
  95878. * Set the bone scaling in local space
  95879. * @param scale defines the scaling vector
  95880. */
  95881. setScale(scale: Vector3): void;
  95882. /**
  95883. * Gets the current scaling in local space
  95884. * @returns the current scaling vector
  95885. */
  95886. getScale(): Vector3;
  95887. /**
  95888. * Gets the current scaling in local space and stores it in a target vector
  95889. * @param result defines the target vector
  95890. */
  95891. getScaleToRef(result: Vector3): void;
  95892. /**
  95893. * Set the yaw, pitch, and roll of the bone in local or world space
  95894. * @param yaw The rotation of the bone on the y axis
  95895. * @param pitch The rotation of the bone on the x axis
  95896. * @param roll The rotation of the bone on the z axis
  95897. * @param space The space that the axes of rotation are in
  95898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95899. */
  95900. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95901. /**
  95902. * Add a rotation to the bone on an axis in local or world space
  95903. * @param axis The axis to rotate the bone on
  95904. * @param amount The amount to rotate the bone
  95905. * @param space The space that the axis is in
  95906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95907. */
  95908. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95909. /**
  95910. * Set the rotation of the bone to a particular axis angle in local or world space
  95911. * @param axis The axis to rotate the bone on
  95912. * @param angle The angle that the bone should be rotated to
  95913. * @param space The space that the axis is in
  95914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95915. */
  95916. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95917. /**
  95918. * Set the euler rotation of the bone in local or world space
  95919. * @param rotation The euler rotation that the bone should be set to
  95920. * @param space The space that the rotation is in
  95921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95922. */
  95923. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95924. /**
  95925. * Set the quaternion rotation of the bone in local or world space
  95926. * @param quat The quaternion rotation that the bone should be set to
  95927. * @param space The space that the rotation is in
  95928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95929. */
  95930. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95931. /**
  95932. * Set the rotation matrix of the bone in local or world space
  95933. * @param rotMat The rotation matrix that the bone should be set to
  95934. * @param space The space that the rotation is in
  95935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95936. */
  95937. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95938. private _rotateWithMatrix;
  95939. private _getNegativeRotationToRef;
  95940. /**
  95941. * Get the position of the bone in local or world space
  95942. * @param space The space that the returned position is in
  95943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95944. * @returns The position of the bone
  95945. */
  95946. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95947. /**
  95948. * Copy the position of the bone to a vector3 in local or world space
  95949. * @param space The space that the returned position is in
  95950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95951. * @param result The vector3 to copy the position to
  95952. */
  95953. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95954. /**
  95955. * Get the absolute position of the bone (world space)
  95956. * @param mesh The mesh that this bone is attached to
  95957. * @returns The absolute position of the bone
  95958. */
  95959. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95960. /**
  95961. * Copy the absolute position of the bone (world space) to the result param
  95962. * @param mesh The mesh that this bone is attached to
  95963. * @param result The vector3 to copy the absolute position to
  95964. */
  95965. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95966. /**
  95967. * Compute the absolute transforms of this bone and its children
  95968. */
  95969. computeAbsoluteTransforms(): void;
  95970. /**
  95971. * Get the world direction from an axis that is in the local space of the bone
  95972. * @param localAxis The local direction that is used to compute the world direction
  95973. * @param mesh The mesh that this bone is attached to
  95974. * @returns The world direction
  95975. */
  95976. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95977. /**
  95978. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95979. * @param localAxis The local direction that is used to compute the world direction
  95980. * @param mesh The mesh that this bone is attached to
  95981. * @param result The vector3 that the world direction will be copied to
  95982. */
  95983. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95984. /**
  95985. * Get the euler rotation of the bone in local or world space
  95986. * @param space The space that the rotation should be in
  95987. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95988. * @returns The euler rotation
  95989. */
  95990. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95991. /**
  95992. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95993. * @param space The space that the rotation should be in
  95994. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95995. * @param result The vector3 that the rotation should be copied to
  95996. */
  95997. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95998. /**
  95999. * Get the quaternion rotation of the bone in either local or world space
  96000. * @param space The space that the rotation should be in
  96001. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96002. * @returns The quaternion rotation
  96003. */
  96004. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96005. /**
  96006. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96007. * @param space The space that the rotation should be in
  96008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96009. * @param result The quaternion that the rotation should be copied to
  96010. */
  96011. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96012. /**
  96013. * Get the rotation matrix of the bone in local or world space
  96014. * @param space The space that the rotation should be in
  96015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96016. * @returns The rotation matrix
  96017. */
  96018. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96019. /**
  96020. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96021. * @param space The space that the rotation should be in
  96022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96023. * @param result The quaternion that the rotation should be copied to
  96024. */
  96025. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96026. /**
  96027. * Get the world position of a point that is in the local space of the bone
  96028. * @param position The local position
  96029. * @param mesh The mesh that this bone is attached to
  96030. * @returns The world position
  96031. */
  96032. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96033. /**
  96034. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96035. * @param position The local position
  96036. * @param mesh The mesh that this bone is attached to
  96037. * @param result The vector3 that the world position should be copied to
  96038. */
  96039. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96040. /**
  96041. * Get the local position of a point that is in world space
  96042. * @param position The world position
  96043. * @param mesh The mesh that this bone is attached to
  96044. * @returns The local position
  96045. */
  96046. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96047. /**
  96048. * Get the local position of a point that is in world space and copy it to the result param
  96049. * @param position The world position
  96050. * @param mesh The mesh that this bone is attached to
  96051. * @param result The vector3 that the local position should be copied to
  96052. */
  96053. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96054. /**
  96055. * Set the current local matrix as the restPose for this bone.
  96056. */
  96057. setCurrentPoseAsRest(): void;
  96058. }
  96059. }
  96060. declare module BABYLON {
  96061. /**
  96062. * Defines a runtime animation
  96063. */
  96064. export class RuntimeAnimation {
  96065. private _events;
  96066. /**
  96067. * The current frame of the runtime animation
  96068. */
  96069. private _currentFrame;
  96070. /**
  96071. * The animation used by the runtime animation
  96072. */
  96073. private _animation;
  96074. /**
  96075. * The target of the runtime animation
  96076. */
  96077. private _target;
  96078. /**
  96079. * The initiating animatable
  96080. */
  96081. private _host;
  96082. /**
  96083. * The original value of the runtime animation
  96084. */
  96085. private _originalValue;
  96086. /**
  96087. * The original blend value of the runtime animation
  96088. */
  96089. private _originalBlendValue;
  96090. /**
  96091. * The offsets cache of the runtime animation
  96092. */
  96093. private _offsetsCache;
  96094. /**
  96095. * The high limits cache of the runtime animation
  96096. */
  96097. private _highLimitsCache;
  96098. /**
  96099. * Specifies if the runtime animation has been stopped
  96100. */
  96101. private _stopped;
  96102. /**
  96103. * The blending factor of the runtime animation
  96104. */
  96105. private _blendingFactor;
  96106. /**
  96107. * The BabylonJS scene
  96108. */
  96109. private _scene;
  96110. /**
  96111. * The current value of the runtime animation
  96112. */
  96113. private _currentValue;
  96114. /** @hidden */
  96115. _animationState: _IAnimationState;
  96116. /**
  96117. * The active target of the runtime animation
  96118. */
  96119. private _activeTargets;
  96120. private _currentActiveTarget;
  96121. private _directTarget;
  96122. /**
  96123. * The target path of the runtime animation
  96124. */
  96125. private _targetPath;
  96126. /**
  96127. * The weight of the runtime animation
  96128. */
  96129. private _weight;
  96130. /**
  96131. * The ratio offset of the runtime animation
  96132. */
  96133. private _ratioOffset;
  96134. /**
  96135. * The previous delay of the runtime animation
  96136. */
  96137. private _previousDelay;
  96138. /**
  96139. * The previous ratio of the runtime animation
  96140. */
  96141. private _previousRatio;
  96142. private _enableBlending;
  96143. private _keys;
  96144. private _minFrame;
  96145. private _maxFrame;
  96146. private _minValue;
  96147. private _maxValue;
  96148. private _targetIsArray;
  96149. /**
  96150. * Gets the current frame of the runtime animation
  96151. */
  96152. get currentFrame(): number;
  96153. /**
  96154. * Gets the weight of the runtime animation
  96155. */
  96156. get weight(): number;
  96157. /**
  96158. * Gets the current value of the runtime animation
  96159. */
  96160. get currentValue(): any;
  96161. /**
  96162. * Gets the target path of the runtime animation
  96163. */
  96164. get targetPath(): string;
  96165. /**
  96166. * Gets the actual target of the runtime animation
  96167. */
  96168. get target(): any;
  96169. /**
  96170. * Gets the additive state of the runtime animation
  96171. */
  96172. get isAdditive(): boolean;
  96173. /** @hidden */
  96174. _onLoop: () => void;
  96175. /**
  96176. * Create a new RuntimeAnimation object
  96177. * @param target defines the target of the animation
  96178. * @param animation defines the source animation object
  96179. * @param scene defines the hosting scene
  96180. * @param host defines the initiating Animatable
  96181. */
  96182. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96183. private _preparePath;
  96184. /**
  96185. * Gets the animation from the runtime animation
  96186. */
  96187. get animation(): Animation;
  96188. /**
  96189. * Resets the runtime animation to the beginning
  96190. * @param restoreOriginal defines whether to restore the target property to the original value
  96191. */
  96192. reset(restoreOriginal?: boolean): void;
  96193. /**
  96194. * Specifies if the runtime animation is stopped
  96195. * @returns Boolean specifying if the runtime animation is stopped
  96196. */
  96197. isStopped(): boolean;
  96198. /**
  96199. * Disposes of the runtime animation
  96200. */
  96201. dispose(): void;
  96202. /**
  96203. * Apply the interpolated value to the target
  96204. * @param currentValue defines the value computed by the animation
  96205. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96206. */
  96207. setValue(currentValue: any, weight: number): void;
  96208. private _getOriginalValues;
  96209. private _setValue;
  96210. /**
  96211. * Gets the loop pmode of the runtime animation
  96212. * @returns Loop Mode
  96213. */
  96214. private _getCorrectLoopMode;
  96215. /**
  96216. * Move the current animation to a given frame
  96217. * @param frame defines the frame to move to
  96218. */
  96219. goToFrame(frame: number): void;
  96220. /**
  96221. * @hidden Internal use only
  96222. */
  96223. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96224. /**
  96225. * Execute the current animation
  96226. * @param delay defines the delay to add to the current frame
  96227. * @param from defines the lower bound of the animation range
  96228. * @param to defines the upper bound of the animation range
  96229. * @param loop defines if the current animation must loop
  96230. * @param speedRatio defines the current speed ratio
  96231. * @param weight defines the weight of the animation (default is -1 so no weight)
  96232. * @param onLoop optional callback called when animation loops
  96233. * @returns a boolean indicating if the animation is running
  96234. */
  96235. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96236. }
  96237. }
  96238. declare module BABYLON {
  96239. /**
  96240. * Class used to store an actual running animation
  96241. */
  96242. export class Animatable {
  96243. /** defines the target object */
  96244. target: any;
  96245. /** defines the starting frame number (default is 0) */
  96246. fromFrame: number;
  96247. /** defines the ending frame number (default is 100) */
  96248. toFrame: number;
  96249. /** defines if the animation must loop (default is false) */
  96250. loopAnimation: boolean;
  96251. /** defines a callback to call when animation ends if it is not looping */
  96252. onAnimationEnd?: (() => void) | null | undefined;
  96253. /** defines a callback to call when animation loops */
  96254. onAnimationLoop?: (() => void) | null | undefined;
  96255. /** defines whether the animation should be evaluated additively */
  96256. isAdditive: boolean;
  96257. private _localDelayOffset;
  96258. private _pausedDelay;
  96259. private _runtimeAnimations;
  96260. private _paused;
  96261. private _scene;
  96262. private _speedRatio;
  96263. private _weight;
  96264. private _syncRoot;
  96265. /**
  96266. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96267. * This will only apply for non looping animation (default is true)
  96268. */
  96269. disposeOnEnd: boolean;
  96270. /**
  96271. * Gets a boolean indicating if the animation has started
  96272. */
  96273. animationStarted: boolean;
  96274. /**
  96275. * Observer raised when the animation ends
  96276. */
  96277. onAnimationEndObservable: Observable<Animatable>;
  96278. /**
  96279. * Observer raised when the animation loops
  96280. */
  96281. onAnimationLoopObservable: Observable<Animatable>;
  96282. /**
  96283. * Gets the root Animatable used to synchronize and normalize animations
  96284. */
  96285. get syncRoot(): Nullable<Animatable>;
  96286. /**
  96287. * Gets the current frame of the first RuntimeAnimation
  96288. * Used to synchronize Animatables
  96289. */
  96290. get masterFrame(): number;
  96291. /**
  96292. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96293. */
  96294. get weight(): number;
  96295. set weight(value: number);
  96296. /**
  96297. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96298. */
  96299. get speedRatio(): number;
  96300. set speedRatio(value: number);
  96301. /**
  96302. * Creates a new Animatable
  96303. * @param scene defines the hosting scene
  96304. * @param target defines the target object
  96305. * @param fromFrame defines the starting frame number (default is 0)
  96306. * @param toFrame defines the ending frame number (default is 100)
  96307. * @param loopAnimation defines if the animation must loop (default is false)
  96308. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96309. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96310. * @param animations defines a group of animation to add to the new Animatable
  96311. * @param onAnimationLoop defines a callback to call when animation loops
  96312. * @param isAdditive defines whether the animation should be evaluated additively
  96313. */
  96314. constructor(scene: Scene,
  96315. /** defines the target object */
  96316. target: any,
  96317. /** defines the starting frame number (default is 0) */
  96318. fromFrame?: number,
  96319. /** defines the ending frame number (default is 100) */
  96320. toFrame?: number,
  96321. /** defines if the animation must loop (default is false) */
  96322. loopAnimation?: boolean, speedRatio?: number,
  96323. /** defines a callback to call when animation ends if it is not looping */
  96324. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96325. /** defines a callback to call when animation loops */
  96326. onAnimationLoop?: (() => void) | null | undefined,
  96327. /** defines whether the animation should be evaluated additively */
  96328. isAdditive?: boolean);
  96329. /**
  96330. * Synchronize and normalize current Animatable with a source Animatable
  96331. * This is useful when using animation weights and when animations are not of the same length
  96332. * @param root defines the root Animatable to synchronize with
  96333. * @returns the current Animatable
  96334. */
  96335. syncWith(root: Animatable): Animatable;
  96336. /**
  96337. * Gets the list of runtime animations
  96338. * @returns an array of RuntimeAnimation
  96339. */
  96340. getAnimations(): RuntimeAnimation[];
  96341. /**
  96342. * Adds more animations to the current animatable
  96343. * @param target defines the target of the animations
  96344. * @param animations defines the new animations to add
  96345. */
  96346. appendAnimations(target: any, animations: Animation[]): void;
  96347. /**
  96348. * Gets the source animation for a specific property
  96349. * @param property defines the propertyu to look for
  96350. * @returns null or the source animation for the given property
  96351. */
  96352. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96353. /**
  96354. * Gets the runtime animation for a specific property
  96355. * @param property defines the propertyu to look for
  96356. * @returns null or the runtime animation for the given property
  96357. */
  96358. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96359. /**
  96360. * Resets the animatable to its original state
  96361. */
  96362. reset(): void;
  96363. /**
  96364. * Allows the animatable to blend with current running animations
  96365. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96366. * @param blendingSpeed defines the blending speed to use
  96367. */
  96368. enableBlending(blendingSpeed: number): void;
  96369. /**
  96370. * Disable animation blending
  96371. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96372. */
  96373. disableBlending(): void;
  96374. /**
  96375. * Jump directly to a given frame
  96376. * @param frame defines the frame to jump to
  96377. */
  96378. goToFrame(frame: number): void;
  96379. /**
  96380. * Pause the animation
  96381. */
  96382. pause(): void;
  96383. /**
  96384. * Restart the animation
  96385. */
  96386. restart(): void;
  96387. private _raiseOnAnimationEnd;
  96388. /**
  96389. * Stop and delete the current animation
  96390. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96391. * @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)
  96392. */
  96393. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96394. /**
  96395. * Wait asynchronously for the animation to end
  96396. * @returns a promise which will be fullfilled when the animation ends
  96397. */
  96398. waitAsync(): Promise<Animatable>;
  96399. /** @hidden */
  96400. _animate(delay: number): boolean;
  96401. }
  96402. interface Scene {
  96403. /** @hidden */
  96404. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96405. /** @hidden */
  96406. _processLateAnimationBindingsForMatrices(holder: {
  96407. totalWeight: number;
  96408. totalAdditiveWeight: number;
  96409. animations: RuntimeAnimation[];
  96410. additiveAnimations: RuntimeAnimation[];
  96411. originalValue: Matrix;
  96412. }): any;
  96413. /** @hidden */
  96414. _processLateAnimationBindingsForQuaternions(holder: {
  96415. totalWeight: number;
  96416. totalAdditiveWeight: number;
  96417. animations: RuntimeAnimation[];
  96418. additiveAnimations: RuntimeAnimation[];
  96419. originalValue: Quaternion;
  96420. }, refQuaternion: Quaternion): Quaternion;
  96421. /** @hidden */
  96422. _processLateAnimationBindings(): void;
  96423. /**
  96424. * Will start the animation sequence of a given target
  96425. * @param target defines the target
  96426. * @param from defines from which frame should animation start
  96427. * @param to defines until which frame should animation run.
  96428. * @param weight defines the weight to apply to the animation (1.0 by default)
  96429. * @param loop defines if the animation loops
  96430. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96431. * @param onAnimationEnd defines the function to be executed when the animation ends
  96432. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96433. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96434. * @param onAnimationLoop defines the callback to call when an animation loops
  96435. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96436. * @returns the animatable object created for this animation
  96437. */
  96438. 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;
  96439. /**
  96440. * Will start the animation sequence of a given target
  96441. * @param target defines the target
  96442. * @param from defines from which frame should animation start
  96443. * @param to defines until which frame should animation run.
  96444. * @param loop defines if the animation loops
  96445. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96446. * @param onAnimationEnd defines the function to be executed when the animation ends
  96447. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96448. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96449. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96450. * @param onAnimationLoop defines the callback to call when an animation loops
  96451. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96452. * @returns the animatable object created for this animation
  96453. */
  96454. 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;
  96455. /**
  96456. * Will start the animation sequence of a given target and its hierarchy
  96457. * @param target defines the target
  96458. * @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.
  96459. * @param from defines from which frame should animation start
  96460. * @param to defines until which frame should animation run.
  96461. * @param loop defines if the animation loops
  96462. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96463. * @param onAnimationEnd defines the function to be executed when the animation ends
  96464. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96465. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96466. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96467. * @param onAnimationLoop defines the callback to call when an animation loops
  96468. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96469. * @returns the list of created animatables
  96470. */
  96471. 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[];
  96472. /**
  96473. * Begin a new animation on a given node
  96474. * @param target defines the target where the animation will take place
  96475. * @param animations defines the list of animations to start
  96476. * @param from defines the initial value
  96477. * @param to defines the final value
  96478. * @param loop defines if you want animation to loop (off by default)
  96479. * @param speedRatio defines the speed ratio to apply to all animations
  96480. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96481. * @param onAnimationLoop defines the callback to call when an animation loops
  96482. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96483. * @returns the list of created animatables
  96484. */
  96485. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96486. /**
  96487. * Begin a new animation on a given node and its hierarchy
  96488. * @param target defines the root node where the animation will take place
  96489. * @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.
  96490. * @param animations defines the list of animations to start
  96491. * @param from defines the initial value
  96492. * @param to defines the final value
  96493. * @param loop defines if you want animation to loop (off by default)
  96494. * @param speedRatio defines the speed ratio to apply to all animations
  96495. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96496. * @param onAnimationLoop defines the callback to call when an animation loops
  96497. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96498. * @returns the list of animatables created for all nodes
  96499. */
  96500. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96501. /**
  96502. * Gets the animatable associated with a specific target
  96503. * @param target defines the target of the animatable
  96504. * @returns the required animatable if found
  96505. */
  96506. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96507. /**
  96508. * Gets all animatables associated with a given target
  96509. * @param target defines the target to look animatables for
  96510. * @returns an array of Animatables
  96511. */
  96512. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96513. /**
  96514. * Stops and removes all animations that have been applied to the scene
  96515. */
  96516. stopAllAnimations(): void;
  96517. /**
  96518. * Gets the current delta time used by animation engine
  96519. */
  96520. deltaTime: number;
  96521. }
  96522. interface Bone {
  96523. /**
  96524. * Copy an animation range from another bone
  96525. * @param source defines the source bone
  96526. * @param rangeName defines the range name to copy
  96527. * @param frameOffset defines the frame offset
  96528. * @param rescaleAsRequired defines if rescaling must be applied if required
  96529. * @param skelDimensionsRatio defines the scaling ratio
  96530. * @returns true if operation was successful
  96531. */
  96532. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96533. }
  96534. }
  96535. declare module BABYLON {
  96536. /**
  96537. * Class used to handle skinning animations
  96538. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96539. */
  96540. export class Skeleton implements IAnimatable {
  96541. /** defines the skeleton name */
  96542. name: string;
  96543. /** defines the skeleton Id */
  96544. id: string;
  96545. /**
  96546. * Defines the list of child bones
  96547. */
  96548. bones: Bone[];
  96549. /**
  96550. * Defines an estimate of the dimension of the skeleton at rest
  96551. */
  96552. dimensionsAtRest: Vector3;
  96553. /**
  96554. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96555. */
  96556. needInitialSkinMatrix: boolean;
  96557. /**
  96558. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96559. */
  96560. overrideMesh: Nullable<AbstractMesh>;
  96561. /**
  96562. * Gets the list of animations attached to this skeleton
  96563. */
  96564. animations: Array<Animation>;
  96565. private _scene;
  96566. private _isDirty;
  96567. private _transformMatrices;
  96568. private _transformMatrixTexture;
  96569. private _meshesWithPoseMatrix;
  96570. private _animatables;
  96571. private _identity;
  96572. private _synchronizedWithMesh;
  96573. private _ranges;
  96574. private _lastAbsoluteTransformsUpdateId;
  96575. private _canUseTextureForBones;
  96576. private _uniqueId;
  96577. /** @hidden */
  96578. _numBonesWithLinkedTransformNode: number;
  96579. /** @hidden */
  96580. _hasWaitingData: Nullable<boolean>;
  96581. /** @hidden */
  96582. _waitingOverrideMeshId: Nullable<string>;
  96583. /**
  96584. * Specifies if the skeleton should be serialized
  96585. */
  96586. doNotSerialize: boolean;
  96587. private _useTextureToStoreBoneMatrices;
  96588. /**
  96589. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96590. * Please note that this option is not available if the hardware does not support it
  96591. */
  96592. get useTextureToStoreBoneMatrices(): boolean;
  96593. set useTextureToStoreBoneMatrices(value: boolean);
  96594. private _animationPropertiesOverride;
  96595. /**
  96596. * Gets or sets the animation properties override
  96597. */
  96598. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96599. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96600. /**
  96601. * List of inspectable custom properties (used by the Inspector)
  96602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96603. */
  96604. inspectableCustomProperties: IInspectable[];
  96605. /**
  96606. * An observable triggered before computing the skeleton's matrices
  96607. */
  96608. onBeforeComputeObservable: Observable<Skeleton>;
  96609. /**
  96610. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96611. */
  96612. get isUsingTextureForMatrices(): boolean;
  96613. /**
  96614. * Gets the unique ID of this skeleton
  96615. */
  96616. get uniqueId(): number;
  96617. /**
  96618. * Creates a new skeleton
  96619. * @param name defines the skeleton name
  96620. * @param id defines the skeleton Id
  96621. * @param scene defines the hosting scene
  96622. */
  96623. constructor(
  96624. /** defines the skeleton name */
  96625. name: string,
  96626. /** defines the skeleton Id */
  96627. id: string, scene: Scene);
  96628. /**
  96629. * Gets the current object class name.
  96630. * @return the class name
  96631. */
  96632. getClassName(): string;
  96633. /**
  96634. * Returns an array containing the root bones
  96635. * @returns an array containing the root bones
  96636. */
  96637. getChildren(): Array<Bone>;
  96638. /**
  96639. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96640. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96641. * @returns a Float32Array containing matrices data
  96642. */
  96643. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96644. /**
  96645. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96646. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96647. * @returns a raw texture containing the data
  96648. */
  96649. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96650. /**
  96651. * Gets the current hosting scene
  96652. * @returns a scene object
  96653. */
  96654. getScene(): Scene;
  96655. /**
  96656. * Gets a string representing the current skeleton data
  96657. * @param fullDetails defines a boolean indicating if we want a verbose version
  96658. * @returns a string representing the current skeleton data
  96659. */
  96660. toString(fullDetails?: boolean): string;
  96661. /**
  96662. * Get bone's index searching by name
  96663. * @param name defines bone's name to search for
  96664. * @return the indice of the bone. Returns -1 if not found
  96665. */
  96666. getBoneIndexByName(name: string): number;
  96667. /**
  96668. * Creater a new animation range
  96669. * @param name defines the name of the range
  96670. * @param from defines the start key
  96671. * @param to defines the end key
  96672. */
  96673. createAnimationRange(name: string, from: number, to: number): void;
  96674. /**
  96675. * Delete a specific animation range
  96676. * @param name defines the name of the range
  96677. * @param deleteFrames defines if frames must be removed as well
  96678. */
  96679. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96680. /**
  96681. * Gets a specific animation range
  96682. * @param name defines the name of the range to look for
  96683. * @returns the requested animation range or null if not found
  96684. */
  96685. getAnimationRange(name: string): Nullable<AnimationRange>;
  96686. /**
  96687. * Gets the list of all animation ranges defined on this skeleton
  96688. * @returns an array
  96689. */
  96690. getAnimationRanges(): Nullable<AnimationRange>[];
  96691. /**
  96692. * Copy animation range from a source skeleton.
  96693. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96694. * @param source defines the source skeleton
  96695. * @param name defines the name of the range to copy
  96696. * @param rescaleAsRequired defines if rescaling must be applied if required
  96697. * @returns true if operation was successful
  96698. */
  96699. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96700. /**
  96701. * Forces the skeleton to go to rest pose
  96702. */
  96703. returnToRest(): void;
  96704. private _getHighestAnimationFrame;
  96705. /**
  96706. * Begin a specific animation range
  96707. * @param name defines the name of the range to start
  96708. * @param loop defines if looping must be turned on (false by default)
  96709. * @param speedRatio defines the speed ratio to apply (1 by default)
  96710. * @param onAnimationEnd defines a callback which will be called when animation will end
  96711. * @returns a new animatable
  96712. */
  96713. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96714. /**
  96715. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96716. * @param skeleton defines the Skeleton containing the animation range to convert
  96717. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96718. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96719. * @returns the original skeleton
  96720. */
  96721. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96722. /** @hidden */
  96723. _markAsDirty(): void;
  96724. /** @hidden */
  96725. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96726. /** @hidden */
  96727. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96728. private _computeTransformMatrices;
  96729. /**
  96730. * Build all resources required to render a skeleton
  96731. */
  96732. prepare(): void;
  96733. /**
  96734. * Gets the list of animatables currently running for this skeleton
  96735. * @returns an array of animatables
  96736. */
  96737. getAnimatables(): IAnimatable[];
  96738. /**
  96739. * Clone the current skeleton
  96740. * @param name defines the name of the new skeleton
  96741. * @param id defines the id of the new skeleton
  96742. * @returns the new skeleton
  96743. */
  96744. clone(name: string, id?: string): Skeleton;
  96745. /**
  96746. * Enable animation blending for this skeleton
  96747. * @param blendingSpeed defines the blending speed to apply
  96748. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96749. */
  96750. enableBlending(blendingSpeed?: number): void;
  96751. /**
  96752. * Releases all resources associated with the current skeleton
  96753. */
  96754. dispose(): void;
  96755. /**
  96756. * Serialize the skeleton in a JSON object
  96757. * @returns a JSON object
  96758. */
  96759. serialize(): any;
  96760. /**
  96761. * Creates a new skeleton from serialized data
  96762. * @param parsedSkeleton defines the serialized data
  96763. * @param scene defines the hosting scene
  96764. * @returns a new skeleton
  96765. */
  96766. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96767. /**
  96768. * Compute all node absolute transforms
  96769. * @param forceUpdate defines if computation must be done even if cache is up to date
  96770. */
  96771. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96772. /**
  96773. * Gets the root pose matrix
  96774. * @returns a matrix
  96775. */
  96776. getPoseMatrix(): Nullable<Matrix>;
  96777. /**
  96778. * Sorts bones per internal index
  96779. */
  96780. sortBones(): void;
  96781. private _sortBones;
  96782. /**
  96783. * Set the current local matrix as the restPose for all bones in the skeleton.
  96784. */
  96785. setCurrentPoseAsRest(): void;
  96786. }
  96787. }
  96788. declare module BABYLON {
  96789. /**
  96790. * Creates an instance based on a source mesh.
  96791. */
  96792. export class InstancedMesh extends AbstractMesh {
  96793. private _sourceMesh;
  96794. private _currentLOD;
  96795. /** @hidden */
  96796. _indexInSourceMeshInstanceArray: number;
  96797. constructor(name: string, source: Mesh);
  96798. /**
  96799. * Returns the string "InstancedMesh".
  96800. */
  96801. getClassName(): string;
  96802. /** Gets the list of lights affecting that mesh */
  96803. get lightSources(): Light[];
  96804. _resyncLightSources(): void;
  96805. _resyncLightSource(light: Light): void;
  96806. _removeLightSource(light: Light, dispose: boolean): void;
  96807. /**
  96808. * If the source mesh receives shadows
  96809. */
  96810. get receiveShadows(): boolean;
  96811. /**
  96812. * The material of the source mesh
  96813. */
  96814. get material(): Nullable<Material>;
  96815. /**
  96816. * Visibility of the source mesh
  96817. */
  96818. get visibility(): number;
  96819. /**
  96820. * Skeleton of the source mesh
  96821. */
  96822. get skeleton(): Nullable<Skeleton>;
  96823. /**
  96824. * Rendering ground id of the source mesh
  96825. */
  96826. get renderingGroupId(): number;
  96827. set renderingGroupId(value: number);
  96828. /**
  96829. * Returns the total number of vertices (integer).
  96830. */
  96831. getTotalVertices(): number;
  96832. /**
  96833. * Returns a positive integer : the total number of indices in this mesh geometry.
  96834. * @returns the numner of indices or zero if the mesh has no geometry.
  96835. */
  96836. getTotalIndices(): number;
  96837. /**
  96838. * The source mesh of the instance
  96839. */
  96840. get sourceMesh(): Mesh;
  96841. /**
  96842. * Creates a new InstancedMesh object from the mesh model.
  96843. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96844. * @param name defines the name of the new instance
  96845. * @returns a new InstancedMesh
  96846. */
  96847. createInstance(name: string): InstancedMesh;
  96848. /**
  96849. * Is this node ready to be used/rendered
  96850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96851. * @return {boolean} is it ready
  96852. */
  96853. isReady(completeCheck?: boolean): boolean;
  96854. /**
  96855. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96856. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96857. * @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.
  96858. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96859. */
  96860. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96861. /**
  96862. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96863. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96864. * The `data` are either a numeric array either a Float32Array.
  96865. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96866. * 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).
  96867. * Note that a new underlying VertexBuffer object is created each call.
  96868. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96869. *
  96870. * Possible `kind` values :
  96871. * - VertexBuffer.PositionKind
  96872. * - VertexBuffer.UVKind
  96873. * - VertexBuffer.UV2Kind
  96874. * - VertexBuffer.UV3Kind
  96875. * - VertexBuffer.UV4Kind
  96876. * - VertexBuffer.UV5Kind
  96877. * - VertexBuffer.UV6Kind
  96878. * - VertexBuffer.ColorKind
  96879. * - VertexBuffer.MatricesIndicesKind
  96880. * - VertexBuffer.MatricesIndicesExtraKind
  96881. * - VertexBuffer.MatricesWeightsKind
  96882. * - VertexBuffer.MatricesWeightsExtraKind
  96883. *
  96884. * Returns the Mesh.
  96885. */
  96886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96887. /**
  96888. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96889. * If the mesh has no geometry, it is simply returned as it is.
  96890. * The `data` are either a numeric array either a Float32Array.
  96891. * No new underlying VertexBuffer object is created.
  96892. * 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.
  96893. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96894. *
  96895. * Possible `kind` values :
  96896. * - VertexBuffer.PositionKind
  96897. * - VertexBuffer.UVKind
  96898. * - VertexBuffer.UV2Kind
  96899. * - VertexBuffer.UV3Kind
  96900. * - VertexBuffer.UV4Kind
  96901. * - VertexBuffer.UV5Kind
  96902. * - VertexBuffer.UV6Kind
  96903. * - VertexBuffer.ColorKind
  96904. * - VertexBuffer.MatricesIndicesKind
  96905. * - VertexBuffer.MatricesIndicesExtraKind
  96906. * - VertexBuffer.MatricesWeightsKind
  96907. * - VertexBuffer.MatricesWeightsExtraKind
  96908. *
  96909. * Returns the Mesh.
  96910. */
  96911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96912. /**
  96913. * Sets the mesh indices.
  96914. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96915. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96916. * This method creates a new index buffer each call.
  96917. * Returns the Mesh.
  96918. */
  96919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96920. /**
  96921. * Boolean : True if the mesh owns the requested kind of data.
  96922. */
  96923. isVerticesDataPresent(kind: string): boolean;
  96924. /**
  96925. * Returns an array of indices (IndicesArray).
  96926. */
  96927. getIndices(): Nullable<IndicesArray>;
  96928. get _positions(): Nullable<Vector3[]>;
  96929. /**
  96930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96931. * This means the mesh underlying bounding box and sphere are recomputed.
  96932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96933. * @returns the current mesh
  96934. */
  96935. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96936. /** @hidden */
  96937. _preActivate(): InstancedMesh;
  96938. /** @hidden */
  96939. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96940. /** @hidden */
  96941. _postActivate(): void;
  96942. getWorldMatrix(): Matrix;
  96943. get isAnInstance(): boolean;
  96944. /**
  96945. * Returns the current associated LOD AbstractMesh.
  96946. */
  96947. getLOD(camera: Camera): AbstractMesh;
  96948. /** @hidden */
  96949. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96950. /** @hidden */
  96951. _syncSubMeshes(): InstancedMesh;
  96952. /** @hidden */
  96953. _generatePointsArray(): boolean;
  96954. /** @hidden */
  96955. _updateBoundingInfo(): AbstractMesh;
  96956. /**
  96957. * Creates a new InstancedMesh from the current mesh.
  96958. * - name (string) : the cloned mesh name
  96959. * - newParent (optional Node) : the optional Node to parent the clone to.
  96960. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96961. *
  96962. * Returns the clone.
  96963. */
  96964. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96965. /**
  96966. * Disposes the InstancedMesh.
  96967. * Returns nothing.
  96968. */
  96969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96970. }
  96971. interface Mesh {
  96972. /**
  96973. * Register a custom buffer that will be instanced
  96974. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96975. * @param kind defines the buffer kind
  96976. * @param stride defines the stride in floats
  96977. */
  96978. registerInstancedBuffer(kind: string, stride: number): void;
  96979. /**
  96980. * true to use the edge renderer for all instances of this mesh
  96981. */
  96982. edgesShareWithInstances: boolean;
  96983. /** @hidden */
  96984. _userInstancedBuffersStorage: {
  96985. data: {
  96986. [key: string]: Float32Array;
  96987. };
  96988. sizes: {
  96989. [key: string]: number;
  96990. };
  96991. vertexBuffers: {
  96992. [key: string]: Nullable<VertexBuffer>;
  96993. };
  96994. strides: {
  96995. [key: string]: number;
  96996. };
  96997. };
  96998. }
  96999. interface AbstractMesh {
  97000. /**
  97001. * Object used to store instanced buffers defined by user
  97002. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97003. */
  97004. instancedBuffers: {
  97005. [key: string]: any;
  97006. };
  97007. }
  97008. }
  97009. declare module BABYLON {
  97010. /**
  97011. * Defines the options associated with the creation of a shader material.
  97012. */
  97013. export interface IShaderMaterialOptions {
  97014. /**
  97015. * Does the material work in alpha blend mode
  97016. */
  97017. needAlphaBlending: boolean;
  97018. /**
  97019. * Does the material work in alpha test mode
  97020. */
  97021. needAlphaTesting: boolean;
  97022. /**
  97023. * The list of attribute names used in the shader
  97024. */
  97025. attributes: string[];
  97026. /**
  97027. * The list of unifrom names used in the shader
  97028. */
  97029. uniforms: string[];
  97030. /**
  97031. * The list of UBO names used in the shader
  97032. */
  97033. uniformBuffers: string[];
  97034. /**
  97035. * The list of sampler names used in the shader
  97036. */
  97037. samplers: string[];
  97038. /**
  97039. * The list of defines used in the shader
  97040. */
  97041. defines: string[];
  97042. }
  97043. /**
  97044. * 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.
  97045. *
  97046. * This returned material effects how the mesh will look based on the code in the shaders.
  97047. *
  97048. * @see https://doc.babylonjs.com/how_to/shader_material
  97049. */
  97050. export class ShaderMaterial extends Material {
  97051. private _shaderPath;
  97052. private _options;
  97053. private _textures;
  97054. private _textureArrays;
  97055. private _floats;
  97056. private _ints;
  97057. private _floatsArrays;
  97058. private _colors3;
  97059. private _colors3Arrays;
  97060. private _colors4;
  97061. private _colors4Arrays;
  97062. private _vectors2;
  97063. private _vectors3;
  97064. private _vectors4;
  97065. private _matrices;
  97066. private _matrixArrays;
  97067. private _matrices3x3;
  97068. private _matrices2x2;
  97069. private _vectors2Arrays;
  97070. private _vectors3Arrays;
  97071. private _vectors4Arrays;
  97072. private _cachedWorldViewMatrix;
  97073. private _cachedWorldViewProjectionMatrix;
  97074. private _renderId;
  97075. private _multiview;
  97076. private _cachedDefines;
  97077. /** Define the Url to load snippets */
  97078. static SnippetUrl: string;
  97079. /** Snippet ID if the material was created from the snippet server */
  97080. snippetId: string;
  97081. /**
  97082. * Instantiate a new shader material.
  97083. * 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.
  97084. * This returned material effects how the mesh will look based on the code in the shaders.
  97085. * @see https://doc.babylonjs.com/how_to/shader_material
  97086. * @param name Define the name of the material in the scene
  97087. * @param scene Define the scene the material belongs to
  97088. * @param shaderPath Defines the route to the shader code in one of three ways:
  97089. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97090. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97091. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97092. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97093. * @param options Define the options used to create the shader
  97094. */
  97095. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97096. /**
  97097. * Gets the shader path used to define the shader code
  97098. * It can be modified to trigger a new compilation
  97099. */
  97100. get shaderPath(): any;
  97101. /**
  97102. * Sets the shader path used to define the shader code
  97103. * It can be modified to trigger a new compilation
  97104. */
  97105. set shaderPath(shaderPath: any);
  97106. /**
  97107. * Gets the options used to compile the shader.
  97108. * They can be modified to trigger a new compilation
  97109. */
  97110. get options(): IShaderMaterialOptions;
  97111. /**
  97112. * Gets the current class name of the material e.g. "ShaderMaterial"
  97113. * Mainly use in serialization.
  97114. * @returns the class name
  97115. */
  97116. getClassName(): string;
  97117. /**
  97118. * Specifies if the material will require alpha blending
  97119. * @returns a boolean specifying if alpha blending is needed
  97120. */
  97121. needAlphaBlending(): boolean;
  97122. /**
  97123. * Specifies if this material should be rendered in alpha test mode
  97124. * @returns a boolean specifying if an alpha test is needed.
  97125. */
  97126. needAlphaTesting(): boolean;
  97127. private _checkUniform;
  97128. /**
  97129. * Set a texture in the shader.
  97130. * @param name Define the name of the uniform samplers as defined in the shader
  97131. * @param texture Define the texture to bind to this sampler
  97132. * @return the material itself allowing "fluent" like uniform updates
  97133. */
  97134. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97135. /**
  97136. * Set a texture array in the shader.
  97137. * @param name Define the name of the uniform sampler array as defined in the shader
  97138. * @param textures Define the list of textures to bind to this sampler
  97139. * @return the material itself allowing "fluent" like uniform updates
  97140. */
  97141. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97142. /**
  97143. * Set a float in the shader.
  97144. * @param name Define the name of the uniform as defined in the shader
  97145. * @param value Define the value to give to the uniform
  97146. * @return the material itself allowing "fluent" like uniform updates
  97147. */
  97148. setFloat(name: string, value: number): ShaderMaterial;
  97149. /**
  97150. * Set a int in the shader.
  97151. * @param name Define the name of the uniform as defined in the shader
  97152. * @param value Define the value to give to the uniform
  97153. * @return the material itself allowing "fluent" like uniform updates
  97154. */
  97155. setInt(name: string, value: number): ShaderMaterial;
  97156. /**
  97157. * Set an array of floats in the shader.
  97158. * @param name Define the name of the uniform as defined in the shader
  97159. * @param value Define the value to give to the uniform
  97160. * @return the material itself allowing "fluent" like uniform updates
  97161. */
  97162. setFloats(name: string, value: number[]): ShaderMaterial;
  97163. /**
  97164. * Set a vec3 in the shader from a Color3.
  97165. * @param name Define the name of the uniform as defined in the shader
  97166. * @param value Define the value to give to the uniform
  97167. * @return the material itself allowing "fluent" like uniform updates
  97168. */
  97169. setColor3(name: string, value: Color3): ShaderMaterial;
  97170. /**
  97171. * Set a vec3 array in the shader from a Color3 array.
  97172. * @param name Define the name of the uniform as defined in the shader
  97173. * @param value Define the value to give to the uniform
  97174. * @return the material itself allowing "fluent" like uniform updates
  97175. */
  97176. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97177. /**
  97178. * Set a vec4 in the shader from a Color4.
  97179. * @param name Define the name of the uniform as defined in the shader
  97180. * @param value Define the value to give to the uniform
  97181. * @return the material itself allowing "fluent" like uniform updates
  97182. */
  97183. setColor4(name: string, value: Color4): ShaderMaterial;
  97184. /**
  97185. * Set a vec4 array in the shader from a Color4 array.
  97186. * @param name Define the name of the uniform as defined in the shader
  97187. * @param value Define the value to give to the uniform
  97188. * @return the material itself allowing "fluent" like uniform updates
  97189. */
  97190. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97191. /**
  97192. * Set a vec2 in the shader from a Vector2.
  97193. * @param name Define the name of the uniform as defined in the shader
  97194. * @param value Define the value to give to the uniform
  97195. * @return the material itself allowing "fluent" like uniform updates
  97196. */
  97197. setVector2(name: string, value: Vector2): ShaderMaterial;
  97198. /**
  97199. * Set a vec3 in the shader from a Vector3.
  97200. * @param name Define the name of the uniform as defined in the shader
  97201. * @param value Define the value to give to the uniform
  97202. * @return the material itself allowing "fluent" like uniform updates
  97203. */
  97204. setVector3(name: string, value: Vector3): ShaderMaterial;
  97205. /**
  97206. * Set a vec4 in the shader from a Vector4.
  97207. * @param name Define the name of the uniform as defined in the shader
  97208. * @param value Define the value to give to the uniform
  97209. * @return the material itself allowing "fluent" like uniform updates
  97210. */
  97211. setVector4(name: string, value: Vector4): ShaderMaterial;
  97212. /**
  97213. * Set a mat4 in the shader from a Matrix.
  97214. * @param name Define the name of the uniform as defined in the shader
  97215. * @param value Define the value to give to the uniform
  97216. * @return the material itself allowing "fluent" like uniform updates
  97217. */
  97218. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97219. /**
  97220. * Set a float32Array in the shader from a matrix array.
  97221. * @param name Define the name of the uniform as defined in the shader
  97222. * @param value Define the value to give to the uniform
  97223. * @return the material itself allowing "fluent" like uniform updates
  97224. */
  97225. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97226. /**
  97227. * Set a mat3 in the shader from a Float32Array.
  97228. * @param name Define the name of the uniform as defined in the shader
  97229. * @param value Define the value to give to the uniform
  97230. * @return the material itself allowing "fluent" like uniform updates
  97231. */
  97232. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97233. /**
  97234. * Set a mat2 in the shader from a Float32Array.
  97235. * @param name Define the name of the uniform as defined in the shader
  97236. * @param value Define the value to give to the uniform
  97237. * @return the material itself allowing "fluent" like uniform updates
  97238. */
  97239. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97240. /**
  97241. * Set a vec2 array in the shader from a number array.
  97242. * @param name Define the name of the uniform as defined in the shader
  97243. * @param value Define the value to give to the uniform
  97244. * @return the material itself allowing "fluent" like uniform updates
  97245. */
  97246. setArray2(name: string, value: number[]): ShaderMaterial;
  97247. /**
  97248. * Set a vec3 array in the shader from a number array.
  97249. * @param name Define the name of the uniform as defined in the shader
  97250. * @param value Define the value to give to the uniform
  97251. * @return the material itself allowing "fluent" like uniform updates
  97252. */
  97253. setArray3(name: string, value: number[]): ShaderMaterial;
  97254. /**
  97255. * Set a vec4 array in the shader from a number array.
  97256. * @param name Define the name of the uniform as defined in the shader
  97257. * @param value Define the value to give to the uniform
  97258. * @return the material itself allowing "fluent" like uniform updates
  97259. */
  97260. setArray4(name: string, value: number[]): ShaderMaterial;
  97261. private _checkCache;
  97262. /**
  97263. * Specifies that the submesh is ready to be used
  97264. * @param mesh defines the mesh to check
  97265. * @param subMesh defines which submesh to check
  97266. * @param useInstances specifies that instances should be used
  97267. * @returns a boolean indicating that the submesh is ready or not
  97268. */
  97269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97270. /**
  97271. * Checks if the material is ready to render the requested mesh
  97272. * @param mesh Define the mesh to render
  97273. * @param useInstances Define whether or not the material is used with instances
  97274. * @returns true if ready, otherwise false
  97275. */
  97276. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97277. /**
  97278. * Binds the world matrix to the material
  97279. * @param world defines the world transformation matrix
  97280. * @param effectOverride - If provided, use this effect instead of internal effect
  97281. */
  97282. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97283. /**
  97284. * Binds the submesh to this material by preparing the effect and shader to draw
  97285. * @param world defines the world transformation matrix
  97286. * @param mesh defines the mesh containing the submesh
  97287. * @param subMesh defines the submesh to bind the material to
  97288. */
  97289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97290. /**
  97291. * Binds the material to the mesh
  97292. * @param world defines the world transformation matrix
  97293. * @param mesh defines the mesh to bind the material to
  97294. * @param effectOverride - If provided, use this effect instead of internal effect
  97295. */
  97296. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97297. protected _afterBind(mesh?: Mesh): void;
  97298. /**
  97299. * Gets the active textures from the material
  97300. * @returns an array of textures
  97301. */
  97302. getActiveTextures(): BaseTexture[];
  97303. /**
  97304. * Specifies if the material uses a texture
  97305. * @param texture defines the texture to check against the material
  97306. * @returns a boolean specifying if the material uses the texture
  97307. */
  97308. hasTexture(texture: BaseTexture): boolean;
  97309. /**
  97310. * Makes a duplicate of the material, and gives it a new name
  97311. * @param name defines the new name for the duplicated material
  97312. * @returns the cloned material
  97313. */
  97314. clone(name: string): ShaderMaterial;
  97315. /**
  97316. * Disposes the material
  97317. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97318. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97319. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97320. */
  97321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97322. /**
  97323. * Serializes this material in a JSON representation
  97324. * @returns the serialized material object
  97325. */
  97326. serialize(): any;
  97327. /**
  97328. * Creates a shader material from parsed shader material data
  97329. * @param source defines the JSON represnetation of the material
  97330. * @param scene defines the hosting scene
  97331. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97332. * @returns a new material
  97333. */
  97334. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97335. /**
  97336. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97337. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97338. * @param url defines the url to load from
  97339. * @param scene defines the hosting scene
  97340. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97341. * @returns a promise that will resolve to the new ShaderMaterial
  97342. */
  97343. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97344. /**
  97345. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97346. * @param snippetId defines the snippet to load
  97347. * @param scene defines the hosting scene
  97348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97349. * @returns a promise that will resolve to the new ShaderMaterial
  97350. */
  97351. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97352. }
  97353. }
  97354. declare module BABYLON {
  97355. /** @hidden */
  97356. export var colorPixelShader: {
  97357. name: string;
  97358. shader: string;
  97359. };
  97360. }
  97361. declare module BABYLON {
  97362. /** @hidden */
  97363. export var colorVertexShader: {
  97364. name: string;
  97365. shader: string;
  97366. };
  97367. }
  97368. declare module BABYLON {
  97369. /**
  97370. * Line mesh
  97371. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97372. */
  97373. export class LinesMesh extends Mesh {
  97374. /**
  97375. * If vertex color should be applied to the mesh
  97376. */
  97377. readonly useVertexColor?: boolean | undefined;
  97378. /**
  97379. * If vertex alpha should be applied to the mesh
  97380. */
  97381. readonly useVertexAlpha?: boolean | undefined;
  97382. /**
  97383. * Color of the line (Default: White)
  97384. */
  97385. color: Color3;
  97386. /**
  97387. * Alpha of the line (Default: 1)
  97388. */
  97389. alpha: number;
  97390. /**
  97391. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97392. * This margin is expressed in world space coordinates, so its value may vary.
  97393. * Default value is 0.1
  97394. */
  97395. intersectionThreshold: number;
  97396. private _colorShader;
  97397. private color4;
  97398. /**
  97399. * Creates a new LinesMesh
  97400. * @param name defines the name
  97401. * @param scene defines the hosting scene
  97402. * @param parent defines the parent mesh if any
  97403. * @param source defines the optional source LinesMesh used to clone data from
  97404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97405. * When false, achieved by calling a clone(), also passing False.
  97406. * This will make creation of children, recursive.
  97407. * @param useVertexColor defines if this LinesMesh supports vertex color
  97408. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97409. */
  97410. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97411. /**
  97412. * If vertex color should be applied to the mesh
  97413. */
  97414. useVertexColor?: boolean | undefined,
  97415. /**
  97416. * If vertex alpha should be applied to the mesh
  97417. */
  97418. useVertexAlpha?: boolean | undefined);
  97419. private _addClipPlaneDefine;
  97420. private _removeClipPlaneDefine;
  97421. isReady(): boolean;
  97422. /**
  97423. * Returns the string "LineMesh"
  97424. */
  97425. getClassName(): string;
  97426. /**
  97427. * @hidden
  97428. */
  97429. get material(): Material;
  97430. /**
  97431. * @hidden
  97432. */
  97433. set material(value: Material);
  97434. /**
  97435. * @hidden
  97436. */
  97437. get checkCollisions(): boolean;
  97438. /** @hidden */
  97439. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97440. /** @hidden */
  97441. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97442. /**
  97443. * Disposes of the line mesh
  97444. * @param doNotRecurse If children should be disposed
  97445. */
  97446. dispose(doNotRecurse?: boolean): void;
  97447. /**
  97448. * Returns a new LineMesh object cloned from the current one.
  97449. */
  97450. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97451. /**
  97452. * Creates a new InstancedLinesMesh object from the mesh model.
  97453. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97454. * @param name defines the name of the new instance
  97455. * @returns a new InstancedLinesMesh
  97456. */
  97457. createInstance(name: string): InstancedLinesMesh;
  97458. }
  97459. /**
  97460. * Creates an instance based on a source LinesMesh
  97461. */
  97462. export class InstancedLinesMesh extends InstancedMesh {
  97463. /**
  97464. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97465. * This margin is expressed in world space coordinates, so its value may vary.
  97466. * Initilized with the intersectionThreshold value of the source LinesMesh
  97467. */
  97468. intersectionThreshold: number;
  97469. constructor(name: string, source: LinesMesh);
  97470. /**
  97471. * Returns the string "InstancedLinesMesh".
  97472. */
  97473. getClassName(): string;
  97474. }
  97475. }
  97476. declare module BABYLON {
  97477. /** @hidden */
  97478. export var linePixelShader: {
  97479. name: string;
  97480. shader: string;
  97481. };
  97482. }
  97483. declare module BABYLON {
  97484. /** @hidden */
  97485. export var lineVertexShader: {
  97486. name: string;
  97487. shader: string;
  97488. };
  97489. }
  97490. declare module BABYLON {
  97491. interface Scene {
  97492. /** @hidden */
  97493. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97494. }
  97495. interface AbstractMesh {
  97496. /**
  97497. * Gets the edgesRenderer associated with the mesh
  97498. */
  97499. edgesRenderer: Nullable<EdgesRenderer>;
  97500. }
  97501. interface LinesMesh {
  97502. /**
  97503. * Enables the edge rendering mode on the mesh.
  97504. * This mode makes the mesh edges visible
  97505. * @param epsilon defines the maximal distance between two angles to detect a face
  97506. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97507. * @returns the currentAbstractMesh
  97508. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97509. */
  97510. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97511. }
  97512. interface InstancedLinesMesh {
  97513. /**
  97514. * Enables the edge rendering mode on the mesh.
  97515. * This mode makes the mesh edges visible
  97516. * @param epsilon defines the maximal distance between two angles to detect a face
  97517. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97518. * @returns the current InstancedLinesMesh
  97519. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97520. */
  97521. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97522. }
  97523. /**
  97524. * Defines the minimum contract an Edges renderer should follow.
  97525. */
  97526. export interface IEdgesRenderer extends IDisposable {
  97527. /**
  97528. * Gets or sets a boolean indicating if the edgesRenderer is active
  97529. */
  97530. isEnabled: boolean;
  97531. /**
  97532. * Renders the edges of the attached mesh,
  97533. */
  97534. render(): void;
  97535. /**
  97536. * Checks wether or not the edges renderer is ready to render.
  97537. * @return true if ready, otherwise false.
  97538. */
  97539. isReady(): boolean;
  97540. /**
  97541. * List of instances to render in case the source mesh has instances
  97542. */
  97543. customInstances: SmartArray<Matrix>;
  97544. }
  97545. /**
  97546. * Defines the additional options of the edges renderer
  97547. */
  97548. export interface IEdgesRendererOptions {
  97549. /**
  97550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97551. * If not defined, the default value is true
  97552. */
  97553. useAlternateEdgeFinder?: boolean;
  97554. /**
  97555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97556. * If not defined, the default value is true.
  97557. * 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)
  97558. * This option is used only if useAlternateEdgeFinder = true
  97559. */
  97560. useFastVertexMerger?: boolean;
  97561. /**
  97562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97563. * The default value is 1e-6
  97564. * This option is used only if useAlternateEdgeFinder = true
  97565. */
  97566. epsilonVertexMerge?: number;
  97567. /**
  97568. * 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
  97569. * 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.
  97570. * This option is used only if useAlternateEdgeFinder = true
  97571. */
  97572. applyTessellation?: boolean;
  97573. /**
  97574. * 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
  97575. * The default value is 1e-6
  97576. * This option is used only if useAlternateEdgeFinder = true
  97577. */
  97578. epsilonVertexAligned?: number;
  97579. }
  97580. /**
  97581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97582. */
  97583. export class EdgesRenderer implements IEdgesRenderer {
  97584. /**
  97585. * Define the size of the edges with an orthographic camera
  97586. */
  97587. edgesWidthScalerForOrthographic: number;
  97588. /**
  97589. * Define the size of the edges with a perspective camera
  97590. */
  97591. edgesWidthScalerForPerspective: number;
  97592. protected _source: AbstractMesh;
  97593. protected _linesPositions: number[];
  97594. protected _linesNormals: number[];
  97595. protected _linesIndices: number[];
  97596. protected _epsilon: number;
  97597. protected _indicesCount: number;
  97598. protected _lineShader: ShaderMaterial;
  97599. protected _ib: DataBuffer;
  97600. protected _buffers: {
  97601. [key: string]: Nullable<VertexBuffer>;
  97602. };
  97603. protected _buffersForInstances: {
  97604. [key: string]: Nullable<VertexBuffer>;
  97605. };
  97606. protected _checkVerticesInsteadOfIndices: boolean;
  97607. protected _options: Nullable<IEdgesRendererOptions>;
  97608. private _meshRebuildObserver;
  97609. private _meshDisposeObserver;
  97610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97611. isEnabled: boolean;
  97612. /**
  97613. * List of instances to render in case the source mesh has instances
  97614. */
  97615. customInstances: SmartArray<Matrix>;
  97616. private static GetShader;
  97617. /**
  97618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97620. * @param source Mesh used to create edges
  97621. * @param epsilon sum of angles in adjacency to check for edge
  97622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97624. * @param options The options to apply when generating the edges
  97625. */
  97626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97627. protected _prepareRessources(): void;
  97628. /** @hidden */
  97629. _rebuild(): void;
  97630. /**
  97631. * Releases the required resources for the edges renderer
  97632. */
  97633. dispose(): void;
  97634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97636. /**
  97637. * Checks if the pair of p0 and p1 is en edge
  97638. * @param faceIndex
  97639. * @param edge
  97640. * @param faceNormals
  97641. * @param p0
  97642. * @param p1
  97643. * @private
  97644. */
  97645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97646. /**
  97647. * push line into the position, normal and index buffer
  97648. * @protected
  97649. */
  97650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97651. /**
  97652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97653. */
  97654. private _tessellateTriangle;
  97655. private _generateEdgesLinesAlternate;
  97656. /**
  97657. * Generates lines edges from adjacencjes
  97658. * @private
  97659. */
  97660. _generateEdgesLines(): void;
  97661. /**
  97662. * Checks wether or not the edges renderer is ready to render.
  97663. * @return true if ready, otherwise false.
  97664. */
  97665. isReady(): boolean;
  97666. /**
  97667. * Renders the edges of the attached mesh,
  97668. */
  97669. render(): void;
  97670. }
  97671. /**
  97672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97673. */
  97674. export class LineEdgesRenderer extends EdgesRenderer {
  97675. /**
  97676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97677. * @param source LineMesh used to generate edges
  97678. * @param epsilon not important (specified angle for edge detection)
  97679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97680. */
  97681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97682. /**
  97683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97684. */
  97685. _generateEdgesLines(): void;
  97686. }
  97687. }
  97688. declare module BABYLON {
  97689. /**
  97690. * This represents the object necessary to create a rendering group.
  97691. * This is exclusively used and created by the rendering manager.
  97692. * To modify the behavior, you use the available helpers in your scene or meshes.
  97693. * @hidden
  97694. */
  97695. export class RenderingGroup {
  97696. index: number;
  97697. private static _zeroVector;
  97698. private _scene;
  97699. private _opaqueSubMeshes;
  97700. private _transparentSubMeshes;
  97701. private _alphaTestSubMeshes;
  97702. private _depthOnlySubMeshes;
  97703. private _particleSystems;
  97704. private _spriteManagers;
  97705. private _opaqueSortCompareFn;
  97706. private _alphaTestSortCompareFn;
  97707. private _transparentSortCompareFn;
  97708. private _renderOpaque;
  97709. private _renderAlphaTest;
  97710. private _renderTransparent;
  97711. /** @hidden */
  97712. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97713. onBeforeTransparentRendering: () => void;
  97714. /**
  97715. * Set the opaque sort comparison function.
  97716. * If null the sub meshes will be render in the order they were created
  97717. */
  97718. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97719. /**
  97720. * Set the alpha test sort comparison function.
  97721. * If null the sub meshes will be render in the order they were created
  97722. */
  97723. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97724. /**
  97725. * Set the transparent sort comparison function.
  97726. * If null the sub meshes will be render in the order they were created
  97727. */
  97728. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97729. /**
  97730. * Creates a new rendering group.
  97731. * @param index The rendering group index
  97732. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97733. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97734. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97735. */
  97736. 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>);
  97737. /**
  97738. * Render all the sub meshes contained in the group.
  97739. * @param customRenderFunction Used to override the default render behaviour of the group.
  97740. * @returns true if rendered some submeshes.
  97741. */
  97742. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97743. /**
  97744. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97745. * @param subMeshes The submeshes to render
  97746. */
  97747. private renderOpaqueSorted;
  97748. /**
  97749. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97750. * @param subMeshes The submeshes to render
  97751. */
  97752. private renderAlphaTestSorted;
  97753. /**
  97754. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97755. * @param subMeshes The submeshes to render
  97756. */
  97757. private renderTransparentSorted;
  97758. /**
  97759. * Renders the submeshes in a specified order.
  97760. * @param subMeshes The submeshes to sort before render
  97761. * @param sortCompareFn The comparison function use to sort
  97762. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97763. * @param transparent Specifies to activate blending if true
  97764. */
  97765. private static renderSorted;
  97766. /**
  97767. * Renders the submeshes in the order they were dispatched (no sort applied).
  97768. * @param subMeshes The submeshes to render
  97769. */
  97770. private static renderUnsorted;
  97771. /**
  97772. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97773. * are rendered back to front if in the same alpha index.
  97774. *
  97775. * @param a The first submesh
  97776. * @param b The second submesh
  97777. * @returns The result of the comparison
  97778. */
  97779. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97780. /**
  97781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97782. * are rendered back to front.
  97783. *
  97784. * @param a The first submesh
  97785. * @param b The second submesh
  97786. * @returns The result of the comparison
  97787. */
  97788. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97789. /**
  97790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97791. * are rendered front to back (prevent overdraw).
  97792. *
  97793. * @param a The first submesh
  97794. * @param b The second submesh
  97795. * @returns The result of the comparison
  97796. */
  97797. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97798. /**
  97799. * Resets the different lists of submeshes to prepare a new frame.
  97800. */
  97801. prepare(): void;
  97802. dispose(): void;
  97803. /**
  97804. * Inserts the submesh in its correct queue depending on its material.
  97805. * @param subMesh The submesh to dispatch
  97806. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97807. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97808. */
  97809. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97810. dispatchSprites(spriteManager: ISpriteManager): void;
  97811. dispatchParticles(particleSystem: IParticleSystem): void;
  97812. private _renderParticles;
  97813. private _renderSprites;
  97814. }
  97815. }
  97816. declare module BABYLON {
  97817. /**
  97818. * Interface describing the different options available in the rendering manager
  97819. * regarding Auto Clear between groups.
  97820. */
  97821. export interface IRenderingManagerAutoClearSetup {
  97822. /**
  97823. * Defines whether or not autoclear is enable.
  97824. */
  97825. autoClear: boolean;
  97826. /**
  97827. * Defines whether or not to autoclear the depth buffer.
  97828. */
  97829. depth: boolean;
  97830. /**
  97831. * Defines whether or not to autoclear the stencil buffer.
  97832. */
  97833. stencil: boolean;
  97834. }
  97835. /**
  97836. * This class is used by the onRenderingGroupObservable
  97837. */
  97838. export class RenderingGroupInfo {
  97839. /**
  97840. * The Scene that being rendered
  97841. */
  97842. scene: Scene;
  97843. /**
  97844. * The camera currently used for the rendering pass
  97845. */
  97846. camera: Nullable<Camera>;
  97847. /**
  97848. * The ID of the renderingGroup being processed
  97849. */
  97850. renderingGroupId: number;
  97851. }
  97852. /**
  97853. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97854. * It is enable to manage the different groups as well as the different necessary sort functions.
  97855. * This should not be used directly aside of the few static configurations
  97856. */
  97857. export class RenderingManager {
  97858. /**
  97859. * The max id used for rendering groups (not included)
  97860. */
  97861. static MAX_RENDERINGGROUPS: number;
  97862. /**
  97863. * The min id used for rendering groups (included)
  97864. */
  97865. static MIN_RENDERINGGROUPS: number;
  97866. /**
  97867. * Used to globally prevent autoclearing scenes.
  97868. */
  97869. static AUTOCLEAR: boolean;
  97870. /**
  97871. * @hidden
  97872. */
  97873. _useSceneAutoClearSetup: boolean;
  97874. private _scene;
  97875. private _renderingGroups;
  97876. private _depthStencilBufferAlreadyCleaned;
  97877. private _autoClearDepthStencil;
  97878. private _customOpaqueSortCompareFn;
  97879. private _customAlphaTestSortCompareFn;
  97880. private _customTransparentSortCompareFn;
  97881. private _renderingGroupInfo;
  97882. /**
  97883. * Instantiates a new rendering group for a particular scene
  97884. * @param scene Defines the scene the groups belongs to
  97885. */
  97886. constructor(scene: Scene);
  97887. private _clearDepthStencilBuffer;
  97888. /**
  97889. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97890. * @hidden
  97891. */
  97892. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97893. /**
  97894. * Resets the different information of the group to prepare a new frame
  97895. * @hidden
  97896. */
  97897. reset(): void;
  97898. /**
  97899. * Dispose and release the group and its associated resources.
  97900. * @hidden
  97901. */
  97902. dispose(): void;
  97903. /**
  97904. * Clear the info related to rendering groups preventing retention points during dispose.
  97905. */
  97906. freeRenderingGroups(): void;
  97907. private _prepareRenderingGroup;
  97908. /**
  97909. * Add a sprite manager to the rendering manager in order to render it this frame.
  97910. * @param spriteManager Define the sprite manager to render
  97911. */
  97912. dispatchSprites(spriteManager: ISpriteManager): void;
  97913. /**
  97914. * Add a particle system to the rendering manager in order to render it this frame.
  97915. * @param particleSystem Define the particle system to render
  97916. */
  97917. dispatchParticles(particleSystem: IParticleSystem): void;
  97918. /**
  97919. * Add a submesh to the manager in order to render it this frame
  97920. * @param subMesh The submesh to dispatch
  97921. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97922. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97923. */
  97924. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97925. /**
  97926. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97927. * This allowed control for front to back rendering or reversly depending of the special needs.
  97928. *
  97929. * @param renderingGroupId The rendering group id corresponding to its index
  97930. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97931. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97932. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97933. */
  97934. 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;
  97935. /**
  97936. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97937. *
  97938. * @param renderingGroupId The rendering group id corresponding to its index
  97939. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97940. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97941. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97942. */
  97943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97944. /**
  97945. * Gets the current auto clear configuration for one rendering group of the rendering
  97946. * manager.
  97947. * @param index the rendering group index to get the information for
  97948. * @returns The auto clear setup for the requested rendering group
  97949. */
  97950. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97951. }
  97952. }
  97953. declare module BABYLON {
  97954. /**
  97955. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97956. */
  97957. export interface ICustomShaderOptions {
  97958. /**
  97959. * Gets or sets the custom shader name to use
  97960. */
  97961. shaderName: string;
  97962. /**
  97963. * The list of attribute names used in the shader
  97964. */
  97965. attributes?: string[];
  97966. /**
  97967. * The list of unifrom names used in the shader
  97968. */
  97969. uniforms?: string[];
  97970. /**
  97971. * The list of sampler names used in the shader
  97972. */
  97973. samplers?: string[];
  97974. /**
  97975. * The list of defines used in the shader
  97976. */
  97977. defines?: string[];
  97978. }
  97979. /**
  97980. * Interface to implement to create a shadow generator compatible with BJS.
  97981. */
  97982. export interface IShadowGenerator {
  97983. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97984. id: string;
  97985. /**
  97986. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97987. * @returns The render target texture if present otherwise, null
  97988. */
  97989. getShadowMap(): Nullable<RenderTargetTexture>;
  97990. /**
  97991. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97992. * @param subMesh The submesh we want to render in the shadow map
  97993. * @param useInstances Defines wether will draw in the map using instances
  97994. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97995. * @returns true if ready otherwise, false
  97996. */
  97997. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97998. /**
  97999. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98000. * @param defines Defines of the material we want to update
  98001. * @param lightIndex Index of the light in the enabled light list of the material
  98002. */
  98003. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98004. /**
  98005. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98006. * defined in the generator but impacting the effect).
  98007. * It implies the unifroms available on the materials are the standard BJS ones.
  98008. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98009. * @param effect The effect we are binfing the information for
  98010. */
  98011. bindShadowLight(lightIndex: string, effect: Effect): void;
  98012. /**
  98013. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98014. * (eq to shadow prjection matrix * light transform matrix)
  98015. * @returns The transform matrix used to create the shadow map
  98016. */
  98017. getTransformMatrix(): Matrix;
  98018. /**
  98019. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98020. * Cube and 2D textures for instance.
  98021. */
  98022. recreateShadowMap(): void;
  98023. /**
  98024. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98025. * @param onCompiled Callback triggered at the and of the effects compilation
  98026. * @param options Sets of optional options forcing the compilation with different modes
  98027. */
  98028. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98029. useInstances: boolean;
  98030. }>): void;
  98031. /**
  98032. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98033. * @param options Sets of optional options forcing the compilation with different modes
  98034. * @returns A promise that resolves when the compilation completes
  98035. */
  98036. forceCompilationAsync(options?: Partial<{
  98037. useInstances: boolean;
  98038. }>): Promise<void>;
  98039. /**
  98040. * Serializes the shadow generator setup to a json object.
  98041. * @returns The serialized JSON object
  98042. */
  98043. serialize(): any;
  98044. /**
  98045. * Disposes the Shadow map and related Textures and effects.
  98046. */
  98047. dispose(): void;
  98048. }
  98049. /**
  98050. * Default implementation IShadowGenerator.
  98051. * This is the main object responsible of generating shadows in the framework.
  98052. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98053. */
  98054. export class ShadowGenerator implements IShadowGenerator {
  98055. /**
  98056. * Name of the shadow generator class
  98057. */
  98058. static CLASSNAME: string;
  98059. /**
  98060. * Shadow generator mode None: no filtering applied.
  98061. */
  98062. static readonly FILTER_NONE: number;
  98063. /**
  98064. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98065. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98066. */
  98067. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98068. /**
  98069. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98070. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98071. */
  98072. static readonly FILTER_POISSONSAMPLING: number;
  98073. /**
  98074. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98075. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98076. */
  98077. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98078. /**
  98079. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98080. * edge artifacts on steep falloff.
  98081. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98082. */
  98083. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98084. /**
  98085. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98086. * edge artifacts on steep falloff.
  98087. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98088. */
  98089. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98090. /**
  98091. * Shadow generator mode PCF: Percentage Closer Filtering
  98092. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98093. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98094. */
  98095. static readonly FILTER_PCF: number;
  98096. /**
  98097. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98098. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98099. * Contact Hardening
  98100. */
  98101. static readonly FILTER_PCSS: number;
  98102. /**
  98103. * Reserved for PCF and PCSS
  98104. * Highest Quality.
  98105. *
  98106. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98107. *
  98108. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98109. */
  98110. static readonly QUALITY_HIGH: number;
  98111. /**
  98112. * Reserved for PCF and PCSS
  98113. * Good tradeoff for quality/perf cross devices
  98114. *
  98115. * Execute PCF on a 3*3 kernel.
  98116. *
  98117. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98118. */
  98119. static readonly QUALITY_MEDIUM: number;
  98120. /**
  98121. * Reserved for PCF and PCSS
  98122. * The lowest quality but the fastest.
  98123. *
  98124. * Execute PCF on a 1*1 kernel.
  98125. *
  98126. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98127. */
  98128. static readonly QUALITY_LOW: number;
  98129. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98130. id: string;
  98131. /** Gets or sets the custom shader name to use */
  98132. customShaderOptions: ICustomShaderOptions;
  98133. /**
  98134. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98135. */
  98136. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98137. /**
  98138. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98139. */
  98140. onAfterShadowMapRenderObservable: Observable<Effect>;
  98141. /**
  98142. * Observable triggered before a mesh is rendered in the shadow map.
  98143. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98144. */
  98145. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98146. /**
  98147. * Observable triggered after a mesh is rendered in the shadow map.
  98148. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98149. */
  98150. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98151. protected _bias: number;
  98152. /**
  98153. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98154. */
  98155. get bias(): number;
  98156. /**
  98157. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98158. */
  98159. set bias(bias: number);
  98160. protected _normalBias: number;
  98161. /**
  98162. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98163. */
  98164. get normalBias(): number;
  98165. /**
  98166. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98167. */
  98168. set normalBias(normalBias: number);
  98169. protected _blurBoxOffset: number;
  98170. /**
  98171. * Gets the blur box offset: offset applied during the blur pass.
  98172. * Only useful if useKernelBlur = false
  98173. */
  98174. get blurBoxOffset(): number;
  98175. /**
  98176. * Sets the blur box offset: offset applied during the blur pass.
  98177. * Only useful if useKernelBlur = false
  98178. */
  98179. set blurBoxOffset(value: number);
  98180. protected _blurScale: number;
  98181. /**
  98182. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98183. * 2 means half of the size.
  98184. */
  98185. get blurScale(): number;
  98186. /**
  98187. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98188. * 2 means half of the size.
  98189. */
  98190. set blurScale(value: number);
  98191. protected _blurKernel: number;
  98192. /**
  98193. * Gets the blur kernel: kernel size of the blur pass.
  98194. * Only useful if useKernelBlur = true
  98195. */
  98196. get blurKernel(): number;
  98197. /**
  98198. * Sets the blur kernel: kernel size of the blur pass.
  98199. * Only useful if useKernelBlur = true
  98200. */
  98201. set blurKernel(value: number);
  98202. protected _useKernelBlur: boolean;
  98203. /**
  98204. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98205. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98206. */
  98207. get useKernelBlur(): boolean;
  98208. /**
  98209. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98210. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98211. */
  98212. set useKernelBlur(value: boolean);
  98213. protected _depthScale: number;
  98214. /**
  98215. * Gets the depth scale used in ESM mode.
  98216. */
  98217. get depthScale(): number;
  98218. /**
  98219. * Sets the depth scale used in ESM mode.
  98220. * This can override the scale stored on the light.
  98221. */
  98222. set depthScale(value: number);
  98223. protected _validateFilter(filter: number): number;
  98224. protected _filter: number;
  98225. /**
  98226. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98227. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98228. */
  98229. get filter(): number;
  98230. /**
  98231. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98232. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98233. */
  98234. set filter(value: number);
  98235. /**
  98236. * Gets if the current filter is set to Poisson Sampling.
  98237. */
  98238. get usePoissonSampling(): boolean;
  98239. /**
  98240. * Sets the current filter to Poisson Sampling.
  98241. */
  98242. set usePoissonSampling(value: boolean);
  98243. /**
  98244. * Gets if the current filter is set to ESM.
  98245. */
  98246. get useExponentialShadowMap(): boolean;
  98247. /**
  98248. * Sets the current filter is to ESM.
  98249. */
  98250. set useExponentialShadowMap(value: boolean);
  98251. /**
  98252. * Gets if the current filter is set to filtered ESM.
  98253. */
  98254. get useBlurExponentialShadowMap(): boolean;
  98255. /**
  98256. * Gets if the current filter is set to filtered ESM.
  98257. */
  98258. set useBlurExponentialShadowMap(value: boolean);
  98259. /**
  98260. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98261. * exponential to prevent steep falloff artifacts).
  98262. */
  98263. get useCloseExponentialShadowMap(): boolean;
  98264. /**
  98265. * Sets the current filter to "close ESM" (using the inverse of the
  98266. * exponential to prevent steep falloff artifacts).
  98267. */
  98268. set useCloseExponentialShadowMap(value: boolean);
  98269. /**
  98270. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98271. * exponential to prevent steep falloff artifacts).
  98272. */
  98273. get useBlurCloseExponentialShadowMap(): boolean;
  98274. /**
  98275. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98276. * exponential to prevent steep falloff artifacts).
  98277. */
  98278. set useBlurCloseExponentialShadowMap(value: boolean);
  98279. /**
  98280. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98281. */
  98282. get usePercentageCloserFiltering(): boolean;
  98283. /**
  98284. * Sets the current filter to "PCF" (percentage closer filtering).
  98285. */
  98286. set usePercentageCloserFiltering(value: boolean);
  98287. protected _filteringQuality: number;
  98288. /**
  98289. * Gets the PCF or PCSS Quality.
  98290. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98291. */
  98292. get filteringQuality(): number;
  98293. /**
  98294. * Sets the PCF or PCSS Quality.
  98295. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98296. */
  98297. set filteringQuality(filteringQuality: number);
  98298. /**
  98299. * Gets if the current filter is set to "PCSS" (contact hardening).
  98300. */
  98301. get useContactHardeningShadow(): boolean;
  98302. /**
  98303. * Sets the current filter to "PCSS" (contact hardening).
  98304. */
  98305. set useContactHardeningShadow(value: boolean);
  98306. protected _contactHardeningLightSizeUVRatio: number;
  98307. /**
  98308. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98309. * Using a ratio helps keeping shape stability independently of the map size.
  98310. *
  98311. * It does not account for the light projection as it was having too much
  98312. * instability during the light setup or during light position changes.
  98313. *
  98314. * Only valid if useContactHardeningShadow is true.
  98315. */
  98316. get contactHardeningLightSizeUVRatio(): number;
  98317. /**
  98318. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98319. * Using a ratio helps keeping shape stability independently of the map size.
  98320. *
  98321. * It does not account for the light projection as it was having too much
  98322. * instability during the light setup or during light position changes.
  98323. *
  98324. * Only valid if useContactHardeningShadow is true.
  98325. */
  98326. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98327. protected _darkness: number;
  98328. /** Gets or sets the actual darkness of a shadow */
  98329. get darkness(): number;
  98330. set darkness(value: number);
  98331. /**
  98332. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98333. * 0 means strongest and 1 would means no shadow.
  98334. * @returns the darkness.
  98335. */
  98336. getDarkness(): number;
  98337. /**
  98338. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98339. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98340. * @returns the shadow generator allowing fluent coding.
  98341. */
  98342. setDarkness(darkness: number): ShadowGenerator;
  98343. protected _transparencyShadow: boolean;
  98344. /** Gets or sets the ability to have transparent shadow */
  98345. get transparencyShadow(): boolean;
  98346. set transparencyShadow(value: boolean);
  98347. /**
  98348. * Sets the ability to have transparent shadow (boolean).
  98349. * @param transparent True if transparent else False
  98350. * @returns the shadow generator allowing fluent coding
  98351. */
  98352. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98353. /**
  98354. * Enables or disables shadows with varying strength based on the transparency
  98355. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98356. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98357. * mesh.visibility * alphaTexture.a
  98358. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98359. */
  98360. enableSoftTransparentShadow: boolean;
  98361. protected _shadowMap: Nullable<RenderTargetTexture>;
  98362. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98363. /**
  98364. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98365. * @returns The render target texture if present otherwise, null
  98366. */
  98367. getShadowMap(): Nullable<RenderTargetTexture>;
  98368. /**
  98369. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98370. * @returns The render target texture if the shadow map is present otherwise, null
  98371. */
  98372. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98373. /**
  98374. * Gets the class name of that object
  98375. * @returns "ShadowGenerator"
  98376. */
  98377. getClassName(): string;
  98378. /**
  98379. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98380. * @param mesh Mesh to add
  98381. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98382. * @returns the Shadow Generator itself
  98383. */
  98384. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98385. /**
  98386. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98387. * @param mesh Mesh to remove
  98388. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98389. * @returns the Shadow Generator itself
  98390. */
  98391. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98392. /**
  98393. * Controls the extent to which the shadows fade out at the edge of the frustum
  98394. */
  98395. frustumEdgeFalloff: number;
  98396. protected _light: IShadowLight;
  98397. /**
  98398. * Returns the associated light object.
  98399. * @returns the light generating the shadow
  98400. */
  98401. getLight(): IShadowLight;
  98402. /**
  98403. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98404. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98405. * It might on the other hand introduce peter panning.
  98406. */
  98407. forceBackFacesOnly: boolean;
  98408. protected _scene: Scene;
  98409. protected _lightDirection: Vector3;
  98410. protected _effect: Effect;
  98411. protected _viewMatrix: Matrix;
  98412. protected _projectionMatrix: Matrix;
  98413. protected _transformMatrix: Matrix;
  98414. protected _cachedPosition: Vector3;
  98415. protected _cachedDirection: Vector3;
  98416. protected _cachedDefines: string;
  98417. protected _currentRenderID: number;
  98418. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98419. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98420. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98421. protected _blurPostProcesses: PostProcess[];
  98422. protected _mapSize: number;
  98423. protected _currentFaceIndex: number;
  98424. protected _currentFaceIndexCache: number;
  98425. protected _textureType: number;
  98426. protected _defaultTextureMatrix: Matrix;
  98427. protected _storedUniqueId: Nullable<number>;
  98428. /** @hidden */
  98429. static _SceneComponentInitialization: (scene: Scene) => void;
  98430. /**
  98431. * Creates a ShadowGenerator object.
  98432. * A ShadowGenerator is the required tool to use the shadows.
  98433. * Each light casting shadows needs to use its own ShadowGenerator.
  98434. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98435. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98436. * @param light The light object generating the shadows.
  98437. * @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.
  98438. */
  98439. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98440. protected _initializeGenerator(): void;
  98441. protected _createTargetRenderTexture(): void;
  98442. protected _initializeShadowMap(): void;
  98443. protected _initializeBlurRTTAndPostProcesses(): void;
  98444. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98445. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98446. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98447. protected _applyFilterValues(): void;
  98448. /**
  98449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98450. * @param onCompiled Callback triggered at the and of the effects compilation
  98451. * @param options Sets of optional options forcing the compilation with different modes
  98452. */
  98453. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98454. useInstances: boolean;
  98455. }>): void;
  98456. /**
  98457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98458. * @param options Sets of optional options forcing the compilation with different modes
  98459. * @returns A promise that resolves when the compilation completes
  98460. */
  98461. forceCompilationAsync(options?: Partial<{
  98462. useInstances: boolean;
  98463. }>): Promise<void>;
  98464. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98465. private _prepareShadowDefines;
  98466. /**
  98467. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98468. * @param subMesh The submesh we want to render in the shadow map
  98469. * @param useInstances Defines wether will draw in the map using instances
  98470. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98471. * @returns true if ready otherwise, false
  98472. */
  98473. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98474. /**
  98475. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98476. * @param defines Defines of the material we want to update
  98477. * @param lightIndex Index of the light in the enabled light list of the material
  98478. */
  98479. prepareDefines(defines: any, lightIndex: number): void;
  98480. /**
  98481. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98482. * defined in the generator but impacting the effect).
  98483. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98484. * @param effect The effect we are binfing the information for
  98485. */
  98486. bindShadowLight(lightIndex: string, effect: Effect): void;
  98487. /**
  98488. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98489. * (eq to shadow prjection matrix * light transform matrix)
  98490. * @returns The transform matrix used to create the shadow map
  98491. */
  98492. getTransformMatrix(): Matrix;
  98493. /**
  98494. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98495. * Cube and 2D textures for instance.
  98496. */
  98497. recreateShadowMap(): void;
  98498. protected _disposeBlurPostProcesses(): void;
  98499. protected _disposeRTTandPostProcesses(): void;
  98500. /**
  98501. * Disposes the ShadowGenerator.
  98502. * Returns nothing.
  98503. */
  98504. dispose(): void;
  98505. /**
  98506. * Serializes the shadow generator setup to a json object.
  98507. * @returns The serialized JSON object
  98508. */
  98509. serialize(): any;
  98510. /**
  98511. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98512. * @param parsedShadowGenerator The JSON object to parse
  98513. * @param scene The scene to create the shadow map for
  98514. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98515. * @returns The parsed shadow generator
  98516. */
  98517. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98518. }
  98519. }
  98520. declare module BABYLON {
  98521. /**
  98522. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98523. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98524. * 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.
  98525. */
  98526. export abstract class Light extends Node {
  98527. /**
  98528. * Falloff Default: light is falling off following the material specification:
  98529. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98530. */
  98531. static readonly FALLOFF_DEFAULT: number;
  98532. /**
  98533. * Falloff Physical: light is falling off following the inverse squared distance law.
  98534. */
  98535. static readonly FALLOFF_PHYSICAL: number;
  98536. /**
  98537. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98538. * to enhance interoperability with other engines.
  98539. */
  98540. static readonly FALLOFF_GLTF: number;
  98541. /**
  98542. * Falloff Standard: light is falling off like in the standard material
  98543. * to enhance interoperability with other materials.
  98544. */
  98545. static readonly FALLOFF_STANDARD: number;
  98546. /**
  98547. * If every light affecting the material is in this lightmapMode,
  98548. * material.lightmapTexture adds or multiplies
  98549. * (depends on material.useLightmapAsShadowmap)
  98550. * after every other light calculations.
  98551. */
  98552. static readonly LIGHTMAP_DEFAULT: number;
  98553. /**
  98554. * material.lightmapTexture as only diffuse lighting from this light
  98555. * adds only specular lighting from this light
  98556. * adds dynamic shadows
  98557. */
  98558. static readonly LIGHTMAP_SPECULAR: number;
  98559. /**
  98560. * material.lightmapTexture as only lighting
  98561. * no light calculation from this light
  98562. * only adds dynamic shadows from this light
  98563. */
  98564. static readonly LIGHTMAP_SHADOWSONLY: number;
  98565. /**
  98566. * Each light type uses the default quantity according to its type:
  98567. * point/spot lights use luminous intensity
  98568. * directional lights use illuminance
  98569. */
  98570. static readonly INTENSITYMODE_AUTOMATIC: number;
  98571. /**
  98572. * lumen (lm)
  98573. */
  98574. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98575. /**
  98576. * candela (lm/sr)
  98577. */
  98578. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98579. /**
  98580. * lux (lm/m^2)
  98581. */
  98582. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98583. /**
  98584. * nit (cd/m^2)
  98585. */
  98586. static readonly INTENSITYMODE_LUMINANCE: number;
  98587. /**
  98588. * Light type const id of the point light.
  98589. */
  98590. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98591. /**
  98592. * Light type const id of the directional light.
  98593. */
  98594. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98595. /**
  98596. * Light type const id of the spot light.
  98597. */
  98598. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98599. /**
  98600. * Light type const id of the hemispheric light.
  98601. */
  98602. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98603. /**
  98604. * Diffuse gives the basic color to an object.
  98605. */
  98606. diffuse: Color3;
  98607. /**
  98608. * Specular produces a highlight color on an object.
  98609. * Note: This is note affecting PBR materials.
  98610. */
  98611. specular: Color3;
  98612. /**
  98613. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98614. * falling off base on range or angle.
  98615. * This can be set to any values in Light.FALLOFF_x.
  98616. *
  98617. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98618. * other types of materials.
  98619. */
  98620. falloffType: number;
  98621. /**
  98622. * Strength of the light.
  98623. * Note: By default it is define in the framework own unit.
  98624. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98625. */
  98626. intensity: number;
  98627. private _range;
  98628. protected _inverseSquaredRange: number;
  98629. /**
  98630. * Defines how far from the source the light is impacting in scene units.
  98631. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98632. */
  98633. get range(): number;
  98634. /**
  98635. * Defines how far from the source the light is impacting in scene units.
  98636. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98637. */
  98638. set range(value: number);
  98639. /**
  98640. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98641. * of light.
  98642. */
  98643. private _photometricScale;
  98644. private _intensityMode;
  98645. /**
  98646. * Gets the photometric scale used to interpret the intensity.
  98647. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98648. */
  98649. get intensityMode(): number;
  98650. /**
  98651. * Sets the photometric scale used to interpret the intensity.
  98652. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98653. */
  98654. set intensityMode(value: number);
  98655. private _radius;
  98656. /**
  98657. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98658. */
  98659. get radius(): number;
  98660. /**
  98661. * sets the light radius used by PBR Materials to simulate soft area lights.
  98662. */
  98663. set radius(value: number);
  98664. private _renderPriority;
  98665. /**
  98666. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98667. * exceeding the number allowed of the materials.
  98668. */
  98669. renderPriority: number;
  98670. private _shadowEnabled;
  98671. /**
  98672. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98673. * the current shadow generator.
  98674. */
  98675. get shadowEnabled(): boolean;
  98676. /**
  98677. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98678. * the current shadow generator.
  98679. */
  98680. set shadowEnabled(value: boolean);
  98681. private _includedOnlyMeshes;
  98682. /**
  98683. * Gets the only meshes impacted by this light.
  98684. */
  98685. get includedOnlyMeshes(): AbstractMesh[];
  98686. /**
  98687. * Sets the only meshes impacted by this light.
  98688. */
  98689. set includedOnlyMeshes(value: AbstractMesh[]);
  98690. private _excludedMeshes;
  98691. /**
  98692. * Gets the meshes not impacted by this light.
  98693. */
  98694. get excludedMeshes(): AbstractMesh[];
  98695. /**
  98696. * Sets the meshes not impacted by this light.
  98697. */
  98698. set excludedMeshes(value: AbstractMesh[]);
  98699. private _excludeWithLayerMask;
  98700. /**
  98701. * Gets the layer id use to find what meshes are not impacted by the light.
  98702. * Inactive if 0
  98703. */
  98704. get excludeWithLayerMask(): number;
  98705. /**
  98706. * Sets the layer id use to find what meshes are not impacted by the light.
  98707. * Inactive if 0
  98708. */
  98709. set excludeWithLayerMask(value: number);
  98710. private _includeOnlyWithLayerMask;
  98711. /**
  98712. * Gets the layer id use to find what meshes are impacted by the light.
  98713. * Inactive if 0
  98714. */
  98715. get includeOnlyWithLayerMask(): number;
  98716. /**
  98717. * Sets the layer id use to find what meshes are impacted by the light.
  98718. * Inactive if 0
  98719. */
  98720. set includeOnlyWithLayerMask(value: number);
  98721. private _lightmapMode;
  98722. /**
  98723. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98724. */
  98725. get lightmapMode(): number;
  98726. /**
  98727. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98728. */
  98729. set lightmapMode(value: number);
  98730. /**
  98731. * Shadow generator associted to the light.
  98732. * @hidden Internal use only.
  98733. */
  98734. _shadowGenerator: Nullable<IShadowGenerator>;
  98735. /**
  98736. * @hidden Internal use only.
  98737. */
  98738. _excludedMeshesIds: string[];
  98739. /**
  98740. * @hidden Internal use only.
  98741. */
  98742. _includedOnlyMeshesIds: string[];
  98743. /**
  98744. * The current light unifom buffer.
  98745. * @hidden Internal use only.
  98746. */
  98747. _uniformBuffer: UniformBuffer;
  98748. /** @hidden */
  98749. _renderId: number;
  98750. /**
  98751. * Creates a Light object in the scene.
  98752. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98753. * @param name The firendly name of the light
  98754. * @param scene The scene the light belongs too
  98755. */
  98756. constructor(name: string, scene: Scene);
  98757. protected abstract _buildUniformLayout(): void;
  98758. /**
  98759. * Sets the passed Effect "effect" with the Light information.
  98760. * @param effect The effect to update
  98761. * @param lightIndex The index of the light in the effect to update
  98762. * @returns The light
  98763. */
  98764. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98765. /**
  98766. * Sets the passed Effect "effect" with the Light textures.
  98767. * @param effect The effect to update
  98768. * @param lightIndex The index of the light in the effect to update
  98769. * @returns The light
  98770. */
  98771. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98772. /**
  98773. * Binds the lights information from the scene to the effect for the given mesh.
  98774. * @param lightIndex Light index
  98775. * @param scene The scene where the light belongs to
  98776. * @param effect The effect we are binding the data to
  98777. * @param useSpecular Defines if specular is supported
  98778. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98779. */
  98780. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98781. /**
  98782. * Sets the passed Effect "effect" with the Light information.
  98783. * @param effect The effect to update
  98784. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98785. * @returns The light
  98786. */
  98787. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98788. /**
  98789. * Returns the string "Light".
  98790. * @returns the class name
  98791. */
  98792. getClassName(): string;
  98793. /** @hidden */
  98794. readonly _isLight: boolean;
  98795. /**
  98796. * Converts the light information to a readable string for debug purpose.
  98797. * @param fullDetails Supports for multiple levels of logging within scene loading
  98798. * @returns the human readable light info
  98799. */
  98800. toString(fullDetails?: boolean): string;
  98801. /** @hidden */
  98802. protected _syncParentEnabledState(): void;
  98803. /**
  98804. * Set the enabled state of this node.
  98805. * @param value - the new enabled state
  98806. */
  98807. setEnabled(value: boolean): void;
  98808. /**
  98809. * Returns the Light associated shadow generator if any.
  98810. * @return the associated shadow generator.
  98811. */
  98812. getShadowGenerator(): Nullable<IShadowGenerator>;
  98813. /**
  98814. * Returns a Vector3, the absolute light position in the World.
  98815. * @returns the world space position of the light
  98816. */
  98817. getAbsolutePosition(): Vector3;
  98818. /**
  98819. * Specifies if the light will affect the passed mesh.
  98820. * @param mesh The mesh to test against the light
  98821. * @return true the mesh is affected otherwise, false.
  98822. */
  98823. canAffectMesh(mesh: AbstractMesh): boolean;
  98824. /**
  98825. * Sort function to order lights for rendering.
  98826. * @param a First Light object to compare to second.
  98827. * @param b Second Light object to compare first.
  98828. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98829. */
  98830. static CompareLightsPriority(a: Light, b: Light): number;
  98831. /**
  98832. * Releases resources associated with this node.
  98833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98835. */
  98836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98837. /**
  98838. * Returns the light type ID (integer).
  98839. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98840. */
  98841. getTypeID(): number;
  98842. /**
  98843. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98844. * @returns the scaled intensity in intensity mode unit
  98845. */
  98846. getScaledIntensity(): number;
  98847. /**
  98848. * Returns a new Light object, named "name", from the current one.
  98849. * @param name The name of the cloned light
  98850. * @param newParent The parent of this light, if it has one
  98851. * @returns the new created light
  98852. */
  98853. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98854. /**
  98855. * Serializes the current light into a Serialization object.
  98856. * @returns the serialized object.
  98857. */
  98858. serialize(): any;
  98859. /**
  98860. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98861. * This new light is named "name" and added to the passed scene.
  98862. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98863. * @param name The friendly name of the light
  98864. * @param scene The scene the new light will belong to
  98865. * @returns the constructor function
  98866. */
  98867. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98868. /**
  98869. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98870. * @param parsedLight The JSON representation of the light
  98871. * @param scene The scene to create the parsed light in
  98872. * @returns the created light after parsing
  98873. */
  98874. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98875. private _hookArrayForExcluded;
  98876. private _hookArrayForIncludedOnly;
  98877. private _resyncMeshes;
  98878. /**
  98879. * Forces the meshes to update their light related information in their rendering used effects
  98880. * @hidden Internal Use Only
  98881. */
  98882. _markMeshesAsLightDirty(): void;
  98883. /**
  98884. * Recomputes the cached photometric scale if needed.
  98885. */
  98886. private _computePhotometricScale;
  98887. /**
  98888. * Returns the Photometric Scale according to the light type and intensity mode.
  98889. */
  98890. private _getPhotometricScale;
  98891. /**
  98892. * Reorder the light in the scene according to their defined priority.
  98893. * @hidden Internal Use Only
  98894. */
  98895. _reorderLightsInScene(): void;
  98896. /**
  98897. * Prepares the list of defines specific to the light type.
  98898. * @param defines the list of defines
  98899. * @param lightIndex defines the index of the light for the effect
  98900. */
  98901. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98902. }
  98903. }
  98904. declare module BABYLON {
  98905. /**
  98906. * Configuration needed for prepass-capable materials
  98907. */
  98908. export class PrePassConfiguration {
  98909. /**
  98910. * Previous world matrices of meshes carrying this material
  98911. * Used for computing velocity
  98912. */
  98913. previousWorldMatrices: {
  98914. [index: number]: Matrix;
  98915. };
  98916. /**
  98917. * Previous view project matrix
  98918. * Used for computing velocity
  98919. */
  98920. previousViewProjection: Matrix;
  98921. /**
  98922. * Previous bones of meshes carrying this material
  98923. * Used for computing velocity
  98924. */
  98925. previousBones: {
  98926. [index: number]: Float32Array;
  98927. };
  98928. /**
  98929. * Add the required uniforms to the current list.
  98930. * @param uniforms defines the current uniform list.
  98931. */
  98932. static AddUniforms(uniforms: string[]): void;
  98933. /**
  98934. * Add the required samplers to the current list.
  98935. * @param samplers defines the current sampler list.
  98936. */
  98937. static AddSamplers(samplers: string[]): void;
  98938. /**
  98939. * Binds the material data.
  98940. * @param effect defines the effect to update
  98941. * @param scene defines the scene the material belongs to.
  98942. * @param mesh The mesh
  98943. * @param world World matrix of this mesh
  98944. * @param isFrozen Is the material frozen
  98945. */
  98946. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  98947. }
  98948. }
  98949. declare module BABYLON {
  98950. /**
  98951. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98952. * This is the base of the follow, arc rotate cameras and Free camera
  98953. * @see https://doc.babylonjs.com/features/cameras
  98954. */
  98955. export class TargetCamera extends Camera {
  98956. private static _RigCamTransformMatrix;
  98957. private static _TargetTransformMatrix;
  98958. private static _TargetFocalPoint;
  98959. private _tmpUpVector;
  98960. private _tmpTargetVector;
  98961. /**
  98962. * Define the current direction the camera is moving to
  98963. */
  98964. cameraDirection: Vector3;
  98965. /**
  98966. * Define the current rotation the camera is rotating to
  98967. */
  98968. cameraRotation: Vector2;
  98969. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98970. ignoreParentScaling: boolean;
  98971. /**
  98972. * When set, the up vector of the camera will be updated by the rotation of the camera
  98973. */
  98974. updateUpVectorFromRotation: boolean;
  98975. private _tmpQuaternion;
  98976. /**
  98977. * Define the current rotation of the camera
  98978. */
  98979. rotation: Vector3;
  98980. /**
  98981. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98982. */
  98983. rotationQuaternion: Quaternion;
  98984. /**
  98985. * Define the current speed of the camera
  98986. */
  98987. speed: number;
  98988. /**
  98989. * Add constraint to the camera to prevent it to move freely in all directions and
  98990. * around all axis.
  98991. */
  98992. noRotationConstraint: boolean;
  98993. /**
  98994. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98995. * panning
  98996. */
  98997. invertRotation: boolean;
  98998. /**
  98999. * Speed multiplier for inverse camera panning
  99000. */
  99001. inverseRotationSpeed: number;
  99002. /**
  99003. * Define the current target of the camera as an object or a position.
  99004. */
  99005. lockedTarget: any;
  99006. /** @hidden */
  99007. _currentTarget: Vector3;
  99008. /** @hidden */
  99009. _initialFocalDistance: number;
  99010. /** @hidden */
  99011. _viewMatrix: Matrix;
  99012. /** @hidden */
  99013. _camMatrix: Matrix;
  99014. /** @hidden */
  99015. _cameraTransformMatrix: Matrix;
  99016. /** @hidden */
  99017. _cameraRotationMatrix: Matrix;
  99018. /** @hidden */
  99019. _referencePoint: Vector3;
  99020. /** @hidden */
  99021. _transformedReferencePoint: Vector3;
  99022. /** @hidden */
  99023. _reset: () => void;
  99024. private _defaultUp;
  99025. /**
  99026. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99027. * This is the base of the follow, arc rotate cameras and Free camera
  99028. * @see https://doc.babylonjs.com/features/cameras
  99029. * @param name Defines the name of the camera in the scene
  99030. * @param position Defines the start position of the camera in the scene
  99031. * @param scene Defines the scene the camera belongs to
  99032. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99033. */
  99034. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99035. /**
  99036. * Gets the position in front of the camera at a given distance.
  99037. * @param distance The distance from the camera we want the position to be
  99038. * @returns the position
  99039. */
  99040. getFrontPosition(distance: number): Vector3;
  99041. /** @hidden */
  99042. _getLockedTargetPosition(): Nullable<Vector3>;
  99043. private _storedPosition;
  99044. private _storedRotation;
  99045. private _storedRotationQuaternion;
  99046. /**
  99047. * Store current camera state of the camera (fov, position, rotation, etc..)
  99048. * @returns the camera
  99049. */
  99050. storeState(): Camera;
  99051. /**
  99052. * Restored camera state. You must call storeState() first
  99053. * @returns whether it was successful or not
  99054. * @hidden
  99055. */
  99056. _restoreStateValues(): boolean;
  99057. /** @hidden */
  99058. _initCache(): void;
  99059. /** @hidden */
  99060. _updateCache(ignoreParentClass?: boolean): void;
  99061. /** @hidden */
  99062. _isSynchronizedViewMatrix(): boolean;
  99063. /** @hidden */
  99064. _computeLocalCameraSpeed(): number;
  99065. /**
  99066. * Defines the target the camera should look at.
  99067. * @param target Defines the new target as a Vector or a mesh
  99068. */
  99069. setTarget(target: Vector3): void;
  99070. /**
  99071. * Defines the target point of the camera.
  99072. * The camera looks towards it form the radius distance.
  99073. */
  99074. get target(): Vector3;
  99075. set target(value: Vector3);
  99076. /**
  99077. * Return the current target position of the camera. This value is expressed in local space.
  99078. * @returns the target position
  99079. */
  99080. getTarget(): Vector3;
  99081. /** @hidden */
  99082. _decideIfNeedsToMove(): boolean;
  99083. /** @hidden */
  99084. _updatePosition(): void;
  99085. /** @hidden */
  99086. _checkInputs(): void;
  99087. protected _updateCameraRotationMatrix(): void;
  99088. /**
  99089. * 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)
  99090. * @returns the current camera
  99091. */
  99092. private _rotateUpVectorWithCameraRotationMatrix;
  99093. private _cachedRotationZ;
  99094. private _cachedQuaternionRotationZ;
  99095. /** @hidden */
  99096. _getViewMatrix(): Matrix;
  99097. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99098. /**
  99099. * @hidden
  99100. */
  99101. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99102. /**
  99103. * @hidden
  99104. */
  99105. _updateRigCameras(): void;
  99106. private _getRigCamPositionAndTarget;
  99107. /**
  99108. * Gets the current object class name.
  99109. * @return the class name
  99110. */
  99111. getClassName(): string;
  99112. }
  99113. }
  99114. declare module BABYLON {
  99115. /**
  99116. * Gather the list of keyboard event types as constants.
  99117. */
  99118. export class KeyboardEventTypes {
  99119. /**
  99120. * The keydown event is fired when a key becomes active (pressed).
  99121. */
  99122. static readonly KEYDOWN: number;
  99123. /**
  99124. * The keyup event is fired when a key has been released.
  99125. */
  99126. static readonly KEYUP: number;
  99127. }
  99128. /**
  99129. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99130. */
  99131. export class KeyboardInfo {
  99132. /**
  99133. * Defines the type of event (KeyboardEventTypes)
  99134. */
  99135. type: number;
  99136. /**
  99137. * Defines the related dom event
  99138. */
  99139. event: KeyboardEvent;
  99140. /**
  99141. * Instantiates a new keyboard info.
  99142. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99143. * @param type Defines the type of event (KeyboardEventTypes)
  99144. * @param event Defines the related dom event
  99145. */
  99146. constructor(
  99147. /**
  99148. * Defines the type of event (KeyboardEventTypes)
  99149. */
  99150. type: number,
  99151. /**
  99152. * Defines the related dom event
  99153. */
  99154. event: KeyboardEvent);
  99155. }
  99156. /**
  99157. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99158. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99159. */
  99160. export class KeyboardInfoPre extends KeyboardInfo {
  99161. /**
  99162. * Defines the type of event (KeyboardEventTypes)
  99163. */
  99164. type: number;
  99165. /**
  99166. * Defines the related dom event
  99167. */
  99168. event: KeyboardEvent;
  99169. /**
  99170. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99171. */
  99172. skipOnPointerObservable: boolean;
  99173. /**
  99174. * Instantiates a new keyboard pre info.
  99175. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99176. * @param type Defines the type of event (KeyboardEventTypes)
  99177. * @param event Defines the related dom event
  99178. */
  99179. constructor(
  99180. /**
  99181. * Defines the type of event (KeyboardEventTypes)
  99182. */
  99183. type: number,
  99184. /**
  99185. * Defines the related dom event
  99186. */
  99187. event: KeyboardEvent);
  99188. }
  99189. }
  99190. declare module BABYLON {
  99191. /**
  99192. * Manage the keyboard inputs to control the movement of a free camera.
  99193. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99194. */
  99195. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99196. /**
  99197. * Defines the camera the input is attached to.
  99198. */
  99199. camera: FreeCamera;
  99200. /**
  99201. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99202. */
  99203. keysUp: number[];
  99204. /**
  99205. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99206. */
  99207. keysUpward: number[];
  99208. /**
  99209. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99210. */
  99211. keysDown: number[];
  99212. /**
  99213. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99214. */
  99215. keysDownward: number[];
  99216. /**
  99217. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99218. */
  99219. keysLeft: number[];
  99220. /**
  99221. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99222. */
  99223. keysRight: number[];
  99224. private _keys;
  99225. private _onCanvasBlurObserver;
  99226. private _onKeyboardObserver;
  99227. private _engine;
  99228. private _scene;
  99229. /**
  99230. * Attach the input controls to a specific dom element to get the input from.
  99231. * @param element Defines the element the controls should be listened from
  99232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99233. */
  99234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99235. /**
  99236. * Detach the current controls from the specified dom element.
  99237. * @param element Defines the element to stop listening the inputs from
  99238. */
  99239. detachControl(element: Nullable<HTMLElement>): void;
  99240. /**
  99241. * Update the current camera state depending on the inputs that have been used this frame.
  99242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99243. */
  99244. checkInputs(): void;
  99245. /**
  99246. * Gets the class name of the current intput.
  99247. * @returns the class name
  99248. */
  99249. getClassName(): string;
  99250. /** @hidden */
  99251. _onLostFocus(): void;
  99252. /**
  99253. * Get the friendly name associated with the input class.
  99254. * @returns the input friendly name
  99255. */
  99256. getSimpleName(): string;
  99257. }
  99258. }
  99259. declare module BABYLON {
  99260. /**
  99261. * Gather the list of pointer event types as constants.
  99262. */
  99263. export class PointerEventTypes {
  99264. /**
  99265. * 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.
  99266. */
  99267. static readonly POINTERDOWN: number;
  99268. /**
  99269. * The pointerup event is fired when a pointer is no longer active.
  99270. */
  99271. static readonly POINTERUP: number;
  99272. /**
  99273. * The pointermove event is fired when a pointer changes coordinates.
  99274. */
  99275. static readonly POINTERMOVE: number;
  99276. /**
  99277. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99278. */
  99279. static readonly POINTERWHEEL: number;
  99280. /**
  99281. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99282. */
  99283. static readonly POINTERPICK: number;
  99284. /**
  99285. * The pointertap event is fired when a the object has been touched and released without drag.
  99286. */
  99287. static readonly POINTERTAP: number;
  99288. /**
  99289. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99290. */
  99291. static readonly POINTERDOUBLETAP: number;
  99292. }
  99293. /**
  99294. * Base class of pointer info types.
  99295. */
  99296. export class PointerInfoBase {
  99297. /**
  99298. * Defines the type of event (PointerEventTypes)
  99299. */
  99300. type: number;
  99301. /**
  99302. * Defines the related dom event
  99303. */
  99304. event: PointerEvent | MouseWheelEvent;
  99305. /**
  99306. * Instantiates the base class of pointers info.
  99307. * @param type Defines the type of event (PointerEventTypes)
  99308. * @param event Defines the related dom event
  99309. */
  99310. constructor(
  99311. /**
  99312. * Defines the type of event (PointerEventTypes)
  99313. */
  99314. type: number,
  99315. /**
  99316. * Defines the related dom event
  99317. */
  99318. event: PointerEvent | MouseWheelEvent);
  99319. }
  99320. /**
  99321. * This class is used to store pointer related info for the onPrePointerObservable event.
  99322. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99323. */
  99324. export class PointerInfoPre extends PointerInfoBase {
  99325. /**
  99326. * Ray from a pointer if availible (eg. 6dof controller)
  99327. */
  99328. ray: Nullable<Ray>;
  99329. /**
  99330. * Defines the local position of the pointer on the canvas.
  99331. */
  99332. localPosition: Vector2;
  99333. /**
  99334. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99335. */
  99336. skipOnPointerObservable: boolean;
  99337. /**
  99338. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99339. * @param type Defines the type of event (PointerEventTypes)
  99340. * @param event Defines the related dom event
  99341. * @param localX Defines the local x coordinates of the pointer when the event occured
  99342. * @param localY Defines the local y coordinates of the pointer when the event occured
  99343. */
  99344. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99345. }
  99346. /**
  99347. * This type contains all the data related to a pointer event in Babylon.js.
  99348. * 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.
  99349. */
  99350. export class PointerInfo extends PointerInfoBase {
  99351. /**
  99352. * Defines the picking info associated to the info (if any)\
  99353. */
  99354. pickInfo: Nullable<PickingInfo>;
  99355. /**
  99356. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99357. * @param type Defines the type of event (PointerEventTypes)
  99358. * @param event Defines the related dom event
  99359. * @param pickInfo Defines the picking info associated to the info (if any)\
  99360. */
  99361. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99362. /**
  99363. * Defines the picking info associated to the info (if any)\
  99364. */
  99365. pickInfo: Nullable<PickingInfo>);
  99366. }
  99367. /**
  99368. * Data relating to a touch event on the screen.
  99369. */
  99370. export interface PointerTouch {
  99371. /**
  99372. * X coordinate of touch.
  99373. */
  99374. x: number;
  99375. /**
  99376. * Y coordinate of touch.
  99377. */
  99378. y: number;
  99379. /**
  99380. * Id of touch. Unique for each finger.
  99381. */
  99382. pointerId: number;
  99383. /**
  99384. * Event type passed from DOM.
  99385. */
  99386. type: any;
  99387. }
  99388. }
  99389. declare module BABYLON {
  99390. /**
  99391. * Manage the mouse inputs to control the movement of a free camera.
  99392. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99393. */
  99394. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99395. /**
  99396. * Define if touch is enabled in the mouse input
  99397. */
  99398. touchEnabled: boolean;
  99399. /**
  99400. * Defines the camera the input is attached to.
  99401. */
  99402. camera: FreeCamera;
  99403. /**
  99404. * Defines the buttons associated with the input to handle camera move.
  99405. */
  99406. buttons: number[];
  99407. /**
  99408. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99409. */
  99410. angularSensibility: number;
  99411. private _pointerInput;
  99412. private _onMouseMove;
  99413. private _observer;
  99414. private previousPosition;
  99415. /**
  99416. * Observable for when a pointer move event occurs containing the move offset
  99417. */
  99418. onPointerMovedObservable: Observable<{
  99419. offsetX: number;
  99420. offsetY: number;
  99421. }>;
  99422. /**
  99423. * @hidden
  99424. * If the camera should be rotated automatically based on pointer movement
  99425. */
  99426. _allowCameraRotation: boolean;
  99427. /**
  99428. * Manage the mouse inputs to control the movement of a free camera.
  99429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99430. * @param touchEnabled Defines if touch is enabled or not
  99431. */
  99432. constructor(
  99433. /**
  99434. * Define if touch is enabled in the mouse input
  99435. */
  99436. touchEnabled?: boolean);
  99437. /**
  99438. * Attach the input controls to a specific dom element to get the input from.
  99439. * @param element Defines the element the controls should be listened from
  99440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99441. */
  99442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99443. /**
  99444. * Called on JS contextmenu event.
  99445. * Override this method to provide functionality.
  99446. */
  99447. protected onContextMenu(evt: PointerEvent): void;
  99448. /**
  99449. * Detach the current controls from the specified dom element.
  99450. * @param element Defines the element to stop listening the inputs from
  99451. */
  99452. detachControl(element: Nullable<HTMLElement>): void;
  99453. /**
  99454. * Gets the class name of the current intput.
  99455. * @returns the class name
  99456. */
  99457. getClassName(): string;
  99458. /**
  99459. * Get the friendly name associated with the input class.
  99460. * @returns the input friendly name
  99461. */
  99462. getSimpleName(): string;
  99463. }
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * Manage the touch inputs to control the movement of a free camera.
  99468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99469. */
  99470. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99471. /**
  99472. * Define if mouse events can be treated as touch events
  99473. */
  99474. allowMouse: boolean;
  99475. /**
  99476. * Defines the camera the input is attached to.
  99477. */
  99478. camera: FreeCamera;
  99479. /**
  99480. * Defines the touch sensibility for rotation.
  99481. * The higher the faster.
  99482. */
  99483. touchAngularSensibility: number;
  99484. /**
  99485. * Defines the touch sensibility for move.
  99486. * The higher the faster.
  99487. */
  99488. touchMoveSensibility: number;
  99489. private _offsetX;
  99490. private _offsetY;
  99491. private _pointerPressed;
  99492. private _pointerInput;
  99493. private _observer;
  99494. private _onLostFocus;
  99495. /**
  99496. * Manage the touch inputs to control the movement of a free camera.
  99497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99498. * @param allowMouse Defines if mouse events can be treated as touch events
  99499. */
  99500. constructor(
  99501. /**
  99502. * Define if mouse events can be treated as touch events
  99503. */
  99504. allowMouse?: boolean);
  99505. /**
  99506. * Attach the input controls to a specific dom element to get the input from.
  99507. * @param element Defines the element the controls should be listened from
  99508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99509. */
  99510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99511. /**
  99512. * Detach the current controls from the specified dom element.
  99513. * @param element Defines the element to stop listening the inputs from
  99514. */
  99515. detachControl(element: Nullable<HTMLElement>): void;
  99516. /**
  99517. * Update the current camera state depending on the inputs that have been used this frame.
  99518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99519. */
  99520. checkInputs(): void;
  99521. /**
  99522. * Gets the class name of the current intput.
  99523. * @returns the class name
  99524. */
  99525. getClassName(): string;
  99526. /**
  99527. * Get the friendly name associated with the input class.
  99528. * @returns the input friendly name
  99529. */
  99530. getSimpleName(): string;
  99531. }
  99532. }
  99533. declare module BABYLON {
  99534. /**
  99535. * Default Inputs manager for the FreeCamera.
  99536. * It groups all the default supported inputs for ease of use.
  99537. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99538. */
  99539. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99540. /**
  99541. * @hidden
  99542. */
  99543. _mouseInput: Nullable<FreeCameraMouseInput>;
  99544. /**
  99545. * Instantiates a new FreeCameraInputsManager.
  99546. * @param camera Defines the camera the inputs belong to
  99547. */
  99548. constructor(camera: FreeCamera);
  99549. /**
  99550. * Add keyboard input support to the input manager.
  99551. * @returns the current input manager
  99552. */
  99553. addKeyboard(): FreeCameraInputsManager;
  99554. /**
  99555. * Add mouse input support to the input manager.
  99556. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99557. * @returns the current input manager
  99558. */
  99559. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99560. /**
  99561. * Removes the mouse input support from the manager
  99562. * @returns the current input manager
  99563. */
  99564. removeMouse(): FreeCameraInputsManager;
  99565. /**
  99566. * Add touch input support to the input manager.
  99567. * @returns the current input manager
  99568. */
  99569. addTouch(): FreeCameraInputsManager;
  99570. /**
  99571. * Remove all attached input methods from a camera
  99572. */
  99573. clear(): void;
  99574. }
  99575. }
  99576. declare module BABYLON {
  99577. /**
  99578. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99579. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99580. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99581. */
  99582. export class FreeCamera extends TargetCamera {
  99583. /**
  99584. * Define the collision ellipsoid of the camera.
  99585. * This is helpful to simulate a camera body like the player body around the camera
  99586. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99587. */
  99588. ellipsoid: Vector3;
  99589. /**
  99590. * Define an offset for the position of the ellipsoid around the camera.
  99591. * This can be helpful to determine the center of the body near the gravity center of the body
  99592. * instead of its head.
  99593. */
  99594. ellipsoidOffset: Vector3;
  99595. /**
  99596. * Enable or disable collisions of the camera with the rest of the scene objects.
  99597. */
  99598. checkCollisions: boolean;
  99599. /**
  99600. * Enable or disable gravity on the camera.
  99601. */
  99602. applyGravity: boolean;
  99603. /**
  99604. * Define the input manager associated to the camera.
  99605. */
  99606. inputs: FreeCameraInputsManager;
  99607. /**
  99608. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99609. * Higher values reduce sensitivity.
  99610. */
  99611. get angularSensibility(): number;
  99612. /**
  99613. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99614. * Higher values reduce sensitivity.
  99615. */
  99616. set angularSensibility(value: number);
  99617. /**
  99618. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99619. */
  99620. get keysUp(): number[];
  99621. set keysUp(value: number[]);
  99622. /**
  99623. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99624. */
  99625. get keysUpward(): number[];
  99626. set keysUpward(value: number[]);
  99627. /**
  99628. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99629. */
  99630. get keysDown(): number[];
  99631. set keysDown(value: number[]);
  99632. /**
  99633. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99634. */
  99635. get keysDownward(): number[];
  99636. set keysDownward(value: number[]);
  99637. /**
  99638. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99639. */
  99640. get keysLeft(): number[];
  99641. set keysLeft(value: number[]);
  99642. /**
  99643. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99644. */
  99645. get keysRight(): number[];
  99646. set keysRight(value: number[]);
  99647. /**
  99648. * Event raised when the camera collide with a mesh in the scene.
  99649. */
  99650. onCollide: (collidedMesh: AbstractMesh) => void;
  99651. private _collider;
  99652. private _needMoveForGravity;
  99653. private _oldPosition;
  99654. private _diffPosition;
  99655. private _newPosition;
  99656. /** @hidden */
  99657. _localDirection: Vector3;
  99658. /** @hidden */
  99659. _transformedDirection: Vector3;
  99660. /**
  99661. * Instantiates a Free Camera.
  99662. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99663. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99664. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99665. * @param name Define the name of the camera in the scene
  99666. * @param position Define the start position of the camera in the scene
  99667. * @param scene Define the scene the camera belongs to
  99668. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99669. */
  99670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99671. /**
  99672. * Attached controls to the current camera.
  99673. * @param element Defines the element the controls should be listened from
  99674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99675. */
  99676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99677. /**
  99678. * Detach the current controls from the camera.
  99679. * The camera will stop reacting to inputs.
  99680. * @param element Defines the element to stop listening the inputs from
  99681. */
  99682. detachControl(element: HTMLElement): void;
  99683. private _collisionMask;
  99684. /**
  99685. * Define a collision mask to limit the list of object the camera can collide with
  99686. */
  99687. get collisionMask(): number;
  99688. set collisionMask(mask: number);
  99689. /** @hidden */
  99690. _collideWithWorld(displacement: Vector3): void;
  99691. private _onCollisionPositionChange;
  99692. /** @hidden */
  99693. _checkInputs(): void;
  99694. /** @hidden */
  99695. _decideIfNeedsToMove(): boolean;
  99696. /** @hidden */
  99697. _updatePosition(): void;
  99698. /**
  99699. * Destroy the camera and release the current resources hold by it.
  99700. */
  99701. dispose(): void;
  99702. /**
  99703. * Gets the current object class name.
  99704. * @return the class name
  99705. */
  99706. getClassName(): string;
  99707. }
  99708. }
  99709. declare module BABYLON {
  99710. /**
  99711. * Represents a gamepad control stick position
  99712. */
  99713. export class StickValues {
  99714. /**
  99715. * The x component of the control stick
  99716. */
  99717. x: number;
  99718. /**
  99719. * The y component of the control stick
  99720. */
  99721. y: number;
  99722. /**
  99723. * Initializes the gamepad x and y control stick values
  99724. * @param x The x component of the gamepad control stick value
  99725. * @param y The y component of the gamepad control stick value
  99726. */
  99727. constructor(
  99728. /**
  99729. * The x component of the control stick
  99730. */
  99731. x: number,
  99732. /**
  99733. * The y component of the control stick
  99734. */
  99735. y: number);
  99736. }
  99737. /**
  99738. * An interface which manages callbacks for gamepad button changes
  99739. */
  99740. export interface GamepadButtonChanges {
  99741. /**
  99742. * Called when a gamepad has been changed
  99743. */
  99744. changed: boolean;
  99745. /**
  99746. * Called when a gamepad press event has been triggered
  99747. */
  99748. pressChanged: boolean;
  99749. /**
  99750. * Called when a touch event has been triggered
  99751. */
  99752. touchChanged: boolean;
  99753. /**
  99754. * Called when a value has changed
  99755. */
  99756. valueChanged: boolean;
  99757. }
  99758. /**
  99759. * Represents a gamepad
  99760. */
  99761. export class Gamepad {
  99762. /**
  99763. * The id of the gamepad
  99764. */
  99765. id: string;
  99766. /**
  99767. * The index of the gamepad
  99768. */
  99769. index: number;
  99770. /**
  99771. * The browser gamepad
  99772. */
  99773. browserGamepad: any;
  99774. /**
  99775. * Specifies what type of gamepad this represents
  99776. */
  99777. type: number;
  99778. private _leftStick;
  99779. private _rightStick;
  99780. /** @hidden */
  99781. _isConnected: boolean;
  99782. private _leftStickAxisX;
  99783. private _leftStickAxisY;
  99784. private _rightStickAxisX;
  99785. private _rightStickAxisY;
  99786. /**
  99787. * Triggered when the left control stick has been changed
  99788. */
  99789. private _onleftstickchanged;
  99790. /**
  99791. * Triggered when the right control stick has been changed
  99792. */
  99793. private _onrightstickchanged;
  99794. /**
  99795. * Represents a gamepad controller
  99796. */
  99797. static GAMEPAD: number;
  99798. /**
  99799. * Represents a generic controller
  99800. */
  99801. static GENERIC: number;
  99802. /**
  99803. * Represents an XBox controller
  99804. */
  99805. static XBOX: number;
  99806. /**
  99807. * Represents a pose-enabled controller
  99808. */
  99809. static POSE_ENABLED: number;
  99810. /**
  99811. * Represents an Dual Shock controller
  99812. */
  99813. static DUALSHOCK: number;
  99814. /**
  99815. * Specifies whether the left control stick should be Y-inverted
  99816. */
  99817. protected _invertLeftStickY: boolean;
  99818. /**
  99819. * Specifies if the gamepad has been connected
  99820. */
  99821. get isConnected(): boolean;
  99822. /**
  99823. * Initializes the gamepad
  99824. * @param id The id of the gamepad
  99825. * @param index The index of the gamepad
  99826. * @param browserGamepad The browser gamepad
  99827. * @param leftStickX The x component of the left joystick
  99828. * @param leftStickY The y component of the left joystick
  99829. * @param rightStickX The x component of the right joystick
  99830. * @param rightStickY The y component of the right joystick
  99831. */
  99832. constructor(
  99833. /**
  99834. * The id of the gamepad
  99835. */
  99836. id: string,
  99837. /**
  99838. * The index of the gamepad
  99839. */
  99840. index: number,
  99841. /**
  99842. * The browser gamepad
  99843. */
  99844. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99845. /**
  99846. * Callback triggered when the left joystick has changed
  99847. * @param callback
  99848. */
  99849. onleftstickchanged(callback: (values: StickValues) => void): void;
  99850. /**
  99851. * Callback triggered when the right joystick has changed
  99852. * @param callback
  99853. */
  99854. onrightstickchanged(callback: (values: StickValues) => void): void;
  99855. /**
  99856. * Gets the left joystick
  99857. */
  99858. get leftStick(): StickValues;
  99859. /**
  99860. * Sets the left joystick values
  99861. */
  99862. set leftStick(newValues: StickValues);
  99863. /**
  99864. * Gets the right joystick
  99865. */
  99866. get rightStick(): StickValues;
  99867. /**
  99868. * Sets the right joystick value
  99869. */
  99870. set rightStick(newValues: StickValues);
  99871. /**
  99872. * Updates the gamepad joystick positions
  99873. */
  99874. update(): void;
  99875. /**
  99876. * Disposes the gamepad
  99877. */
  99878. dispose(): void;
  99879. }
  99880. /**
  99881. * Represents a generic gamepad
  99882. */
  99883. export class GenericPad extends Gamepad {
  99884. private _buttons;
  99885. private _onbuttondown;
  99886. private _onbuttonup;
  99887. /**
  99888. * Observable triggered when a button has been pressed
  99889. */
  99890. onButtonDownObservable: Observable<number>;
  99891. /**
  99892. * Observable triggered when a button has been released
  99893. */
  99894. onButtonUpObservable: Observable<number>;
  99895. /**
  99896. * Callback triggered when a button has been pressed
  99897. * @param callback Called when a button has been pressed
  99898. */
  99899. onbuttondown(callback: (buttonPressed: number) => void): void;
  99900. /**
  99901. * Callback triggered when a button has been released
  99902. * @param callback Called when a button has been released
  99903. */
  99904. onbuttonup(callback: (buttonReleased: number) => void): void;
  99905. /**
  99906. * Initializes the generic gamepad
  99907. * @param id The id of the generic gamepad
  99908. * @param index The index of the generic gamepad
  99909. * @param browserGamepad The browser gamepad
  99910. */
  99911. constructor(id: string, index: number, browserGamepad: any);
  99912. private _setButtonValue;
  99913. /**
  99914. * Updates the generic gamepad
  99915. */
  99916. update(): void;
  99917. /**
  99918. * Disposes the generic gamepad
  99919. */
  99920. dispose(): void;
  99921. }
  99922. }
  99923. declare module BABYLON {
  99924. /**
  99925. * Defines the types of pose enabled controllers that are supported
  99926. */
  99927. export enum PoseEnabledControllerType {
  99928. /**
  99929. * HTC Vive
  99930. */
  99931. VIVE = 0,
  99932. /**
  99933. * Oculus Rift
  99934. */
  99935. OCULUS = 1,
  99936. /**
  99937. * Windows mixed reality
  99938. */
  99939. WINDOWS = 2,
  99940. /**
  99941. * Samsung gear VR
  99942. */
  99943. GEAR_VR = 3,
  99944. /**
  99945. * Google Daydream
  99946. */
  99947. DAYDREAM = 4,
  99948. /**
  99949. * Generic
  99950. */
  99951. GENERIC = 5
  99952. }
  99953. /**
  99954. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99955. */
  99956. export interface MutableGamepadButton {
  99957. /**
  99958. * Value of the button/trigger
  99959. */
  99960. value: number;
  99961. /**
  99962. * If the button/trigger is currently touched
  99963. */
  99964. touched: boolean;
  99965. /**
  99966. * If the button/trigger is currently pressed
  99967. */
  99968. pressed: boolean;
  99969. }
  99970. /**
  99971. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99972. * @hidden
  99973. */
  99974. export interface ExtendedGamepadButton extends GamepadButton {
  99975. /**
  99976. * If the button/trigger is currently pressed
  99977. */
  99978. readonly pressed: boolean;
  99979. /**
  99980. * If the button/trigger is currently touched
  99981. */
  99982. readonly touched: boolean;
  99983. /**
  99984. * Value of the button/trigger
  99985. */
  99986. readonly value: number;
  99987. }
  99988. /** @hidden */
  99989. export interface _GamePadFactory {
  99990. /**
  99991. * Returns whether or not the current gamepad can be created for this type of controller.
  99992. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99993. * @returns true if it can be created, otherwise false
  99994. */
  99995. canCreate(gamepadInfo: any): boolean;
  99996. /**
  99997. * Creates a new instance of the Gamepad.
  99998. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99999. * @returns the new gamepad instance
  100000. */
  100001. create(gamepadInfo: any): Gamepad;
  100002. }
  100003. /**
  100004. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100005. */
  100006. export class PoseEnabledControllerHelper {
  100007. /** @hidden */
  100008. static _ControllerFactories: _GamePadFactory[];
  100009. /** @hidden */
  100010. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100011. /**
  100012. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100013. * @param vrGamepad the gamepad to initialized
  100014. * @returns a vr controller of the type the gamepad identified as
  100015. */
  100016. static InitiateController(vrGamepad: any): Gamepad;
  100017. }
  100018. /**
  100019. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100020. */
  100021. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100022. /**
  100023. * If the controller is used in a webXR session
  100024. */
  100025. isXR: boolean;
  100026. private _deviceRoomPosition;
  100027. private _deviceRoomRotationQuaternion;
  100028. /**
  100029. * The device position in babylon space
  100030. */
  100031. devicePosition: Vector3;
  100032. /**
  100033. * The device rotation in babylon space
  100034. */
  100035. deviceRotationQuaternion: Quaternion;
  100036. /**
  100037. * The scale factor of the device in babylon space
  100038. */
  100039. deviceScaleFactor: number;
  100040. /**
  100041. * (Likely devicePosition should be used instead) The device position in its room space
  100042. */
  100043. position: Vector3;
  100044. /**
  100045. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100046. */
  100047. rotationQuaternion: Quaternion;
  100048. /**
  100049. * The type of controller (Eg. Windows mixed reality)
  100050. */
  100051. controllerType: PoseEnabledControllerType;
  100052. protected _calculatedPosition: Vector3;
  100053. private _calculatedRotation;
  100054. /**
  100055. * The raw pose from the device
  100056. */
  100057. rawPose: DevicePose;
  100058. private _trackPosition;
  100059. private _maxRotationDistFromHeadset;
  100060. private _draggedRoomRotation;
  100061. /**
  100062. * @hidden
  100063. */
  100064. _disableTrackPosition(fixedPosition: Vector3): void;
  100065. /**
  100066. * Internal, the mesh attached to the controller
  100067. * @hidden
  100068. */
  100069. _mesh: Nullable<AbstractMesh>;
  100070. private _poseControlledCamera;
  100071. private _leftHandSystemQuaternion;
  100072. /**
  100073. * Internal, matrix used to convert room space to babylon space
  100074. * @hidden
  100075. */
  100076. _deviceToWorld: Matrix;
  100077. /**
  100078. * Node to be used when casting a ray from the controller
  100079. * @hidden
  100080. */
  100081. _pointingPoseNode: Nullable<TransformNode>;
  100082. /**
  100083. * Name of the child mesh that can be used to cast a ray from the controller
  100084. */
  100085. static readonly POINTING_POSE: string;
  100086. /**
  100087. * Creates a new PoseEnabledController from a gamepad
  100088. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100089. */
  100090. constructor(browserGamepad: any);
  100091. private _workingMatrix;
  100092. /**
  100093. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100094. */
  100095. update(): void;
  100096. /**
  100097. * Updates only the pose device and mesh without doing any button event checking
  100098. */
  100099. protected _updatePoseAndMesh(): void;
  100100. /**
  100101. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100102. * @param poseData raw pose fromthe device
  100103. */
  100104. updateFromDevice(poseData: DevicePose): void;
  100105. /**
  100106. * @hidden
  100107. */
  100108. _meshAttachedObservable: Observable<AbstractMesh>;
  100109. /**
  100110. * Attaches a mesh to the controller
  100111. * @param mesh the mesh to be attached
  100112. */
  100113. attachToMesh(mesh: AbstractMesh): void;
  100114. /**
  100115. * Attaches the controllers mesh to a camera
  100116. * @param camera the camera the mesh should be attached to
  100117. */
  100118. attachToPoseControlledCamera(camera: TargetCamera): void;
  100119. /**
  100120. * Disposes of the controller
  100121. */
  100122. dispose(): void;
  100123. /**
  100124. * The mesh that is attached to the controller
  100125. */
  100126. get mesh(): Nullable<AbstractMesh>;
  100127. /**
  100128. * Gets the ray of the controller in the direction the controller is pointing
  100129. * @param length the length the resulting ray should be
  100130. * @returns a ray in the direction the controller is pointing
  100131. */
  100132. getForwardRay(length?: number): Ray;
  100133. }
  100134. }
  100135. declare module BABYLON {
  100136. /**
  100137. * Defines the WebVRController object that represents controllers tracked in 3D space
  100138. */
  100139. export abstract class WebVRController extends PoseEnabledController {
  100140. /**
  100141. * Internal, the default controller model for the controller
  100142. */
  100143. protected _defaultModel: Nullable<AbstractMesh>;
  100144. /**
  100145. * Fired when the trigger state has changed
  100146. */
  100147. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100148. /**
  100149. * Fired when the main button state has changed
  100150. */
  100151. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100152. /**
  100153. * Fired when the secondary button state has changed
  100154. */
  100155. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100156. /**
  100157. * Fired when the pad state has changed
  100158. */
  100159. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100160. /**
  100161. * Fired when controllers stick values have changed
  100162. */
  100163. onPadValuesChangedObservable: Observable<StickValues>;
  100164. /**
  100165. * Array of button availible on the controller
  100166. */
  100167. protected _buttons: Array<MutableGamepadButton>;
  100168. private _onButtonStateChange;
  100169. /**
  100170. * Fired when a controller button's state has changed
  100171. * @param callback the callback containing the button that was modified
  100172. */
  100173. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100174. /**
  100175. * X and Y axis corresponding to the controllers joystick
  100176. */
  100177. pad: StickValues;
  100178. /**
  100179. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100180. */
  100181. hand: string;
  100182. /**
  100183. * The default controller model for the controller
  100184. */
  100185. get defaultModel(): Nullable<AbstractMesh>;
  100186. /**
  100187. * Creates a new WebVRController from a gamepad
  100188. * @param vrGamepad the gamepad that the WebVRController should be created from
  100189. */
  100190. constructor(vrGamepad: any);
  100191. /**
  100192. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100193. */
  100194. update(): void;
  100195. /**
  100196. * Function to be called when a button is modified
  100197. */
  100198. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100199. /**
  100200. * Loads a mesh and attaches it to the controller
  100201. * @param scene the scene the mesh should be added to
  100202. * @param meshLoaded callback for when the mesh has been loaded
  100203. */
  100204. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100205. private _setButtonValue;
  100206. private _changes;
  100207. private _checkChanges;
  100208. /**
  100209. * Disposes of th webVRCOntroller
  100210. */
  100211. dispose(): void;
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * The HemisphericLight simulates the ambient environment light,
  100217. * so the passed direction is the light reflection direction, not the incoming direction.
  100218. */
  100219. export class HemisphericLight extends Light {
  100220. /**
  100221. * The groundColor is the light in the opposite direction to the one specified during creation.
  100222. * 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.
  100223. */
  100224. groundColor: Color3;
  100225. /**
  100226. * The light reflection direction, not the incoming direction.
  100227. */
  100228. direction: Vector3;
  100229. /**
  100230. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100231. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100232. * The HemisphericLight can't cast shadows.
  100233. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100234. * @param name The friendly name of the light
  100235. * @param direction The direction of the light reflection
  100236. * @param scene The scene the light belongs to
  100237. */
  100238. constructor(name: string, direction: Vector3, scene: Scene);
  100239. protected _buildUniformLayout(): void;
  100240. /**
  100241. * Returns the string "HemisphericLight".
  100242. * @return The class name
  100243. */
  100244. getClassName(): string;
  100245. /**
  100246. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100247. * Returns the updated direction.
  100248. * @param target The target the direction should point to
  100249. * @return The computed direction
  100250. */
  100251. setDirectionToTarget(target: Vector3): Vector3;
  100252. /**
  100253. * Returns the shadow generator associated to the light.
  100254. * @returns Always null for hemispheric lights because it does not support shadows.
  100255. */
  100256. getShadowGenerator(): Nullable<IShadowGenerator>;
  100257. /**
  100258. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100259. * @param effect The effect to update
  100260. * @param lightIndex The index of the light in the effect to update
  100261. * @returns The hemispheric light
  100262. */
  100263. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100264. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100265. /**
  100266. * Computes the world matrix of the node
  100267. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100268. * @param useWasUpdatedFlag defines a reserved property
  100269. * @returns the world matrix
  100270. */
  100271. computeWorldMatrix(): Matrix;
  100272. /**
  100273. * Returns the integer 3.
  100274. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100275. */
  100276. getTypeID(): number;
  100277. /**
  100278. * Prepares the list of defines specific to the light type.
  100279. * @param defines the list of defines
  100280. * @param lightIndex defines the index of the light for the effect
  100281. */
  100282. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100283. }
  100284. }
  100285. declare module BABYLON {
  100286. /** @hidden */
  100287. export var vrMultiviewToSingleviewPixelShader: {
  100288. name: string;
  100289. shader: string;
  100290. };
  100291. }
  100292. declare module BABYLON {
  100293. /**
  100294. * Renders to multiple views with a single draw call
  100295. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100296. */
  100297. export class MultiviewRenderTarget extends RenderTargetTexture {
  100298. /**
  100299. * Creates a multiview render target
  100300. * @param scene scene used with the render target
  100301. * @param size the size of the render target (used for each view)
  100302. */
  100303. constructor(scene: Scene, size?: number | {
  100304. width: number;
  100305. height: number;
  100306. } | {
  100307. ratio: number;
  100308. });
  100309. /**
  100310. * @hidden
  100311. * @param faceIndex the face index, if its a cube texture
  100312. */
  100313. _bindFrameBuffer(faceIndex?: number): void;
  100314. /**
  100315. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100316. * @returns the view count
  100317. */
  100318. getViewCount(): number;
  100319. }
  100320. }
  100321. declare module BABYLON {
  100322. interface Engine {
  100323. /**
  100324. * Creates a new multiview render target
  100325. * @param width defines the width of the texture
  100326. * @param height defines the height of the texture
  100327. * @returns the created multiview texture
  100328. */
  100329. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100330. /**
  100331. * Binds a multiview framebuffer to be drawn to
  100332. * @param multiviewTexture texture to bind
  100333. */
  100334. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100335. }
  100336. interface Camera {
  100337. /**
  100338. * @hidden
  100339. * 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)
  100340. */
  100341. _useMultiviewToSingleView: boolean;
  100342. /**
  100343. * @hidden
  100344. * 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)
  100345. */
  100346. _multiviewTexture: Nullable<RenderTargetTexture>;
  100347. /**
  100348. * @hidden
  100349. * ensures the multiview texture of the camera exists and has the specified width/height
  100350. * @param width height to set on the multiview texture
  100351. * @param height width to set on the multiview texture
  100352. */
  100353. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100354. }
  100355. interface Scene {
  100356. /** @hidden */
  100357. _transformMatrixR: Matrix;
  100358. /** @hidden */
  100359. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100360. /** @hidden */
  100361. _createMultiviewUbo(): void;
  100362. /** @hidden */
  100363. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100364. /** @hidden */
  100365. _renderMultiviewToSingleView(camera: Camera): void;
  100366. }
  100367. }
  100368. declare module BABYLON {
  100369. /**
  100370. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100371. * This will not be used for webXR as it supports displaying texture arrays directly
  100372. */
  100373. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100374. /**
  100375. * Gets a string identifying the name of the class
  100376. * @returns "VRMultiviewToSingleviewPostProcess" string
  100377. */
  100378. getClassName(): string;
  100379. /**
  100380. * Initializes a VRMultiviewToSingleview
  100381. * @param name name of the post process
  100382. * @param camera camera to be applied to
  100383. * @param scaleFactor scaling factor to the size of the output texture
  100384. */
  100385. constructor(name: string, camera: Camera, scaleFactor: number);
  100386. }
  100387. }
  100388. declare module BABYLON {
  100389. /**
  100390. * Interface used to define additional presentation attributes
  100391. */
  100392. export interface IVRPresentationAttributes {
  100393. /**
  100394. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100395. */
  100396. highRefreshRate: boolean;
  100397. /**
  100398. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100399. */
  100400. foveationLevel: number;
  100401. }
  100402. interface Engine {
  100403. /** @hidden */
  100404. _vrDisplay: any;
  100405. /** @hidden */
  100406. _vrSupported: boolean;
  100407. /** @hidden */
  100408. _oldSize: Size;
  100409. /** @hidden */
  100410. _oldHardwareScaleFactor: number;
  100411. /** @hidden */
  100412. _vrExclusivePointerMode: boolean;
  100413. /** @hidden */
  100414. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100415. /** @hidden */
  100416. _onVRDisplayPointerRestricted: () => void;
  100417. /** @hidden */
  100418. _onVRDisplayPointerUnrestricted: () => void;
  100419. /** @hidden */
  100420. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100421. /** @hidden */
  100422. _onVrDisplayDisconnect: Nullable<() => void>;
  100423. /** @hidden */
  100424. _onVrDisplayPresentChange: Nullable<() => void>;
  100425. /**
  100426. * Observable signaled when VR display mode changes
  100427. */
  100428. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100429. /**
  100430. * Observable signaled when VR request present is complete
  100431. */
  100432. onVRRequestPresentComplete: Observable<boolean>;
  100433. /**
  100434. * Observable signaled when VR request present starts
  100435. */
  100436. onVRRequestPresentStart: Observable<Engine>;
  100437. /**
  100438. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100439. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100440. */
  100441. isInVRExclusivePointerMode: boolean;
  100442. /**
  100443. * Gets a boolean indicating if a webVR device was detected
  100444. * @returns true if a webVR device was detected
  100445. */
  100446. isVRDevicePresent(): boolean;
  100447. /**
  100448. * Gets the current webVR device
  100449. * @returns the current webVR device (or null)
  100450. */
  100451. getVRDevice(): any;
  100452. /**
  100453. * Initializes a webVR display and starts listening to display change events
  100454. * The onVRDisplayChangedObservable will be notified upon these changes
  100455. * @returns A promise containing a VRDisplay and if vr is supported
  100456. */
  100457. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100458. /** @hidden */
  100459. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100460. /**
  100461. * Gets or sets the presentation attributes used to configure VR rendering
  100462. */
  100463. vrPresentationAttributes?: IVRPresentationAttributes;
  100464. /**
  100465. * Call this function to switch to webVR mode
  100466. * Will do nothing if webVR is not supported or if there is no webVR device
  100467. * @param options the webvr options provided to the camera. mainly used for multiview
  100468. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100469. */
  100470. enableVR(options: WebVROptions): void;
  100471. /** @hidden */
  100472. _onVRFullScreenTriggered(): void;
  100473. }
  100474. }
  100475. declare module BABYLON {
  100476. /**
  100477. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100478. * IMPORTANT!! The data is right-hand data.
  100479. * @export
  100480. * @interface DevicePose
  100481. */
  100482. export interface DevicePose {
  100483. /**
  100484. * The position of the device, values in array are [x,y,z].
  100485. */
  100486. readonly position: Nullable<Float32Array>;
  100487. /**
  100488. * The linearVelocity of the device, values in array are [x,y,z].
  100489. */
  100490. readonly linearVelocity: Nullable<Float32Array>;
  100491. /**
  100492. * The linearAcceleration of the device, values in array are [x,y,z].
  100493. */
  100494. readonly linearAcceleration: Nullable<Float32Array>;
  100495. /**
  100496. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100497. */
  100498. readonly orientation: Nullable<Float32Array>;
  100499. /**
  100500. * The angularVelocity of the device, values in array are [x,y,z].
  100501. */
  100502. readonly angularVelocity: Nullable<Float32Array>;
  100503. /**
  100504. * The angularAcceleration of the device, values in array are [x,y,z].
  100505. */
  100506. readonly angularAcceleration: Nullable<Float32Array>;
  100507. }
  100508. /**
  100509. * Interface representing a pose controlled object in Babylon.
  100510. * A pose controlled object has both regular pose values as well as pose values
  100511. * from an external device such as a VR head mounted display
  100512. */
  100513. export interface PoseControlled {
  100514. /**
  100515. * The position of the object in babylon space.
  100516. */
  100517. position: Vector3;
  100518. /**
  100519. * The rotation quaternion of the object in babylon space.
  100520. */
  100521. rotationQuaternion: Quaternion;
  100522. /**
  100523. * The position of the device in babylon space.
  100524. */
  100525. devicePosition?: Vector3;
  100526. /**
  100527. * The rotation quaternion of the device in babylon space.
  100528. */
  100529. deviceRotationQuaternion: Quaternion;
  100530. /**
  100531. * The raw pose coming from the device.
  100532. */
  100533. rawPose: Nullable<DevicePose>;
  100534. /**
  100535. * The scale of the device to be used when translating from device space to babylon space.
  100536. */
  100537. deviceScaleFactor: number;
  100538. /**
  100539. * Updates the poseControlled values based on the input device pose.
  100540. * @param poseData the pose data to update the object with
  100541. */
  100542. updateFromDevice(poseData: DevicePose): void;
  100543. }
  100544. /**
  100545. * Set of options to customize the webVRCamera
  100546. */
  100547. export interface WebVROptions {
  100548. /**
  100549. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100550. */
  100551. trackPosition?: boolean;
  100552. /**
  100553. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100554. */
  100555. positionScale?: number;
  100556. /**
  100557. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100558. */
  100559. displayName?: string;
  100560. /**
  100561. * Should the native controller meshes be initialized. (default: true)
  100562. */
  100563. controllerMeshes?: boolean;
  100564. /**
  100565. * Creating a default HemiLight only on controllers. (default: true)
  100566. */
  100567. defaultLightingOnControllers?: boolean;
  100568. /**
  100569. * If you don't want to use the default VR button of the helper. (default: false)
  100570. */
  100571. useCustomVRButton?: boolean;
  100572. /**
  100573. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100574. */
  100575. customVRButton?: HTMLButtonElement;
  100576. /**
  100577. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100578. */
  100579. rayLength?: number;
  100580. /**
  100581. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100582. */
  100583. defaultHeight?: number;
  100584. /**
  100585. * If multiview should be used if availible (default: false)
  100586. */
  100587. useMultiview?: boolean;
  100588. }
  100589. /**
  100590. * This represents a WebVR camera.
  100591. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100592. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100593. */
  100594. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100595. private webVROptions;
  100596. /**
  100597. * @hidden
  100598. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100599. */
  100600. _vrDevice: any;
  100601. /**
  100602. * The rawPose of the vrDevice.
  100603. */
  100604. rawPose: Nullable<DevicePose>;
  100605. private _onVREnabled;
  100606. private _specsVersion;
  100607. private _attached;
  100608. private _frameData;
  100609. protected _descendants: Array<Node>;
  100610. private _deviceRoomPosition;
  100611. /** @hidden */
  100612. _deviceRoomRotationQuaternion: Quaternion;
  100613. private _standingMatrix;
  100614. /**
  100615. * Represents device position in babylon space.
  100616. */
  100617. devicePosition: Vector3;
  100618. /**
  100619. * Represents device rotation in babylon space.
  100620. */
  100621. deviceRotationQuaternion: Quaternion;
  100622. /**
  100623. * The scale of the device to be used when translating from device space to babylon space.
  100624. */
  100625. deviceScaleFactor: number;
  100626. private _deviceToWorld;
  100627. private _worldToDevice;
  100628. /**
  100629. * References to the webVR controllers for the vrDevice.
  100630. */
  100631. controllers: Array<WebVRController>;
  100632. /**
  100633. * Emits an event when a controller is attached.
  100634. */
  100635. onControllersAttachedObservable: Observable<WebVRController[]>;
  100636. /**
  100637. * Emits an event when a controller's mesh has been loaded;
  100638. */
  100639. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100640. /**
  100641. * Emits an event when the HMD's pose has been updated.
  100642. */
  100643. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100644. private _poseSet;
  100645. /**
  100646. * If the rig cameras be used as parent instead of this camera.
  100647. */
  100648. rigParenting: boolean;
  100649. private _lightOnControllers;
  100650. private _defaultHeight?;
  100651. /**
  100652. * Instantiates a WebVRFreeCamera.
  100653. * @param name The name of the WebVRFreeCamera
  100654. * @param position The starting anchor position for the camera
  100655. * @param scene The scene the camera belongs to
  100656. * @param webVROptions a set of customizable options for the webVRCamera
  100657. */
  100658. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100659. /**
  100660. * Gets the device distance from the ground in meters.
  100661. * @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.
  100662. */
  100663. deviceDistanceToRoomGround(): number;
  100664. /**
  100665. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100666. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100667. */
  100668. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100669. /**
  100670. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100671. * @returns A promise with a boolean set to if the standing matrix is supported.
  100672. */
  100673. useStandingMatrixAsync(): Promise<boolean>;
  100674. /**
  100675. * Disposes the camera
  100676. */
  100677. dispose(): void;
  100678. /**
  100679. * Gets a vrController by name.
  100680. * @param name The name of the controller to retreive
  100681. * @returns the controller matching the name specified or null if not found
  100682. */
  100683. getControllerByName(name: string): Nullable<WebVRController>;
  100684. private _leftController;
  100685. /**
  100686. * The controller corresponding to the users left hand.
  100687. */
  100688. get leftController(): Nullable<WebVRController>;
  100689. private _rightController;
  100690. /**
  100691. * The controller corresponding to the users right hand.
  100692. */
  100693. get rightController(): Nullable<WebVRController>;
  100694. /**
  100695. * Casts a ray forward from the vrCamera's gaze.
  100696. * @param length Length of the ray (default: 100)
  100697. * @returns the ray corresponding to the gaze
  100698. */
  100699. getForwardRay(length?: number): Ray;
  100700. /**
  100701. * @hidden
  100702. * Updates the camera based on device's frame data
  100703. */
  100704. _checkInputs(): void;
  100705. /**
  100706. * Updates the poseControlled values based on the input device pose.
  100707. * @param poseData Pose coming from the device
  100708. */
  100709. updateFromDevice(poseData: DevicePose): void;
  100710. private _htmlElementAttached;
  100711. private _detachIfAttached;
  100712. /**
  100713. * WebVR's attach control will start broadcasting frames to the device.
  100714. * Note that in certain browsers (chrome for example) this function must be called
  100715. * within a user-interaction callback. Example:
  100716. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100717. *
  100718. * @param element html element to attach the vrDevice to
  100719. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100720. */
  100721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100722. /**
  100723. * Detaches the camera from the html element and disables VR
  100724. *
  100725. * @param element html element to detach from
  100726. */
  100727. detachControl(element: HTMLElement): void;
  100728. /**
  100729. * @returns the name of this class
  100730. */
  100731. getClassName(): string;
  100732. /**
  100733. * Calls resetPose on the vrDisplay
  100734. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100735. */
  100736. resetToCurrentRotation(): void;
  100737. /**
  100738. * @hidden
  100739. * Updates the rig cameras (left and right eye)
  100740. */
  100741. _updateRigCameras(): void;
  100742. private _workingVector;
  100743. private _oneVector;
  100744. private _workingMatrix;
  100745. private updateCacheCalled;
  100746. private _correctPositionIfNotTrackPosition;
  100747. /**
  100748. * @hidden
  100749. * Updates the cached values of the camera
  100750. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100751. */
  100752. _updateCache(ignoreParentClass?: boolean): void;
  100753. /**
  100754. * @hidden
  100755. * Get current device position in babylon world
  100756. */
  100757. _computeDevicePosition(): void;
  100758. /**
  100759. * Updates the current device position and rotation in the babylon world
  100760. */
  100761. update(): void;
  100762. /**
  100763. * @hidden
  100764. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100765. * @returns an identity matrix
  100766. */
  100767. _getViewMatrix(): Matrix;
  100768. private _tmpMatrix;
  100769. /**
  100770. * This function is called by the two RIG cameras.
  100771. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100772. * @hidden
  100773. */
  100774. _getWebVRViewMatrix(): Matrix;
  100775. /** @hidden */
  100776. _getWebVRProjectionMatrix(): Matrix;
  100777. private _onGamepadConnectedObserver;
  100778. private _onGamepadDisconnectedObserver;
  100779. private _updateCacheWhenTrackingDisabledObserver;
  100780. /**
  100781. * Initializes the controllers and their meshes
  100782. */
  100783. initControllers(): void;
  100784. }
  100785. }
  100786. declare module BABYLON {
  100787. /**
  100788. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100789. *
  100790. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100791. *
  100792. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100793. */
  100794. export class MaterialHelper {
  100795. /**
  100796. * Bind the current view position to an effect.
  100797. * @param effect The effect to be bound
  100798. * @param scene The scene the eyes position is used from
  100799. * @param variableName name of the shader variable that will hold the eye position
  100800. */
  100801. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100802. /**
  100803. * Helps preparing the defines values about the UVs in used in the effect.
  100804. * UVs are shared as much as we can accross channels in the shaders.
  100805. * @param texture The texture we are preparing the UVs for
  100806. * @param defines The defines to update
  100807. * @param key The channel key "diffuse", "specular"... used in the shader
  100808. */
  100809. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100810. /**
  100811. * Binds a texture matrix value to its corrsponding uniform
  100812. * @param texture The texture to bind the matrix for
  100813. * @param uniformBuffer The uniform buffer receivin the data
  100814. * @param key The channel key "diffuse", "specular"... used in the shader
  100815. */
  100816. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100817. /**
  100818. * Gets the current status of the fog (should it be enabled?)
  100819. * @param mesh defines the mesh to evaluate for fog support
  100820. * @param scene defines the hosting scene
  100821. * @returns true if fog must be enabled
  100822. */
  100823. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100824. /**
  100825. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100826. * @param mesh defines the current mesh
  100827. * @param scene defines the current scene
  100828. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100829. * @param pointsCloud defines if point cloud rendering has to be turned on
  100830. * @param fogEnabled defines if fog has to be turned on
  100831. * @param alphaTest defines if alpha testing has to be turned on
  100832. * @param defines defines the current list of defines
  100833. */
  100834. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100835. /**
  100836. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100837. * @param scene defines the current scene
  100838. * @param engine defines the current engine
  100839. * @param defines specifies the list of active defines
  100840. * @param useInstances defines if instances have to be turned on
  100841. * @param useClipPlane defines if clip plane have to be turned on
  100842. * @param useInstances defines if instances have to be turned on
  100843. * @param useThinInstances defines if thin instances have to be turned on
  100844. */
  100845. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100846. /**
  100847. * Prepares the defines for bones
  100848. * @param mesh The mesh containing the geometry data we will draw
  100849. * @param defines The defines to update
  100850. */
  100851. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100852. /**
  100853. * Prepares the defines for morph targets
  100854. * @param mesh The mesh containing the geometry data we will draw
  100855. * @param defines The defines to update
  100856. */
  100857. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100858. /**
  100859. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100860. * @param mesh The mesh containing the geometry data we will draw
  100861. * @param defines The defines to update
  100862. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100863. * @param useBones Precise whether bones should be used or not (override mesh info)
  100864. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100865. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100866. * @returns false if defines are considered not dirty and have not been checked
  100867. */
  100868. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100869. /**
  100870. * Prepares the defines related to multiview
  100871. * @param scene The scene we are intending to draw
  100872. * @param defines The defines to update
  100873. */
  100874. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100875. /**
  100876. * Prepares the defines related to the prepass
  100877. * @param scene The scene we are intending to draw
  100878. * @param defines The defines to update
  100879. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100880. */
  100881. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100882. /**
  100883. * Prepares the defines related to the light information passed in parameter
  100884. * @param scene The scene we are intending to draw
  100885. * @param mesh The mesh the effect is compiling for
  100886. * @param light The light the effect is compiling for
  100887. * @param lightIndex The index of the light
  100888. * @param defines The defines to update
  100889. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100890. * @param state Defines the current state regarding what is needed (normals, etc...)
  100891. */
  100892. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100893. needNormals: boolean;
  100894. needRebuild: boolean;
  100895. shadowEnabled: boolean;
  100896. specularEnabled: boolean;
  100897. lightmapMode: boolean;
  100898. }): void;
  100899. /**
  100900. * Prepares the defines related to the light information passed in parameter
  100901. * @param scene The scene we are intending to draw
  100902. * @param mesh The mesh the effect is compiling for
  100903. * @param defines The defines to update
  100904. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100905. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100906. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100907. * @returns true if normals will be required for the rest of the effect
  100908. */
  100909. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100910. /**
  100911. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100912. * @param lightIndex defines the light index
  100913. * @param uniformsList The uniform list
  100914. * @param samplersList The sampler list
  100915. * @param projectedLightTexture defines if projected texture must be used
  100916. * @param uniformBuffersList defines an optional list of uniform buffers
  100917. */
  100918. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100919. /**
  100920. * Prepares the uniforms and samplers list to be used in the effect
  100921. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100922. * @param samplersList The sampler list
  100923. * @param defines The defines helping in the list generation
  100924. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100925. */
  100926. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100927. /**
  100928. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100929. * @param defines The defines to update while falling back
  100930. * @param fallbacks The authorized effect fallbacks
  100931. * @param maxSimultaneousLights The maximum number of lights allowed
  100932. * @param rank the current rank of the Effect
  100933. * @returns The newly affected rank
  100934. */
  100935. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100936. private static _TmpMorphInfluencers;
  100937. /**
  100938. * Prepares the list of attributes required for morph targets according to the effect defines.
  100939. * @param attribs The current list of supported attribs
  100940. * @param mesh The mesh to prepare the morph targets attributes for
  100941. * @param influencers The number of influencers
  100942. */
  100943. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100944. /**
  100945. * Prepares the list of attributes required for morph targets according to the effect defines.
  100946. * @param attribs The current list of supported attribs
  100947. * @param mesh The mesh to prepare the morph targets attributes for
  100948. * @param defines The current Defines of the effect
  100949. */
  100950. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100951. /**
  100952. * Prepares the list of attributes required for bones according to the effect defines.
  100953. * @param attribs The current list of supported attribs
  100954. * @param mesh The mesh to prepare the bones attributes for
  100955. * @param defines The current Defines of the effect
  100956. * @param fallbacks The current efffect fallback strategy
  100957. */
  100958. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100959. /**
  100960. * Check and prepare the list of attributes required for instances according to the effect defines.
  100961. * @param attribs The current list of supported attribs
  100962. * @param defines The current MaterialDefines of the effect
  100963. */
  100964. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100965. /**
  100966. * Add the list of attributes required for instances to the attribs array.
  100967. * @param attribs The current list of supported attribs
  100968. */
  100969. static PushAttributesForInstances(attribs: string[]): void;
  100970. /**
  100971. * Binds the light information to the effect.
  100972. * @param light The light containing the generator
  100973. * @param effect The effect we are binding the data to
  100974. * @param lightIndex The light index in the effect used to render
  100975. */
  100976. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100977. /**
  100978. * Binds the lights information from the scene to the effect for the given mesh.
  100979. * @param light Light to bind
  100980. * @param lightIndex Light index
  100981. * @param scene The scene where the light belongs to
  100982. * @param effect The effect we are binding the data to
  100983. * @param useSpecular Defines if specular is supported
  100984. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100985. */
  100986. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100987. /**
  100988. * Binds the lights information from the scene to the effect for the given mesh.
  100989. * @param scene The scene the lights belongs to
  100990. * @param mesh The mesh we are binding the information to render
  100991. * @param effect The effect we are binding the data to
  100992. * @param defines The generated defines for the effect
  100993. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100994. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100995. */
  100996. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100997. private static _tempFogColor;
  100998. /**
  100999. * Binds the fog information from the scene to the effect for the given mesh.
  101000. * @param scene The scene the lights belongs to
  101001. * @param mesh The mesh we are binding the information to render
  101002. * @param effect The effect we are binding the data to
  101003. * @param linearSpace Defines if the fog effect is applied in linear space
  101004. */
  101005. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101006. /**
  101007. * Binds the bones information from the mesh to the effect.
  101008. * @param mesh The mesh we are binding the information to render
  101009. * @param effect The effect we are binding the data to
  101010. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101011. */
  101012. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101013. private static _CopyBonesTransformationMatrices;
  101014. /**
  101015. * Binds the morph targets information from the mesh to the effect.
  101016. * @param abstractMesh The mesh we are binding the information to render
  101017. * @param effect The effect we are binding the data to
  101018. */
  101019. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101020. /**
  101021. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101022. * @param defines The generated defines used in the effect
  101023. * @param effect The effect we are binding the data to
  101024. * @param scene The scene we are willing to render with logarithmic scale for
  101025. */
  101026. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101027. /**
  101028. * Binds the clip plane information from the scene to the effect.
  101029. * @param scene The scene the clip plane information are extracted from
  101030. * @param effect The effect we are binding the data to
  101031. */
  101032. static BindClipPlane(effect: Effect, scene: Scene): void;
  101033. }
  101034. }
  101035. declare module BABYLON {
  101036. /**
  101037. * Block used to expose an input value
  101038. */
  101039. export class InputBlock extends NodeMaterialBlock {
  101040. private _mode;
  101041. private _associatedVariableName;
  101042. private _storedValue;
  101043. private _valueCallback;
  101044. private _type;
  101045. private _animationType;
  101046. /** Gets or set a value used to limit the range of float values */
  101047. min: number;
  101048. /** Gets or set a value used to limit the range of float values */
  101049. max: number;
  101050. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101051. isBoolean: boolean;
  101052. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101053. matrixMode: number;
  101054. /** @hidden */
  101055. _systemValue: Nullable<NodeMaterialSystemValues>;
  101056. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101057. isConstant: boolean;
  101058. /** Gets or sets the group to use to display this block in the Inspector */
  101059. groupInInspector: string;
  101060. /** Gets an observable raised when the value is changed */
  101061. onValueChangedObservable: Observable<InputBlock>;
  101062. /**
  101063. * Gets or sets the connection point type (default is float)
  101064. */
  101065. get type(): NodeMaterialBlockConnectionPointTypes;
  101066. /**
  101067. * Creates a new InputBlock
  101068. * @param name defines the block name
  101069. * @param target defines the target of that block (Vertex by default)
  101070. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101071. */
  101072. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101073. /**
  101074. * Validates if a name is a reserve word.
  101075. * @param newName the new name to be given to the node.
  101076. * @returns false if the name is a reserve word, else true.
  101077. */
  101078. validateBlockName(newName: string): boolean;
  101079. /**
  101080. * Gets the output component
  101081. */
  101082. get output(): NodeMaterialConnectionPoint;
  101083. /**
  101084. * Set the source of this connection point to a vertex attribute
  101085. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101086. * @returns the current connection point
  101087. */
  101088. setAsAttribute(attributeName?: string): InputBlock;
  101089. /**
  101090. * Set the source of this connection point to a system value
  101091. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101092. * @returns the current connection point
  101093. */
  101094. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101095. /**
  101096. * Gets or sets the value of that point.
  101097. * Please note that this value will be ignored if valueCallback is defined
  101098. */
  101099. get value(): any;
  101100. set value(value: any);
  101101. /**
  101102. * Gets or sets a callback used to get the value of that point.
  101103. * Please note that setting this value will force the connection point to ignore the value property
  101104. */
  101105. get valueCallback(): () => any;
  101106. set valueCallback(value: () => any);
  101107. /**
  101108. * Gets or sets the associated variable name in the shader
  101109. */
  101110. get associatedVariableName(): string;
  101111. set associatedVariableName(value: string);
  101112. /** Gets or sets the type of animation applied to the input */
  101113. get animationType(): AnimatedInputBlockTypes;
  101114. set animationType(value: AnimatedInputBlockTypes);
  101115. /**
  101116. * Gets a boolean indicating that this connection point not defined yet
  101117. */
  101118. get isUndefined(): boolean;
  101119. /**
  101120. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101121. * In this case the connection point name must be the name of the uniform to use.
  101122. * Can only be set on inputs
  101123. */
  101124. get isUniform(): boolean;
  101125. set isUniform(value: boolean);
  101126. /**
  101127. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101128. * In this case the connection point name must be the name of the attribute to use
  101129. * Can only be set on inputs
  101130. */
  101131. get isAttribute(): boolean;
  101132. set isAttribute(value: boolean);
  101133. /**
  101134. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101135. * Can only be set on exit points
  101136. */
  101137. get isVarying(): boolean;
  101138. set isVarying(value: boolean);
  101139. /**
  101140. * Gets a boolean indicating that the current connection point is a system value
  101141. */
  101142. get isSystemValue(): boolean;
  101143. /**
  101144. * Gets or sets the current well known value or null if not defined as a system value
  101145. */
  101146. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101147. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101148. /**
  101149. * Gets the current class name
  101150. * @returns the class name
  101151. */
  101152. getClassName(): string;
  101153. /**
  101154. * Animate the input if animationType !== None
  101155. * @param scene defines the rendering scene
  101156. */
  101157. animate(scene: Scene): void;
  101158. private _emitDefine;
  101159. initialize(state: NodeMaterialBuildState): void;
  101160. /**
  101161. * Set the input block to its default value (based on its type)
  101162. */
  101163. setDefaultValue(): void;
  101164. private _emitConstant;
  101165. /** @hidden */
  101166. get _noContextSwitch(): boolean;
  101167. private _emit;
  101168. /** @hidden */
  101169. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101170. /** @hidden */
  101171. _transmit(effect: Effect, scene: Scene): void;
  101172. protected _buildBlock(state: NodeMaterialBuildState): void;
  101173. protected _dumpPropertiesCode(): string;
  101174. dispose(): void;
  101175. serialize(): any;
  101176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101177. }
  101178. }
  101179. declare module BABYLON {
  101180. /**
  101181. * Enum used to define the compatibility state between two connection points
  101182. */
  101183. export enum NodeMaterialConnectionPointCompatibilityStates {
  101184. /** Points are compatibles */
  101185. Compatible = 0,
  101186. /** Points are incompatible because of their types */
  101187. TypeIncompatible = 1,
  101188. /** Points are incompatible because of their targets (vertex vs fragment) */
  101189. TargetIncompatible = 2
  101190. }
  101191. /**
  101192. * Defines the direction of a connection point
  101193. */
  101194. export enum NodeMaterialConnectionPointDirection {
  101195. /** Input */
  101196. Input = 0,
  101197. /** Output */
  101198. Output = 1
  101199. }
  101200. /**
  101201. * Defines a connection point for a block
  101202. */
  101203. export class NodeMaterialConnectionPoint {
  101204. /** @hidden */
  101205. _ownerBlock: NodeMaterialBlock;
  101206. /** @hidden */
  101207. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101208. private _endpoints;
  101209. private _associatedVariableName;
  101210. private _direction;
  101211. /** @hidden */
  101212. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101213. /** @hidden */
  101214. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101215. private _type;
  101216. /** @hidden */
  101217. _enforceAssociatedVariableName: boolean;
  101218. /** Gets the direction of the point */
  101219. get direction(): NodeMaterialConnectionPointDirection;
  101220. /** Indicates that this connection point needs dual validation before being connected to another point */
  101221. needDualDirectionValidation: boolean;
  101222. /**
  101223. * Gets or sets the additional types supported by this connection point
  101224. */
  101225. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101226. /**
  101227. * Gets or sets the additional types excluded by this connection point
  101228. */
  101229. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101230. /**
  101231. * Observable triggered when this point is connected
  101232. */
  101233. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101234. /**
  101235. * Gets or sets the associated variable name in the shader
  101236. */
  101237. get associatedVariableName(): string;
  101238. set associatedVariableName(value: string);
  101239. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101240. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101241. /**
  101242. * Gets or sets the connection point type (default is float)
  101243. */
  101244. get type(): NodeMaterialBlockConnectionPointTypes;
  101245. set type(value: NodeMaterialBlockConnectionPointTypes);
  101246. /**
  101247. * Gets or sets the connection point name
  101248. */
  101249. name: string;
  101250. /**
  101251. * Gets or sets the connection point name
  101252. */
  101253. displayName: string;
  101254. /**
  101255. * Gets or sets a boolean indicating that this connection point can be omitted
  101256. */
  101257. isOptional: boolean;
  101258. /**
  101259. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101260. */
  101261. isExposedOnFrame: boolean;
  101262. /**
  101263. * Gets or sets number indicating the position that the port is exposed to on a frame
  101264. */
  101265. exposedPortPosition: number;
  101266. /**
  101267. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101268. */
  101269. define: string;
  101270. /** @hidden */
  101271. _prioritizeVertex: boolean;
  101272. private _target;
  101273. /** Gets or sets the target of that connection point */
  101274. get target(): NodeMaterialBlockTargets;
  101275. set target(value: NodeMaterialBlockTargets);
  101276. /**
  101277. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101278. */
  101279. get isConnected(): boolean;
  101280. /**
  101281. * Gets a boolean indicating that the current point is connected to an input block
  101282. */
  101283. get isConnectedToInputBlock(): boolean;
  101284. /**
  101285. * Gets a the connected input block (if any)
  101286. */
  101287. get connectInputBlock(): Nullable<InputBlock>;
  101288. /** Get the other side of the connection (if any) */
  101289. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101290. /** Get the block that owns this connection point */
  101291. get ownerBlock(): NodeMaterialBlock;
  101292. /** Get the block connected on the other side of this connection (if any) */
  101293. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101294. /** Get the block connected on the endpoints of this connection (if any) */
  101295. get connectedBlocks(): Array<NodeMaterialBlock>;
  101296. /** Gets the list of connected endpoints */
  101297. get endpoints(): NodeMaterialConnectionPoint[];
  101298. /** Gets a boolean indicating if that output point is connected to at least one input */
  101299. get hasEndpoints(): boolean;
  101300. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101301. get isConnectedInVertexShader(): boolean;
  101302. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101303. get isConnectedInFragmentShader(): boolean;
  101304. /**
  101305. * Creates a block suitable to be used as an input for this input point.
  101306. * If null is returned, a block based on the point type will be created.
  101307. * @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
  101308. */
  101309. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101310. /**
  101311. * Creates a new connection point
  101312. * @param name defines the connection point name
  101313. * @param ownerBlock defines the block hosting this connection point
  101314. * @param direction defines the direction of the connection point
  101315. */
  101316. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101317. /**
  101318. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101319. * @returns the class name
  101320. */
  101321. getClassName(): string;
  101322. /**
  101323. * Gets a boolean indicating if the current point can be connected to another point
  101324. * @param connectionPoint defines the other connection point
  101325. * @returns a boolean
  101326. */
  101327. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101328. /**
  101329. * Gets a number indicating if the current point can be connected to another point
  101330. * @param connectionPoint defines the other connection point
  101331. * @returns a number defining the compatibility state
  101332. */
  101333. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101334. /**
  101335. * Connect this point to another connection point
  101336. * @param connectionPoint defines the other connection point
  101337. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101338. * @returns the current connection point
  101339. */
  101340. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101341. /**
  101342. * Disconnect this point from one of his endpoint
  101343. * @param endpoint defines the other connection point
  101344. * @returns the current connection point
  101345. */
  101346. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101347. /**
  101348. * Serializes this point in a JSON representation
  101349. * @param isInput defines if the connection point is an input (default is true)
  101350. * @returns the serialized point object
  101351. */
  101352. serialize(isInput?: boolean): any;
  101353. /**
  101354. * Release resources
  101355. */
  101356. dispose(): void;
  101357. }
  101358. }
  101359. declare module BABYLON {
  101360. /**
  101361. * Enum used to define the material modes
  101362. */
  101363. export enum NodeMaterialModes {
  101364. /** Regular material */
  101365. Material = 0,
  101366. /** For post process */
  101367. PostProcess = 1,
  101368. /** For particle system */
  101369. Particle = 2,
  101370. /** For procedural texture */
  101371. ProceduralTexture = 3
  101372. }
  101373. }
  101374. declare module BABYLON {
  101375. /**
  101376. * Block used to read a texture from a sampler
  101377. */
  101378. export class TextureBlock extends NodeMaterialBlock {
  101379. private _defineName;
  101380. private _linearDefineName;
  101381. private _gammaDefineName;
  101382. private _tempTextureRead;
  101383. private _samplerName;
  101384. private _transformedUVName;
  101385. private _textureTransformName;
  101386. private _textureInfoName;
  101387. private _mainUVName;
  101388. private _mainUVDefineName;
  101389. private _fragmentOnly;
  101390. /**
  101391. * Gets or sets the texture associated with the node
  101392. */
  101393. texture: Nullable<Texture>;
  101394. /**
  101395. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101396. */
  101397. convertToGammaSpace: boolean;
  101398. /**
  101399. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101400. */
  101401. convertToLinearSpace: boolean;
  101402. /**
  101403. * Create a new TextureBlock
  101404. * @param name defines the block name
  101405. */
  101406. constructor(name: string, fragmentOnly?: boolean);
  101407. /**
  101408. * Gets the current class name
  101409. * @returns the class name
  101410. */
  101411. getClassName(): string;
  101412. /**
  101413. * Gets the uv input component
  101414. */
  101415. get uv(): NodeMaterialConnectionPoint;
  101416. /**
  101417. * Gets the rgba output component
  101418. */
  101419. get rgba(): NodeMaterialConnectionPoint;
  101420. /**
  101421. * Gets the rgb output component
  101422. */
  101423. get rgb(): NodeMaterialConnectionPoint;
  101424. /**
  101425. * Gets the r output component
  101426. */
  101427. get r(): NodeMaterialConnectionPoint;
  101428. /**
  101429. * Gets the g output component
  101430. */
  101431. get g(): NodeMaterialConnectionPoint;
  101432. /**
  101433. * Gets the b output component
  101434. */
  101435. get b(): NodeMaterialConnectionPoint;
  101436. /**
  101437. * Gets the a output component
  101438. */
  101439. get a(): NodeMaterialConnectionPoint;
  101440. get target(): NodeMaterialBlockTargets;
  101441. autoConfigure(material: NodeMaterial): void;
  101442. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101444. isReady(): boolean;
  101445. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101446. private get _isMixed();
  101447. private _injectVertexCode;
  101448. private _writeTextureRead;
  101449. private _writeOutput;
  101450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101451. protected _dumpPropertiesCode(): string;
  101452. serialize(): any;
  101453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101454. }
  101455. }
  101456. declare module BABYLON {
  101457. /** @hidden */
  101458. export var reflectionFunction: {
  101459. name: string;
  101460. shader: string;
  101461. };
  101462. }
  101463. declare module BABYLON {
  101464. /**
  101465. * Base block used to read a reflection texture from a sampler
  101466. */
  101467. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101468. /** @hidden */
  101469. _define3DName: string;
  101470. /** @hidden */
  101471. _defineCubicName: string;
  101472. /** @hidden */
  101473. _defineExplicitName: string;
  101474. /** @hidden */
  101475. _defineProjectionName: string;
  101476. /** @hidden */
  101477. _defineLocalCubicName: string;
  101478. /** @hidden */
  101479. _defineSphericalName: string;
  101480. /** @hidden */
  101481. _definePlanarName: string;
  101482. /** @hidden */
  101483. _defineEquirectangularName: string;
  101484. /** @hidden */
  101485. _defineMirroredEquirectangularFixedName: string;
  101486. /** @hidden */
  101487. _defineEquirectangularFixedName: string;
  101488. /** @hidden */
  101489. _defineSkyboxName: string;
  101490. /** @hidden */
  101491. _defineOppositeZ: string;
  101492. /** @hidden */
  101493. _cubeSamplerName: string;
  101494. /** @hidden */
  101495. _2DSamplerName: string;
  101496. protected _positionUVWName: string;
  101497. protected _directionWName: string;
  101498. protected _reflectionVectorName: string;
  101499. /** @hidden */
  101500. _reflectionCoordsName: string;
  101501. /** @hidden */
  101502. _reflectionMatrixName: string;
  101503. protected _reflectionColorName: string;
  101504. /**
  101505. * Gets or sets the texture associated with the node
  101506. */
  101507. texture: Nullable<BaseTexture>;
  101508. /**
  101509. * Create a new ReflectionTextureBaseBlock
  101510. * @param name defines the block name
  101511. */
  101512. constructor(name: string);
  101513. /**
  101514. * Gets the current class name
  101515. * @returns the class name
  101516. */
  101517. getClassName(): string;
  101518. /**
  101519. * Gets the world position input component
  101520. */
  101521. abstract get position(): NodeMaterialConnectionPoint;
  101522. /**
  101523. * Gets the world position input component
  101524. */
  101525. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101526. /**
  101527. * Gets the world normal input component
  101528. */
  101529. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101530. /**
  101531. * Gets the world input component
  101532. */
  101533. abstract get world(): NodeMaterialConnectionPoint;
  101534. /**
  101535. * Gets the camera (or eye) position component
  101536. */
  101537. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101538. /**
  101539. * Gets the view input component
  101540. */
  101541. abstract get view(): NodeMaterialConnectionPoint;
  101542. protected _getTexture(): Nullable<BaseTexture>;
  101543. autoConfigure(material: NodeMaterial): void;
  101544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101545. isReady(): boolean;
  101546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101547. /**
  101548. * Gets the code to inject in the vertex shader
  101549. * @param state current state of the node material building
  101550. * @returns the shader code
  101551. */
  101552. handleVertexSide(state: NodeMaterialBuildState): string;
  101553. /**
  101554. * Handles the inits for the fragment code path
  101555. * @param state node material build state
  101556. */
  101557. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101558. /**
  101559. * Generates the reflection coords code for the fragment code path
  101560. * @param worldNormalVarName name of the world normal variable
  101561. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101562. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101563. * @returns the shader code
  101564. */
  101565. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101566. /**
  101567. * Generates the reflection color code for the fragment code path
  101568. * @param lodVarName name of the lod variable
  101569. * @param swizzleLookupTexture swizzle to use for the final color variable
  101570. * @returns the shader code
  101571. */
  101572. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101573. /**
  101574. * Generates the code corresponding to the connected output points
  101575. * @param state node material build state
  101576. * @param varName name of the variable to output
  101577. * @returns the shader code
  101578. */
  101579. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101580. protected _buildBlock(state: NodeMaterialBuildState): this;
  101581. protected _dumpPropertiesCode(): string;
  101582. serialize(): any;
  101583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101584. }
  101585. }
  101586. declare module BABYLON {
  101587. /**
  101588. * Defines a connection point to be used for points with a custom object type
  101589. */
  101590. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101591. private _blockType;
  101592. private _blockName;
  101593. private _nameForCheking?;
  101594. /**
  101595. * Creates a new connection point
  101596. * @param name defines the connection point name
  101597. * @param ownerBlock defines the block hosting this connection point
  101598. * @param direction defines the direction of the connection point
  101599. */
  101600. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101601. /**
  101602. * Gets a number indicating if the current point can be connected to another point
  101603. * @param connectionPoint defines the other connection point
  101604. * @returns a number defining the compatibility state
  101605. */
  101606. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101607. /**
  101608. * Creates a block suitable to be used as an input for this input point.
  101609. * If null is returned, a block based on the point type will be created.
  101610. * @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
  101611. */
  101612. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101613. }
  101614. }
  101615. declare module BABYLON {
  101616. /**
  101617. * Enum defining the type of properties that can be edited in the property pages in the NME
  101618. */
  101619. export enum PropertyTypeForEdition {
  101620. /** property is a boolean */
  101621. Boolean = 0,
  101622. /** property is a float */
  101623. Float = 1,
  101624. /** property is a Vector2 */
  101625. Vector2 = 2,
  101626. /** property is a list of values */
  101627. List = 3
  101628. }
  101629. /**
  101630. * Interface that defines an option in a variable of type list
  101631. */
  101632. export interface IEditablePropertyListOption {
  101633. /** label of the option */
  101634. "label": string;
  101635. /** value of the option */
  101636. "value": number;
  101637. }
  101638. /**
  101639. * Interface that defines the options available for an editable property
  101640. */
  101641. export interface IEditablePropertyOption {
  101642. /** min value */
  101643. "min"?: number;
  101644. /** max value */
  101645. "max"?: number;
  101646. /** notifiers: indicates which actions to take when the property is changed */
  101647. "notifiers"?: {
  101648. /** the material should be rebuilt */
  101649. "rebuild"?: boolean;
  101650. /** the preview should be updated */
  101651. "update"?: boolean;
  101652. };
  101653. /** list of the options for a variable of type list */
  101654. "options"?: IEditablePropertyListOption[];
  101655. }
  101656. /**
  101657. * Interface that describes an editable property
  101658. */
  101659. export interface IPropertyDescriptionForEdition {
  101660. /** name of the property */
  101661. "propertyName": string;
  101662. /** display name of the property */
  101663. "displayName": string;
  101664. /** type of the property */
  101665. "type": PropertyTypeForEdition;
  101666. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101667. "groupName": string;
  101668. /** options for the property */
  101669. "options": IEditablePropertyOption;
  101670. }
  101671. /**
  101672. * Decorator that flags a property in a node material block as being editable
  101673. */
  101674. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101675. }
  101676. declare module BABYLON {
  101677. /**
  101678. * Block used to implement the refraction part of the sub surface module of the PBR material
  101679. */
  101680. export class RefractionBlock extends NodeMaterialBlock {
  101681. /** @hidden */
  101682. _define3DName: string;
  101683. /** @hidden */
  101684. _refractionMatrixName: string;
  101685. /** @hidden */
  101686. _defineLODRefractionAlpha: string;
  101687. /** @hidden */
  101688. _defineLinearSpecularRefraction: string;
  101689. /** @hidden */
  101690. _defineOppositeZ: string;
  101691. /** @hidden */
  101692. _cubeSamplerName: string;
  101693. /** @hidden */
  101694. _2DSamplerName: string;
  101695. /** @hidden */
  101696. _vRefractionMicrosurfaceInfosName: string;
  101697. /** @hidden */
  101698. _vRefractionInfosName: string;
  101699. private _scene;
  101700. /**
  101701. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101702. * Materials half opaque for instance using refraction could benefit from this control.
  101703. */
  101704. linkRefractionWithTransparency: boolean;
  101705. /**
  101706. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101707. */
  101708. invertRefractionY: boolean;
  101709. /**
  101710. * Gets or sets the texture associated with the node
  101711. */
  101712. texture: Nullable<BaseTexture>;
  101713. /**
  101714. * Create a new RefractionBlock
  101715. * @param name defines the block name
  101716. */
  101717. constructor(name: string);
  101718. /**
  101719. * Gets the current class name
  101720. * @returns the class name
  101721. */
  101722. getClassName(): string;
  101723. /**
  101724. * Gets the intensity input component
  101725. */
  101726. get intensity(): NodeMaterialConnectionPoint;
  101727. /**
  101728. * Gets the index of refraction input component
  101729. */
  101730. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101731. /**
  101732. * Gets the tint at distance input component
  101733. */
  101734. get tintAtDistance(): NodeMaterialConnectionPoint;
  101735. /**
  101736. * Gets the view input component
  101737. */
  101738. get view(): NodeMaterialConnectionPoint;
  101739. /**
  101740. * Gets the refraction object output component
  101741. */
  101742. get refraction(): NodeMaterialConnectionPoint;
  101743. /**
  101744. * Returns true if the block has a texture
  101745. */
  101746. get hasTexture(): boolean;
  101747. protected _getTexture(): Nullable<BaseTexture>;
  101748. autoConfigure(material: NodeMaterial): void;
  101749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101750. isReady(): boolean;
  101751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101752. /**
  101753. * Gets the main code of the block (fragment side)
  101754. * @param state current state of the node material building
  101755. * @returns the shader code
  101756. */
  101757. getCode(state: NodeMaterialBuildState): string;
  101758. protected _buildBlock(state: NodeMaterialBuildState): this;
  101759. protected _dumpPropertiesCode(): string;
  101760. serialize(): any;
  101761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101762. }
  101763. }
  101764. declare module BABYLON {
  101765. /**
  101766. * Base block used as input for post process
  101767. */
  101768. export class CurrentScreenBlock extends NodeMaterialBlock {
  101769. private _samplerName;
  101770. private _linearDefineName;
  101771. private _gammaDefineName;
  101772. private _mainUVName;
  101773. private _tempTextureRead;
  101774. /**
  101775. * Gets or sets the texture associated with the node
  101776. */
  101777. texture: Nullable<BaseTexture>;
  101778. /**
  101779. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101780. */
  101781. convertToGammaSpace: boolean;
  101782. /**
  101783. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101784. */
  101785. convertToLinearSpace: boolean;
  101786. /**
  101787. * Create a new CurrentScreenBlock
  101788. * @param name defines the block name
  101789. */
  101790. constructor(name: string);
  101791. /**
  101792. * Gets the current class name
  101793. * @returns the class name
  101794. */
  101795. getClassName(): string;
  101796. /**
  101797. * Gets the uv input component
  101798. */
  101799. get uv(): NodeMaterialConnectionPoint;
  101800. /**
  101801. * Gets the rgba output component
  101802. */
  101803. get rgba(): NodeMaterialConnectionPoint;
  101804. /**
  101805. * Gets the rgb output component
  101806. */
  101807. get rgb(): NodeMaterialConnectionPoint;
  101808. /**
  101809. * Gets the r output component
  101810. */
  101811. get r(): NodeMaterialConnectionPoint;
  101812. /**
  101813. * Gets the g output component
  101814. */
  101815. get g(): NodeMaterialConnectionPoint;
  101816. /**
  101817. * Gets the b output component
  101818. */
  101819. get b(): NodeMaterialConnectionPoint;
  101820. /**
  101821. * Gets the a output component
  101822. */
  101823. get a(): NodeMaterialConnectionPoint;
  101824. /**
  101825. * Initialize the block and prepare the context for build
  101826. * @param state defines the state that will be used for the build
  101827. */
  101828. initialize(state: NodeMaterialBuildState): void;
  101829. get target(): NodeMaterialBlockTargets;
  101830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101831. isReady(): boolean;
  101832. private _injectVertexCode;
  101833. private _writeTextureRead;
  101834. private _writeOutput;
  101835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101836. serialize(): any;
  101837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101838. }
  101839. }
  101840. declare module BABYLON {
  101841. /**
  101842. * Base block used for the particle texture
  101843. */
  101844. export class ParticleTextureBlock extends NodeMaterialBlock {
  101845. private _samplerName;
  101846. private _linearDefineName;
  101847. private _gammaDefineName;
  101848. private _tempTextureRead;
  101849. /**
  101850. * Gets or sets the texture associated with the node
  101851. */
  101852. texture: Nullable<BaseTexture>;
  101853. /**
  101854. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101855. */
  101856. convertToGammaSpace: boolean;
  101857. /**
  101858. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101859. */
  101860. convertToLinearSpace: boolean;
  101861. /**
  101862. * Create a new ParticleTextureBlock
  101863. * @param name defines the block name
  101864. */
  101865. constructor(name: string);
  101866. /**
  101867. * Gets the current class name
  101868. * @returns the class name
  101869. */
  101870. getClassName(): string;
  101871. /**
  101872. * Gets the uv input component
  101873. */
  101874. get uv(): NodeMaterialConnectionPoint;
  101875. /**
  101876. * Gets the rgba output component
  101877. */
  101878. get rgba(): NodeMaterialConnectionPoint;
  101879. /**
  101880. * Gets the rgb output component
  101881. */
  101882. get rgb(): NodeMaterialConnectionPoint;
  101883. /**
  101884. * Gets the r output component
  101885. */
  101886. get r(): NodeMaterialConnectionPoint;
  101887. /**
  101888. * Gets the g output component
  101889. */
  101890. get g(): NodeMaterialConnectionPoint;
  101891. /**
  101892. * Gets the b output component
  101893. */
  101894. get b(): NodeMaterialConnectionPoint;
  101895. /**
  101896. * Gets the a output component
  101897. */
  101898. get a(): NodeMaterialConnectionPoint;
  101899. /**
  101900. * Initialize the block and prepare the context for build
  101901. * @param state defines the state that will be used for the build
  101902. */
  101903. initialize(state: NodeMaterialBuildState): void;
  101904. autoConfigure(material: NodeMaterial): void;
  101905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101906. isReady(): boolean;
  101907. private _writeOutput;
  101908. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101909. serialize(): any;
  101910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101911. }
  101912. }
  101913. declare module BABYLON {
  101914. /**
  101915. * Class used to store shared data between 2 NodeMaterialBuildState
  101916. */
  101917. export class NodeMaterialBuildStateSharedData {
  101918. /**
  101919. * Gets the list of emitted varyings
  101920. */
  101921. temps: string[];
  101922. /**
  101923. * Gets the list of emitted varyings
  101924. */
  101925. varyings: string[];
  101926. /**
  101927. * Gets the varying declaration string
  101928. */
  101929. varyingDeclaration: string;
  101930. /**
  101931. * Input blocks
  101932. */
  101933. inputBlocks: InputBlock[];
  101934. /**
  101935. * Input blocks
  101936. */
  101937. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101938. /**
  101939. * Bindable blocks (Blocks that need to set data to the effect)
  101940. */
  101941. bindableBlocks: NodeMaterialBlock[];
  101942. /**
  101943. * List of blocks that can provide a compilation fallback
  101944. */
  101945. blocksWithFallbacks: NodeMaterialBlock[];
  101946. /**
  101947. * List of blocks that can provide a define update
  101948. */
  101949. blocksWithDefines: NodeMaterialBlock[];
  101950. /**
  101951. * List of blocks that can provide a repeatable content
  101952. */
  101953. repeatableContentBlocks: NodeMaterialBlock[];
  101954. /**
  101955. * List of blocks that can provide a dynamic list of uniforms
  101956. */
  101957. dynamicUniformBlocks: NodeMaterialBlock[];
  101958. /**
  101959. * List of blocks that can block the isReady function for the material
  101960. */
  101961. blockingBlocks: NodeMaterialBlock[];
  101962. /**
  101963. * Gets the list of animated inputs
  101964. */
  101965. animatedInputs: InputBlock[];
  101966. /**
  101967. * Build Id used to avoid multiple recompilations
  101968. */
  101969. buildId: number;
  101970. /** List of emitted variables */
  101971. variableNames: {
  101972. [key: string]: number;
  101973. };
  101974. /** List of emitted defines */
  101975. defineNames: {
  101976. [key: string]: number;
  101977. };
  101978. /** Should emit comments? */
  101979. emitComments: boolean;
  101980. /** Emit build activity */
  101981. verbose: boolean;
  101982. /** Gets or sets the hosting scene */
  101983. scene: Scene;
  101984. /**
  101985. * Gets the compilation hints emitted at compilation time
  101986. */
  101987. hints: {
  101988. needWorldViewMatrix: boolean;
  101989. needWorldViewProjectionMatrix: boolean;
  101990. needAlphaBlending: boolean;
  101991. needAlphaTesting: boolean;
  101992. };
  101993. /**
  101994. * List of compilation checks
  101995. */
  101996. checks: {
  101997. emitVertex: boolean;
  101998. emitFragment: boolean;
  101999. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102000. };
  102001. /**
  102002. * Is vertex program allowed to be empty?
  102003. */
  102004. allowEmptyVertexProgram: boolean;
  102005. /** Creates a new shared data */
  102006. constructor();
  102007. /**
  102008. * Emits console errors and exceptions if there is a failing check
  102009. */
  102010. emitErrors(): void;
  102011. }
  102012. }
  102013. declare module BABYLON {
  102014. /**
  102015. * Class used to store node based material build state
  102016. */
  102017. export class NodeMaterialBuildState {
  102018. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102019. supportUniformBuffers: boolean;
  102020. /**
  102021. * Gets the list of emitted attributes
  102022. */
  102023. attributes: string[];
  102024. /**
  102025. * Gets the list of emitted uniforms
  102026. */
  102027. uniforms: string[];
  102028. /**
  102029. * Gets the list of emitted constants
  102030. */
  102031. constants: string[];
  102032. /**
  102033. * Gets the list of emitted samplers
  102034. */
  102035. samplers: string[];
  102036. /**
  102037. * Gets the list of emitted functions
  102038. */
  102039. functions: {
  102040. [key: string]: string;
  102041. };
  102042. /**
  102043. * Gets the list of emitted extensions
  102044. */
  102045. extensions: {
  102046. [key: string]: string;
  102047. };
  102048. /**
  102049. * Gets the target of the compilation state
  102050. */
  102051. target: NodeMaterialBlockTargets;
  102052. /**
  102053. * Gets the list of emitted counters
  102054. */
  102055. counters: {
  102056. [key: string]: number;
  102057. };
  102058. /**
  102059. * Shared data between multiple NodeMaterialBuildState instances
  102060. */
  102061. sharedData: NodeMaterialBuildStateSharedData;
  102062. /** @hidden */
  102063. _vertexState: NodeMaterialBuildState;
  102064. /** @hidden */
  102065. _attributeDeclaration: string;
  102066. /** @hidden */
  102067. _uniformDeclaration: string;
  102068. /** @hidden */
  102069. _constantDeclaration: string;
  102070. /** @hidden */
  102071. _samplerDeclaration: string;
  102072. /** @hidden */
  102073. _varyingTransfer: string;
  102074. /** @hidden */
  102075. _injectAtEnd: string;
  102076. private _repeatableContentAnchorIndex;
  102077. /** @hidden */
  102078. _builtCompilationString: string;
  102079. /**
  102080. * Gets the emitted compilation strings
  102081. */
  102082. compilationString: string;
  102083. /**
  102084. * Finalize the compilation strings
  102085. * @param state defines the current compilation state
  102086. */
  102087. finalize(state: NodeMaterialBuildState): void;
  102088. /** @hidden */
  102089. get _repeatableContentAnchor(): string;
  102090. /** @hidden */
  102091. _getFreeVariableName(prefix: string): string;
  102092. /** @hidden */
  102093. _getFreeDefineName(prefix: string): string;
  102094. /** @hidden */
  102095. _excludeVariableName(name: string): void;
  102096. /** @hidden */
  102097. _emit2DSampler(name: string): void;
  102098. /** @hidden */
  102099. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102100. /** @hidden */
  102101. _emitExtension(name: string, extension: string, define?: string): void;
  102102. /** @hidden */
  102103. _emitFunction(name: string, code: string, comments: string): void;
  102104. /** @hidden */
  102105. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102106. replaceStrings?: {
  102107. search: RegExp;
  102108. replace: string;
  102109. }[];
  102110. repeatKey?: string;
  102111. }): string;
  102112. /** @hidden */
  102113. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102114. repeatKey?: string;
  102115. removeAttributes?: boolean;
  102116. removeUniforms?: boolean;
  102117. removeVaryings?: boolean;
  102118. removeIfDef?: boolean;
  102119. replaceStrings?: {
  102120. search: RegExp;
  102121. replace: string;
  102122. }[];
  102123. }, storeKey?: string): void;
  102124. /** @hidden */
  102125. _registerTempVariable(name: string): boolean;
  102126. /** @hidden */
  102127. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102128. /** @hidden */
  102129. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102130. /** @hidden */
  102131. _emitFloat(value: number): string;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * Helper class used to generate session unique ID
  102137. */
  102138. export class UniqueIdGenerator {
  102139. private static _UniqueIdCounter;
  102140. /**
  102141. * Gets an unique (relatively to the current scene) Id
  102142. */
  102143. static get UniqueId(): number;
  102144. }
  102145. }
  102146. declare module BABYLON {
  102147. /**
  102148. * Defines a block that can be used inside a node based material
  102149. */
  102150. export class NodeMaterialBlock {
  102151. private _buildId;
  102152. private _buildTarget;
  102153. private _target;
  102154. private _isFinalMerger;
  102155. private _isInput;
  102156. private _name;
  102157. protected _isUnique: boolean;
  102158. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102159. inputsAreExclusive: boolean;
  102160. /** @hidden */
  102161. _codeVariableName: string;
  102162. /** @hidden */
  102163. _inputs: NodeMaterialConnectionPoint[];
  102164. /** @hidden */
  102165. _outputs: NodeMaterialConnectionPoint[];
  102166. /** @hidden */
  102167. _preparationId: number;
  102168. /**
  102169. * Gets the name of the block
  102170. */
  102171. get name(): string;
  102172. /**
  102173. * Sets the name of the block. Will check if the name is valid.
  102174. */
  102175. set name(newName: string);
  102176. /**
  102177. * Gets or sets the unique id of the node
  102178. */
  102179. uniqueId: number;
  102180. /**
  102181. * Gets or sets the comments associated with this block
  102182. */
  102183. comments: string;
  102184. /**
  102185. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102186. */
  102187. get isUnique(): boolean;
  102188. /**
  102189. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102190. */
  102191. get isFinalMerger(): boolean;
  102192. /**
  102193. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102194. */
  102195. get isInput(): boolean;
  102196. /**
  102197. * Gets or sets the build Id
  102198. */
  102199. get buildId(): number;
  102200. set buildId(value: number);
  102201. /**
  102202. * Gets or sets the target of the block
  102203. */
  102204. get target(): NodeMaterialBlockTargets;
  102205. set target(value: NodeMaterialBlockTargets);
  102206. /**
  102207. * Gets the list of input points
  102208. */
  102209. get inputs(): NodeMaterialConnectionPoint[];
  102210. /** Gets the list of output points */
  102211. get outputs(): NodeMaterialConnectionPoint[];
  102212. /**
  102213. * Find an input by its name
  102214. * @param name defines the name of the input to look for
  102215. * @returns the input or null if not found
  102216. */
  102217. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102218. /**
  102219. * Find an output by its name
  102220. * @param name defines the name of the outputto look for
  102221. * @returns the output or null if not found
  102222. */
  102223. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102224. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102225. visibleInInspector: boolean;
  102226. /**
  102227. * Creates a new NodeMaterialBlock
  102228. * @param name defines the block name
  102229. * @param target defines the target of that block (Vertex by default)
  102230. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102231. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102232. */
  102233. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102234. /**
  102235. * Initialize the block and prepare the context for build
  102236. * @param state defines the state that will be used for the build
  102237. */
  102238. initialize(state: NodeMaterialBuildState): void;
  102239. /**
  102240. * Bind data to effect. Will only be called for blocks with isBindable === true
  102241. * @param effect defines the effect to bind data to
  102242. * @param nodeMaterial defines the hosting NodeMaterial
  102243. * @param mesh defines the mesh that will be rendered
  102244. * @param subMesh defines the submesh that will be rendered
  102245. */
  102246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102247. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102248. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102249. protected _writeFloat(value: number): string;
  102250. /**
  102251. * Gets the current class name e.g. "NodeMaterialBlock"
  102252. * @returns the class name
  102253. */
  102254. getClassName(): string;
  102255. /**
  102256. * Register a new input. Must be called inside a block constructor
  102257. * @param name defines the connection point name
  102258. * @param type defines the connection point type
  102259. * @param isOptional defines a boolean indicating that this input can be omitted
  102260. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102261. * @param point an already created connection point. If not provided, create a new one
  102262. * @returns the current block
  102263. */
  102264. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102265. /**
  102266. * Register a new output. Must be called inside a block constructor
  102267. * @param name defines the connection point name
  102268. * @param type defines the connection point type
  102269. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102270. * @param point an already created connection point. If not provided, create a new one
  102271. * @returns the current block
  102272. */
  102273. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102274. /**
  102275. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102276. * @param forOutput defines an optional connection point to check compatibility with
  102277. * @returns the first available input or null
  102278. */
  102279. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102280. /**
  102281. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102282. * @param forBlock defines an optional block to check compatibility with
  102283. * @returns the first available input or null
  102284. */
  102285. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102286. /**
  102287. * Gets the sibling of the given output
  102288. * @param current defines the current output
  102289. * @returns the next output in the list or null
  102290. */
  102291. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102292. /**
  102293. * Connect current block with another block
  102294. * @param other defines the block to connect with
  102295. * @param options define the various options to help pick the right connections
  102296. * @returns the current block
  102297. */
  102298. connectTo(other: NodeMaterialBlock, options?: {
  102299. input?: string;
  102300. output?: string;
  102301. outputSwizzle?: string;
  102302. }): this | undefined;
  102303. protected _buildBlock(state: NodeMaterialBuildState): void;
  102304. /**
  102305. * Add uniforms, samplers and uniform buffers at compilation time
  102306. * @param state defines the state to update
  102307. * @param nodeMaterial defines the node material requesting the update
  102308. * @param defines defines the material defines to update
  102309. * @param uniformBuffers defines the list of uniform buffer names
  102310. */
  102311. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102312. /**
  102313. * Add potential fallbacks if shader compilation fails
  102314. * @param mesh defines the mesh to be rendered
  102315. * @param fallbacks defines the current prioritized list of fallbacks
  102316. */
  102317. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102318. /**
  102319. * Initialize defines for shader compilation
  102320. * @param mesh defines the mesh to be rendered
  102321. * @param nodeMaterial defines the node material requesting the update
  102322. * @param defines defines the material defines to update
  102323. * @param useInstances specifies that instances should be used
  102324. */
  102325. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102326. /**
  102327. * Update defines for shader compilation
  102328. * @param mesh defines the mesh to be rendered
  102329. * @param nodeMaterial defines the node material requesting the update
  102330. * @param defines defines the material defines to update
  102331. * @param useInstances specifies that instances should be used
  102332. * @param subMesh defines which submesh to render
  102333. */
  102334. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102335. /**
  102336. * Lets the block try to connect some inputs automatically
  102337. * @param material defines the hosting NodeMaterial
  102338. */
  102339. autoConfigure(material: NodeMaterial): void;
  102340. /**
  102341. * Function called when a block is declared as repeatable content generator
  102342. * @param vertexShaderState defines the current compilation state for the vertex shader
  102343. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102344. * @param mesh defines the mesh to be rendered
  102345. * @param defines defines the material defines to update
  102346. */
  102347. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102348. /**
  102349. * Checks if the block is ready
  102350. * @param mesh defines the mesh to be rendered
  102351. * @param nodeMaterial defines the node material requesting the update
  102352. * @param defines defines the material defines to update
  102353. * @param useInstances specifies that instances should be used
  102354. * @returns true if the block is ready
  102355. */
  102356. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102357. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102358. private _processBuild;
  102359. /**
  102360. * Validates the new name for the block node.
  102361. * @param newName the new name to be given to the node.
  102362. * @returns false if the name is a reserve word, else true.
  102363. */
  102364. validateBlockName(newName: string): boolean;
  102365. /**
  102366. * Compile the current node and generate the shader code
  102367. * @param state defines the current compilation state (uniforms, samplers, current string)
  102368. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102369. * @returns true if already built
  102370. */
  102371. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102372. protected _inputRename(name: string): string;
  102373. protected _outputRename(name: string): string;
  102374. protected _dumpPropertiesCode(): string;
  102375. /** @hidden */
  102376. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102377. /** @hidden */
  102378. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102379. /**
  102380. * Clone the current block to a new identical block
  102381. * @param scene defines the hosting scene
  102382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102383. * @returns a copy of the current block
  102384. */
  102385. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102386. /**
  102387. * Serializes this block in a JSON representation
  102388. * @returns the serialized block object
  102389. */
  102390. serialize(): any;
  102391. /** @hidden */
  102392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102393. private _deserializePortDisplayNamesAndExposedOnFrame;
  102394. /**
  102395. * Release resources
  102396. */
  102397. dispose(): void;
  102398. }
  102399. }
  102400. declare module BABYLON {
  102401. /**
  102402. * Base class of materials working in push mode in babylon JS
  102403. * @hidden
  102404. */
  102405. export class PushMaterial extends Material {
  102406. protected _activeEffect: Effect;
  102407. protected _normalMatrix: Matrix;
  102408. constructor(name: string, scene: Scene);
  102409. getEffect(): Effect;
  102410. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102411. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102412. /**
  102413. * Binds the given world matrix to the active effect
  102414. *
  102415. * @param world the matrix to bind
  102416. */
  102417. bindOnlyWorldMatrix(world: Matrix): void;
  102418. /**
  102419. * Binds the given normal matrix to the active effect
  102420. *
  102421. * @param normalMatrix the matrix to bind
  102422. */
  102423. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102424. bind(world: Matrix, mesh?: Mesh): void;
  102425. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102426. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102427. }
  102428. }
  102429. declare module BABYLON {
  102430. /**
  102431. * Root class for all node material optimizers
  102432. */
  102433. export class NodeMaterialOptimizer {
  102434. /**
  102435. * Function used to optimize a NodeMaterial graph
  102436. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102437. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102438. */
  102439. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102440. }
  102441. }
  102442. declare module BABYLON {
  102443. /**
  102444. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102445. */
  102446. export class TransformBlock extends NodeMaterialBlock {
  102447. /**
  102448. * Defines the value to use to complement W value to transform it to a Vector4
  102449. */
  102450. complementW: number;
  102451. /**
  102452. * Defines the value to use to complement z value to transform it to a Vector4
  102453. */
  102454. complementZ: number;
  102455. /**
  102456. * Creates a new TransformBlock
  102457. * @param name defines the block name
  102458. */
  102459. constructor(name: string);
  102460. /**
  102461. * Gets the current class name
  102462. * @returns the class name
  102463. */
  102464. getClassName(): string;
  102465. /**
  102466. * Gets the vector input
  102467. */
  102468. get vector(): NodeMaterialConnectionPoint;
  102469. /**
  102470. * Gets the output component
  102471. */
  102472. get output(): NodeMaterialConnectionPoint;
  102473. /**
  102474. * Gets the xyz output component
  102475. */
  102476. get xyz(): NodeMaterialConnectionPoint;
  102477. /**
  102478. * Gets the matrix transform input
  102479. */
  102480. get transform(): NodeMaterialConnectionPoint;
  102481. protected _buildBlock(state: NodeMaterialBuildState): this;
  102482. /**
  102483. * Update defines for shader compilation
  102484. * @param mesh defines the mesh to be rendered
  102485. * @param nodeMaterial defines the node material requesting the update
  102486. * @param defines defines the material defines to update
  102487. * @param useInstances specifies that instances should be used
  102488. * @param subMesh defines which submesh to render
  102489. */
  102490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102491. serialize(): any;
  102492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102493. protected _dumpPropertiesCode(): string;
  102494. }
  102495. }
  102496. declare module BABYLON {
  102497. /**
  102498. * Block used to output the vertex position
  102499. */
  102500. export class VertexOutputBlock extends NodeMaterialBlock {
  102501. /**
  102502. * Creates a new VertexOutputBlock
  102503. * @param name defines the block name
  102504. */
  102505. constructor(name: string);
  102506. /**
  102507. * Gets the current class name
  102508. * @returns the class name
  102509. */
  102510. getClassName(): string;
  102511. /**
  102512. * Gets the vector input component
  102513. */
  102514. get vector(): NodeMaterialConnectionPoint;
  102515. protected _buildBlock(state: NodeMaterialBuildState): this;
  102516. }
  102517. }
  102518. declare module BABYLON {
  102519. /**
  102520. * Block used to output the final color
  102521. */
  102522. export class FragmentOutputBlock extends NodeMaterialBlock {
  102523. /**
  102524. * Create a new FragmentOutputBlock
  102525. * @param name defines the block name
  102526. */
  102527. constructor(name: string);
  102528. /**
  102529. * Gets the current class name
  102530. * @returns the class name
  102531. */
  102532. getClassName(): string;
  102533. /**
  102534. * Gets the rgba input component
  102535. */
  102536. get rgba(): NodeMaterialConnectionPoint;
  102537. /**
  102538. * Gets the rgb input component
  102539. */
  102540. get rgb(): NodeMaterialConnectionPoint;
  102541. /**
  102542. * Gets the a input component
  102543. */
  102544. get a(): NodeMaterialConnectionPoint;
  102545. protected _buildBlock(state: NodeMaterialBuildState): this;
  102546. }
  102547. }
  102548. declare module BABYLON {
  102549. /**
  102550. * Block used for the particle ramp gradient section
  102551. */
  102552. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102553. /**
  102554. * Create a new ParticleRampGradientBlock
  102555. * @param name defines the block name
  102556. */
  102557. constructor(name: string);
  102558. /**
  102559. * Gets the current class name
  102560. * @returns the class name
  102561. */
  102562. getClassName(): string;
  102563. /**
  102564. * Gets the color input component
  102565. */
  102566. get color(): NodeMaterialConnectionPoint;
  102567. /**
  102568. * Gets the rampColor output component
  102569. */
  102570. get rampColor(): NodeMaterialConnectionPoint;
  102571. /**
  102572. * Initialize the block and prepare the context for build
  102573. * @param state defines the state that will be used for the build
  102574. */
  102575. initialize(state: NodeMaterialBuildState): void;
  102576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102577. }
  102578. }
  102579. declare module BABYLON {
  102580. /**
  102581. * Block used for the particle blend multiply section
  102582. */
  102583. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102584. /**
  102585. * Create a new ParticleBlendMultiplyBlock
  102586. * @param name defines the block name
  102587. */
  102588. constructor(name: string);
  102589. /**
  102590. * Gets the current class name
  102591. * @returns the class name
  102592. */
  102593. getClassName(): string;
  102594. /**
  102595. * Gets the color input component
  102596. */
  102597. get color(): NodeMaterialConnectionPoint;
  102598. /**
  102599. * Gets the alphaTexture input component
  102600. */
  102601. get alphaTexture(): NodeMaterialConnectionPoint;
  102602. /**
  102603. * Gets the alphaColor input component
  102604. */
  102605. get alphaColor(): NodeMaterialConnectionPoint;
  102606. /**
  102607. * Gets the blendColor output component
  102608. */
  102609. get blendColor(): NodeMaterialConnectionPoint;
  102610. /**
  102611. * Initialize the block and prepare the context for build
  102612. * @param state defines the state that will be used for the build
  102613. */
  102614. initialize(state: NodeMaterialBuildState): void;
  102615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102616. }
  102617. }
  102618. declare module BABYLON {
  102619. /**
  102620. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102621. */
  102622. export class VectorMergerBlock extends NodeMaterialBlock {
  102623. /**
  102624. * Create a new VectorMergerBlock
  102625. * @param name defines the block name
  102626. */
  102627. constructor(name: string);
  102628. /**
  102629. * Gets the current class name
  102630. * @returns the class name
  102631. */
  102632. getClassName(): string;
  102633. /**
  102634. * Gets the xyz component (input)
  102635. */
  102636. get xyzIn(): NodeMaterialConnectionPoint;
  102637. /**
  102638. * Gets the xy component (input)
  102639. */
  102640. get xyIn(): NodeMaterialConnectionPoint;
  102641. /**
  102642. * Gets the x component (input)
  102643. */
  102644. get x(): NodeMaterialConnectionPoint;
  102645. /**
  102646. * Gets the y component (input)
  102647. */
  102648. get y(): NodeMaterialConnectionPoint;
  102649. /**
  102650. * Gets the z component (input)
  102651. */
  102652. get z(): NodeMaterialConnectionPoint;
  102653. /**
  102654. * Gets the w component (input)
  102655. */
  102656. get w(): NodeMaterialConnectionPoint;
  102657. /**
  102658. * Gets the xyzw component (output)
  102659. */
  102660. get xyzw(): NodeMaterialConnectionPoint;
  102661. /**
  102662. * Gets the xyz component (output)
  102663. */
  102664. get xyzOut(): NodeMaterialConnectionPoint;
  102665. /**
  102666. * Gets the xy component (output)
  102667. */
  102668. get xyOut(): NodeMaterialConnectionPoint;
  102669. /**
  102670. * Gets the xy component (output)
  102671. * @deprecated Please use xyOut instead.
  102672. */
  102673. get xy(): NodeMaterialConnectionPoint;
  102674. /**
  102675. * Gets the xyz component (output)
  102676. * @deprecated Please use xyzOut instead.
  102677. */
  102678. get xyz(): NodeMaterialConnectionPoint;
  102679. protected _buildBlock(state: NodeMaterialBuildState): this;
  102680. }
  102681. }
  102682. declare module BABYLON {
  102683. /**
  102684. * Block used to remap a float from a range to a new one
  102685. */
  102686. export class RemapBlock extends NodeMaterialBlock {
  102687. /**
  102688. * Gets or sets the source range
  102689. */
  102690. sourceRange: Vector2;
  102691. /**
  102692. * Gets or sets the target range
  102693. */
  102694. targetRange: Vector2;
  102695. /**
  102696. * Creates a new RemapBlock
  102697. * @param name defines the block name
  102698. */
  102699. constructor(name: string);
  102700. /**
  102701. * Gets the current class name
  102702. * @returns the class name
  102703. */
  102704. getClassName(): string;
  102705. /**
  102706. * Gets the input component
  102707. */
  102708. get input(): NodeMaterialConnectionPoint;
  102709. /**
  102710. * Gets the source min input component
  102711. */
  102712. get sourceMin(): NodeMaterialConnectionPoint;
  102713. /**
  102714. * Gets the source max input component
  102715. */
  102716. get sourceMax(): NodeMaterialConnectionPoint;
  102717. /**
  102718. * Gets the target min input component
  102719. */
  102720. get targetMin(): NodeMaterialConnectionPoint;
  102721. /**
  102722. * Gets the target max input component
  102723. */
  102724. get targetMax(): NodeMaterialConnectionPoint;
  102725. /**
  102726. * Gets the output component
  102727. */
  102728. get output(): NodeMaterialConnectionPoint;
  102729. protected _buildBlock(state: NodeMaterialBuildState): this;
  102730. protected _dumpPropertiesCode(): string;
  102731. serialize(): any;
  102732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102733. }
  102734. }
  102735. declare module BABYLON {
  102736. /**
  102737. * Block used to multiply 2 values
  102738. */
  102739. export class MultiplyBlock extends NodeMaterialBlock {
  102740. /**
  102741. * Creates a new MultiplyBlock
  102742. * @param name defines the block name
  102743. */
  102744. constructor(name: string);
  102745. /**
  102746. * Gets the current class name
  102747. * @returns the class name
  102748. */
  102749. getClassName(): string;
  102750. /**
  102751. * Gets the left operand input component
  102752. */
  102753. get left(): NodeMaterialConnectionPoint;
  102754. /**
  102755. * Gets the right operand input component
  102756. */
  102757. get right(): NodeMaterialConnectionPoint;
  102758. /**
  102759. * Gets the output component
  102760. */
  102761. get output(): NodeMaterialConnectionPoint;
  102762. protected _buildBlock(state: NodeMaterialBuildState): this;
  102763. }
  102764. }
  102765. declare module BABYLON {
  102766. /**
  102767. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102768. */
  102769. export class ColorSplitterBlock extends NodeMaterialBlock {
  102770. /**
  102771. * Create a new ColorSplitterBlock
  102772. * @param name defines the block name
  102773. */
  102774. constructor(name: string);
  102775. /**
  102776. * Gets the current class name
  102777. * @returns the class name
  102778. */
  102779. getClassName(): string;
  102780. /**
  102781. * Gets the rgba component (input)
  102782. */
  102783. get rgba(): NodeMaterialConnectionPoint;
  102784. /**
  102785. * Gets the rgb component (input)
  102786. */
  102787. get rgbIn(): NodeMaterialConnectionPoint;
  102788. /**
  102789. * Gets the rgb component (output)
  102790. */
  102791. get rgbOut(): NodeMaterialConnectionPoint;
  102792. /**
  102793. * Gets the r component (output)
  102794. */
  102795. get r(): NodeMaterialConnectionPoint;
  102796. /**
  102797. * Gets the g component (output)
  102798. */
  102799. get g(): NodeMaterialConnectionPoint;
  102800. /**
  102801. * Gets the b component (output)
  102802. */
  102803. get b(): NodeMaterialConnectionPoint;
  102804. /**
  102805. * Gets the a component (output)
  102806. */
  102807. get a(): NodeMaterialConnectionPoint;
  102808. protected _inputRename(name: string): string;
  102809. protected _outputRename(name: string): string;
  102810. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102811. }
  102812. }
  102813. declare module BABYLON {
  102814. /**
  102815. * Operations supported by the Trigonometry block
  102816. */
  102817. export enum TrigonometryBlockOperations {
  102818. /** Cos */
  102819. Cos = 0,
  102820. /** Sin */
  102821. Sin = 1,
  102822. /** Abs */
  102823. Abs = 2,
  102824. /** Exp */
  102825. Exp = 3,
  102826. /** Exp2 */
  102827. Exp2 = 4,
  102828. /** Round */
  102829. Round = 5,
  102830. /** Floor */
  102831. Floor = 6,
  102832. /** Ceiling */
  102833. Ceiling = 7,
  102834. /** Square root */
  102835. Sqrt = 8,
  102836. /** Log */
  102837. Log = 9,
  102838. /** Tangent */
  102839. Tan = 10,
  102840. /** Arc tangent */
  102841. ArcTan = 11,
  102842. /** Arc cosinus */
  102843. ArcCos = 12,
  102844. /** Arc sinus */
  102845. ArcSin = 13,
  102846. /** Fraction */
  102847. Fract = 14,
  102848. /** Sign */
  102849. Sign = 15,
  102850. /** To radians (from degrees) */
  102851. Radians = 16,
  102852. /** To degrees (from radians) */
  102853. Degrees = 17
  102854. }
  102855. /**
  102856. * Block used to apply trigonometry operation to floats
  102857. */
  102858. export class TrigonometryBlock extends NodeMaterialBlock {
  102859. /**
  102860. * Gets or sets the operation applied by the block
  102861. */
  102862. operation: TrigonometryBlockOperations;
  102863. /**
  102864. * Creates a new TrigonometryBlock
  102865. * @param name defines the block name
  102866. */
  102867. constructor(name: string);
  102868. /**
  102869. * Gets the current class name
  102870. * @returns the class name
  102871. */
  102872. getClassName(): string;
  102873. /**
  102874. * Gets the input component
  102875. */
  102876. get input(): NodeMaterialConnectionPoint;
  102877. /**
  102878. * Gets the output component
  102879. */
  102880. get output(): NodeMaterialConnectionPoint;
  102881. protected _buildBlock(state: NodeMaterialBuildState): this;
  102882. serialize(): any;
  102883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102884. protected _dumpPropertiesCode(): string;
  102885. }
  102886. }
  102887. declare module BABYLON {
  102888. /**
  102889. * Interface used to configure the node material editor
  102890. */
  102891. export interface INodeMaterialEditorOptions {
  102892. /** Define the URl to load node editor script */
  102893. editorURL?: string;
  102894. }
  102895. /** @hidden */
  102896. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102897. NORMAL: boolean;
  102898. TANGENT: boolean;
  102899. UV1: boolean;
  102900. /** BONES */
  102901. NUM_BONE_INFLUENCERS: number;
  102902. BonesPerMesh: number;
  102903. BONETEXTURE: boolean;
  102904. /** MORPH TARGETS */
  102905. MORPHTARGETS: boolean;
  102906. MORPHTARGETS_NORMAL: boolean;
  102907. MORPHTARGETS_TANGENT: boolean;
  102908. MORPHTARGETS_UV: boolean;
  102909. NUM_MORPH_INFLUENCERS: number;
  102910. /** IMAGE PROCESSING */
  102911. IMAGEPROCESSING: boolean;
  102912. VIGNETTE: boolean;
  102913. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102914. VIGNETTEBLENDMODEOPAQUE: boolean;
  102915. TONEMAPPING: boolean;
  102916. TONEMAPPING_ACES: boolean;
  102917. CONTRAST: boolean;
  102918. EXPOSURE: boolean;
  102919. COLORCURVES: boolean;
  102920. COLORGRADING: boolean;
  102921. COLORGRADING3D: boolean;
  102922. SAMPLER3DGREENDEPTH: boolean;
  102923. SAMPLER3DBGRMAP: boolean;
  102924. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102925. /** MISC. */
  102926. BUMPDIRECTUV: number;
  102927. constructor();
  102928. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102929. }
  102930. /**
  102931. * Class used to configure NodeMaterial
  102932. */
  102933. export interface INodeMaterialOptions {
  102934. /**
  102935. * Defines if blocks should emit comments
  102936. */
  102937. emitComments: boolean;
  102938. }
  102939. /**
  102940. * Class used to create a node based material built by assembling shader blocks
  102941. */
  102942. export class NodeMaterial extends PushMaterial {
  102943. private static _BuildIdGenerator;
  102944. private _options;
  102945. private _vertexCompilationState;
  102946. private _fragmentCompilationState;
  102947. private _sharedData;
  102948. private _buildId;
  102949. private _buildWasSuccessful;
  102950. private _cachedWorldViewMatrix;
  102951. private _cachedWorldViewProjectionMatrix;
  102952. private _optimizers;
  102953. private _animationFrame;
  102954. /** Define the Url to load node editor script */
  102955. static EditorURL: string;
  102956. /** Define the Url to load snippets */
  102957. static SnippetUrl: string;
  102958. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102959. static IgnoreTexturesAtLoadTime: boolean;
  102960. private BJSNODEMATERIALEDITOR;
  102961. /** Get the inspector from bundle or global */
  102962. private _getGlobalNodeMaterialEditor;
  102963. /**
  102964. * Snippet ID if the material was created from the snippet server
  102965. */
  102966. snippetId: string;
  102967. /**
  102968. * Gets or sets data used by visual editor
  102969. * @see https://nme.babylonjs.com
  102970. */
  102971. editorData: any;
  102972. /**
  102973. * 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)
  102974. */
  102975. ignoreAlpha: boolean;
  102976. /**
  102977. * Defines the maximum number of lights that can be used in the material
  102978. */
  102979. maxSimultaneousLights: number;
  102980. /**
  102981. * Observable raised when the material is built
  102982. */
  102983. onBuildObservable: Observable<NodeMaterial>;
  102984. /**
  102985. * Gets or sets the root nodes of the material vertex shader
  102986. */
  102987. _vertexOutputNodes: NodeMaterialBlock[];
  102988. /**
  102989. * Gets or sets the root nodes of the material fragment (pixel) shader
  102990. */
  102991. _fragmentOutputNodes: NodeMaterialBlock[];
  102992. /** Gets or sets options to control the node material overall behavior */
  102993. get options(): INodeMaterialOptions;
  102994. set options(options: INodeMaterialOptions);
  102995. /**
  102996. * Default configuration related to image processing available in the standard Material.
  102997. */
  102998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102999. /**
  103000. * Gets the image processing configuration used either in this material.
  103001. */
  103002. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103003. /**
  103004. * Sets the Default image processing configuration used either in the this material.
  103005. *
  103006. * If sets to null, the scene one is in use.
  103007. */
  103008. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103009. /**
  103010. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103011. */
  103012. attachedBlocks: NodeMaterialBlock[];
  103013. /**
  103014. * Specifies the mode of the node material
  103015. * @hidden
  103016. */
  103017. _mode: NodeMaterialModes;
  103018. /**
  103019. * Gets the mode property
  103020. */
  103021. get mode(): NodeMaterialModes;
  103022. /**
  103023. * Create a new node based material
  103024. * @param name defines the material name
  103025. * @param scene defines the hosting scene
  103026. * @param options defines creation option
  103027. */
  103028. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103029. /**
  103030. * Gets the current class name of the material e.g. "NodeMaterial"
  103031. * @returns the class name
  103032. */
  103033. getClassName(): string;
  103034. /**
  103035. * Keep track of the image processing observer to allow dispose and replace.
  103036. */
  103037. private _imageProcessingObserver;
  103038. /**
  103039. * Attaches a new image processing configuration to the Standard Material.
  103040. * @param configuration
  103041. */
  103042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103043. /**
  103044. * Get a block by its name
  103045. * @param name defines the name of the block to retrieve
  103046. * @returns the required block or null if not found
  103047. */
  103048. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103049. /**
  103050. * Get a block by its name
  103051. * @param predicate defines the predicate used to find the good candidate
  103052. * @returns the required block or null if not found
  103053. */
  103054. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103055. /**
  103056. * Get an input block by its name
  103057. * @param predicate defines the predicate used to find the good candidate
  103058. * @returns the required input block or null if not found
  103059. */
  103060. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103061. /**
  103062. * Gets the list of input blocks attached to this material
  103063. * @returns an array of InputBlocks
  103064. */
  103065. getInputBlocks(): InputBlock[];
  103066. /**
  103067. * Adds a new optimizer to the list of optimizers
  103068. * @param optimizer defines the optimizers to add
  103069. * @returns the current material
  103070. */
  103071. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103072. /**
  103073. * Remove an optimizer from the list of optimizers
  103074. * @param optimizer defines the optimizers to remove
  103075. * @returns the current material
  103076. */
  103077. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103078. /**
  103079. * Add a new block to the list of output nodes
  103080. * @param node defines the node to add
  103081. * @returns the current material
  103082. */
  103083. addOutputNode(node: NodeMaterialBlock): this;
  103084. /**
  103085. * Remove a block from the list of root nodes
  103086. * @param node defines the node to remove
  103087. * @returns the current material
  103088. */
  103089. removeOutputNode(node: NodeMaterialBlock): this;
  103090. private _addVertexOutputNode;
  103091. private _removeVertexOutputNode;
  103092. private _addFragmentOutputNode;
  103093. private _removeFragmentOutputNode;
  103094. /**
  103095. * Specifies if the material will require alpha blending
  103096. * @returns a boolean specifying if alpha blending is needed
  103097. */
  103098. needAlphaBlending(): boolean;
  103099. /**
  103100. * Specifies if this material should be rendered in alpha test mode
  103101. * @returns a boolean specifying if an alpha test is needed.
  103102. */
  103103. needAlphaTesting(): boolean;
  103104. private _initializeBlock;
  103105. private _resetDualBlocks;
  103106. /**
  103107. * Remove a block from the current node material
  103108. * @param block defines the block to remove
  103109. */
  103110. removeBlock(block: NodeMaterialBlock): void;
  103111. /**
  103112. * Build the material and generates the inner effect
  103113. * @param verbose defines if the build should log activity
  103114. */
  103115. build(verbose?: boolean): void;
  103116. /**
  103117. * Runs an otpimization phase to try to improve the shader code
  103118. */
  103119. optimize(): void;
  103120. private _prepareDefinesForAttributes;
  103121. /**
  103122. * Create a post process from the material
  103123. * @param camera The camera to apply the render pass to.
  103124. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103126. * @param engine The engine which the post process will be applied. (default: current engine)
  103127. * @param reusable If the post process can be reused on the same frame. (default: false)
  103128. * @param textureType Type of textures used when performing the post process. (default: 0)
  103129. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103130. * @returns the post process created
  103131. */
  103132. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103133. /**
  103134. * Create the post process effect from the material
  103135. * @param postProcess The post process to create the effect for
  103136. */
  103137. createEffectForPostProcess(postProcess: PostProcess): void;
  103138. private _createEffectForPostProcess;
  103139. /**
  103140. * Create a new procedural texture based on this node material
  103141. * @param size defines the size of the texture
  103142. * @param scene defines the hosting scene
  103143. * @returns the new procedural texture attached to this node material
  103144. */
  103145. createProceduralTexture(size: number | {
  103146. width: number;
  103147. height: number;
  103148. layers?: number;
  103149. }, scene: Scene): Nullable<ProceduralTexture>;
  103150. private _createEffectForParticles;
  103151. private _checkInternals;
  103152. /**
  103153. * Create the effect to be used as the custom effect for a particle system
  103154. * @param particleSystem Particle system to create the effect for
  103155. * @param onCompiled defines a function to call when the effect creation is successful
  103156. * @param onError defines a function to call when the effect creation has failed
  103157. */
  103158. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103159. private _processDefines;
  103160. /**
  103161. * Get if the submesh is ready to be used and all its information available.
  103162. * Child classes can use it to update shaders
  103163. * @param mesh defines the mesh to check
  103164. * @param subMesh defines which submesh to check
  103165. * @param useInstances specifies that instances should be used
  103166. * @returns a boolean indicating that the submesh is ready or not
  103167. */
  103168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103169. /**
  103170. * Get a string representing the shaders built by the current node graph
  103171. */
  103172. get compiledShaders(): string;
  103173. /**
  103174. * Binds the world matrix to the material
  103175. * @param world defines the world transformation matrix
  103176. */
  103177. bindOnlyWorldMatrix(world: Matrix): void;
  103178. /**
  103179. * Binds the submesh to this material by preparing the effect and shader to draw
  103180. * @param world defines the world transformation matrix
  103181. * @param mesh defines the mesh containing the submesh
  103182. * @param subMesh defines the submesh to bind the material to
  103183. */
  103184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103185. /**
  103186. * Gets the active textures from the material
  103187. * @returns an array of textures
  103188. */
  103189. getActiveTextures(): BaseTexture[];
  103190. /**
  103191. * Gets the list of texture blocks
  103192. * @returns an array of texture blocks
  103193. */
  103194. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103195. /**
  103196. * Specifies if the material uses a texture
  103197. * @param texture defines the texture to check against the material
  103198. * @returns a boolean specifying if the material uses the texture
  103199. */
  103200. hasTexture(texture: BaseTexture): boolean;
  103201. /**
  103202. * Disposes the material
  103203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103206. */
  103207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103208. /** Creates the node editor window. */
  103209. private _createNodeEditor;
  103210. /**
  103211. * Launch the node material editor
  103212. * @param config Define the configuration of the editor
  103213. * @return a promise fulfilled when the node editor is visible
  103214. */
  103215. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103216. /**
  103217. * Clear the current material
  103218. */
  103219. clear(): void;
  103220. /**
  103221. * Clear the current material and set it to a default state
  103222. */
  103223. setToDefault(): void;
  103224. /**
  103225. * Clear the current material and set it to a default state for post process
  103226. */
  103227. setToDefaultPostProcess(): void;
  103228. /**
  103229. * Clear the current material and set it to a default state for procedural texture
  103230. */
  103231. setToDefaultProceduralTexture(): void;
  103232. /**
  103233. * Clear the current material and set it to a default state for particle
  103234. */
  103235. setToDefaultParticle(): void;
  103236. /**
  103237. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103238. * @param url defines the url to load from
  103239. * @returns a promise that will fullfil when the material is fully loaded
  103240. */
  103241. loadAsync(url: string): Promise<void>;
  103242. private _gatherBlocks;
  103243. /**
  103244. * Generate a string containing the code declaration required to create an equivalent of this material
  103245. * @returns a string
  103246. */
  103247. generateCode(): string;
  103248. /**
  103249. * Serializes this material in a JSON representation
  103250. * @returns the serialized material object
  103251. */
  103252. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103253. private _restoreConnections;
  103254. /**
  103255. * Clear the current graph and load a new one from a serialization object
  103256. * @param source defines the JSON representation of the material
  103257. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103258. * @param merge defines whether or not the source must be merged or replace the current content
  103259. */
  103260. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103261. /**
  103262. * Makes a duplicate of the current material.
  103263. * @param name - name to use for the new material.
  103264. */
  103265. clone(name: string): NodeMaterial;
  103266. /**
  103267. * Creates a node material from parsed material data
  103268. * @param source defines the JSON representation of the material
  103269. * @param scene defines the hosting scene
  103270. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103271. * @returns a new node material
  103272. */
  103273. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103274. /**
  103275. * Creates a node material from a snippet saved in a remote file
  103276. * @param name defines the name of the material to create
  103277. * @param url defines the url to load from
  103278. * @param scene defines the hosting scene
  103279. * @returns a promise that will resolve to the new node material
  103280. */
  103281. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103282. /**
  103283. * Creates a node material from a snippet saved by the node material editor
  103284. * @param snippetId defines the snippet to load
  103285. * @param scene defines the hosting scene
  103286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103287. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103288. * @returns a promise that will resolve to the new node material
  103289. */
  103290. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103291. /**
  103292. * Creates a new node material set to default basic configuration
  103293. * @param name defines the name of the material
  103294. * @param scene defines the hosting scene
  103295. * @returns a new NodeMaterial
  103296. */
  103297. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103298. }
  103299. }
  103300. declare module BABYLON {
  103301. interface ThinEngine {
  103302. /**
  103303. * Unbind a list of render target textures from the webGL context
  103304. * This is used only when drawBuffer extension or webGL2 are active
  103305. * @param textures defines the render target textures to unbind
  103306. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103307. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103308. */
  103309. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103310. /**
  103311. * Create a multi render target texture
  103312. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103313. * @param size defines the size of the texture
  103314. * @param options defines the creation options
  103315. * @returns the cube texture as an InternalTexture
  103316. */
  103317. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103318. /**
  103319. * Update the sample count for a given multiple render target texture
  103320. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103321. * @param textures defines the textures to update
  103322. * @param samples defines the sample count to set
  103323. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103324. */
  103325. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103326. /**
  103327. * Select a subsets of attachments to draw to.
  103328. * @param attachments gl attachments
  103329. */
  103330. bindAttachments(attachments: number[]): void;
  103331. }
  103332. }
  103333. declare module BABYLON {
  103334. /**
  103335. * Creation options of the multi render target texture.
  103336. */
  103337. export interface IMultiRenderTargetOptions {
  103338. /**
  103339. * Define if the texture needs to create mip maps after render.
  103340. */
  103341. generateMipMaps?: boolean;
  103342. /**
  103343. * Define the types of all the draw buffers we want to create
  103344. */
  103345. types?: number[];
  103346. /**
  103347. * Define the sampling modes of all the draw buffers we want to create
  103348. */
  103349. samplingModes?: number[];
  103350. /**
  103351. * Define if a depth buffer is required
  103352. */
  103353. generateDepthBuffer?: boolean;
  103354. /**
  103355. * Define if a stencil buffer is required
  103356. */
  103357. generateStencilBuffer?: boolean;
  103358. /**
  103359. * Define if a depth texture is required instead of a depth buffer
  103360. */
  103361. generateDepthTexture?: boolean;
  103362. /**
  103363. * Define the number of desired draw buffers
  103364. */
  103365. textureCount?: number;
  103366. /**
  103367. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103368. */
  103369. doNotChangeAspectRatio?: boolean;
  103370. /**
  103371. * Define the default type of the buffers we are creating
  103372. */
  103373. defaultType?: number;
  103374. }
  103375. /**
  103376. * A multi render target, like a render target provides the ability to render to a texture.
  103377. * Unlike the render target, it can render to several draw buffers in one draw.
  103378. * This is specially interesting in deferred rendering or for any effects requiring more than
  103379. * just one color from a single pass.
  103380. */
  103381. export class MultiRenderTarget extends RenderTargetTexture {
  103382. private _internalTextures;
  103383. private _textures;
  103384. private _multiRenderTargetOptions;
  103385. private _count;
  103386. /**
  103387. * Get if draw buffers are currently supported by the used hardware and browser.
  103388. */
  103389. get isSupported(): boolean;
  103390. /**
  103391. * Get the list of textures generated by the multi render target.
  103392. */
  103393. get textures(): Texture[];
  103394. /**
  103395. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103396. */
  103397. get count(): number;
  103398. /**
  103399. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103400. */
  103401. get depthTexture(): Texture;
  103402. /**
  103403. * Set the wrapping mode on U of all the textures we are rendering to.
  103404. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103405. */
  103406. set wrapU(wrap: number);
  103407. /**
  103408. * Set the wrapping mode on V of all the textures we are rendering to.
  103409. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103410. */
  103411. set wrapV(wrap: number);
  103412. /**
  103413. * Instantiate a new multi render target texture.
  103414. * A multi render target, like a render target provides the ability to render to a texture.
  103415. * Unlike the render target, it can render to several draw buffers in one draw.
  103416. * This is specially interesting in deferred rendering or for any effects requiring more than
  103417. * just one color from a single pass.
  103418. * @param name Define the name of the texture
  103419. * @param size Define the size of the buffers to render to
  103420. * @param count Define the number of target we are rendering into
  103421. * @param scene Define the scene the texture belongs to
  103422. * @param options Define the options used to create the multi render target
  103423. */
  103424. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103425. private _initTypes;
  103426. /** @hidden */
  103427. _rebuild(forceFullRebuild?: boolean): void;
  103428. private _createInternalTextures;
  103429. private _createTextures;
  103430. /**
  103431. * Define the number of samples used if MSAA is enabled.
  103432. */
  103433. get samples(): number;
  103434. set samples(value: number);
  103435. /**
  103436. * Resize all the textures in the multi render target.
  103437. * Be careful as it will recreate all the data in the new texture.
  103438. * @param size Define the new size
  103439. */
  103440. resize(size: any): void;
  103441. /**
  103442. * Changes the number of render targets in this MRT
  103443. * Be careful as it will recreate all the data in the new texture.
  103444. * @param count new texture count
  103445. * @param options Specifies texture types and sampling modes for new textures
  103446. */
  103447. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103448. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103449. /**
  103450. * Dispose the render targets and their associated resources
  103451. */
  103452. dispose(): void;
  103453. /**
  103454. * Release all the underlying texture used as draw buffers.
  103455. */
  103456. releaseInternalTextures(): void;
  103457. }
  103458. }
  103459. declare module BABYLON {
  103460. /** @hidden */
  103461. export var imageProcessingPixelShader: {
  103462. name: string;
  103463. shader: string;
  103464. };
  103465. }
  103466. declare module BABYLON {
  103467. /**
  103468. * ImageProcessingPostProcess
  103469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103470. */
  103471. export class ImageProcessingPostProcess extends PostProcess {
  103472. /**
  103473. * Default configuration related to image processing available in the PBR Material.
  103474. */
  103475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103476. /**
  103477. * Gets the image processing configuration used either in this material.
  103478. */
  103479. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103480. /**
  103481. * Sets the Default image processing configuration used either in the this material.
  103482. *
  103483. * If sets to null, the scene one is in use.
  103484. */
  103485. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103486. /**
  103487. * Keep track of the image processing observer to allow dispose and replace.
  103488. */
  103489. private _imageProcessingObserver;
  103490. /**
  103491. * Attaches a new image processing configuration to the PBR Material.
  103492. * @param configuration
  103493. */
  103494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103495. /**
  103496. * If the post process is supported.
  103497. */
  103498. get isSupported(): boolean;
  103499. /**
  103500. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103501. */
  103502. get colorCurves(): Nullable<ColorCurves>;
  103503. /**
  103504. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103505. */
  103506. set colorCurves(value: Nullable<ColorCurves>);
  103507. /**
  103508. * Gets wether the color curves effect is enabled.
  103509. */
  103510. get colorCurvesEnabled(): boolean;
  103511. /**
  103512. * Sets wether the color curves effect is enabled.
  103513. */
  103514. set colorCurvesEnabled(value: boolean);
  103515. /**
  103516. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103517. */
  103518. get colorGradingTexture(): Nullable<BaseTexture>;
  103519. /**
  103520. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103521. */
  103522. set colorGradingTexture(value: Nullable<BaseTexture>);
  103523. /**
  103524. * Gets wether the color grading effect is enabled.
  103525. */
  103526. get colorGradingEnabled(): boolean;
  103527. /**
  103528. * Gets wether the color grading effect is enabled.
  103529. */
  103530. set colorGradingEnabled(value: boolean);
  103531. /**
  103532. * Gets exposure used in the effect.
  103533. */
  103534. get exposure(): number;
  103535. /**
  103536. * Sets exposure used in the effect.
  103537. */
  103538. set exposure(value: number);
  103539. /**
  103540. * Gets wether tonemapping is enabled or not.
  103541. */
  103542. get toneMappingEnabled(): boolean;
  103543. /**
  103544. * Sets wether tonemapping is enabled or not
  103545. */
  103546. set toneMappingEnabled(value: boolean);
  103547. /**
  103548. * Gets the type of tone mapping effect.
  103549. */
  103550. get toneMappingType(): number;
  103551. /**
  103552. * Sets the type of tone mapping effect.
  103553. */
  103554. set toneMappingType(value: number);
  103555. /**
  103556. * Gets contrast used in the effect.
  103557. */
  103558. get contrast(): number;
  103559. /**
  103560. * Sets contrast used in the effect.
  103561. */
  103562. set contrast(value: number);
  103563. /**
  103564. * Gets Vignette stretch size.
  103565. */
  103566. get vignetteStretch(): number;
  103567. /**
  103568. * Sets Vignette stretch size.
  103569. */
  103570. set vignetteStretch(value: number);
  103571. /**
  103572. * Gets Vignette centre X Offset.
  103573. */
  103574. get vignetteCentreX(): number;
  103575. /**
  103576. * Sets Vignette centre X Offset.
  103577. */
  103578. set vignetteCentreX(value: number);
  103579. /**
  103580. * Gets Vignette centre Y Offset.
  103581. */
  103582. get vignetteCentreY(): number;
  103583. /**
  103584. * Sets Vignette centre Y Offset.
  103585. */
  103586. set vignetteCentreY(value: number);
  103587. /**
  103588. * Gets Vignette weight or intensity of the vignette effect.
  103589. */
  103590. get vignetteWeight(): number;
  103591. /**
  103592. * Sets Vignette weight or intensity of the vignette effect.
  103593. */
  103594. set vignetteWeight(value: number);
  103595. /**
  103596. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103597. * if vignetteEnabled is set to true.
  103598. */
  103599. get vignetteColor(): Color4;
  103600. /**
  103601. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103602. * if vignetteEnabled is set to true.
  103603. */
  103604. set vignetteColor(value: Color4);
  103605. /**
  103606. * Gets Camera field of view used by the Vignette effect.
  103607. */
  103608. get vignetteCameraFov(): number;
  103609. /**
  103610. * Sets Camera field of view used by the Vignette effect.
  103611. */
  103612. set vignetteCameraFov(value: number);
  103613. /**
  103614. * Gets the vignette blend mode allowing different kind of effect.
  103615. */
  103616. get vignetteBlendMode(): number;
  103617. /**
  103618. * Sets the vignette blend mode allowing different kind of effect.
  103619. */
  103620. set vignetteBlendMode(value: number);
  103621. /**
  103622. * Gets wether the vignette effect is enabled.
  103623. */
  103624. get vignetteEnabled(): boolean;
  103625. /**
  103626. * Sets wether the vignette effect is enabled.
  103627. */
  103628. set vignetteEnabled(value: boolean);
  103629. private _fromLinearSpace;
  103630. /**
  103631. * Gets wether the input of the processing is in Gamma or Linear Space.
  103632. */
  103633. get fromLinearSpace(): boolean;
  103634. /**
  103635. * Sets wether the input of the processing is in Gamma or Linear Space.
  103636. */
  103637. set fromLinearSpace(value: boolean);
  103638. /**
  103639. * Defines cache preventing GC.
  103640. */
  103641. private _defines;
  103642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103643. /**
  103644. * "ImageProcessingPostProcess"
  103645. * @returns "ImageProcessingPostProcess"
  103646. */
  103647. getClassName(): string;
  103648. /**
  103649. * @hidden
  103650. */
  103651. _updateParameters(): void;
  103652. dispose(camera?: Camera): void;
  103653. }
  103654. }
  103655. declare module BABYLON {
  103656. /**
  103657. * Interface for defining prepass effects in the prepass post-process pipeline
  103658. */
  103659. export interface PrePassEffectConfiguration {
  103660. /**
  103661. * Name of the effect
  103662. */
  103663. name: string;
  103664. /**
  103665. * Post process to attach for this effect
  103666. */
  103667. postProcess?: PostProcess;
  103668. /**
  103669. * Textures required in the MRT
  103670. */
  103671. texturesRequired: number[];
  103672. /**
  103673. * Is the effect enabled
  103674. */
  103675. enabled: boolean;
  103676. /**
  103677. * Disposes the effect configuration
  103678. */
  103679. dispose?: () => void;
  103680. /**
  103681. * Creates the associated post process
  103682. */
  103683. createPostProcess?: () => PostProcess;
  103684. }
  103685. }
  103686. declare module BABYLON {
  103687. /**
  103688. * Renders a pre pass of the scene
  103689. * This means every mesh in the scene will be rendered to a render target texture
  103690. * And then this texture will be composited to the rendering canvas with post processes
  103691. * It is necessary for effects like subsurface scattering or deferred shading
  103692. */
  103693. export class PrePassRenderer {
  103694. /** @hidden */
  103695. static _SceneComponentInitialization: (scene: Scene) => void;
  103696. private _textureFormats;
  103697. /**
  103698. * To save performance, we can excluded skinned meshes from the prepass
  103699. */
  103700. excludedSkinnedMesh: AbstractMesh[];
  103701. private _textureIndices;
  103702. private _scene;
  103703. private _engine;
  103704. private _isDirty;
  103705. /**
  103706. * Number of textures in the multi render target texture where the scene is directly rendered
  103707. */
  103708. mrtCount: number;
  103709. /**
  103710. * The render target where the scene is directly rendered
  103711. */
  103712. prePassRT: MultiRenderTarget;
  103713. private _multiRenderAttachments;
  103714. private _defaultAttachments;
  103715. private _clearAttachments;
  103716. private _postProcesses;
  103717. private readonly _clearColor;
  103718. /**
  103719. * Image processing post process for composition
  103720. */
  103721. imageProcessingPostProcess: ImageProcessingPostProcess;
  103722. /**
  103723. * Configuration for prepass effects
  103724. */
  103725. private _effectConfigurations;
  103726. private _mrtFormats;
  103727. private _mrtLayout;
  103728. private _enabled;
  103729. /**
  103730. * Indicates if the prepass is enabled
  103731. */
  103732. get enabled(): boolean;
  103733. /**
  103734. * How many samples are used for MSAA of the scene render target
  103735. */
  103736. get samples(): number;
  103737. set samples(n: number);
  103738. /**
  103739. * Instanciates a prepass renderer
  103740. * @param scene The scene
  103741. */
  103742. constructor(scene: Scene);
  103743. private _initializeAttachments;
  103744. private _createCompositionEffect;
  103745. /**
  103746. * Indicates if rendering a prepass is supported
  103747. */
  103748. get isSupported(): boolean;
  103749. /**
  103750. * Sets the proper output textures to draw in the engine.
  103751. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103752. */
  103753. bindAttachmentsForEffect(effect: Effect): void;
  103754. /**
  103755. * @hidden
  103756. */
  103757. _beforeCameraDraw(): void;
  103758. /**
  103759. * @hidden
  103760. */
  103761. _afterCameraDraw(): void;
  103762. private _checkRTSize;
  103763. private _bindFrameBuffer;
  103764. /**
  103765. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103766. */
  103767. clear(): void;
  103768. private _setState;
  103769. /**
  103770. * Adds an effect configuration to the prepass.
  103771. * If an effect has already been added, it won't add it twice and will return the configuration
  103772. * already present.
  103773. * @param cfg the effect configuration
  103774. * @return the effect configuration now used by the prepass
  103775. */
  103776. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103777. /**
  103778. * Returns the index of a texture in the multi render target texture array.
  103779. * @param type Texture type
  103780. * @return The index
  103781. */
  103782. getIndex(type: number): number;
  103783. private _enable;
  103784. private _disable;
  103785. private _resetLayout;
  103786. private _resetPostProcessChain;
  103787. private _bindPostProcessChain;
  103788. /**
  103789. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103790. */
  103791. markAsDirty(): void;
  103792. /**
  103793. * Enables a texture on the MultiRenderTarget for prepass
  103794. */
  103795. private _enableTextures;
  103796. private _update;
  103797. private _markAllMaterialsAsPrePassDirty;
  103798. /**
  103799. * Disposes the prepass renderer.
  103800. */
  103801. dispose(): void;
  103802. }
  103803. }
  103804. declare module BABYLON {
  103805. /**
  103806. * Size options for a post process
  103807. */
  103808. export type PostProcessOptions = {
  103809. width: number;
  103810. height: number;
  103811. };
  103812. /**
  103813. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103814. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103815. */
  103816. export class PostProcess {
  103817. /**
  103818. * Gets or sets the unique id of the post process
  103819. */
  103820. uniqueId: number;
  103821. /** Name of the PostProcess. */
  103822. name: string;
  103823. /**
  103824. * Width of the texture to apply the post process on
  103825. */
  103826. width: number;
  103827. /**
  103828. * Height of the texture to apply the post process on
  103829. */
  103830. height: number;
  103831. /**
  103832. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103833. */
  103834. nodeMaterialSource: Nullable<NodeMaterial>;
  103835. /**
  103836. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103837. * @hidden
  103838. */
  103839. _outputTexture: Nullable<InternalTexture>;
  103840. /**
  103841. * Sampling mode used by the shader
  103842. * See https://doc.babylonjs.com/classes/3.1/texture
  103843. */
  103844. renderTargetSamplingMode: number;
  103845. /**
  103846. * Clear color to use when screen clearing
  103847. */
  103848. clearColor: Color4;
  103849. /**
  103850. * If the buffer needs to be cleared before applying the post process. (default: true)
  103851. * Should be set to false if shader will overwrite all previous pixels.
  103852. */
  103853. autoClear: boolean;
  103854. /**
  103855. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103856. */
  103857. alphaMode: number;
  103858. /**
  103859. * Sets the setAlphaBlendConstants of the babylon engine
  103860. */
  103861. alphaConstants: Color4;
  103862. /**
  103863. * Animations to be used for the post processing
  103864. */
  103865. animations: Animation[];
  103866. /**
  103867. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103868. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103869. */
  103870. enablePixelPerfectMode: boolean;
  103871. /**
  103872. * Force the postprocess to be applied without taking in account viewport
  103873. */
  103874. forceFullscreenViewport: boolean;
  103875. /**
  103876. * List of inspectable custom properties (used by the Inspector)
  103877. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103878. */
  103879. inspectableCustomProperties: IInspectable[];
  103880. /**
  103881. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103882. *
  103883. * | Value | Type | Description |
  103884. * | ----- | ----------------------------------- | ----------- |
  103885. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103886. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103887. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103888. *
  103889. */
  103890. scaleMode: number;
  103891. /**
  103892. * Force textures to be a power of two (default: false)
  103893. */
  103894. alwaysForcePOT: boolean;
  103895. private _samples;
  103896. /**
  103897. * Number of sample textures (default: 1)
  103898. */
  103899. get samples(): number;
  103900. set samples(n: number);
  103901. /**
  103902. * Modify the scale of the post process to be the same as the viewport (default: false)
  103903. */
  103904. adaptScaleToCurrentViewport: boolean;
  103905. private _camera;
  103906. protected _scene: Scene;
  103907. private _engine;
  103908. private _options;
  103909. private _reusable;
  103910. private _textureType;
  103911. private _textureFormat;
  103912. /**
  103913. * Smart array of input and output textures for the post process.
  103914. * @hidden
  103915. */
  103916. _textures: SmartArray<InternalTexture>;
  103917. /**
  103918. * The index in _textures that corresponds to the output texture.
  103919. * @hidden
  103920. */
  103921. _currentRenderTextureInd: number;
  103922. private _effect;
  103923. private _samplers;
  103924. private _fragmentUrl;
  103925. private _vertexUrl;
  103926. private _parameters;
  103927. private _scaleRatio;
  103928. protected _indexParameters: any;
  103929. private _shareOutputWithPostProcess;
  103930. private _texelSize;
  103931. private _forcedOutputTexture;
  103932. /**
  103933. * Prepass configuration in case this post process needs a texture from prepass
  103934. * @hidden
  103935. */
  103936. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103937. /**
  103938. * Returns the fragment url or shader name used in the post process.
  103939. * @returns the fragment url or name in the shader store.
  103940. */
  103941. getEffectName(): string;
  103942. /**
  103943. * An event triggered when the postprocess is activated.
  103944. */
  103945. onActivateObservable: Observable<Camera>;
  103946. private _onActivateObserver;
  103947. /**
  103948. * A function that is added to the onActivateObservable
  103949. */
  103950. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103951. /**
  103952. * An event triggered when the postprocess changes its size.
  103953. */
  103954. onSizeChangedObservable: Observable<PostProcess>;
  103955. private _onSizeChangedObserver;
  103956. /**
  103957. * A function that is added to the onSizeChangedObservable
  103958. */
  103959. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103960. /**
  103961. * An event triggered when the postprocess applies its effect.
  103962. */
  103963. onApplyObservable: Observable<Effect>;
  103964. private _onApplyObserver;
  103965. /**
  103966. * A function that is added to the onApplyObservable
  103967. */
  103968. set onApply(callback: (effect: Effect) => void);
  103969. /**
  103970. * An event triggered before rendering the postprocess
  103971. */
  103972. onBeforeRenderObservable: Observable<Effect>;
  103973. private _onBeforeRenderObserver;
  103974. /**
  103975. * A function that is added to the onBeforeRenderObservable
  103976. */
  103977. set onBeforeRender(callback: (effect: Effect) => void);
  103978. /**
  103979. * An event triggered after rendering the postprocess
  103980. */
  103981. onAfterRenderObservable: Observable<Effect>;
  103982. private _onAfterRenderObserver;
  103983. /**
  103984. * A function that is added to the onAfterRenderObservable
  103985. */
  103986. set onAfterRender(callback: (efect: Effect) => void);
  103987. /**
  103988. * 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
  103989. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103990. */
  103991. get inputTexture(): InternalTexture;
  103992. set inputTexture(value: InternalTexture);
  103993. /**
  103994. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103995. * the only way to unset it is to use this function to restore its internal state
  103996. */
  103997. restoreDefaultInputTexture(): void;
  103998. /**
  103999. * Gets the camera which post process is applied to.
  104000. * @returns The camera the post process is applied to.
  104001. */
  104002. getCamera(): Camera;
  104003. /**
  104004. * Gets the texel size of the postprocess.
  104005. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104006. */
  104007. get texelSize(): Vector2;
  104008. /**
  104009. * Creates a new instance PostProcess
  104010. * @param name The name of the PostProcess.
  104011. * @param fragmentUrl The url of the fragment shader to be used.
  104012. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104013. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104014. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104015. * @param camera The camera to apply the render pass to.
  104016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104017. * @param engine The engine which the post process will be applied. (default: current engine)
  104018. * @param reusable If the post process can be reused on the same frame. (default: false)
  104019. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104020. * @param textureType Type of textures used when performing the post process. (default: 0)
  104021. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104022. * @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
  104023. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104024. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104025. */
  104026. 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);
  104027. /**
  104028. * Gets a string identifying the name of the class
  104029. * @returns "PostProcess" string
  104030. */
  104031. getClassName(): string;
  104032. /**
  104033. * Gets the engine which this post process belongs to.
  104034. * @returns The engine the post process was enabled with.
  104035. */
  104036. getEngine(): Engine;
  104037. /**
  104038. * The effect that is created when initializing the post process.
  104039. * @returns The created effect corresponding the the postprocess.
  104040. */
  104041. getEffect(): Effect;
  104042. /**
  104043. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104044. * @param postProcess The post process to share the output with.
  104045. * @returns This post process.
  104046. */
  104047. shareOutputWith(postProcess: PostProcess): PostProcess;
  104048. /**
  104049. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104050. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104051. */
  104052. useOwnOutput(): void;
  104053. /**
  104054. * Updates the effect with the current post process compile time values and recompiles the shader.
  104055. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104056. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104057. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104058. * @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
  104059. * @param onCompiled Called when the shader has been compiled.
  104060. * @param onError Called if there is an error when compiling a shader.
  104061. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104062. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104063. */
  104064. 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;
  104065. /**
  104066. * The post process is reusable if it can be used multiple times within one frame.
  104067. * @returns If the post process is reusable
  104068. */
  104069. isReusable(): boolean;
  104070. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104071. markTextureDirty(): void;
  104072. /**
  104073. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104074. * 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.
  104075. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104076. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104077. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104078. * @returns The target texture that was bound to be written to.
  104079. */
  104080. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104081. /**
  104082. * If the post process is supported.
  104083. */
  104084. get isSupported(): boolean;
  104085. /**
  104086. * The aspect ratio of the output texture.
  104087. */
  104088. get aspectRatio(): number;
  104089. /**
  104090. * Get a value indicating if the post-process is ready to be used
  104091. * @returns true if the post-process is ready (shader is compiled)
  104092. */
  104093. isReady(): boolean;
  104094. /**
  104095. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104096. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104097. */
  104098. apply(): Nullable<Effect>;
  104099. private _disposeTextures;
  104100. /**
  104101. * Sets the required values to the prepass renderer.
  104102. * @param prePassRenderer defines the prepass renderer to setup.
  104103. * @returns true if the pre pass is needed.
  104104. */
  104105. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104106. /**
  104107. * Disposes the post process.
  104108. * @param camera The camera to dispose the post process on.
  104109. */
  104110. dispose(camera?: Camera): void;
  104111. /**
  104112. * Serializes the particle system to a JSON object
  104113. * @returns the JSON object
  104114. */
  104115. serialize(): any;
  104116. /**
  104117. * Creates a material from parsed material data
  104118. * @param parsedPostProcess defines parsed post process data
  104119. * @param scene defines the hosting scene
  104120. * @param rootUrl defines the root URL to use to load textures
  104121. * @returns a new post process
  104122. */
  104123. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104124. }
  104125. }
  104126. declare module BABYLON {
  104127. /** @hidden */
  104128. export var kernelBlurVaryingDeclaration: {
  104129. name: string;
  104130. shader: string;
  104131. };
  104132. }
  104133. declare module BABYLON {
  104134. /** @hidden */
  104135. export var kernelBlurFragment: {
  104136. name: string;
  104137. shader: string;
  104138. };
  104139. }
  104140. declare module BABYLON {
  104141. /** @hidden */
  104142. export var kernelBlurFragment2: {
  104143. name: string;
  104144. shader: string;
  104145. };
  104146. }
  104147. declare module BABYLON {
  104148. /** @hidden */
  104149. export var kernelBlurPixelShader: {
  104150. name: string;
  104151. shader: string;
  104152. };
  104153. }
  104154. declare module BABYLON {
  104155. /** @hidden */
  104156. export var kernelBlurVertex: {
  104157. name: string;
  104158. shader: string;
  104159. };
  104160. }
  104161. declare module BABYLON {
  104162. /** @hidden */
  104163. export var kernelBlurVertexShader: {
  104164. name: string;
  104165. shader: string;
  104166. };
  104167. }
  104168. declare module BABYLON {
  104169. /**
  104170. * The Blur Post Process which blurs an image based on a kernel and direction.
  104171. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104172. */
  104173. export class BlurPostProcess extends PostProcess {
  104174. private blockCompilation;
  104175. protected _kernel: number;
  104176. protected _idealKernel: number;
  104177. protected _packedFloat: boolean;
  104178. private _staticDefines;
  104179. /** The direction in which to blur the image. */
  104180. direction: Vector2;
  104181. /**
  104182. * Sets the length in pixels of the blur sample region
  104183. */
  104184. set kernel(v: number);
  104185. /**
  104186. * Gets the length in pixels of the blur sample region
  104187. */
  104188. get kernel(): number;
  104189. /**
  104190. * Sets wether or not the blur needs to unpack/repack floats
  104191. */
  104192. set packedFloat(v: boolean);
  104193. /**
  104194. * Gets wether or not the blur is unpacking/repacking floats
  104195. */
  104196. get packedFloat(): boolean;
  104197. /**
  104198. * Gets a string identifying the name of the class
  104199. * @returns "BlurPostProcess" string
  104200. */
  104201. getClassName(): string;
  104202. /**
  104203. * Creates a new instance BlurPostProcess
  104204. * @param name The name of the effect.
  104205. * @param direction The direction in which to blur the image.
  104206. * @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.
  104207. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104208. * @param camera The camera to apply the render pass to.
  104209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104210. * @param engine The engine which the post process will be applied. (default: current engine)
  104211. * @param reusable If the post process can be reused on the same frame. (default: false)
  104212. * @param textureType Type of textures used when performing the post process. (default: 0)
  104213. * @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)
  104214. */
  104215. 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);
  104216. /**
  104217. * Updates the effect with the current post process compile time values and recompiles the shader.
  104218. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104219. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104220. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104221. * @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
  104222. * @param onCompiled Called when the shader has been compiled.
  104223. * @param onError Called if there is an error when compiling a shader.
  104224. */
  104225. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104226. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104227. /**
  104228. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104229. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104230. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104231. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104232. * The gaps between physical kernels are compensated for in the weighting of the samples
  104233. * @param idealKernel Ideal blur kernel.
  104234. * @return Nearest best kernel.
  104235. */
  104236. protected _nearestBestKernel(idealKernel: number): number;
  104237. /**
  104238. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104239. * @param x The point on the Gaussian distribution to sample.
  104240. * @return the value of the Gaussian function at x.
  104241. */
  104242. protected _gaussianWeight(x: number): number;
  104243. /**
  104244. * Generates a string that can be used as a floating point number in GLSL.
  104245. * @param x Value to print.
  104246. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104247. * @return GLSL float string.
  104248. */
  104249. protected _glslFloat(x: number, decimalFigures?: number): string;
  104250. /** @hidden */
  104251. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /**
  104256. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104257. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104258. * You can then easily use it as a reflectionTexture on a flat surface.
  104259. * In case the surface is not a plane, please consider relying on reflection probes.
  104260. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104261. */
  104262. export class MirrorTexture extends RenderTargetTexture {
  104263. private scene;
  104264. /**
  104265. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104266. * 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.
  104267. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104268. */
  104269. mirrorPlane: Plane;
  104270. /**
  104271. * Define the blur ratio used to blur the reflection if needed.
  104272. */
  104273. set blurRatio(value: number);
  104274. get blurRatio(): number;
  104275. /**
  104276. * Define the adaptive blur kernel used to blur the reflection if needed.
  104277. * This will autocompute the closest best match for the `blurKernel`
  104278. */
  104279. set adaptiveBlurKernel(value: number);
  104280. /**
  104281. * Define the blur kernel used to blur the reflection if needed.
  104282. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104283. */
  104284. set blurKernel(value: number);
  104285. /**
  104286. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104287. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104288. */
  104289. set blurKernelX(value: number);
  104290. get blurKernelX(): number;
  104291. /**
  104292. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104293. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104294. */
  104295. set blurKernelY(value: number);
  104296. get blurKernelY(): number;
  104297. private _autoComputeBlurKernel;
  104298. protected _onRatioRescale(): void;
  104299. private _updateGammaSpace;
  104300. private _imageProcessingConfigChangeObserver;
  104301. private _transformMatrix;
  104302. private _mirrorMatrix;
  104303. private _savedViewMatrix;
  104304. private _blurX;
  104305. private _blurY;
  104306. private _adaptiveBlurKernel;
  104307. private _blurKernelX;
  104308. private _blurKernelY;
  104309. private _blurRatio;
  104310. /**
  104311. * Instantiates a Mirror Texture.
  104312. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104313. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104314. * You can then easily use it as a reflectionTexture on a flat surface.
  104315. * In case the surface is not a plane, please consider relying on reflection probes.
  104316. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104317. * @param name
  104318. * @param size
  104319. * @param scene
  104320. * @param generateMipMaps
  104321. * @param type
  104322. * @param samplingMode
  104323. * @param generateDepthBuffer
  104324. */
  104325. constructor(name: string, size: number | {
  104326. width: number;
  104327. height: number;
  104328. } | {
  104329. ratio: number;
  104330. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104331. private _preparePostProcesses;
  104332. /**
  104333. * Clone the mirror texture.
  104334. * @returns the cloned texture
  104335. */
  104336. clone(): MirrorTexture;
  104337. /**
  104338. * Serialize the texture to a JSON representation you could use in Parse later on
  104339. * @returns the serialized JSON representation
  104340. */
  104341. serialize(): any;
  104342. /**
  104343. * Dispose the texture and release its associated resources.
  104344. */
  104345. dispose(): void;
  104346. }
  104347. }
  104348. declare module BABYLON {
  104349. /**
  104350. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104351. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104352. */
  104353. export class Texture extends BaseTexture {
  104354. /**
  104355. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104356. */
  104357. static SerializeBuffers: boolean;
  104358. /** @hidden */
  104359. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104360. /** @hidden */
  104361. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104362. /** @hidden */
  104363. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104364. /** nearest is mag = nearest and min = nearest and mip = linear */
  104365. static readonly NEAREST_SAMPLINGMODE: number;
  104366. /** nearest is mag = nearest and min = nearest and mip = linear */
  104367. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104369. static readonly BILINEAR_SAMPLINGMODE: number;
  104370. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104371. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104372. /** Trilinear is mag = linear and min = linear and mip = linear */
  104373. static readonly TRILINEAR_SAMPLINGMODE: number;
  104374. /** Trilinear is mag = linear and min = linear and mip = linear */
  104375. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104376. /** mag = nearest and min = nearest and mip = nearest */
  104377. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104378. /** mag = nearest and min = linear and mip = nearest */
  104379. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104380. /** mag = nearest and min = linear and mip = linear */
  104381. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104382. /** mag = nearest and min = linear and mip = none */
  104383. static readonly NEAREST_LINEAR: number;
  104384. /** mag = nearest and min = nearest and mip = none */
  104385. static readonly NEAREST_NEAREST: number;
  104386. /** mag = linear and min = nearest and mip = nearest */
  104387. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104388. /** mag = linear and min = nearest and mip = linear */
  104389. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104390. /** mag = linear and min = linear and mip = none */
  104391. static readonly LINEAR_LINEAR: number;
  104392. /** mag = linear and min = nearest and mip = none */
  104393. static readonly LINEAR_NEAREST: number;
  104394. /** Explicit coordinates mode */
  104395. static readonly EXPLICIT_MODE: number;
  104396. /** Spherical coordinates mode */
  104397. static readonly SPHERICAL_MODE: number;
  104398. /** Planar coordinates mode */
  104399. static readonly PLANAR_MODE: number;
  104400. /** Cubic coordinates mode */
  104401. static readonly CUBIC_MODE: number;
  104402. /** Projection coordinates mode */
  104403. static readonly PROJECTION_MODE: number;
  104404. /** Inverse Cubic coordinates mode */
  104405. static readonly SKYBOX_MODE: number;
  104406. /** Inverse Cubic coordinates mode */
  104407. static readonly INVCUBIC_MODE: number;
  104408. /** Equirectangular coordinates mode */
  104409. static readonly EQUIRECTANGULAR_MODE: number;
  104410. /** Equirectangular Fixed coordinates mode */
  104411. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104412. /** Equirectangular Fixed Mirrored coordinates mode */
  104413. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104414. /** Texture is not repeating outside of 0..1 UVs */
  104415. static readonly CLAMP_ADDRESSMODE: number;
  104416. /** Texture is repeating outside of 0..1 UVs */
  104417. static readonly WRAP_ADDRESSMODE: number;
  104418. /** Texture is repeating and mirrored */
  104419. static readonly MIRROR_ADDRESSMODE: number;
  104420. /**
  104421. * 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
  104422. */
  104423. static UseSerializedUrlIfAny: boolean;
  104424. /**
  104425. * Define the url of the texture.
  104426. */
  104427. url: Nullable<string>;
  104428. /**
  104429. * Define an offset on the texture to offset the u coordinates of the UVs
  104430. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104431. */
  104432. uOffset: number;
  104433. /**
  104434. * Define an offset on the texture to offset the v coordinates of the UVs
  104435. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104436. */
  104437. vOffset: number;
  104438. /**
  104439. * Define an offset on the texture to scale the u coordinates of the UVs
  104440. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104441. */
  104442. uScale: number;
  104443. /**
  104444. * Define an offset on the texture to scale the v coordinates of the UVs
  104445. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104446. */
  104447. vScale: number;
  104448. /**
  104449. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104450. * @see https://doc.babylonjs.com/how_to/more_materials
  104451. */
  104452. uAng: number;
  104453. /**
  104454. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104455. * @see https://doc.babylonjs.com/how_to/more_materials
  104456. */
  104457. vAng: number;
  104458. /**
  104459. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104460. * @see https://doc.babylonjs.com/how_to/more_materials
  104461. */
  104462. wAng: number;
  104463. /**
  104464. * Defines the center of rotation (U)
  104465. */
  104466. uRotationCenter: number;
  104467. /**
  104468. * Defines the center of rotation (V)
  104469. */
  104470. vRotationCenter: number;
  104471. /**
  104472. * Defines the center of rotation (W)
  104473. */
  104474. wRotationCenter: number;
  104475. /**
  104476. * Are mip maps generated for this texture or not.
  104477. */
  104478. get noMipmap(): boolean;
  104479. /**
  104480. * List of inspectable custom properties (used by the Inspector)
  104481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104482. */
  104483. inspectableCustomProperties: Nullable<IInspectable[]>;
  104484. private _noMipmap;
  104485. /** @hidden */
  104486. _invertY: boolean;
  104487. private _rowGenerationMatrix;
  104488. private _cachedTextureMatrix;
  104489. private _projectionModeMatrix;
  104490. private _t0;
  104491. private _t1;
  104492. private _t2;
  104493. private _cachedUOffset;
  104494. private _cachedVOffset;
  104495. private _cachedUScale;
  104496. private _cachedVScale;
  104497. private _cachedUAng;
  104498. private _cachedVAng;
  104499. private _cachedWAng;
  104500. private _cachedProjectionMatrixId;
  104501. private _cachedCoordinatesMode;
  104502. /** @hidden */
  104503. protected _initialSamplingMode: number;
  104504. /** @hidden */
  104505. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104506. private _deleteBuffer;
  104507. protected _format: Nullable<number>;
  104508. private _delayedOnLoad;
  104509. private _delayedOnError;
  104510. private _mimeType?;
  104511. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104512. get mimeType(): string | undefined;
  104513. /**
  104514. * Observable triggered once the texture has been loaded.
  104515. */
  104516. onLoadObservable: Observable<Texture>;
  104517. protected _isBlocking: boolean;
  104518. /**
  104519. * Is the texture preventing material to render while loading.
  104520. * If false, a default texture will be used instead of the loading one during the preparation step.
  104521. */
  104522. set isBlocking(value: boolean);
  104523. get isBlocking(): boolean;
  104524. /**
  104525. * Get the current sampling mode associated with the texture.
  104526. */
  104527. get samplingMode(): number;
  104528. /**
  104529. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104530. */
  104531. get invertY(): boolean;
  104532. /**
  104533. * Instantiates a new texture.
  104534. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104535. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104536. * @param url defines the url of the picture to load as a texture
  104537. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104538. * @param noMipmap defines if the texture will require mip maps or not
  104539. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104540. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104541. * @param onLoad defines a callback triggered when the texture has been loaded
  104542. * @param onError defines a callback triggered when an error occurred during the loading session
  104543. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104544. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104545. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104546. * @param mimeType defines an optional mime type information
  104547. */
  104548. 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);
  104549. /**
  104550. * Update the url (and optional buffer) of this texture if url was null during construction.
  104551. * @param url the url of the texture
  104552. * @param buffer the buffer of the texture (defaults to null)
  104553. * @param onLoad callback called when the texture is loaded (defaults to null)
  104554. */
  104555. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104556. /**
  104557. * Finish the loading sequence of a texture flagged as delayed load.
  104558. * @hidden
  104559. */
  104560. delayLoad(): void;
  104561. private _prepareRowForTextureGeneration;
  104562. /**
  104563. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104564. * @returns the transform matrix of the texture.
  104565. */
  104566. getTextureMatrix(uBase?: number): Matrix;
  104567. /**
  104568. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104569. * @returns The reflection texture transform
  104570. */
  104571. getReflectionTextureMatrix(): Matrix;
  104572. /**
  104573. * Clones the texture.
  104574. * @returns the cloned texture
  104575. */
  104576. clone(): Texture;
  104577. /**
  104578. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104579. * @returns The JSON representation of the texture
  104580. */
  104581. serialize(): any;
  104582. /**
  104583. * Get the current class name of the texture useful for serialization or dynamic coding.
  104584. * @returns "Texture"
  104585. */
  104586. getClassName(): string;
  104587. /**
  104588. * Dispose the texture and release its associated resources.
  104589. */
  104590. dispose(): void;
  104591. /**
  104592. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104593. * @param parsedTexture Define the JSON representation of the texture
  104594. * @param scene Define the scene the parsed texture should be instantiated in
  104595. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104596. * @returns The parsed texture if successful
  104597. */
  104598. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104599. /**
  104600. * Creates a texture from its base 64 representation.
  104601. * @param data Define the base64 payload without the data: prefix
  104602. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104603. * @param scene Define the scene the texture should belong to
  104604. * @param noMipmap Forces the texture to not create mip map information if true
  104605. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104606. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104607. * @param onLoad define a callback triggered when the texture has been loaded
  104608. * @param onError define a callback triggered when an error occurred during the loading session
  104609. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104610. * @returns the created texture
  104611. */
  104612. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104613. /**
  104614. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104615. * @param data Define the base64 payload without the data: prefix
  104616. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104617. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104618. * @param scene Define the scene the texture should belong to
  104619. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104620. * @param noMipmap Forces the texture to not create mip map information if true
  104621. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104622. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104623. * @param onLoad define a callback triggered when the texture has been loaded
  104624. * @param onError define a callback triggered when an error occurred during the loading session
  104625. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104626. * @returns the created texture
  104627. */
  104628. 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;
  104629. }
  104630. }
  104631. declare module BABYLON {
  104632. /**
  104633. * PostProcessManager is used to manage one or more post processes or post process pipelines
  104634. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  104635. */
  104636. export class PostProcessManager {
  104637. private _scene;
  104638. private _indexBuffer;
  104639. private _vertexBuffers;
  104640. /**
  104641. * Creates a new instance PostProcess
  104642. * @param scene The scene that the post process is associated with.
  104643. */
  104644. constructor(scene: Scene);
  104645. private _prepareBuffers;
  104646. private _buildIndexBuffer;
  104647. /**
  104648. * Rebuilds the vertex buffers of the manager.
  104649. * @hidden
  104650. */
  104651. _rebuild(): void;
  104652. /**
  104653. * Prepares a frame to be run through a post process.
  104654. * @param sourceTexture The input texture to the post procesess. (default: null)
  104655. * @param postProcesses An array of post processes to be run. (default: null)
  104656. * @returns True if the post processes were able to be run.
  104657. * @hidden
  104658. */
  104659. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  104660. /**
  104661. * Manually render a set of post processes to a texture.
  104662. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  104663. * @param postProcesses An array of post processes to be run.
  104664. * @param targetTexture The target texture to render to.
  104665. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  104666. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  104667. * @param lodLevel defines which lod of the texture to render to
  104668. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  104669. */
  104670. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  104671. /**
  104672. * Finalize the result of the output of the postprocesses.
  104673. * @param doNotPresent If true the result will not be displayed to the screen.
  104674. * @param targetTexture The target texture to render to.
  104675. * @param faceIndex The index of the face to bind the target texture to.
  104676. * @param postProcesses The array of post processes to render.
  104677. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  104678. * @hidden
  104679. */
  104680. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  104681. /**
  104682. * Disposes of the post process manager.
  104683. */
  104684. dispose(): void;
  104685. }
  104686. }
  104687. declare module BABYLON {
  104688. /**
  104689. * This Helps creating a texture that will be created from a camera in your scene.
  104690. * It is basically a dynamic texture that could be used to create special effects for instance.
  104691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  104692. */
  104693. export class RenderTargetTexture extends Texture {
  104694. /**
  104695. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  104696. */
  104697. static readonly REFRESHRATE_RENDER_ONCE: number;
  104698. /**
  104699. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  104700. */
  104701. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  104702. /**
  104703. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  104704. * the central point of your effect and can save a lot of performances.
  104705. */
  104706. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  104707. /**
  104708. * Use this predicate to dynamically define the list of mesh you want to render.
  104709. * If set, the renderList property will be overwritten.
  104710. */
  104711. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  104712. private _renderList;
  104713. /**
  104714. * Use this list to define the list of mesh you want to render.
  104715. */
  104716. get renderList(): Nullable<Array<AbstractMesh>>;
  104717. set renderList(value: Nullable<Array<AbstractMesh>>);
  104718. /**
  104719. * Use this function to overload the renderList array at rendering time.
  104720. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  104721. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  104722. * the cube (if the RTT is a cube, else layerOrFace=0).
  104723. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  104724. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  104725. * hold dummy elements!
  104726. */
  104727. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  104728. private _hookArray;
  104729. /**
  104730. * Define if particles should be rendered in your texture.
  104731. */
  104732. renderParticles: boolean;
  104733. /**
  104734. * Define if sprites should be rendered in your texture.
  104735. */
  104736. renderSprites: boolean;
  104737. /**
  104738. * Define the camera used to render the texture.
  104739. */
  104740. activeCamera: Nullable<Camera>;
  104741. /**
  104742. * Override the mesh isReady function with your own one.
  104743. */
  104744. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  104745. /**
  104746. * Override the render function of the texture with your own one.
  104747. */
  104748. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  104749. /**
  104750. * Define if camera post processes should be use while rendering the texture.
  104751. */
  104752. useCameraPostProcesses: boolean;
  104753. /**
  104754. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  104755. */
  104756. ignoreCameraViewport: boolean;
  104757. private _postProcessManager;
  104758. private _postProcesses;
  104759. private _resizeObserver;
  104760. /**
  104761. * An event triggered when the texture is unbind.
  104762. */
  104763. onBeforeBindObservable: Observable<RenderTargetTexture>;
  104764. /**
  104765. * An event triggered when the texture is unbind.
  104766. */
  104767. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  104768. private _onAfterUnbindObserver;
  104769. /**
  104770. * Set a after unbind callback in the texture.
  104771. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  104772. */
  104773. set onAfterUnbind(callback: () => void);
  104774. /**
  104775. * An event triggered before rendering the texture
  104776. */
  104777. onBeforeRenderObservable: Observable<number>;
  104778. private _onBeforeRenderObserver;
  104779. /**
  104780. * Set a before render callback in the texture.
  104781. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104782. */
  104783. set onBeforeRender(callback: (faceIndex: number) => void);
  104784. /**
  104785. * An event triggered after rendering the texture
  104786. */
  104787. onAfterRenderObservable: Observable<number>;
  104788. private _onAfterRenderObserver;
  104789. /**
  104790. * Set a after render callback in the texture.
  104791. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104792. */
  104793. set onAfterRender(callback: (faceIndex: number) => void);
  104794. /**
  104795. * An event triggered after the texture clear
  104796. */
  104797. onClearObservable: Observable<Engine>;
  104798. private _onClearObserver;
  104799. /**
  104800. * Set a clear callback in the texture.
  104801. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104802. */
  104803. set onClear(callback: (Engine: Engine) => void);
  104804. /**
  104805. * An event triggered when the texture is resized.
  104806. */
  104807. onResizeObservable: Observable<RenderTargetTexture>;
  104808. /**
  104809. * Define the clear color of the Render Target if it should be different from the scene.
  104810. */
  104811. clearColor: Color4;
  104812. protected _size: number | {
  104813. width: number;
  104814. height: number;
  104815. layers?: number;
  104816. };
  104817. protected _initialSizeParameter: number | {
  104818. width: number;
  104819. height: number;
  104820. } | {
  104821. ratio: number;
  104822. };
  104823. protected _sizeRatio: Nullable<number>;
  104824. /** @hidden */
  104825. _generateMipMaps: boolean;
  104826. protected _renderingManager: RenderingManager;
  104827. /** @hidden */
  104828. _waitingRenderList?: string[];
  104829. protected _doNotChangeAspectRatio: boolean;
  104830. protected _currentRefreshId: number;
  104831. protected _refreshRate: number;
  104832. protected _textureMatrix: Matrix;
  104833. protected _samples: number;
  104834. protected _renderTargetOptions: RenderTargetCreationOptions;
  104835. /**
  104836. * Gets render target creation options that were used.
  104837. */
  104838. get renderTargetOptions(): RenderTargetCreationOptions;
  104839. protected _onRatioRescale(): void;
  104840. /**
  104841. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104842. * It must define where the camera used to render the texture is set
  104843. */
  104844. boundingBoxPosition: Vector3;
  104845. private _boundingBoxSize;
  104846. /**
  104847. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104848. * When defined, the cubemap will switch to local mode
  104849. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104850. * @example https://www.babylonjs-playground.com/#RNASML
  104851. */
  104852. set boundingBoxSize(value: Vector3);
  104853. get boundingBoxSize(): Vector3;
  104854. /**
  104855. * In case the RTT has been created with a depth texture, get the associated
  104856. * depth texture.
  104857. * Otherwise, return null.
  104858. */
  104859. get depthStencilTexture(): Nullable<InternalTexture>;
  104860. /**
  104861. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104862. * or used a shadow, depth texture...
  104863. * @param name The friendly name of the texture
  104864. * @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)
  104865. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104866. * @param generateMipMaps True if mip maps need to be generated after render.
  104867. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104868. * @param type The type of the buffer in the RTT (int, half float, float...)
  104869. * @param isCube True if a cube texture needs to be created
  104870. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104871. * @param generateDepthBuffer True to generate a depth buffer
  104872. * @param generateStencilBuffer True to generate a stencil buffer
  104873. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104874. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104875. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104876. */
  104877. constructor(name: string, size: number | {
  104878. width: number;
  104879. height: number;
  104880. layers?: number;
  104881. } | {
  104882. ratio: number;
  104883. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104884. /**
  104885. * Creates a depth stencil texture.
  104886. * This is only available in WebGL 2 or with the depth texture extension available.
  104887. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104888. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104889. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104890. */
  104891. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104892. private _processSizeParameter;
  104893. /**
  104894. * Define the number of samples to use in case of MSAA.
  104895. * It defaults to one meaning no MSAA has been enabled.
  104896. */
  104897. get samples(): number;
  104898. set samples(value: number);
  104899. /**
  104900. * Resets the refresh counter of the texture and start bak from scratch.
  104901. * Could be useful to regenerate the texture if it is setup to render only once.
  104902. */
  104903. resetRefreshCounter(): void;
  104904. /**
  104905. * Define the refresh rate of the texture or the rendering frequency.
  104906. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104907. */
  104908. get refreshRate(): number;
  104909. set refreshRate(value: number);
  104910. /**
  104911. * Adds a post process to the render target rendering passes.
  104912. * @param postProcess define the post process to add
  104913. */
  104914. addPostProcess(postProcess: PostProcess): void;
  104915. /**
  104916. * Clear all the post processes attached to the render target
  104917. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104918. */
  104919. clearPostProcesses(dispose?: boolean): void;
  104920. /**
  104921. * Remove one of the post process from the list of attached post processes to the texture
  104922. * @param postProcess define the post process to remove from the list
  104923. */
  104924. removePostProcess(postProcess: PostProcess): void;
  104925. /** @hidden */
  104926. _shouldRender(): boolean;
  104927. /**
  104928. * Gets the actual render size of the texture.
  104929. * @returns the width of the render size
  104930. */
  104931. getRenderSize(): number;
  104932. /**
  104933. * Gets the actual render width of the texture.
  104934. * @returns the width of the render size
  104935. */
  104936. getRenderWidth(): number;
  104937. /**
  104938. * Gets the actual render height of the texture.
  104939. * @returns the height of the render size
  104940. */
  104941. getRenderHeight(): number;
  104942. /**
  104943. * Gets the actual number of layers of the texture.
  104944. * @returns the number of layers
  104945. */
  104946. getRenderLayers(): number;
  104947. /**
  104948. * Get if the texture can be rescaled or not.
  104949. */
  104950. get canRescale(): boolean;
  104951. /**
  104952. * Resize the texture using a ratio.
  104953. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104954. */
  104955. scale(ratio: number): void;
  104956. /**
  104957. * Get the texture reflection matrix used to rotate/transform the reflection.
  104958. * @returns the reflection matrix
  104959. */
  104960. getReflectionTextureMatrix(): Matrix;
  104961. /**
  104962. * Resize the texture to a new desired size.
  104963. * Be carrefull as it will recreate all the data in the new texture.
  104964. * @param size Define the new size. It can be:
  104965. * - a number for squared texture,
  104966. * - an object containing { width: number, height: number }
  104967. * - or an object containing a ratio { ratio: number }
  104968. */
  104969. resize(size: number | {
  104970. width: number;
  104971. height: number;
  104972. } | {
  104973. ratio: number;
  104974. }): void;
  104975. private _defaultRenderListPrepared;
  104976. /**
  104977. * Renders all the objects from the render list into the texture.
  104978. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104979. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104980. */
  104981. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104982. private _bestReflectionRenderTargetDimension;
  104983. private _prepareRenderingManager;
  104984. /**
  104985. * @hidden
  104986. * @param faceIndex face index to bind to if this is a cubetexture
  104987. * @param layer defines the index of the texture to bind in the array
  104988. */
  104989. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104990. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104991. private renderToTarget;
  104992. /**
  104993. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104994. * This allowed control for front to back rendering or reversly depending of the special needs.
  104995. *
  104996. * @param renderingGroupId The rendering group id corresponding to its index
  104997. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104998. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104999. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105000. */
  105001. 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;
  105002. /**
  105003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105004. *
  105005. * @param renderingGroupId The rendering group id corresponding to its index
  105006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105007. */
  105008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105009. /**
  105010. * Clones the texture.
  105011. * @returns the cloned texture
  105012. */
  105013. clone(): RenderTargetTexture;
  105014. /**
  105015. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  105016. * @returns The JSON representation of the texture
  105017. */
  105018. serialize(): any;
  105019. /**
  105020. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  105021. */
  105022. disposeFramebufferObjects(): void;
  105023. /**
  105024. * Dispose the texture and release its associated resources.
  105025. */
  105026. dispose(): void;
  105027. /** @hidden */
  105028. _rebuild(): void;
  105029. /**
  105030. * Clear the info related to rendering groups preventing retention point in material dispose.
  105031. */
  105032. freeRenderingGroups(): void;
  105033. /**
  105034. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  105035. * @returns the view count
  105036. */
  105037. getViewCount(): number;
  105038. }
  105039. }
  105040. declare module BABYLON {
  105041. /**
  105042. * Class used to manipulate GUIDs
  105043. */
  105044. export class GUID {
  105045. /**
  105046. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105047. * Be aware Math.random() could cause collisions, but:
  105048. * "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"
  105049. * @returns a pseudo random id
  105050. */
  105051. static RandomId(): string;
  105052. }
  105053. }
  105054. declare module BABYLON {
  105055. /**
  105056. * Options to be used when creating a shadow depth material
  105057. */
  105058. export interface IIOptionShadowDepthMaterial {
  105059. /** Variables in the vertex shader code that need to have their names remapped.
  105060. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  105061. * "var_name" should be either: worldPos or vNormalW
  105062. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  105063. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  105064. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  105065. */
  105066. remappedVariables?: string[];
  105067. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  105068. standalone?: boolean;
  105069. }
  105070. /**
  105071. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  105072. */
  105073. export class ShadowDepthWrapper {
  105074. private _scene;
  105075. private _options?;
  105076. private _baseMaterial;
  105077. private _onEffectCreatedObserver;
  105078. private _subMeshToEffect;
  105079. private _subMeshToDepthEffect;
  105080. private _meshes;
  105081. /** @hidden */
  105082. _matriceNames: any;
  105083. /** Gets the standalone status of the wrapper */
  105084. get standalone(): boolean;
  105085. /** Gets the base material the wrapper is built upon */
  105086. get baseMaterial(): Material;
  105087. /**
  105088. * Instantiate a new shadow depth wrapper.
  105089. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  105090. * generate the shadow depth map. For more information, please refer to the documentation:
  105091. * https://doc.babylonjs.com/babylon101/shadows
  105092. * @param baseMaterial Material to wrap
  105093. * @param scene Define the scene the material belongs to
  105094. * @param options Options used to create the wrapper
  105095. */
  105096. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  105097. /**
  105098. * Gets the effect to use to generate the depth map
  105099. * @param subMesh subMesh to get the effect for
  105100. * @param shadowGenerator shadow generator to get the effect for
  105101. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  105102. */
  105103. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  105104. /**
  105105. * Specifies that the submesh is ready to be used for depth rendering
  105106. * @param subMesh submesh to check
  105107. * @param defines the list of defines to take into account when checking the effect
  105108. * @param shadowGenerator combined with subMesh, it defines the effect to check
  105109. * @param useInstances specifies that instances should be used
  105110. * @returns a boolean indicating that the submesh is ready or not
  105111. */
  105112. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  105113. /**
  105114. * Disposes the resources
  105115. */
  105116. dispose(): void;
  105117. private _makeEffect;
  105118. }
  105119. }
  105120. declare module BABYLON {
  105121. /**
  105122. * Options for compiling materials.
  105123. */
  105124. export interface IMaterialCompilationOptions {
  105125. /**
  105126. * Defines whether clip planes are enabled.
  105127. */
  105128. clipPlane: boolean;
  105129. /**
  105130. * Defines whether instances are enabled.
  105131. */
  105132. useInstances: boolean;
  105133. }
  105134. /**
  105135. * Options passed when calling customShaderNameResolve
  105136. */
  105137. export interface ICustomShaderNameResolveOptions {
  105138. /**
  105139. * 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
  105140. */
  105141. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  105142. }
  105143. /**
  105144. * Base class for the main features of a material in Babylon.js
  105145. */
  105146. export class Material implements IAnimatable {
  105147. /**
  105148. * Returns the triangle fill mode
  105149. */
  105150. static readonly TriangleFillMode: number;
  105151. /**
  105152. * Returns the wireframe mode
  105153. */
  105154. static readonly WireFrameFillMode: number;
  105155. /**
  105156. * Returns the point fill mode
  105157. */
  105158. static readonly PointFillMode: number;
  105159. /**
  105160. * Returns the point list draw mode
  105161. */
  105162. static readonly PointListDrawMode: number;
  105163. /**
  105164. * Returns the line list draw mode
  105165. */
  105166. static readonly LineListDrawMode: number;
  105167. /**
  105168. * Returns the line loop draw mode
  105169. */
  105170. static readonly LineLoopDrawMode: number;
  105171. /**
  105172. * Returns the line strip draw mode
  105173. */
  105174. static readonly LineStripDrawMode: number;
  105175. /**
  105176. * Returns the triangle strip draw mode
  105177. */
  105178. static readonly TriangleStripDrawMode: number;
  105179. /**
  105180. * Returns the triangle fan draw mode
  105181. */
  105182. static readonly TriangleFanDrawMode: number;
  105183. /**
  105184. * Stores the clock-wise side orientation
  105185. */
  105186. static readonly ClockWiseSideOrientation: number;
  105187. /**
  105188. * Stores the counter clock-wise side orientation
  105189. */
  105190. static readonly CounterClockWiseSideOrientation: number;
  105191. /**
  105192. * The dirty texture flag value
  105193. */
  105194. static readonly TextureDirtyFlag: number;
  105195. /**
  105196. * The dirty light flag value
  105197. */
  105198. static readonly LightDirtyFlag: number;
  105199. /**
  105200. * The dirty fresnel flag value
  105201. */
  105202. static readonly FresnelDirtyFlag: number;
  105203. /**
  105204. * The dirty attribute flag value
  105205. */
  105206. static readonly AttributesDirtyFlag: number;
  105207. /**
  105208. * The dirty misc flag value
  105209. */
  105210. static readonly MiscDirtyFlag: number;
  105211. /**
  105212. * The dirty prepass flag value
  105213. */
  105214. static readonly PrePassDirtyFlag: number;
  105215. /**
  105216. * The all dirty flag value
  105217. */
  105218. static readonly AllDirtyFlag: number;
  105219. /**
  105220. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105221. */
  105222. static readonly MATERIAL_OPAQUE: number;
  105223. /**
  105224. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105225. */
  105226. static readonly MATERIAL_ALPHATEST: number;
  105227. /**
  105228. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105229. */
  105230. static readonly MATERIAL_ALPHABLEND: number;
  105231. /**
  105232. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105233. * They are also discarded below the alpha cutoff threshold to improve performances.
  105234. */
  105235. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  105236. /**
  105237. * The Whiteout method is used to blend normals.
  105238. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105239. */
  105240. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  105241. /**
  105242. * The Reoriented Normal Mapping method is used to blend normals.
  105243. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105244. */
  105245. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  105246. /**
  105247. * Custom callback helping to override the default shader used in the material.
  105248. */
  105249. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  105250. /**
  105251. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  105252. */
  105253. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  105254. /**
  105255. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  105256. * This means that the material can keep using a previous shader while a new one is being compiled.
  105257. * This is mostly used when shader parallel compilation is supported (true by default)
  105258. */
  105259. allowShaderHotSwapping: boolean;
  105260. /**
  105261. * The ID of the material
  105262. */
  105263. id: string;
  105264. /**
  105265. * Gets or sets the unique id of the material
  105266. */
  105267. uniqueId: number;
  105268. /**
  105269. * The name of the material
  105270. */
  105271. name: string;
  105272. /**
  105273. * Gets or sets user defined metadata
  105274. */
  105275. metadata: any;
  105276. /**
  105277. * For internal use only. Please do not use.
  105278. */
  105279. reservedDataStore: any;
  105280. /**
  105281. * Specifies if the ready state should be checked on each call
  105282. */
  105283. checkReadyOnEveryCall: boolean;
  105284. /**
  105285. * Specifies if the ready state should be checked once
  105286. */
  105287. checkReadyOnlyOnce: boolean;
  105288. /**
  105289. * The state of the material
  105290. */
  105291. state: string;
  105292. /**
  105293. * If the material can be rendered to several textures with MRT extension
  105294. */
  105295. get canRenderToMRT(): boolean;
  105296. /**
  105297. * The alpha value of the material
  105298. */
  105299. protected _alpha: number;
  105300. /**
  105301. * List of inspectable custom properties (used by the Inspector)
  105302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105303. */
  105304. inspectableCustomProperties: IInspectable[];
  105305. /**
  105306. * Sets the alpha value of the material
  105307. */
  105308. set alpha(value: number);
  105309. /**
  105310. * Gets the alpha value of the material
  105311. */
  105312. get alpha(): number;
  105313. /**
  105314. * Specifies if back face culling is enabled
  105315. */
  105316. protected _backFaceCulling: boolean;
  105317. /**
  105318. * Sets the back-face culling state
  105319. */
  105320. set backFaceCulling(value: boolean);
  105321. /**
  105322. * Gets the back-face culling state
  105323. */
  105324. get backFaceCulling(): boolean;
  105325. /**
  105326. * Stores the value for side orientation
  105327. */
  105328. sideOrientation: number;
  105329. /**
  105330. * Callback triggered when the material is compiled
  105331. */
  105332. onCompiled: Nullable<(effect: Effect) => void>;
  105333. /**
  105334. * Callback triggered when an error occurs
  105335. */
  105336. onError: Nullable<(effect: Effect, errors: string) => void>;
  105337. /**
  105338. * Callback triggered to get the render target textures
  105339. */
  105340. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105341. /**
  105342. * Gets a boolean indicating that current material needs to register RTT
  105343. */
  105344. get hasRenderTargetTextures(): boolean;
  105345. /**
  105346. * Specifies if the material should be serialized
  105347. */
  105348. doNotSerialize: boolean;
  105349. /**
  105350. * @hidden
  105351. */
  105352. _storeEffectOnSubMeshes: boolean;
  105353. /**
  105354. * Stores the animations for the material
  105355. */
  105356. animations: Nullable<Array<Animation>>;
  105357. /**
  105358. * An event triggered when the material is disposed
  105359. */
  105360. onDisposeObservable: Observable<Material>;
  105361. /**
  105362. * An observer which watches for dispose events
  105363. */
  105364. private _onDisposeObserver;
  105365. private _onUnBindObservable;
  105366. /**
  105367. * Called during a dispose event
  105368. */
  105369. set onDispose(callback: () => void);
  105370. private _onBindObservable;
  105371. /**
  105372. * An event triggered when the material is bound
  105373. */
  105374. get onBindObservable(): Observable<AbstractMesh>;
  105375. /**
  105376. * An observer which watches for bind events
  105377. */
  105378. private _onBindObserver;
  105379. /**
  105380. * Called during a bind event
  105381. */
  105382. set onBind(callback: (Mesh: AbstractMesh) => void);
  105383. /**
  105384. * An event triggered when the material is unbound
  105385. */
  105386. get onUnBindObservable(): Observable<Material>;
  105387. protected _onEffectCreatedObservable: Nullable<Observable<{
  105388. effect: Effect;
  105389. subMesh: Nullable<SubMesh>;
  105390. }>>;
  105391. /**
  105392. * An event triggered when the effect is (re)created
  105393. */
  105394. get onEffectCreatedObservable(): Observable<{
  105395. effect: Effect;
  105396. subMesh: Nullable<SubMesh>;
  105397. }>;
  105398. /**
  105399. * Stores the value of the alpha mode
  105400. */
  105401. private _alphaMode;
  105402. /**
  105403. * Sets the value of the alpha mode.
  105404. *
  105405. * | Value | Type | Description |
  105406. * | --- | --- | --- |
  105407. * | 0 | ALPHA_DISABLE | |
  105408. * | 1 | ALPHA_ADD | |
  105409. * | 2 | ALPHA_COMBINE | |
  105410. * | 3 | ALPHA_SUBTRACT | |
  105411. * | 4 | ALPHA_MULTIPLY | |
  105412. * | 5 | ALPHA_MAXIMIZED | |
  105413. * | 6 | ALPHA_ONEONE | |
  105414. * | 7 | ALPHA_PREMULTIPLIED | |
  105415. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105416. * | 9 | ALPHA_INTERPOLATE | |
  105417. * | 10 | ALPHA_SCREENMODE | |
  105418. *
  105419. */
  105420. set alphaMode(value: number);
  105421. /**
  105422. * Gets the value of the alpha mode
  105423. */
  105424. get alphaMode(): number;
  105425. /**
  105426. * Stores the state of the need depth pre-pass value
  105427. */
  105428. private _needDepthPrePass;
  105429. /**
  105430. * Sets the need depth pre-pass value
  105431. */
  105432. set needDepthPrePass(value: boolean);
  105433. /**
  105434. * Gets the depth pre-pass value
  105435. */
  105436. get needDepthPrePass(): boolean;
  105437. /**
  105438. * Specifies if depth writing should be disabled
  105439. */
  105440. disableDepthWrite: boolean;
  105441. /**
  105442. * Specifies if color writing should be disabled
  105443. */
  105444. disableColorWrite: boolean;
  105445. /**
  105446. * Specifies if depth writing should be forced
  105447. */
  105448. forceDepthWrite: boolean;
  105449. /**
  105450. * Specifies the depth function that should be used. 0 means the default engine function
  105451. */
  105452. depthFunction: number;
  105453. /**
  105454. * Specifies if there should be a separate pass for culling
  105455. */
  105456. separateCullingPass: boolean;
  105457. /**
  105458. * Stores the state specifing if fog should be enabled
  105459. */
  105460. private _fogEnabled;
  105461. /**
  105462. * Sets the state for enabling fog
  105463. */
  105464. set fogEnabled(value: boolean);
  105465. /**
  105466. * Gets the value of the fog enabled state
  105467. */
  105468. get fogEnabled(): boolean;
  105469. /**
  105470. * Stores the size of points
  105471. */
  105472. pointSize: number;
  105473. /**
  105474. * Stores the z offset value
  105475. */
  105476. zOffset: number;
  105477. get wireframe(): boolean;
  105478. /**
  105479. * Sets the state of wireframe mode
  105480. */
  105481. set wireframe(value: boolean);
  105482. /**
  105483. * Gets the value specifying if point clouds are enabled
  105484. */
  105485. get pointsCloud(): boolean;
  105486. /**
  105487. * Sets the state of point cloud mode
  105488. */
  105489. set pointsCloud(value: boolean);
  105490. /**
  105491. * Gets the material fill mode
  105492. */
  105493. get fillMode(): number;
  105494. /**
  105495. * Sets the material fill mode
  105496. */
  105497. set fillMode(value: number);
  105498. /**
  105499. * @hidden
  105500. * Stores the effects for the material
  105501. */
  105502. _effect: Nullable<Effect>;
  105503. /**
  105504. * Specifies if uniform buffers should be used
  105505. */
  105506. private _useUBO;
  105507. /**
  105508. * Stores a reference to the scene
  105509. */
  105510. private _scene;
  105511. /**
  105512. * Stores the fill mode state
  105513. */
  105514. private _fillMode;
  105515. /**
  105516. * Specifies if the depth write state should be cached
  105517. */
  105518. private _cachedDepthWriteState;
  105519. /**
  105520. * Specifies if the color write state should be cached
  105521. */
  105522. private _cachedColorWriteState;
  105523. /**
  105524. * Specifies if the depth function state should be cached
  105525. */
  105526. private _cachedDepthFunctionState;
  105527. /**
  105528. * Stores the uniform buffer
  105529. */
  105530. protected _uniformBuffer: UniformBuffer;
  105531. /** @hidden */
  105532. _indexInSceneMaterialArray: number;
  105533. /** @hidden */
  105534. meshMap: Nullable<{
  105535. [id: string]: AbstractMesh | undefined;
  105536. }>;
  105537. /**
  105538. * Creates a material instance
  105539. * @param name defines the name of the material
  105540. * @param scene defines the scene to reference
  105541. * @param doNotAdd specifies if the material should be added to the scene
  105542. */
  105543. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105544. /**
  105545. * Returns a string representation of the current material
  105546. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105547. * @returns a string with material information
  105548. */
  105549. toString(fullDetails?: boolean): string;
  105550. /**
  105551. * Gets the class name of the material
  105552. * @returns a string with the class name of the material
  105553. */
  105554. getClassName(): string;
  105555. /**
  105556. * Specifies if updates for the material been locked
  105557. */
  105558. get isFrozen(): boolean;
  105559. /**
  105560. * Locks updates for the material
  105561. */
  105562. freeze(): void;
  105563. /**
  105564. * Unlocks updates for the material
  105565. */
  105566. unfreeze(): void;
  105567. /**
  105568. * Specifies if the material is ready to be used
  105569. * @param mesh defines the mesh to check
  105570. * @param useInstances specifies if instances should be used
  105571. * @returns a boolean indicating if the material is ready to be used
  105572. */
  105573. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105574. /**
  105575. * Specifies that the submesh is ready to be used
  105576. * @param mesh defines the mesh to check
  105577. * @param subMesh defines which submesh to check
  105578. * @param useInstances specifies that instances should be used
  105579. * @returns a boolean indicating that the submesh is ready or not
  105580. */
  105581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105582. /**
  105583. * Returns the material effect
  105584. * @returns the effect associated with the material
  105585. */
  105586. getEffect(): Nullable<Effect>;
  105587. /**
  105588. * Returns the current scene
  105589. * @returns a Scene
  105590. */
  105591. getScene(): Scene;
  105592. /**
  105593. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105594. */
  105595. protected _forceAlphaTest: boolean;
  105596. /**
  105597. * The transparency mode of the material.
  105598. */
  105599. protected _transparencyMode: Nullable<number>;
  105600. /**
  105601. * Gets the current transparency mode.
  105602. */
  105603. get transparencyMode(): Nullable<number>;
  105604. /**
  105605. * Sets the transparency mode of the material.
  105606. *
  105607. * | Value | Type | Description |
  105608. * | ----- | ----------------------------------- | ----------- |
  105609. * | 0 | OPAQUE | |
  105610. * | 1 | ALPHATEST | |
  105611. * | 2 | ALPHABLEND | |
  105612. * | 3 | ALPHATESTANDBLEND | |
  105613. *
  105614. */
  105615. set transparencyMode(value: Nullable<number>);
  105616. /**
  105617. * Returns true if alpha blending should be disabled.
  105618. */
  105619. protected get _disableAlphaBlending(): boolean;
  105620. /**
  105621. * Specifies whether or not this material should be rendered in alpha blend mode.
  105622. * @returns a boolean specifying if alpha blending is needed
  105623. */
  105624. needAlphaBlending(): boolean;
  105625. /**
  105626. * Specifies if the mesh will require alpha blending
  105627. * @param mesh defines the mesh to check
  105628. * @returns a boolean specifying if alpha blending is needed for the mesh
  105629. */
  105630. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105631. /**
  105632. * Specifies whether or not this material should be rendered in alpha test mode.
  105633. * @returns a boolean specifying if an alpha test is needed.
  105634. */
  105635. needAlphaTesting(): boolean;
  105636. /**
  105637. * Specifies if material alpha testing should be turned on for the mesh
  105638. * @param mesh defines the mesh to check
  105639. */
  105640. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105641. /**
  105642. * Gets the texture used for the alpha test
  105643. * @returns the texture to use for alpha testing
  105644. */
  105645. getAlphaTestTexture(): Nullable<BaseTexture>;
  105646. /**
  105647. * Marks the material to indicate that it needs to be re-calculated
  105648. */
  105649. markDirty(): void;
  105650. /** @hidden */
  105651. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105652. /**
  105653. * Binds the material to the mesh
  105654. * @param world defines the world transformation matrix
  105655. * @param mesh defines the mesh to bind the material to
  105656. */
  105657. bind(world: Matrix, mesh?: Mesh): void;
  105658. /**
  105659. * Binds the submesh to the material
  105660. * @param world defines the world transformation matrix
  105661. * @param mesh defines the mesh containing the submesh
  105662. * @param subMesh defines the submesh to bind the material to
  105663. */
  105664. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105665. /**
  105666. * Binds the world matrix to the material
  105667. * @param world defines the world transformation matrix
  105668. */
  105669. bindOnlyWorldMatrix(world: Matrix): void;
  105670. /**
  105671. * Binds the scene's uniform buffer to the effect.
  105672. * @param effect defines the effect to bind to the scene uniform buffer
  105673. * @param sceneUbo defines the uniform buffer storing scene data
  105674. */
  105675. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105676. /**
  105677. * Binds the view matrix to the effect
  105678. * @param effect defines the effect to bind the view matrix to
  105679. */
  105680. bindView(effect: Effect): void;
  105681. /**
  105682. * Binds the view projection matrix to the effect
  105683. * @param effect defines the effect to bind the view projection matrix to
  105684. */
  105685. bindViewProjection(effect: Effect): void;
  105686. /**
  105687. * Processes to execute after binding the material to a mesh
  105688. * @param mesh defines the rendered mesh
  105689. */
  105690. protected _afterBind(mesh?: Mesh): void;
  105691. /**
  105692. * Unbinds the material from the mesh
  105693. */
  105694. unbind(): void;
  105695. /**
  105696. * Gets the active textures from the material
  105697. * @returns an array of textures
  105698. */
  105699. getActiveTextures(): BaseTexture[];
  105700. /**
  105701. * Specifies if the material uses a texture
  105702. * @param texture defines the texture to check against the material
  105703. * @returns a boolean specifying if the material uses the texture
  105704. */
  105705. hasTexture(texture: BaseTexture): boolean;
  105706. /**
  105707. * Makes a duplicate of the material, and gives it a new name
  105708. * @param name defines the new name for the duplicated material
  105709. * @returns the cloned material
  105710. */
  105711. clone(name: string): Nullable<Material>;
  105712. /**
  105713. * Gets the meshes bound to the material
  105714. * @returns an array of meshes bound to the material
  105715. */
  105716. getBindedMeshes(): AbstractMesh[];
  105717. /**
  105718. * Force shader compilation
  105719. * @param mesh defines the mesh associated with this material
  105720. * @param onCompiled defines a function to execute once the material is compiled
  105721. * @param options defines the options to configure the compilation
  105722. * @param onError defines a function to execute if the material fails compiling
  105723. */
  105724. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105725. /**
  105726. * Force shader compilation
  105727. * @param mesh defines the mesh that will use this material
  105728. * @param options defines additional options for compiling the shaders
  105729. * @returns a promise that resolves when the compilation completes
  105730. */
  105731. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105732. private static readonly _AllDirtyCallBack;
  105733. private static readonly _ImageProcessingDirtyCallBack;
  105734. private static readonly _TextureDirtyCallBack;
  105735. private static readonly _FresnelDirtyCallBack;
  105736. private static readonly _MiscDirtyCallBack;
  105737. private static readonly _PrePassDirtyCallBack;
  105738. private static readonly _LightsDirtyCallBack;
  105739. private static readonly _AttributeDirtyCallBack;
  105740. private static _FresnelAndMiscDirtyCallBack;
  105741. private static _TextureAndMiscDirtyCallBack;
  105742. private static readonly _DirtyCallbackArray;
  105743. private static readonly _RunDirtyCallBacks;
  105744. /**
  105745. * Marks a define in the material to indicate that it needs to be re-computed
  105746. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105747. */
  105748. markAsDirty(flag: number): void;
  105749. /**
  105750. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105751. * @param func defines a function which checks material defines against the submeshes
  105752. */
  105753. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105754. /**
  105755. * Indicates that the scene should check if the rendering now needs a prepass
  105756. */
  105757. protected _markScenePrePassDirty(): void;
  105758. /**
  105759. * Indicates that we need to re-calculated for all submeshes
  105760. */
  105761. protected _markAllSubMeshesAsAllDirty(): void;
  105762. /**
  105763. * Indicates that image processing needs to be re-calculated for all submeshes
  105764. */
  105765. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105766. /**
  105767. * Indicates that textures need to be re-calculated for all submeshes
  105768. */
  105769. protected _markAllSubMeshesAsTexturesDirty(): void;
  105770. /**
  105771. * Indicates that fresnel needs to be re-calculated for all submeshes
  105772. */
  105773. protected _markAllSubMeshesAsFresnelDirty(): void;
  105774. /**
  105775. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105776. */
  105777. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105778. /**
  105779. * Indicates that lights need to be re-calculated for all submeshes
  105780. */
  105781. protected _markAllSubMeshesAsLightsDirty(): void;
  105782. /**
  105783. * Indicates that attributes need to be re-calculated for all submeshes
  105784. */
  105785. protected _markAllSubMeshesAsAttributesDirty(): void;
  105786. /**
  105787. * Indicates that misc needs to be re-calculated for all submeshes
  105788. */
  105789. protected _markAllSubMeshesAsMiscDirty(): void;
  105790. /**
  105791. * Indicates that prepass needs to be re-calculated for all submeshes
  105792. */
  105793. protected _markAllSubMeshesAsPrePassDirty(): void;
  105794. /**
  105795. * Indicates that textures and misc need to be re-calculated for all submeshes
  105796. */
  105797. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105798. /**
  105799. * Sets the required values to the prepass renderer.
  105800. * @param prePassRenderer defines the prepass renderer to setup.
  105801. * @returns true if the pre pass is needed.
  105802. */
  105803. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105804. /**
  105805. * Disposes the material
  105806. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105807. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105808. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105809. */
  105810. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105811. /** @hidden */
  105812. private releaseVertexArrayObject;
  105813. /**
  105814. * Serializes this material
  105815. * @returns the serialized material object
  105816. */
  105817. serialize(): any;
  105818. /**
  105819. * Creates a material from parsed material data
  105820. * @param parsedMaterial defines parsed material data
  105821. * @param scene defines the hosting scene
  105822. * @param rootUrl defines the root URL to use to load textures
  105823. * @returns a new material
  105824. */
  105825. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105826. }
  105827. }
  105828. declare module BABYLON {
  105829. /**
  105830. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105831. * separate meshes. This can be use to improve performances.
  105832. * @see https://doc.babylonjs.com/how_to/multi_materials
  105833. */
  105834. export class MultiMaterial extends Material {
  105835. private _subMaterials;
  105836. /**
  105837. * Gets or Sets the list of Materials used within the multi material.
  105838. * They need to be ordered according to the submeshes order in the associated mesh
  105839. */
  105840. get subMaterials(): Nullable<Material>[];
  105841. set subMaterials(value: Nullable<Material>[]);
  105842. /**
  105843. * Function used to align with Node.getChildren()
  105844. * @returns the list of Materials used within the multi material
  105845. */
  105846. getChildren(): Nullable<Material>[];
  105847. /**
  105848. * Instantiates a new Multi Material
  105849. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105850. * separate meshes. This can be use to improve performances.
  105851. * @see https://doc.babylonjs.com/how_to/multi_materials
  105852. * @param name Define the name in the scene
  105853. * @param scene Define the scene the material belongs to
  105854. */
  105855. constructor(name: string, scene: Scene);
  105856. private _hookArray;
  105857. /**
  105858. * Get one of the submaterial by its index in the submaterials array
  105859. * @param index The index to look the sub material at
  105860. * @returns The Material if the index has been defined
  105861. */
  105862. getSubMaterial(index: number): Nullable<Material>;
  105863. /**
  105864. * Get the list of active textures for the whole sub materials list.
  105865. * @returns All the textures that will be used during the rendering
  105866. */
  105867. getActiveTextures(): BaseTexture[];
  105868. /**
  105869. * Gets the current class name of the material e.g. "MultiMaterial"
  105870. * Mainly use in serialization.
  105871. * @returns the class name
  105872. */
  105873. getClassName(): string;
  105874. /**
  105875. * Checks if the material is ready to render the requested sub mesh
  105876. * @param mesh Define the mesh the submesh belongs to
  105877. * @param subMesh Define the sub mesh to look readyness for
  105878. * @param useInstances Define whether or not the material is used with instances
  105879. * @returns true if ready, otherwise false
  105880. */
  105881. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105882. /**
  105883. * Clones the current material and its related sub materials
  105884. * @param name Define the name of the newly cloned material
  105885. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105886. * @returns the cloned material
  105887. */
  105888. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105889. /**
  105890. * Serializes the materials into a JSON representation.
  105891. * @returns the JSON representation
  105892. */
  105893. serialize(): any;
  105894. /**
  105895. * Dispose the material and release its associated resources
  105896. * @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)
  105897. * @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)
  105898. * @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)
  105899. */
  105900. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105901. /**
  105902. * Creates a MultiMaterial from parsed MultiMaterial data.
  105903. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105904. * @param scene defines the hosting scene
  105905. * @returns a new MultiMaterial
  105906. */
  105907. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105908. }
  105909. }
  105910. declare module BABYLON {
  105911. /**
  105912. * Defines a subdivision inside a mesh
  105913. */
  105914. export class SubMesh implements ICullable {
  105915. /** the material index to use */
  105916. materialIndex: number;
  105917. /** vertex index start */
  105918. verticesStart: number;
  105919. /** vertices count */
  105920. verticesCount: number;
  105921. /** index start */
  105922. indexStart: number;
  105923. /** indices count */
  105924. indexCount: number;
  105925. /** @hidden */
  105926. _materialDefines: Nullable<MaterialDefines>;
  105927. /** @hidden */
  105928. _materialEffect: Nullable<Effect>;
  105929. /** @hidden */
  105930. _effectOverride: Nullable<Effect>;
  105931. /**
  105932. * Gets material defines used by the effect associated to the sub mesh
  105933. */
  105934. get materialDefines(): Nullable<MaterialDefines>;
  105935. /**
  105936. * Sets material defines used by the effect associated to the sub mesh
  105937. */
  105938. set materialDefines(defines: Nullable<MaterialDefines>);
  105939. /**
  105940. * Gets associated effect
  105941. */
  105942. get effect(): Nullable<Effect>;
  105943. /**
  105944. * Sets associated effect (effect used to render this submesh)
  105945. * @param effect defines the effect to associate with
  105946. * @param defines defines the set of defines used to compile this effect
  105947. */
  105948. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105949. /** @hidden */
  105950. _linesIndexCount: number;
  105951. private _mesh;
  105952. private _renderingMesh;
  105953. private _boundingInfo;
  105954. private _linesIndexBuffer;
  105955. /** @hidden */
  105956. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105957. /** @hidden */
  105958. _trianglePlanes: Plane[];
  105959. /** @hidden */
  105960. _lastColliderTransformMatrix: Nullable<Matrix>;
  105961. /** @hidden */
  105962. _renderId: number;
  105963. /** @hidden */
  105964. _alphaIndex: number;
  105965. /** @hidden */
  105966. _distanceToCamera: number;
  105967. /** @hidden */
  105968. _id: number;
  105969. private _currentMaterial;
  105970. /**
  105971. * Add a new submesh to a mesh
  105972. * @param materialIndex defines the material index to use
  105973. * @param verticesStart defines vertex index start
  105974. * @param verticesCount defines vertices count
  105975. * @param indexStart defines index start
  105976. * @param indexCount defines indices count
  105977. * @param mesh defines the parent mesh
  105978. * @param renderingMesh defines an optional rendering mesh
  105979. * @param createBoundingBox defines if bounding box should be created for this submesh
  105980. * @returns the new submesh
  105981. */
  105982. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105983. /**
  105984. * Creates a new submesh
  105985. * @param materialIndex defines the material index to use
  105986. * @param verticesStart defines vertex index start
  105987. * @param verticesCount defines vertices count
  105988. * @param indexStart defines index start
  105989. * @param indexCount defines indices count
  105990. * @param mesh defines the parent mesh
  105991. * @param renderingMesh defines an optional rendering mesh
  105992. * @param createBoundingBox defines if bounding box should be created for this submesh
  105993. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105994. */
  105995. constructor(
  105996. /** the material index to use */
  105997. materialIndex: number,
  105998. /** vertex index start */
  105999. verticesStart: number,
  106000. /** vertices count */
  106001. verticesCount: number,
  106002. /** index start */
  106003. indexStart: number,
  106004. /** indices count */
  106005. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  106006. /**
  106007. * Returns true if this submesh covers the entire parent mesh
  106008. * @ignorenaming
  106009. */
  106010. get IsGlobal(): boolean;
  106011. /**
  106012. * Returns the submesh BoudingInfo object
  106013. * @returns current bounding info (or mesh's one if the submesh is global)
  106014. */
  106015. getBoundingInfo(): BoundingInfo;
  106016. /**
  106017. * Sets the submesh BoundingInfo
  106018. * @param boundingInfo defines the new bounding info to use
  106019. * @returns the SubMesh
  106020. */
  106021. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  106022. /**
  106023. * Returns the mesh of the current submesh
  106024. * @return the parent mesh
  106025. */
  106026. getMesh(): AbstractMesh;
  106027. /**
  106028. * Returns the rendering mesh of the submesh
  106029. * @returns the rendering mesh (could be different from parent mesh)
  106030. */
  106031. getRenderingMesh(): Mesh;
  106032. /**
  106033. * Returns the replacement mesh of the submesh
  106034. * @returns the replacement mesh (could be different from parent mesh)
  106035. */
  106036. getReplacementMesh(): Nullable<AbstractMesh>;
  106037. /**
  106038. * Returns the effective mesh of the submesh
  106039. * @returns the effective mesh (could be different from parent mesh)
  106040. */
  106041. getEffectiveMesh(): AbstractMesh;
  106042. /**
  106043. * Returns the submesh material
  106044. * @returns null or the current material
  106045. */
  106046. getMaterial(): Nullable<Material>;
  106047. private _IsMultiMaterial;
  106048. /**
  106049. * Sets a new updated BoundingInfo object to the submesh
  106050. * @param data defines an optional position array to use to determine the bounding info
  106051. * @returns the SubMesh
  106052. */
  106053. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  106054. /** @hidden */
  106055. _checkCollision(collider: Collider): boolean;
  106056. /**
  106057. * Updates the submesh BoundingInfo
  106058. * @param world defines the world matrix to use to update the bounding info
  106059. * @returns the submesh
  106060. */
  106061. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  106062. /**
  106063. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  106064. * @param frustumPlanes defines the frustum planes
  106065. * @returns true if the submesh is intersecting with the frustum
  106066. */
  106067. isInFrustum(frustumPlanes: Plane[]): boolean;
  106068. /**
  106069. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  106070. * @param frustumPlanes defines the frustum planes
  106071. * @returns true if the submesh is inside the frustum
  106072. */
  106073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  106074. /**
  106075. * Renders the submesh
  106076. * @param enableAlphaMode defines if alpha needs to be used
  106077. * @returns the submesh
  106078. */
  106079. render(enableAlphaMode: boolean): SubMesh;
  106080. /**
  106081. * @hidden
  106082. */
  106083. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  106084. /**
  106085. * Checks if the submesh intersects with a ray
  106086. * @param ray defines the ray to test
  106087. * @returns true is the passed ray intersects the submesh bounding box
  106088. */
  106089. canIntersects(ray: Ray): boolean;
  106090. /**
  106091. * Intersects current submesh with a ray
  106092. * @param ray defines the ray to test
  106093. * @param positions defines mesh's positions array
  106094. * @param indices defines mesh's indices array
  106095. * @param fastCheck defines if the first intersection will be used (and not the closest)
  106096. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106097. * @returns intersection info or null if no intersection
  106098. */
  106099. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  106100. /** @hidden */
  106101. private _intersectLines;
  106102. /** @hidden */
  106103. private _intersectUnIndexedLines;
  106104. /** @hidden */
  106105. private _intersectTriangles;
  106106. /** @hidden */
  106107. private _intersectUnIndexedTriangles;
  106108. /** @hidden */
  106109. _rebuild(): void;
  106110. /**
  106111. * Creates a new submesh from the passed mesh
  106112. * @param newMesh defines the new hosting mesh
  106113. * @param newRenderingMesh defines an optional rendering mesh
  106114. * @returns the new submesh
  106115. */
  106116. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  106117. /**
  106118. * Release associated resources
  106119. */
  106120. dispose(): void;
  106121. /**
  106122. * Gets the class name
  106123. * @returns the string "SubMesh".
  106124. */
  106125. getClassName(): string;
  106126. /**
  106127. * Creates a new submesh from indices data
  106128. * @param materialIndex the index of the main mesh material
  106129. * @param startIndex the index where to start the copy in the mesh indices array
  106130. * @param indexCount the number of indices to copy then from the startIndex
  106131. * @param mesh the main mesh to create the submesh from
  106132. * @param renderingMesh the optional rendering mesh
  106133. * @returns a new submesh
  106134. */
  106135. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  106136. }
  106137. }
  106138. declare module BABYLON {
  106139. /**
  106140. * Class used to represent data loading progression
  106141. */
  106142. export class SceneLoaderFlags {
  106143. private static _ForceFullSceneLoadingForIncremental;
  106144. private static _ShowLoadingScreen;
  106145. private static _CleanBoneMatrixWeights;
  106146. private static _loggingLevel;
  106147. /**
  106148. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106149. */
  106150. static get ForceFullSceneLoadingForIncremental(): boolean;
  106151. static set ForceFullSceneLoadingForIncremental(value: boolean);
  106152. /**
  106153. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106154. */
  106155. static get ShowLoadingScreen(): boolean;
  106156. static set ShowLoadingScreen(value: boolean);
  106157. /**
  106158. * Defines the current logging level (while loading the scene)
  106159. * @ignorenaming
  106160. */
  106161. static get loggingLevel(): number;
  106162. static set loggingLevel(value: number);
  106163. /**
  106164. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106165. */
  106166. static get CleanBoneMatrixWeights(): boolean;
  106167. static set CleanBoneMatrixWeights(value: boolean);
  106168. }
  106169. }
  106170. declare module BABYLON {
  106171. /**
  106172. * Class used to store geometry data (vertex buffers + index buffer)
  106173. */
  106174. export class Geometry implements IGetSetVerticesData {
  106175. /**
  106176. * Gets or sets the ID of the geometry
  106177. */
  106178. id: string;
  106179. /**
  106180. * Gets or sets the unique ID of the geometry
  106181. */
  106182. uniqueId: number;
  106183. /**
  106184. * Gets the delay loading state of the geometry (none by default which means not delayed)
  106185. */
  106186. delayLoadState: number;
  106187. /**
  106188. * Gets the file containing the data to load when running in delay load state
  106189. */
  106190. delayLoadingFile: Nullable<string>;
  106191. /**
  106192. * Callback called when the geometry is updated
  106193. */
  106194. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  106195. private _scene;
  106196. private _engine;
  106197. private _meshes;
  106198. private _totalVertices;
  106199. /** @hidden */
  106200. _indices: IndicesArray;
  106201. /** @hidden */
  106202. _vertexBuffers: {
  106203. [key: string]: VertexBuffer;
  106204. };
  106205. private _isDisposed;
  106206. private _extend;
  106207. private _boundingBias;
  106208. /** @hidden */
  106209. _delayInfo: Array<string>;
  106210. private _indexBuffer;
  106211. private _indexBufferIsUpdatable;
  106212. /** @hidden */
  106213. _boundingInfo: Nullable<BoundingInfo>;
  106214. /** @hidden */
  106215. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  106216. /** @hidden */
  106217. _softwareSkinningFrameId: number;
  106218. private _vertexArrayObjects;
  106219. private _updatable;
  106220. /** @hidden */
  106221. _positions: Nullable<Vector3[]>;
  106222. /**
  106223. * 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
  106224. */
  106225. get boundingBias(): Vector2;
  106226. /**
  106227. * 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
  106228. */
  106229. set boundingBias(value: Vector2);
  106230. /**
  106231. * Static function used to attach a new empty geometry to a mesh
  106232. * @param mesh defines the mesh to attach the geometry to
  106233. * @returns the new Geometry
  106234. */
  106235. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  106236. /** Get the list of meshes using this geometry */
  106237. get meshes(): Mesh[];
  106238. /**
  106239. * 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
  106240. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  106241. */
  106242. useBoundingInfoFromGeometry: boolean;
  106243. /**
  106244. * Creates a new geometry
  106245. * @param id defines the unique ID
  106246. * @param scene defines the hosting scene
  106247. * @param vertexData defines the VertexData used to get geometry data
  106248. * @param updatable defines if geometry must be updatable (false by default)
  106249. * @param mesh defines the mesh that will be associated with the geometry
  106250. */
  106251. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  106252. /**
  106253. * Gets the current extend of the geometry
  106254. */
  106255. get extend(): {
  106256. minimum: Vector3;
  106257. maximum: Vector3;
  106258. };
  106259. /**
  106260. * Gets the hosting scene
  106261. * @returns the hosting Scene
  106262. */
  106263. getScene(): Scene;
  106264. /**
  106265. * Gets the hosting engine
  106266. * @returns the hosting Engine
  106267. */
  106268. getEngine(): Engine;
  106269. /**
  106270. * Defines if the geometry is ready to use
  106271. * @returns true if the geometry is ready to be used
  106272. */
  106273. isReady(): boolean;
  106274. /**
  106275. * Gets a value indicating that the geometry should not be serialized
  106276. */
  106277. get doNotSerialize(): boolean;
  106278. /** @hidden */
  106279. _rebuild(): void;
  106280. /**
  106281. * Affects all geometry data in one call
  106282. * @param vertexData defines the geometry data
  106283. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106284. */
  106285. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106286. /**
  106287. * Set specific vertex data
  106288. * @param kind defines the data kind (Position, normal, etc...)
  106289. * @param data defines the vertex data to use
  106290. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106291. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106292. */
  106293. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106294. /**
  106295. * Removes a specific vertex data
  106296. * @param kind defines the data kind (Position, normal, etc...)
  106297. */
  106298. removeVerticesData(kind: string): void;
  106299. /**
  106300. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106301. * @param buffer defines the vertex buffer to use
  106302. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106303. */
  106304. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106305. /**
  106306. * Update a specific vertex buffer
  106307. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106308. * It will do nothing if the buffer is not updatable
  106309. * @param kind defines the data kind (Position, normal, etc...)
  106310. * @param data defines the data to use
  106311. * @param offset defines the offset in the target buffer where to store the data
  106312. * @param useBytes set to true if the offset is in bytes
  106313. */
  106314. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106315. /**
  106316. * Update a specific vertex buffer
  106317. * This function will create a new buffer if the current one is not updatable
  106318. * @param kind defines the data kind (Position, normal, etc...)
  106319. * @param data defines the data to use
  106320. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106321. */
  106322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106323. private _updateBoundingInfo;
  106324. /** @hidden */
  106325. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106326. /**
  106327. * Gets total number of vertices
  106328. * @returns the total number of vertices
  106329. */
  106330. getTotalVertices(): number;
  106331. /**
  106332. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106333. * @param kind defines the data kind (Position, normal, etc...)
  106334. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106335. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106336. * @returns a float array containing vertex data
  106337. */
  106338. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106339. /**
  106340. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106341. * @param kind defines the data kind (Position, normal, etc...)
  106342. * @returns true if the vertex buffer with the specified kind is updatable
  106343. */
  106344. isVertexBufferUpdatable(kind: string): boolean;
  106345. /**
  106346. * Gets a specific vertex buffer
  106347. * @param kind defines the data kind (Position, normal, etc...)
  106348. * @returns a VertexBuffer
  106349. */
  106350. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106351. /**
  106352. * Returns all vertex buffers
  106353. * @return an object holding all vertex buffers indexed by kind
  106354. */
  106355. getVertexBuffers(): Nullable<{
  106356. [key: string]: VertexBuffer;
  106357. }>;
  106358. /**
  106359. * Gets a boolean indicating if specific vertex buffer is present
  106360. * @param kind defines the data kind (Position, normal, etc...)
  106361. * @returns true if data is present
  106362. */
  106363. isVerticesDataPresent(kind: string): boolean;
  106364. /**
  106365. * Gets a list of all attached data kinds (Position, normal, etc...)
  106366. * @returns a list of string containing all kinds
  106367. */
  106368. getVerticesDataKinds(): string[];
  106369. /**
  106370. * Update index buffer
  106371. * @param indices defines the indices to store in the index buffer
  106372. * @param offset defines the offset in the target buffer where to store the data
  106373. * @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)
  106374. */
  106375. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106376. /**
  106377. * Creates a new index buffer
  106378. * @param indices defines the indices to store in the index buffer
  106379. * @param totalVertices defines the total number of vertices (could be null)
  106380. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106381. */
  106382. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106383. /**
  106384. * Return the total number of indices
  106385. * @returns the total number of indices
  106386. */
  106387. getTotalIndices(): number;
  106388. /**
  106389. * Gets the index buffer array
  106390. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106391. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106392. * @returns the index buffer array
  106393. */
  106394. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106395. /**
  106396. * Gets the index buffer
  106397. * @return the index buffer
  106398. */
  106399. getIndexBuffer(): Nullable<DataBuffer>;
  106400. /** @hidden */
  106401. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106402. /**
  106403. * Release the associated resources for a specific mesh
  106404. * @param mesh defines the source mesh
  106405. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106406. */
  106407. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106408. /**
  106409. * Apply current geometry to a given mesh
  106410. * @param mesh defines the mesh to apply geometry to
  106411. */
  106412. applyToMesh(mesh: Mesh): void;
  106413. private _updateExtend;
  106414. private _applyToMesh;
  106415. private notifyUpdate;
  106416. /**
  106417. * Load the geometry if it was flagged as delay loaded
  106418. * @param scene defines the hosting scene
  106419. * @param onLoaded defines a callback called when the geometry is loaded
  106420. */
  106421. load(scene: Scene, onLoaded?: () => void): void;
  106422. private _queueLoad;
  106423. /**
  106424. * Invert the geometry to move from a right handed system to a left handed one.
  106425. */
  106426. toLeftHanded(): void;
  106427. /** @hidden */
  106428. _resetPointsArrayCache(): void;
  106429. /** @hidden */
  106430. _generatePointsArray(): boolean;
  106431. /**
  106432. * Gets a value indicating if the geometry is disposed
  106433. * @returns true if the geometry was disposed
  106434. */
  106435. isDisposed(): boolean;
  106436. private _disposeVertexArrayObjects;
  106437. /**
  106438. * Free all associated resources
  106439. */
  106440. dispose(): void;
  106441. /**
  106442. * Clone the current geometry into a new geometry
  106443. * @param id defines the unique ID of the new geometry
  106444. * @returns a new geometry object
  106445. */
  106446. copy(id: string): Geometry;
  106447. /**
  106448. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106449. * @return a JSON representation of the current geometry data (without the vertices data)
  106450. */
  106451. serialize(): any;
  106452. private toNumberArray;
  106453. /**
  106454. * Serialize all vertices data into a JSON oject
  106455. * @returns a JSON representation of the current geometry data
  106456. */
  106457. serializeVerticeData(): any;
  106458. /**
  106459. * Extracts a clone of a mesh geometry
  106460. * @param mesh defines the source mesh
  106461. * @param id defines the unique ID of the new geometry object
  106462. * @returns the new geometry object
  106463. */
  106464. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106465. /**
  106466. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106467. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106468. * Be aware Math.random() could cause collisions, but:
  106469. * "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"
  106470. * @returns a string containing a new GUID
  106471. */
  106472. static RandomId(): string;
  106473. /** @hidden */
  106474. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106475. private static _CleanMatricesWeights;
  106476. /**
  106477. * Create a new geometry from persisted data (Using .babylon file format)
  106478. * @param parsedVertexData defines the persisted data
  106479. * @param scene defines the hosting scene
  106480. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106481. * @returns the new geometry object
  106482. */
  106483. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106484. }
  106485. }
  106486. declare module BABYLON {
  106487. /**
  106488. * Define an interface for all classes that will get and set the data on vertices
  106489. */
  106490. export interface IGetSetVerticesData {
  106491. /**
  106492. * Gets a boolean indicating if specific vertex data is present
  106493. * @param kind defines the vertex data kind to use
  106494. * @returns true is data kind is present
  106495. */
  106496. isVerticesDataPresent(kind: string): boolean;
  106497. /**
  106498. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106499. * @param kind defines the data kind (Position, normal, etc...)
  106500. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106502. * @returns a float array containing vertex data
  106503. */
  106504. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106505. /**
  106506. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106507. * @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.
  106508. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106509. * @returns the indices array or an empty array if the mesh has no geometry
  106510. */
  106511. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106512. /**
  106513. * Set specific vertex data
  106514. * @param kind defines the data kind (Position, normal, etc...)
  106515. * @param data defines the vertex data to use
  106516. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106517. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106518. */
  106519. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106520. /**
  106521. * Update a specific associated vertex buffer
  106522. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106523. * - VertexBuffer.PositionKind
  106524. * - VertexBuffer.UVKind
  106525. * - VertexBuffer.UV2Kind
  106526. * - VertexBuffer.UV3Kind
  106527. * - VertexBuffer.UV4Kind
  106528. * - VertexBuffer.UV5Kind
  106529. * - VertexBuffer.UV6Kind
  106530. * - VertexBuffer.ColorKind
  106531. * - VertexBuffer.MatricesIndicesKind
  106532. * - VertexBuffer.MatricesIndicesExtraKind
  106533. * - VertexBuffer.MatricesWeightsKind
  106534. * - VertexBuffer.MatricesWeightsExtraKind
  106535. * @param data defines the data source
  106536. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106537. * @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)
  106538. */
  106539. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106540. /**
  106541. * Creates a new index buffer
  106542. * @param indices defines the indices to store in the index buffer
  106543. * @param totalVertices defines the total number of vertices (could be null)
  106544. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106545. */
  106546. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106547. }
  106548. /**
  106549. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106550. */
  106551. export class VertexData {
  106552. /**
  106553. * Mesh side orientation : usually the external or front surface
  106554. */
  106555. static readonly FRONTSIDE: number;
  106556. /**
  106557. * Mesh side orientation : usually the internal or back surface
  106558. */
  106559. static readonly BACKSIDE: number;
  106560. /**
  106561. * Mesh side orientation : both internal and external or front and back surfaces
  106562. */
  106563. static readonly DOUBLESIDE: number;
  106564. /**
  106565. * Mesh side orientation : by default, `FRONTSIDE`
  106566. */
  106567. static readonly DEFAULTSIDE: number;
  106568. /**
  106569. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106570. */
  106571. positions: Nullable<FloatArray>;
  106572. /**
  106573. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106574. */
  106575. normals: Nullable<FloatArray>;
  106576. /**
  106577. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106578. */
  106579. tangents: Nullable<FloatArray>;
  106580. /**
  106581. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106582. */
  106583. uvs: Nullable<FloatArray>;
  106584. /**
  106585. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106586. */
  106587. uvs2: Nullable<FloatArray>;
  106588. /**
  106589. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106590. */
  106591. uvs3: Nullable<FloatArray>;
  106592. /**
  106593. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106594. */
  106595. uvs4: Nullable<FloatArray>;
  106596. /**
  106597. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106598. */
  106599. uvs5: Nullable<FloatArray>;
  106600. /**
  106601. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106602. */
  106603. uvs6: Nullable<FloatArray>;
  106604. /**
  106605. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106606. */
  106607. colors: Nullable<FloatArray>;
  106608. /**
  106609. * 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).
  106610. */
  106611. matricesIndices: Nullable<FloatArray>;
  106612. /**
  106613. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106614. */
  106615. matricesWeights: Nullable<FloatArray>;
  106616. /**
  106617. * An array extending the number of possible indices
  106618. */
  106619. matricesIndicesExtra: Nullable<FloatArray>;
  106620. /**
  106621. * An array extending the number of possible weights when the number of indices is extended
  106622. */
  106623. matricesWeightsExtra: Nullable<FloatArray>;
  106624. /**
  106625. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106626. */
  106627. indices: Nullable<IndicesArray>;
  106628. /**
  106629. * Uses the passed data array to set the set the values for the specified kind of data
  106630. * @param data a linear array of floating numbers
  106631. * @param kind the type of data that is being set, eg positions, colors etc
  106632. */
  106633. set(data: FloatArray, kind: string): void;
  106634. /**
  106635. * Associates the vertexData to the passed Mesh.
  106636. * Sets it as updatable or not (default `false`)
  106637. * @param mesh the mesh the vertexData is applied to
  106638. * @param updatable when used and having the value true allows new data to update the vertexData
  106639. * @returns the VertexData
  106640. */
  106641. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106642. /**
  106643. * Associates the vertexData to the passed Geometry.
  106644. * Sets it as updatable or not (default `false`)
  106645. * @param geometry the geometry the vertexData is applied to
  106646. * @param updatable when used and having the value true allows new data to update the vertexData
  106647. * @returns VertexData
  106648. */
  106649. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106650. /**
  106651. * Updates the associated mesh
  106652. * @param mesh the mesh to be updated
  106653. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106654. * @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
  106655. * @returns VertexData
  106656. */
  106657. updateMesh(mesh: Mesh): VertexData;
  106658. /**
  106659. * Updates the associated geometry
  106660. * @param geometry the geometry to be updated
  106661. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106662. * @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
  106663. * @returns VertexData.
  106664. */
  106665. updateGeometry(geometry: Geometry): VertexData;
  106666. private _applyTo;
  106667. private _update;
  106668. /**
  106669. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106670. * @param matrix the transforming matrix
  106671. * @returns the VertexData
  106672. */
  106673. transform(matrix: Matrix): VertexData;
  106674. /**
  106675. * Merges the passed VertexData into the current one
  106676. * @param other the VertexData to be merged into the current one
  106677. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106678. * @returns the modified VertexData
  106679. */
  106680. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106681. private _mergeElement;
  106682. private _validate;
  106683. /**
  106684. * Serializes the VertexData
  106685. * @returns a serialized object
  106686. */
  106687. serialize(): any;
  106688. /**
  106689. * Extracts the vertexData from a mesh
  106690. * @param mesh the mesh from which to extract the VertexData
  106691. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106692. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106693. * @returns the object VertexData associated to the passed mesh
  106694. */
  106695. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106696. /**
  106697. * Extracts the vertexData from the geometry
  106698. * @param geometry the geometry from which to extract the VertexData
  106699. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106700. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106701. * @returns the object VertexData associated to the passed mesh
  106702. */
  106703. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106704. private static _ExtractFrom;
  106705. /**
  106706. * Creates the VertexData for a Ribbon
  106707. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106708. * * pathArray array of paths, each of which an array of successive Vector3
  106709. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106710. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106711. * * 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
  106712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106713. * * 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)
  106714. * * 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)
  106715. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106716. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106717. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106718. * @returns the VertexData of the ribbon
  106719. */
  106720. static CreateRibbon(options: {
  106721. pathArray: Vector3[][];
  106722. closeArray?: boolean;
  106723. closePath?: boolean;
  106724. offset?: number;
  106725. sideOrientation?: number;
  106726. frontUVs?: Vector4;
  106727. backUVs?: Vector4;
  106728. invertUV?: boolean;
  106729. uvs?: Vector2[];
  106730. colors?: Color4[];
  106731. }): VertexData;
  106732. /**
  106733. * Creates the VertexData for a box
  106734. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106735. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106736. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106737. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106738. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106739. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106740. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106742. * * 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)
  106743. * * 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)
  106744. * @returns the VertexData of the box
  106745. */
  106746. static CreateBox(options: {
  106747. size?: number;
  106748. width?: number;
  106749. height?: number;
  106750. depth?: number;
  106751. faceUV?: Vector4[];
  106752. faceColors?: Color4[];
  106753. sideOrientation?: number;
  106754. frontUVs?: Vector4;
  106755. backUVs?: Vector4;
  106756. }): VertexData;
  106757. /**
  106758. * Creates the VertexData for a tiled box
  106759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106760. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106761. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106762. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106764. * @returns the VertexData of the box
  106765. */
  106766. static CreateTiledBox(options: {
  106767. pattern?: number;
  106768. width?: number;
  106769. height?: number;
  106770. depth?: number;
  106771. tileSize?: number;
  106772. tileWidth?: number;
  106773. tileHeight?: number;
  106774. alignHorizontal?: number;
  106775. alignVertical?: number;
  106776. faceUV?: Vector4[];
  106777. faceColors?: Color4[];
  106778. sideOrientation?: number;
  106779. }): VertexData;
  106780. /**
  106781. * Creates the VertexData for a tiled plane
  106782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106783. * * pattern a limited pattern arrangement depending on the number
  106784. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106785. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106786. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106787. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106788. * * 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)
  106789. * * 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)
  106790. * @returns the VertexData of the tiled plane
  106791. */
  106792. static CreateTiledPlane(options: {
  106793. pattern?: number;
  106794. tileSize?: number;
  106795. tileWidth?: number;
  106796. tileHeight?: number;
  106797. size?: number;
  106798. width?: number;
  106799. height?: number;
  106800. alignHorizontal?: number;
  106801. alignVertical?: number;
  106802. sideOrientation?: number;
  106803. frontUVs?: Vector4;
  106804. backUVs?: Vector4;
  106805. }): VertexData;
  106806. /**
  106807. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106808. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106809. * * segments sets the number of horizontal strips optional, default 32
  106810. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106811. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106812. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106813. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106814. * * 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
  106815. * * 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
  106816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106817. * * 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)
  106818. * * 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)
  106819. * @returns the VertexData of the ellipsoid
  106820. */
  106821. static CreateSphere(options: {
  106822. segments?: number;
  106823. diameter?: number;
  106824. diameterX?: number;
  106825. diameterY?: number;
  106826. diameterZ?: number;
  106827. arc?: number;
  106828. slice?: number;
  106829. sideOrientation?: number;
  106830. frontUVs?: Vector4;
  106831. backUVs?: Vector4;
  106832. }): VertexData;
  106833. /**
  106834. * Creates the VertexData for a cylinder, cone or prism
  106835. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106836. * * height sets the height (y direction) of the cylinder, optional, default 2
  106837. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106838. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106839. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106840. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106841. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106842. * * 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
  106843. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106844. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106845. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106846. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106848. * * 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)
  106849. * * 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)
  106850. * @returns the VertexData of the cylinder, cone or prism
  106851. */
  106852. static CreateCylinder(options: {
  106853. height?: number;
  106854. diameterTop?: number;
  106855. diameterBottom?: number;
  106856. diameter?: number;
  106857. tessellation?: number;
  106858. subdivisions?: number;
  106859. arc?: number;
  106860. faceColors?: Color4[];
  106861. faceUV?: Vector4[];
  106862. hasRings?: boolean;
  106863. enclose?: boolean;
  106864. sideOrientation?: number;
  106865. frontUVs?: Vector4;
  106866. backUVs?: Vector4;
  106867. }): VertexData;
  106868. /**
  106869. * Creates the VertexData for a torus
  106870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106871. * * diameter the diameter of the torus, optional default 1
  106872. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106873. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106875. * * 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)
  106876. * * 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)
  106877. * @returns the VertexData of the torus
  106878. */
  106879. static CreateTorus(options: {
  106880. diameter?: number;
  106881. thickness?: number;
  106882. tessellation?: number;
  106883. sideOrientation?: number;
  106884. frontUVs?: Vector4;
  106885. backUVs?: Vector4;
  106886. }): VertexData;
  106887. /**
  106888. * Creates the VertexData of the LineSystem
  106889. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106890. * - lines an array of lines, each line being an array of successive Vector3
  106891. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106892. * @returns the VertexData of the LineSystem
  106893. */
  106894. static CreateLineSystem(options: {
  106895. lines: Vector3[][];
  106896. colors?: Nullable<Color4[][]>;
  106897. }): VertexData;
  106898. /**
  106899. * Create the VertexData for a DashedLines
  106900. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106901. * - points an array successive Vector3
  106902. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106903. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106904. * - dashNb the intended total number of dashes, optional, default 200
  106905. * @returns the VertexData for the DashedLines
  106906. */
  106907. static CreateDashedLines(options: {
  106908. points: Vector3[];
  106909. dashSize?: number;
  106910. gapSize?: number;
  106911. dashNb?: number;
  106912. }): VertexData;
  106913. /**
  106914. * Creates the VertexData for a Ground
  106915. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106916. * - width the width (x direction) of the ground, optional, default 1
  106917. * - height the height (z direction) of the ground, optional, default 1
  106918. * - subdivisions the number of subdivisions per side, optional, default 1
  106919. * @returns the VertexData of the Ground
  106920. */
  106921. static CreateGround(options: {
  106922. width?: number;
  106923. height?: number;
  106924. subdivisions?: number;
  106925. subdivisionsX?: number;
  106926. subdivisionsY?: number;
  106927. }): VertexData;
  106928. /**
  106929. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106930. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106931. * * xmin the ground minimum X coordinate, optional, default -1
  106932. * * zmin the ground minimum Z coordinate, optional, default -1
  106933. * * xmax the ground maximum X coordinate, optional, default 1
  106934. * * zmax the ground maximum Z coordinate, optional, default 1
  106935. * * 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}
  106936. * * 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}
  106937. * @returns the VertexData of the TiledGround
  106938. */
  106939. static CreateTiledGround(options: {
  106940. xmin: number;
  106941. zmin: number;
  106942. xmax: number;
  106943. zmax: number;
  106944. subdivisions?: {
  106945. w: number;
  106946. h: number;
  106947. };
  106948. precision?: {
  106949. w: number;
  106950. h: number;
  106951. };
  106952. }): VertexData;
  106953. /**
  106954. * Creates the VertexData of the Ground designed from a heightmap
  106955. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106956. * * width the width (x direction) of the ground
  106957. * * height the height (z direction) of the ground
  106958. * * subdivisions the number of subdivisions per side
  106959. * * minHeight the minimum altitude on the ground, optional, default 0
  106960. * * maxHeight the maximum altitude on the ground, optional default 1
  106961. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106962. * * buffer the array holding the image color data
  106963. * * bufferWidth the width of image
  106964. * * bufferHeight the height of image
  106965. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106966. * @returns the VertexData of the Ground designed from a heightmap
  106967. */
  106968. static CreateGroundFromHeightMap(options: {
  106969. width: number;
  106970. height: number;
  106971. subdivisions: number;
  106972. minHeight: number;
  106973. maxHeight: number;
  106974. colorFilter: Color3;
  106975. buffer: Uint8Array;
  106976. bufferWidth: number;
  106977. bufferHeight: number;
  106978. alphaFilter: number;
  106979. }): VertexData;
  106980. /**
  106981. * Creates the VertexData for a Plane
  106982. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106983. * * size sets the width and height of the plane to the value of size, optional default 1
  106984. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106985. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106987. * * 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)
  106988. * * 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)
  106989. * @returns the VertexData of the box
  106990. */
  106991. static CreatePlane(options: {
  106992. size?: number;
  106993. width?: number;
  106994. height?: number;
  106995. sideOrientation?: number;
  106996. frontUVs?: Vector4;
  106997. backUVs?: Vector4;
  106998. }): VertexData;
  106999. /**
  107000. * Creates the VertexData of the Disc or regular Polygon
  107001. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  107002. * * radius the radius of the disc, optional default 0.5
  107003. * * tessellation the number of polygon sides, optional, default 64
  107004. * * 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
  107005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107006. * * 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)
  107007. * * 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)
  107008. * @returns the VertexData of the box
  107009. */
  107010. static CreateDisc(options: {
  107011. radius?: number;
  107012. tessellation?: number;
  107013. arc?: number;
  107014. sideOrientation?: number;
  107015. frontUVs?: Vector4;
  107016. backUVs?: Vector4;
  107017. }): VertexData;
  107018. /**
  107019. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  107020. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  107021. * @param polygon a mesh built from polygonTriangulation.build()
  107022. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107023. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107024. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107025. * @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)
  107026. * @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)
  107027. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  107028. * @returns the VertexData of the Polygon
  107029. */
  107030. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  107031. /**
  107032. * Creates the VertexData of the IcoSphere
  107033. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  107034. * * radius the radius of the IcoSphere, optional default 1
  107035. * * radiusX allows stretching in the x direction, optional, default radius
  107036. * * radiusY allows stretching in the y direction, optional, default radius
  107037. * * radiusZ allows stretching in the z direction, optional, default radius
  107038. * * flat when true creates a flat shaded mesh, optional, default true
  107039. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107041. * * 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)
  107042. * * 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)
  107043. * @returns the VertexData of the IcoSphere
  107044. */
  107045. static CreateIcoSphere(options: {
  107046. radius?: number;
  107047. radiusX?: number;
  107048. radiusY?: number;
  107049. radiusZ?: number;
  107050. flat?: boolean;
  107051. subdivisions?: number;
  107052. sideOrientation?: number;
  107053. frontUVs?: Vector4;
  107054. backUVs?: Vector4;
  107055. }): VertexData;
  107056. /**
  107057. * Creates the VertexData for a Polyhedron
  107058. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  107059. * * type provided types are:
  107060. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  107061. * * 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)
  107062. * * size the size of the IcoSphere, optional default 1
  107063. * * sizeX allows stretching in the x direction, optional, default size
  107064. * * sizeY allows stretching in the y direction, optional, default size
  107065. * * sizeZ allows stretching in the z direction, optional, default size
  107066. * * 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
  107067. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107068. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107069. * * flat when true creates a flat shaded mesh, optional, default true
  107070. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107072. * * 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)
  107073. * * 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)
  107074. * @returns the VertexData of the Polyhedron
  107075. */
  107076. static CreatePolyhedron(options: {
  107077. type?: number;
  107078. size?: number;
  107079. sizeX?: number;
  107080. sizeY?: number;
  107081. sizeZ?: number;
  107082. custom?: any;
  107083. faceUV?: Vector4[];
  107084. faceColors?: Color4[];
  107085. flat?: boolean;
  107086. sideOrientation?: number;
  107087. frontUVs?: Vector4;
  107088. backUVs?: Vector4;
  107089. }): VertexData;
  107090. /**
  107091. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  107092. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  107093. * @returns the VertexData of the Capsule
  107094. */
  107095. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  107096. /**
  107097. * Creates the VertexData for a TorusKnot
  107098. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  107099. * * radius the radius of the torus knot, optional, default 2
  107100. * * tube the thickness of the tube, optional, default 0.5
  107101. * * radialSegments the number of sides on each tube segments, optional, default 32
  107102. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  107103. * * p the number of windings around the z axis, optional, default 2
  107104. * * q the number of windings around the x axis, optional, default 3
  107105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107106. * * 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)
  107107. * * 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)
  107108. * @returns the VertexData of the Torus Knot
  107109. */
  107110. static CreateTorusKnot(options: {
  107111. radius?: number;
  107112. tube?: number;
  107113. radialSegments?: number;
  107114. tubularSegments?: number;
  107115. p?: number;
  107116. q?: number;
  107117. sideOrientation?: number;
  107118. frontUVs?: Vector4;
  107119. backUVs?: Vector4;
  107120. }): VertexData;
  107121. /**
  107122. * Compute normals for given positions and indices
  107123. * @param positions an array of vertex positions, [...., x, y, z, ......]
  107124. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  107125. * @param normals an array of vertex normals, [...., x, y, z, ......]
  107126. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  107127. * * facetNormals : optional array of facet normals (vector3)
  107128. * * facetPositions : optional array of facet positions (vector3)
  107129. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  107130. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  107131. * * bInfo : optional bounding info, required for facetPartitioning computation
  107132. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  107133. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  107134. * * useRightHandedSystem: optional boolean to for right handed system computation
  107135. * * depthSort : optional boolean to enable the facet depth sort computation
  107136. * * distanceTo : optional Vector3 to compute the facet depth from this location
  107137. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  107138. */
  107139. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  107140. facetNormals?: any;
  107141. facetPositions?: any;
  107142. facetPartitioning?: any;
  107143. ratio?: number;
  107144. bInfo?: any;
  107145. bbSize?: Vector3;
  107146. subDiv?: any;
  107147. useRightHandedSystem?: boolean;
  107148. depthSort?: boolean;
  107149. distanceTo?: Vector3;
  107150. depthSortedFacets?: any;
  107151. }): void;
  107152. /** @hidden */
  107153. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  107154. /**
  107155. * Applies VertexData created from the imported parameters to the geometry
  107156. * @param parsedVertexData the parsed data from an imported file
  107157. * @param geometry the geometry to apply the VertexData to
  107158. */
  107159. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  107160. }
  107161. }
  107162. declare module BABYLON {
  107163. /**
  107164. * Defines a target to use with MorphTargetManager
  107165. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107166. */
  107167. export class MorphTarget implements IAnimatable {
  107168. /** defines the name of the target */
  107169. name: string;
  107170. /**
  107171. * Gets or sets the list of animations
  107172. */
  107173. animations: Animation[];
  107174. private _scene;
  107175. private _positions;
  107176. private _normals;
  107177. private _tangents;
  107178. private _uvs;
  107179. private _influence;
  107180. private _uniqueId;
  107181. /**
  107182. * Observable raised when the influence changes
  107183. */
  107184. onInfluenceChanged: Observable<boolean>;
  107185. /** @hidden */
  107186. _onDataLayoutChanged: Observable<void>;
  107187. /**
  107188. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  107189. */
  107190. get influence(): number;
  107191. set influence(influence: number);
  107192. /**
  107193. * Gets or sets the id of the morph Target
  107194. */
  107195. id: string;
  107196. private _animationPropertiesOverride;
  107197. /**
  107198. * Gets or sets the animation properties override
  107199. */
  107200. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107201. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107202. /**
  107203. * Creates a new MorphTarget
  107204. * @param name defines the name of the target
  107205. * @param influence defines the influence to use
  107206. * @param scene defines the scene the morphtarget belongs to
  107207. */
  107208. constructor(
  107209. /** defines the name of the target */
  107210. name: string, influence?: number, scene?: Nullable<Scene>);
  107211. /**
  107212. * Gets the unique ID of this manager
  107213. */
  107214. get uniqueId(): number;
  107215. /**
  107216. * Gets a boolean defining if the target contains position data
  107217. */
  107218. get hasPositions(): boolean;
  107219. /**
  107220. * Gets a boolean defining if the target contains normal data
  107221. */
  107222. get hasNormals(): boolean;
  107223. /**
  107224. * Gets a boolean defining if the target contains tangent data
  107225. */
  107226. get hasTangents(): boolean;
  107227. /**
  107228. * Gets a boolean defining if the target contains texture coordinates data
  107229. */
  107230. get hasUVs(): boolean;
  107231. /**
  107232. * Affects position data to this target
  107233. * @param data defines the position data to use
  107234. */
  107235. setPositions(data: Nullable<FloatArray>): void;
  107236. /**
  107237. * Gets the position data stored in this target
  107238. * @returns a FloatArray containing the position data (or null if not present)
  107239. */
  107240. getPositions(): Nullable<FloatArray>;
  107241. /**
  107242. * Affects normal data to this target
  107243. * @param data defines the normal data to use
  107244. */
  107245. setNormals(data: Nullable<FloatArray>): void;
  107246. /**
  107247. * Gets the normal data stored in this target
  107248. * @returns a FloatArray containing the normal data (or null if not present)
  107249. */
  107250. getNormals(): Nullable<FloatArray>;
  107251. /**
  107252. * Affects tangent data to this target
  107253. * @param data defines the tangent data to use
  107254. */
  107255. setTangents(data: Nullable<FloatArray>): void;
  107256. /**
  107257. * Gets the tangent data stored in this target
  107258. * @returns a FloatArray containing the tangent data (or null if not present)
  107259. */
  107260. getTangents(): Nullable<FloatArray>;
  107261. /**
  107262. * Affects texture coordinates data to this target
  107263. * @param data defines the texture coordinates data to use
  107264. */
  107265. setUVs(data: Nullable<FloatArray>): void;
  107266. /**
  107267. * Gets the texture coordinates data stored in this target
  107268. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  107269. */
  107270. getUVs(): Nullable<FloatArray>;
  107271. /**
  107272. * Clone the current target
  107273. * @returns a new MorphTarget
  107274. */
  107275. clone(): MorphTarget;
  107276. /**
  107277. * Serializes the current target into a Serialization object
  107278. * @returns the serialized object
  107279. */
  107280. serialize(): any;
  107281. /**
  107282. * Returns the string "MorphTarget"
  107283. * @returns "MorphTarget"
  107284. */
  107285. getClassName(): string;
  107286. /**
  107287. * Creates a new target from serialized data
  107288. * @param serializationObject defines the serialized data to use
  107289. * @returns a new MorphTarget
  107290. */
  107291. static Parse(serializationObject: any): MorphTarget;
  107292. /**
  107293. * Creates a MorphTarget from mesh data
  107294. * @param mesh defines the source mesh
  107295. * @param name defines the name to use for the new target
  107296. * @param influence defines the influence to attach to the target
  107297. * @returns a new MorphTarget
  107298. */
  107299. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107300. }
  107301. }
  107302. declare module BABYLON {
  107303. /**
  107304. * This class is used to deform meshes using morphing between different targets
  107305. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107306. */
  107307. export class MorphTargetManager {
  107308. private _targets;
  107309. private _targetInfluenceChangedObservers;
  107310. private _targetDataLayoutChangedObservers;
  107311. private _activeTargets;
  107312. private _scene;
  107313. private _influences;
  107314. private _supportsNormals;
  107315. private _supportsTangents;
  107316. private _supportsUVs;
  107317. private _vertexCount;
  107318. private _uniqueId;
  107319. private _tempInfluences;
  107320. /**
  107321. * Gets or sets a boolean indicating if normals must be morphed
  107322. */
  107323. enableNormalMorphing: boolean;
  107324. /**
  107325. * Gets or sets a boolean indicating if tangents must be morphed
  107326. */
  107327. enableTangentMorphing: boolean;
  107328. /**
  107329. * Gets or sets a boolean indicating if UV must be morphed
  107330. */
  107331. enableUVMorphing: boolean;
  107332. /**
  107333. * Creates a new MorphTargetManager
  107334. * @param scene defines the current scene
  107335. */
  107336. constructor(scene?: Nullable<Scene>);
  107337. /**
  107338. * Gets the unique ID of this manager
  107339. */
  107340. get uniqueId(): number;
  107341. /**
  107342. * Gets the number of vertices handled by this manager
  107343. */
  107344. get vertexCount(): number;
  107345. /**
  107346. * Gets a boolean indicating if this manager supports morphing of normals
  107347. */
  107348. get supportsNormals(): boolean;
  107349. /**
  107350. * Gets a boolean indicating if this manager supports morphing of tangents
  107351. */
  107352. get supportsTangents(): boolean;
  107353. /**
  107354. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107355. */
  107356. get supportsUVs(): boolean;
  107357. /**
  107358. * Gets the number of targets stored in this manager
  107359. */
  107360. get numTargets(): number;
  107361. /**
  107362. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107363. */
  107364. get numInfluencers(): number;
  107365. /**
  107366. * Gets the list of influences (one per target)
  107367. */
  107368. get influences(): Float32Array;
  107369. /**
  107370. * Gets the active target at specified index. An active target is a target with an influence > 0
  107371. * @param index defines the index to check
  107372. * @returns the requested target
  107373. */
  107374. getActiveTarget(index: number): MorphTarget;
  107375. /**
  107376. * Gets the target at specified index
  107377. * @param index defines the index to check
  107378. * @returns the requested target
  107379. */
  107380. getTarget(index: number): MorphTarget;
  107381. /**
  107382. * Add a new target to this manager
  107383. * @param target defines the target to add
  107384. */
  107385. addTarget(target: MorphTarget): void;
  107386. /**
  107387. * Removes a target from the manager
  107388. * @param target defines the target to remove
  107389. */
  107390. removeTarget(target: MorphTarget): void;
  107391. /**
  107392. * Clone the current manager
  107393. * @returns a new MorphTargetManager
  107394. */
  107395. clone(): MorphTargetManager;
  107396. /**
  107397. * Serializes the current manager into a Serialization object
  107398. * @returns the serialized object
  107399. */
  107400. serialize(): any;
  107401. private _syncActiveTargets;
  107402. /**
  107403. * Syncrhonize the targets with all the meshes using this morph target manager
  107404. */
  107405. synchronize(): void;
  107406. /**
  107407. * Creates a new MorphTargetManager from serialized data
  107408. * @param serializationObject defines the serialized data
  107409. * @param scene defines the hosting scene
  107410. * @returns the new MorphTargetManager
  107411. */
  107412. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107413. }
  107414. }
  107415. declare module BABYLON {
  107416. /**
  107417. * Class used to represent a specific level of detail of a mesh
  107418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107419. */
  107420. export class MeshLODLevel {
  107421. /** Defines the distance where this level should start being displayed */
  107422. distance: number;
  107423. /** Defines the mesh to use to render this level */
  107424. mesh: Nullable<Mesh>;
  107425. /**
  107426. * Creates a new LOD level
  107427. * @param distance defines the distance where this level should star being displayed
  107428. * @param mesh defines the mesh to use to render this level
  107429. */
  107430. constructor(
  107431. /** Defines the distance where this level should start being displayed */
  107432. distance: number,
  107433. /** Defines the mesh to use to render this level */
  107434. mesh: Nullable<Mesh>);
  107435. }
  107436. }
  107437. declare module BABYLON {
  107438. /**
  107439. * Helper class used to generate a canvas to manipulate images
  107440. */
  107441. export class CanvasGenerator {
  107442. /**
  107443. * Create a new canvas (or offscreen canvas depending on the context)
  107444. * @param width defines the expected width
  107445. * @param height defines the expected height
  107446. * @return a new canvas or offscreen canvas
  107447. */
  107448. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107449. }
  107450. }
  107451. declare module BABYLON {
  107452. /**
  107453. * Mesh representing the gorund
  107454. */
  107455. export class GroundMesh extends Mesh {
  107456. /** If octree should be generated */
  107457. generateOctree: boolean;
  107458. private _heightQuads;
  107459. /** @hidden */
  107460. _subdivisionsX: number;
  107461. /** @hidden */
  107462. _subdivisionsY: number;
  107463. /** @hidden */
  107464. _width: number;
  107465. /** @hidden */
  107466. _height: number;
  107467. /** @hidden */
  107468. _minX: number;
  107469. /** @hidden */
  107470. _maxX: number;
  107471. /** @hidden */
  107472. _minZ: number;
  107473. /** @hidden */
  107474. _maxZ: number;
  107475. constructor(name: string, scene: Scene);
  107476. /**
  107477. * "GroundMesh"
  107478. * @returns "GroundMesh"
  107479. */
  107480. getClassName(): string;
  107481. /**
  107482. * The minimum of x and y subdivisions
  107483. */
  107484. get subdivisions(): number;
  107485. /**
  107486. * X subdivisions
  107487. */
  107488. get subdivisionsX(): number;
  107489. /**
  107490. * Y subdivisions
  107491. */
  107492. get subdivisionsY(): number;
  107493. /**
  107494. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107495. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107496. * @param chunksCount the number of subdivisions for x and y
  107497. * @param octreeBlocksSize (Default: 32)
  107498. */
  107499. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107500. /**
  107501. * Returns a height (y) value in the Worl system :
  107502. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107503. * @param x x coordinate
  107504. * @param z z coordinate
  107505. * @returns the ground y position if (x, z) are outside the ground surface.
  107506. */
  107507. getHeightAtCoordinates(x: number, z: number): number;
  107508. /**
  107509. * Returns a normalized vector (Vector3) orthogonal to the ground
  107510. * at the ground coordinates (x, z) expressed in the World system.
  107511. * @param x x coordinate
  107512. * @param z z coordinate
  107513. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107514. */
  107515. getNormalAtCoordinates(x: number, z: number): Vector3;
  107516. /**
  107517. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107518. * at the ground coordinates (x, z) expressed in the World system.
  107519. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107520. * @param x x coordinate
  107521. * @param z z coordinate
  107522. * @param ref vector to store the result
  107523. * @returns the GroundMesh.
  107524. */
  107525. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107526. /**
  107527. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107528. * if the ground has been updated.
  107529. * This can be used in the render loop.
  107530. * @returns the GroundMesh.
  107531. */
  107532. updateCoordinateHeights(): GroundMesh;
  107533. private _getFacetAt;
  107534. private _initHeightQuads;
  107535. private _computeHeightQuads;
  107536. /**
  107537. * Serializes this ground mesh
  107538. * @param serializationObject object to write serialization to
  107539. */
  107540. serialize(serializationObject: any): void;
  107541. /**
  107542. * Parses a serialized ground mesh
  107543. * @param parsedMesh the serialized mesh
  107544. * @param scene the scene to create the ground mesh in
  107545. * @returns the created ground mesh
  107546. */
  107547. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107548. }
  107549. }
  107550. declare module BABYLON {
  107551. /**
  107552. * Interface for Physics-Joint data
  107553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107554. */
  107555. export interface PhysicsJointData {
  107556. /**
  107557. * The main pivot of the joint
  107558. */
  107559. mainPivot?: Vector3;
  107560. /**
  107561. * The connected pivot of the joint
  107562. */
  107563. connectedPivot?: Vector3;
  107564. /**
  107565. * The main axis of the joint
  107566. */
  107567. mainAxis?: Vector3;
  107568. /**
  107569. * The connected axis of the joint
  107570. */
  107571. connectedAxis?: Vector3;
  107572. /**
  107573. * The collision of the joint
  107574. */
  107575. collision?: boolean;
  107576. /**
  107577. * Native Oimo/Cannon/Energy data
  107578. */
  107579. nativeParams?: any;
  107580. }
  107581. /**
  107582. * This is a holder class for the physics joint created by the physics plugin
  107583. * It holds a set of functions to control the underlying joint
  107584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107585. */
  107586. export class PhysicsJoint {
  107587. /**
  107588. * The type of the physics joint
  107589. */
  107590. type: number;
  107591. /**
  107592. * The data for the physics joint
  107593. */
  107594. jointData: PhysicsJointData;
  107595. private _physicsJoint;
  107596. protected _physicsPlugin: IPhysicsEnginePlugin;
  107597. /**
  107598. * Initializes the physics joint
  107599. * @param type The type of the physics joint
  107600. * @param jointData The data for the physics joint
  107601. */
  107602. constructor(
  107603. /**
  107604. * The type of the physics joint
  107605. */
  107606. type: number,
  107607. /**
  107608. * The data for the physics joint
  107609. */
  107610. jointData: PhysicsJointData);
  107611. /**
  107612. * Gets the physics joint
  107613. */
  107614. get physicsJoint(): any;
  107615. /**
  107616. * Sets the physics joint
  107617. */
  107618. set physicsJoint(newJoint: any);
  107619. /**
  107620. * Sets the physics plugin
  107621. */
  107622. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107623. /**
  107624. * Execute a function that is physics-plugin specific.
  107625. * @param {Function} func the function that will be executed.
  107626. * It accepts two parameters: the physics world and the physics joint
  107627. */
  107628. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107629. /**
  107630. * Distance-Joint type
  107631. */
  107632. static DistanceJoint: number;
  107633. /**
  107634. * Hinge-Joint type
  107635. */
  107636. static HingeJoint: number;
  107637. /**
  107638. * Ball-and-Socket joint type
  107639. */
  107640. static BallAndSocketJoint: number;
  107641. /**
  107642. * Wheel-Joint type
  107643. */
  107644. static WheelJoint: number;
  107645. /**
  107646. * Slider-Joint type
  107647. */
  107648. static SliderJoint: number;
  107649. /**
  107650. * Prismatic-Joint type
  107651. */
  107652. static PrismaticJoint: number;
  107653. /**
  107654. * Universal-Joint type
  107655. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107656. */
  107657. static UniversalJoint: number;
  107658. /**
  107659. * Hinge-Joint 2 type
  107660. */
  107661. static Hinge2Joint: number;
  107662. /**
  107663. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107664. */
  107665. static PointToPointJoint: number;
  107666. /**
  107667. * Spring-Joint type
  107668. */
  107669. static SpringJoint: number;
  107670. /**
  107671. * Lock-Joint type
  107672. */
  107673. static LockJoint: number;
  107674. }
  107675. /**
  107676. * A class representing a physics distance joint
  107677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107678. */
  107679. export class DistanceJoint extends PhysicsJoint {
  107680. /**
  107681. *
  107682. * @param jointData The data for the Distance-Joint
  107683. */
  107684. constructor(jointData: DistanceJointData);
  107685. /**
  107686. * Update the predefined distance.
  107687. * @param maxDistance The maximum preferred distance
  107688. * @param minDistance The minimum preferred distance
  107689. */
  107690. updateDistance(maxDistance: number, minDistance?: number): void;
  107691. }
  107692. /**
  107693. * Represents a Motor-Enabled Joint
  107694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107695. */
  107696. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107697. /**
  107698. * Initializes the Motor-Enabled Joint
  107699. * @param type The type of the joint
  107700. * @param jointData The physica joint data for the joint
  107701. */
  107702. constructor(type: number, jointData: PhysicsJointData);
  107703. /**
  107704. * Set the motor values.
  107705. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107706. * @param force the force to apply
  107707. * @param maxForce max force for this motor.
  107708. */
  107709. setMotor(force?: number, maxForce?: number): void;
  107710. /**
  107711. * Set the motor's limits.
  107712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107713. * @param upperLimit The upper limit of the motor
  107714. * @param lowerLimit The lower limit of the motor
  107715. */
  107716. setLimit(upperLimit: number, lowerLimit?: number): void;
  107717. }
  107718. /**
  107719. * This class represents a single physics Hinge-Joint
  107720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107721. */
  107722. export class HingeJoint extends MotorEnabledJoint {
  107723. /**
  107724. * Initializes the Hinge-Joint
  107725. * @param jointData The joint data for the Hinge-Joint
  107726. */
  107727. constructor(jointData: PhysicsJointData);
  107728. /**
  107729. * Set the motor values.
  107730. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107731. * @param {number} force the force to apply
  107732. * @param {number} maxForce max force for this motor.
  107733. */
  107734. setMotor(force?: number, maxForce?: number): void;
  107735. /**
  107736. * Set the motor's limits.
  107737. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107738. * @param upperLimit The upper limit of the motor
  107739. * @param lowerLimit The lower limit of the motor
  107740. */
  107741. setLimit(upperLimit: number, lowerLimit?: number): void;
  107742. }
  107743. /**
  107744. * This class represents a dual hinge physics joint (same as wheel joint)
  107745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107746. */
  107747. export class Hinge2Joint extends MotorEnabledJoint {
  107748. /**
  107749. * Initializes the Hinge2-Joint
  107750. * @param jointData The joint data for the Hinge2-Joint
  107751. */
  107752. constructor(jointData: PhysicsJointData);
  107753. /**
  107754. * Set the motor values.
  107755. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107756. * @param {number} targetSpeed the speed the motor is to reach
  107757. * @param {number} maxForce max force for this motor.
  107758. * @param {motorIndex} the motor's index, 0 or 1.
  107759. */
  107760. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107761. /**
  107762. * Set the motor limits.
  107763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107764. * @param {number} upperLimit the upper limit
  107765. * @param {number} lowerLimit lower limit
  107766. * @param {motorIndex} the motor's index, 0 or 1.
  107767. */
  107768. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107769. }
  107770. /**
  107771. * Interface for a motor enabled joint
  107772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107773. */
  107774. export interface IMotorEnabledJoint {
  107775. /**
  107776. * Physics joint
  107777. */
  107778. physicsJoint: any;
  107779. /**
  107780. * Sets the motor of the motor-enabled joint
  107781. * @param force The force of the motor
  107782. * @param maxForce The maximum force of the motor
  107783. * @param motorIndex The index of the motor
  107784. */
  107785. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107786. /**
  107787. * Sets the limit of the motor
  107788. * @param upperLimit The upper limit of the motor
  107789. * @param lowerLimit The lower limit of the motor
  107790. * @param motorIndex The index of the motor
  107791. */
  107792. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107793. }
  107794. /**
  107795. * Joint data for a Distance-Joint
  107796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107797. */
  107798. export interface DistanceJointData extends PhysicsJointData {
  107799. /**
  107800. * Max distance the 2 joint objects can be apart
  107801. */
  107802. maxDistance: number;
  107803. }
  107804. /**
  107805. * Joint data from a spring joint
  107806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107807. */
  107808. export interface SpringJointData extends PhysicsJointData {
  107809. /**
  107810. * Length of the spring
  107811. */
  107812. length: number;
  107813. /**
  107814. * Stiffness of the spring
  107815. */
  107816. stiffness: number;
  107817. /**
  107818. * Damping of the spring
  107819. */
  107820. damping: number;
  107821. /** this callback will be called when applying the force to the impostors. */
  107822. forceApplicationCallback: () => void;
  107823. }
  107824. }
  107825. declare module BABYLON {
  107826. /**
  107827. * Holds the data for the raycast result
  107828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107829. */
  107830. export class PhysicsRaycastResult {
  107831. private _hasHit;
  107832. private _hitDistance;
  107833. private _hitNormalWorld;
  107834. private _hitPointWorld;
  107835. private _rayFromWorld;
  107836. private _rayToWorld;
  107837. /**
  107838. * Gets if there was a hit
  107839. */
  107840. get hasHit(): boolean;
  107841. /**
  107842. * Gets the distance from the hit
  107843. */
  107844. get hitDistance(): number;
  107845. /**
  107846. * Gets the hit normal/direction in the world
  107847. */
  107848. get hitNormalWorld(): Vector3;
  107849. /**
  107850. * Gets the hit point in the world
  107851. */
  107852. get hitPointWorld(): Vector3;
  107853. /**
  107854. * Gets the ray "start point" of the ray in the world
  107855. */
  107856. get rayFromWorld(): Vector3;
  107857. /**
  107858. * Gets the ray "end point" of the ray in the world
  107859. */
  107860. get rayToWorld(): Vector3;
  107861. /**
  107862. * Sets the hit data (normal & point in world space)
  107863. * @param hitNormalWorld defines the normal in world space
  107864. * @param hitPointWorld defines the point in world space
  107865. */
  107866. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107867. /**
  107868. * Sets the distance from the start point to the hit point
  107869. * @param distance
  107870. */
  107871. setHitDistance(distance: number): void;
  107872. /**
  107873. * Calculates the distance manually
  107874. */
  107875. calculateHitDistance(): void;
  107876. /**
  107877. * Resets all the values to default
  107878. * @param from The from point on world space
  107879. * @param to The to point on world space
  107880. */
  107881. reset(from?: Vector3, to?: Vector3): void;
  107882. }
  107883. /**
  107884. * Interface for the size containing width and height
  107885. */
  107886. interface IXYZ {
  107887. /**
  107888. * X
  107889. */
  107890. x: number;
  107891. /**
  107892. * Y
  107893. */
  107894. y: number;
  107895. /**
  107896. * Z
  107897. */
  107898. z: number;
  107899. }
  107900. }
  107901. declare module BABYLON {
  107902. /**
  107903. * Interface used to describe a physics joint
  107904. */
  107905. export interface PhysicsImpostorJoint {
  107906. /** Defines the main impostor to which the joint is linked */
  107907. mainImpostor: PhysicsImpostor;
  107908. /** Defines the impostor that is connected to the main impostor using this joint */
  107909. connectedImpostor: PhysicsImpostor;
  107910. /** Defines the joint itself */
  107911. joint: PhysicsJoint;
  107912. }
  107913. /** @hidden */
  107914. export interface IPhysicsEnginePlugin {
  107915. world: any;
  107916. name: string;
  107917. setGravity(gravity: Vector3): void;
  107918. setTimeStep(timeStep: number): void;
  107919. getTimeStep(): number;
  107920. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107921. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107922. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107923. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107924. removePhysicsBody(impostor: PhysicsImpostor): void;
  107925. generateJoint(joint: PhysicsImpostorJoint): void;
  107926. removeJoint(joint: PhysicsImpostorJoint): void;
  107927. isSupported(): boolean;
  107928. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107929. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107930. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107931. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107932. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107933. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107934. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107935. getBodyMass(impostor: PhysicsImpostor): number;
  107936. getBodyFriction(impostor: PhysicsImpostor): number;
  107937. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107938. getBodyRestitution(impostor: PhysicsImpostor): number;
  107939. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107940. getBodyPressure?(impostor: PhysicsImpostor): number;
  107941. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107942. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107943. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107944. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107945. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107946. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107947. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107948. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107949. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107950. sleepBody(impostor: PhysicsImpostor): void;
  107951. wakeUpBody(impostor: PhysicsImpostor): void;
  107952. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107953. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107954. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107955. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107956. getRadius(impostor: PhysicsImpostor): number;
  107957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107959. dispose(): void;
  107960. }
  107961. /**
  107962. * Interface used to define a physics engine
  107963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107964. */
  107965. export interface IPhysicsEngine {
  107966. /**
  107967. * Gets the gravity vector used by the simulation
  107968. */
  107969. gravity: Vector3;
  107970. /**
  107971. * Sets the gravity vector used by the simulation
  107972. * @param gravity defines the gravity vector to use
  107973. */
  107974. setGravity(gravity: Vector3): void;
  107975. /**
  107976. * Set the time step of the physics engine.
  107977. * Default is 1/60.
  107978. * To slow it down, enter 1/600 for example.
  107979. * To speed it up, 1/30
  107980. * @param newTimeStep the new timestep to apply to this world.
  107981. */
  107982. setTimeStep(newTimeStep: number): void;
  107983. /**
  107984. * Get the time step of the physics engine.
  107985. * @returns the current time step
  107986. */
  107987. getTimeStep(): number;
  107988. /**
  107989. * Set the sub time step of the physics engine.
  107990. * Default is 0 meaning there is no sub steps
  107991. * To increase physics resolution precision, set a small value (like 1 ms)
  107992. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107993. */
  107994. setSubTimeStep(subTimeStep: number): void;
  107995. /**
  107996. * Get the sub time step of the physics engine.
  107997. * @returns the current sub time step
  107998. */
  107999. getSubTimeStep(): number;
  108000. /**
  108001. * Release all resources
  108002. */
  108003. dispose(): void;
  108004. /**
  108005. * Gets the name of the current physics plugin
  108006. * @returns the name of the plugin
  108007. */
  108008. getPhysicsPluginName(): string;
  108009. /**
  108010. * Adding a new impostor for the impostor tracking.
  108011. * This will be done by the impostor itself.
  108012. * @param impostor the impostor to add
  108013. */
  108014. addImpostor(impostor: PhysicsImpostor): void;
  108015. /**
  108016. * Remove an impostor from the engine.
  108017. * This impostor and its mesh will not longer be updated by the physics engine.
  108018. * @param impostor the impostor to remove
  108019. */
  108020. removeImpostor(impostor: PhysicsImpostor): void;
  108021. /**
  108022. * Add a joint to the physics engine
  108023. * @param mainImpostor defines the main impostor to which the joint is added.
  108024. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108025. * @param joint defines the joint that will connect both impostors.
  108026. */
  108027. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108028. /**
  108029. * Removes a joint from the simulation
  108030. * @param mainImpostor defines the impostor used with the joint
  108031. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108032. * @param joint defines the joint to remove
  108033. */
  108034. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108035. /**
  108036. * Gets the current plugin used to run the simulation
  108037. * @returns current plugin
  108038. */
  108039. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108040. /**
  108041. * Gets the list of physic impostors
  108042. * @returns an array of PhysicsImpostor
  108043. */
  108044. getImpostors(): Array<PhysicsImpostor>;
  108045. /**
  108046. * Gets the impostor for a physics enabled object
  108047. * @param object defines the object impersonated by the impostor
  108048. * @returns the PhysicsImpostor or null if not found
  108049. */
  108050. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108051. /**
  108052. * Gets the impostor for a physics body object
  108053. * @param body defines physics body used by the impostor
  108054. * @returns the PhysicsImpostor or null if not found
  108055. */
  108056. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108057. /**
  108058. * Does a raycast in the physics world
  108059. * @param from when should the ray start?
  108060. * @param to when should the ray end?
  108061. * @returns PhysicsRaycastResult
  108062. */
  108063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108064. /**
  108065. * Called by the scene. No need to call it.
  108066. * @param delta defines the timespam between frames
  108067. */
  108068. _step(delta: number): void;
  108069. }
  108070. }
  108071. declare module BABYLON {
  108072. /**
  108073. * The interface for the physics imposter parameters
  108074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108075. */
  108076. export interface PhysicsImpostorParameters {
  108077. /**
  108078. * The mass of the physics imposter
  108079. */
  108080. mass: number;
  108081. /**
  108082. * The friction of the physics imposter
  108083. */
  108084. friction?: number;
  108085. /**
  108086. * The coefficient of restitution of the physics imposter
  108087. */
  108088. restitution?: number;
  108089. /**
  108090. * The native options of the physics imposter
  108091. */
  108092. nativeOptions?: any;
  108093. /**
  108094. * Specifies if the parent should be ignored
  108095. */
  108096. ignoreParent?: boolean;
  108097. /**
  108098. * Specifies if bi-directional transformations should be disabled
  108099. */
  108100. disableBidirectionalTransformation?: boolean;
  108101. /**
  108102. * The pressure inside the physics imposter, soft object only
  108103. */
  108104. pressure?: number;
  108105. /**
  108106. * The stiffness the physics imposter, soft object only
  108107. */
  108108. stiffness?: number;
  108109. /**
  108110. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  108111. */
  108112. velocityIterations?: number;
  108113. /**
  108114. * The number of iterations used in maintaining consistent vertex positions, soft object only
  108115. */
  108116. positionIterations?: number;
  108117. /**
  108118. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  108119. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  108120. * Add to fix multiple points
  108121. */
  108122. fixedPoints?: number;
  108123. /**
  108124. * The collision margin around a soft object
  108125. */
  108126. margin?: number;
  108127. /**
  108128. * The collision margin around a soft object
  108129. */
  108130. damping?: number;
  108131. /**
  108132. * The path for a rope based on an extrusion
  108133. */
  108134. path?: any;
  108135. /**
  108136. * The shape of an extrusion used for a rope based on an extrusion
  108137. */
  108138. shape?: any;
  108139. }
  108140. /**
  108141. * Interface for a physics-enabled object
  108142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108143. */
  108144. export interface IPhysicsEnabledObject {
  108145. /**
  108146. * The position of the physics-enabled object
  108147. */
  108148. position: Vector3;
  108149. /**
  108150. * The rotation of the physics-enabled object
  108151. */
  108152. rotationQuaternion: Nullable<Quaternion>;
  108153. /**
  108154. * The scale of the physics-enabled object
  108155. */
  108156. scaling: Vector3;
  108157. /**
  108158. * The rotation of the physics-enabled object
  108159. */
  108160. rotation?: Vector3;
  108161. /**
  108162. * The parent of the physics-enabled object
  108163. */
  108164. parent?: any;
  108165. /**
  108166. * The bounding info of the physics-enabled object
  108167. * @returns The bounding info of the physics-enabled object
  108168. */
  108169. getBoundingInfo(): BoundingInfo;
  108170. /**
  108171. * Computes the world matrix
  108172. * @param force Specifies if the world matrix should be computed by force
  108173. * @returns A world matrix
  108174. */
  108175. computeWorldMatrix(force: boolean): Matrix;
  108176. /**
  108177. * Gets the world matrix
  108178. * @returns A world matrix
  108179. */
  108180. getWorldMatrix?(): Matrix;
  108181. /**
  108182. * Gets the child meshes
  108183. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  108184. * @returns An array of abstract meshes
  108185. */
  108186. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  108187. /**
  108188. * Gets the vertex data
  108189. * @param kind The type of vertex data
  108190. * @returns A nullable array of numbers, or a float32 array
  108191. */
  108192. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  108193. /**
  108194. * Gets the indices from the mesh
  108195. * @returns A nullable array of index arrays
  108196. */
  108197. getIndices?(): Nullable<IndicesArray>;
  108198. /**
  108199. * Gets the scene from the mesh
  108200. * @returns the indices array or null
  108201. */
  108202. getScene?(): Scene;
  108203. /**
  108204. * Gets the absolute position from the mesh
  108205. * @returns the absolute position
  108206. */
  108207. getAbsolutePosition(): Vector3;
  108208. /**
  108209. * Gets the absolute pivot point from the mesh
  108210. * @returns the absolute pivot point
  108211. */
  108212. getAbsolutePivotPoint(): Vector3;
  108213. /**
  108214. * Rotates the mesh
  108215. * @param axis The axis of rotation
  108216. * @param amount The amount of rotation
  108217. * @param space The space of the rotation
  108218. * @returns The rotation transform node
  108219. */
  108220. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  108221. /**
  108222. * Translates the mesh
  108223. * @param axis The axis of translation
  108224. * @param distance The distance of translation
  108225. * @param space The space of the translation
  108226. * @returns The transform node
  108227. */
  108228. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  108229. /**
  108230. * Sets the absolute position of the mesh
  108231. * @param absolutePosition The absolute position of the mesh
  108232. * @returns The transform node
  108233. */
  108234. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  108235. /**
  108236. * Gets the class name of the mesh
  108237. * @returns The class name
  108238. */
  108239. getClassName(): string;
  108240. }
  108241. /**
  108242. * Represents a physics imposter
  108243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108244. */
  108245. export class PhysicsImpostor {
  108246. /**
  108247. * The physics-enabled object used as the physics imposter
  108248. */
  108249. object: IPhysicsEnabledObject;
  108250. /**
  108251. * The type of the physics imposter
  108252. */
  108253. type: number;
  108254. private _options;
  108255. private _scene?;
  108256. /**
  108257. * The default object size of the imposter
  108258. */
  108259. static DEFAULT_OBJECT_SIZE: Vector3;
  108260. /**
  108261. * The identity quaternion of the imposter
  108262. */
  108263. static IDENTITY_QUATERNION: Quaternion;
  108264. /** @hidden */
  108265. _pluginData: any;
  108266. private _physicsEngine;
  108267. private _physicsBody;
  108268. private _bodyUpdateRequired;
  108269. private _onBeforePhysicsStepCallbacks;
  108270. private _onAfterPhysicsStepCallbacks;
  108271. /** @hidden */
  108272. _onPhysicsCollideCallbacks: Array<{
  108273. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108274. otherImpostors: Array<PhysicsImpostor>;
  108275. }>;
  108276. private _deltaPosition;
  108277. private _deltaRotation;
  108278. private _deltaRotationConjugated;
  108279. /** @hidden */
  108280. _isFromLine: boolean;
  108281. private _parent;
  108282. private _isDisposed;
  108283. private static _tmpVecs;
  108284. private static _tmpQuat;
  108285. /**
  108286. * Specifies if the physics imposter is disposed
  108287. */
  108288. get isDisposed(): boolean;
  108289. /**
  108290. * Gets the mass of the physics imposter
  108291. */
  108292. get mass(): number;
  108293. set mass(value: number);
  108294. /**
  108295. * Gets the coefficient of friction
  108296. */
  108297. get friction(): number;
  108298. /**
  108299. * Sets the coefficient of friction
  108300. */
  108301. set friction(value: number);
  108302. /**
  108303. * Gets the coefficient of restitution
  108304. */
  108305. get restitution(): number;
  108306. /**
  108307. * Sets the coefficient of restitution
  108308. */
  108309. set restitution(value: number);
  108310. /**
  108311. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108312. */
  108313. get pressure(): number;
  108314. /**
  108315. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108316. */
  108317. set pressure(value: number);
  108318. /**
  108319. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108320. */
  108321. get stiffness(): number;
  108322. /**
  108323. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108324. */
  108325. set stiffness(value: number);
  108326. /**
  108327. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108328. */
  108329. get velocityIterations(): number;
  108330. /**
  108331. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108332. */
  108333. set velocityIterations(value: number);
  108334. /**
  108335. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108336. */
  108337. get positionIterations(): number;
  108338. /**
  108339. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108340. */
  108341. set positionIterations(value: number);
  108342. /**
  108343. * The unique id of the physics imposter
  108344. * set by the physics engine when adding this impostor to the array
  108345. */
  108346. uniqueId: number;
  108347. /**
  108348. * @hidden
  108349. */
  108350. soft: boolean;
  108351. /**
  108352. * @hidden
  108353. */
  108354. segments: number;
  108355. private _joints;
  108356. /**
  108357. * Initializes the physics imposter
  108358. * @param object The physics-enabled object used as the physics imposter
  108359. * @param type The type of the physics imposter
  108360. * @param _options The options for the physics imposter
  108361. * @param _scene The Babylon scene
  108362. */
  108363. constructor(
  108364. /**
  108365. * The physics-enabled object used as the physics imposter
  108366. */
  108367. object: IPhysicsEnabledObject,
  108368. /**
  108369. * The type of the physics imposter
  108370. */
  108371. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108372. /**
  108373. * This function will completly initialize this impostor.
  108374. * It will create a new body - but only if this mesh has no parent.
  108375. * If it has, this impostor will not be used other than to define the impostor
  108376. * of the child mesh.
  108377. * @hidden
  108378. */
  108379. _init(): void;
  108380. private _getPhysicsParent;
  108381. /**
  108382. * Should a new body be generated.
  108383. * @returns boolean specifying if body initialization is required
  108384. */
  108385. isBodyInitRequired(): boolean;
  108386. /**
  108387. * Sets the updated scaling
  108388. * @param updated Specifies if the scaling is updated
  108389. */
  108390. setScalingUpdated(): void;
  108391. /**
  108392. * Force a regeneration of this or the parent's impostor's body.
  108393. * Use under cautious - This will remove all joints already implemented.
  108394. */
  108395. forceUpdate(): void;
  108396. /**
  108397. * Gets the body that holds this impostor. Either its own, or its parent.
  108398. */
  108399. get physicsBody(): any;
  108400. /**
  108401. * Get the parent of the physics imposter
  108402. * @returns Physics imposter or null
  108403. */
  108404. get parent(): Nullable<PhysicsImpostor>;
  108405. /**
  108406. * Sets the parent of the physics imposter
  108407. */
  108408. set parent(value: Nullable<PhysicsImpostor>);
  108409. /**
  108410. * Set the physics body. Used mainly by the physics engine/plugin
  108411. */
  108412. set physicsBody(physicsBody: any);
  108413. /**
  108414. * Resets the update flags
  108415. */
  108416. resetUpdateFlags(): void;
  108417. /**
  108418. * Gets the object extend size
  108419. * @returns the object extend size
  108420. */
  108421. getObjectExtendSize(): Vector3;
  108422. /**
  108423. * Gets the object center
  108424. * @returns The object center
  108425. */
  108426. getObjectCenter(): Vector3;
  108427. /**
  108428. * Get a specific parameter from the options parameters
  108429. * @param paramName The object parameter name
  108430. * @returns The object parameter
  108431. */
  108432. getParam(paramName: string): any;
  108433. /**
  108434. * Sets a specific parameter in the options given to the physics plugin
  108435. * @param paramName The parameter name
  108436. * @param value The value of the parameter
  108437. */
  108438. setParam(paramName: string, value: number): void;
  108439. /**
  108440. * Specifically change the body's mass option. Won't recreate the physics body object
  108441. * @param mass The mass of the physics imposter
  108442. */
  108443. setMass(mass: number): void;
  108444. /**
  108445. * Gets the linear velocity
  108446. * @returns linear velocity or null
  108447. */
  108448. getLinearVelocity(): Nullable<Vector3>;
  108449. /**
  108450. * Sets the linear velocity
  108451. * @param velocity linear velocity or null
  108452. */
  108453. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108454. /**
  108455. * Gets the angular velocity
  108456. * @returns angular velocity or null
  108457. */
  108458. getAngularVelocity(): Nullable<Vector3>;
  108459. /**
  108460. * Sets the angular velocity
  108461. * @param velocity The velocity or null
  108462. */
  108463. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108464. /**
  108465. * Execute a function with the physics plugin native code
  108466. * Provide a function the will have two variables - the world object and the physics body object
  108467. * @param func The function to execute with the physics plugin native code
  108468. */
  108469. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108470. /**
  108471. * Register a function that will be executed before the physics world is stepping forward
  108472. * @param func The function to execute before the physics world is stepped forward
  108473. */
  108474. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108475. /**
  108476. * Unregister a function that will be executed before the physics world is stepping forward
  108477. * @param func The function to execute before the physics world is stepped forward
  108478. */
  108479. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108480. /**
  108481. * Register a function that will be executed after the physics step
  108482. * @param func The function to execute after physics step
  108483. */
  108484. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108485. /**
  108486. * Unregisters a function that will be executed after the physics step
  108487. * @param func The function to execute after physics step
  108488. */
  108489. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108490. /**
  108491. * register a function that will be executed when this impostor collides against a different body
  108492. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108493. * @param func Callback that is executed on collision
  108494. */
  108495. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108496. /**
  108497. * Unregisters the physics imposter on contact
  108498. * @param collideAgainst The physics object to collide against
  108499. * @param func Callback to execute on collision
  108500. */
  108501. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108502. private _tmpQuat;
  108503. private _tmpQuat2;
  108504. /**
  108505. * Get the parent rotation
  108506. * @returns The parent rotation
  108507. */
  108508. getParentsRotation(): Quaternion;
  108509. /**
  108510. * this function is executed by the physics engine.
  108511. */
  108512. beforeStep: () => void;
  108513. /**
  108514. * this function is executed by the physics engine
  108515. */
  108516. afterStep: () => void;
  108517. /**
  108518. * Legacy collision detection event support
  108519. */
  108520. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108521. /**
  108522. * event and body object due to cannon's event-based architecture.
  108523. */
  108524. onCollide: (e: {
  108525. body: any;
  108526. }) => void;
  108527. /**
  108528. * Apply a force
  108529. * @param force The force to apply
  108530. * @param contactPoint The contact point for the force
  108531. * @returns The physics imposter
  108532. */
  108533. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108534. /**
  108535. * Apply an impulse
  108536. * @param force The impulse force
  108537. * @param contactPoint The contact point for the impulse force
  108538. * @returns The physics imposter
  108539. */
  108540. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108541. /**
  108542. * A help function to create a joint
  108543. * @param otherImpostor A physics imposter used to create a joint
  108544. * @param jointType The type of joint
  108545. * @param jointData The data for the joint
  108546. * @returns The physics imposter
  108547. */
  108548. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108549. /**
  108550. * Add a joint to this impostor with a different impostor
  108551. * @param otherImpostor A physics imposter used to add a joint
  108552. * @param joint The joint to add
  108553. * @returns The physics imposter
  108554. */
  108555. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108556. /**
  108557. * Add an anchor to a cloth impostor
  108558. * @param otherImpostor rigid impostor to anchor to
  108559. * @param width ratio across width from 0 to 1
  108560. * @param height ratio up height from 0 to 1
  108561. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108562. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108563. * @returns impostor the soft imposter
  108564. */
  108565. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108566. /**
  108567. * Add a hook to a rope impostor
  108568. * @param otherImpostor rigid impostor to anchor to
  108569. * @param length ratio across rope from 0 to 1
  108570. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108571. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108572. * @returns impostor the rope imposter
  108573. */
  108574. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108575. /**
  108576. * Will keep this body still, in a sleep mode.
  108577. * @returns the physics imposter
  108578. */
  108579. sleep(): PhysicsImpostor;
  108580. /**
  108581. * Wake the body up.
  108582. * @returns The physics imposter
  108583. */
  108584. wakeUp(): PhysicsImpostor;
  108585. /**
  108586. * Clones the physics imposter
  108587. * @param newObject The physics imposter clones to this physics-enabled object
  108588. * @returns A nullable physics imposter
  108589. */
  108590. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108591. /**
  108592. * Disposes the physics imposter
  108593. */
  108594. dispose(): void;
  108595. /**
  108596. * Sets the delta position
  108597. * @param position The delta position amount
  108598. */
  108599. setDeltaPosition(position: Vector3): void;
  108600. /**
  108601. * Sets the delta rotation
  108602. * @param rotation The delta rotation amount
  108603. */
  108604. setDeltaRotation(rotation: Quaternion): void;
  108605. /**
  108606. * Gets the box size of the physics imposter and stores the result in the input parameter
  108607. * @param result Stores the box size
  108608. * @returns The physics imposter
  108609. */
  108610. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108611. /**
  108612. * Gets the radius of the physics imposter
  108613. * @returns Radius of the physics imposter
  108614. */
  108615. getRadius(): number;
  108616. /**
  108617. * Sync a bone with this impostor
  108618. * @param bone The bone to sync to the impostor.
  108619. * @param boneMesh The mesh that the bone is influencing.
  108620. * @param jointPivot The pivot of the joint / bone in local space.
  108621. * @param distToJoint Optional distance from the impostor to the joint.
  108622. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108623. */
  108624. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108625. /**
  108626. * Sync impostor to a bone
  108627. * @param bone The bone that the impostor will be synced to.
  108628. * @param boneMesh The mesh that the bone is influencing.
  108629. * @param jointPivot The pivot of the joint / bone in local space.
  108630. * @param distToJoint Optional distance from the impostor to the joint.
  108631. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108632. * @param boneAxis Optional vector3 axis the bone is aligned with
  108633. */
  108634. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108635. /**
  108636. * No-Imposter type
  108637. */
  108638. static NoImpostor: number;
  108639. /**
  108640. * Sphere-Imposter type
  108641. */
  108642. static SphereImpostor: number;
  108643. /**
  108644. * Box-Imposter type
  108645. */
  108646. static BoxImpostor: number;
  108647. /**
  108648. * Plane-Imposter type
  108649. */
  108650. static PlaneImpostor: number;
  108651. /**
  108652. * Mesh-imposter type
  108653. */
  108654. static MeshImpostor: number;
  108655. /**
  108656. * Capsule-Impostor type (Ammo.js plugin only)
  108657. */
  108658. static CapsuleImpostor: number;
  108659. /**
  108660. * Cylinder-Imposter type
  108661. */
  108662. static CylinderImpostor: number;
  108663. /**
  108664. * Particle-Imposter type
  108665. */
  108666. static ParticleImpostor: number;
  108667. /**
  108668. * Heightmap-Imposter type
  108669. */
  108670. static HeightmapImpostor: number;
  108671. /**
  108672. * ConvexHull-Impostor type (Ammo.js plugin only)
  108673. */
  108674. static ConvexHullImpostor: number;
  108675. /**
  108676. * Custom-Imposter type (Ammo.js plugin only)
  108677. */
  108678. static CustomImpostor: number;
  108679. /**
  108680. * Rope-Imposter type
  108681. */
  108682. static RopeImpostor: number;
  108683. /**
  108684. * Cloth-Imposter type
  108685. */
  108686. static ClothImpostor: number;
  108687. /**
  108688. * Softbody-Imposter type
  108689. */
  108690. static SoftbodyImpostor: number;
  108691. }
  108692. }
  108693. declare module BABYLON {
  108694. /**
  108695. * @hidden
  108696. **/
  108697. export class _CreationDataStorage {
  108698. closePath?: boolean;
  108699. closeArray?: boolean;
  108700. idx: number[];
  108701. dashSize: number;
  108702. gapSize: number;
  108703. path3D: Path3D;
  108704. pathArray: Vector3[][];
  108705. arc: number;
  108706. radius: number;
  108707. cap: number;
  108708. tessellation: number;
  108709. }
  108710. /**
  108711. * @hidden
  108712. **/
  108713. class _InstanceDataStorage {
  108714. visibleInstances: any;
  108715. batchCache: _InstancesBatch;
  108716. instancesBufferSize: number;
  108717. instancesBuffer: Nullable<Buffer>;
  108718. instancesData: Float32Array;
  108719. overridenInstanceCount: number;
  108720. isFrozen: boolean;
  108721. previousBatch: Nullable<_InstancesBatch>;
  108722. hardwareInstancedRendering: boolean;
  108723. sideOrientation: number;
  108724. manualUpdate: boolean;
  108725. previousRenderId: number;
  108726. }
  108727. /**
  108728. * @hidden
  108729. **/
  108730. export class _InstancesBatch {
  108731. mustReturn: boolean;
  108732. visibleInstances: Nullable<InstancedMesh[]>[];
  108733. renderSelf: boolean[];
  108734. hardwareInstancedRendering: boolean[];
  108735. }
  108736. /**
  108737. * @hidden
  108738. **/
  108739. class _ThinInstanceDataStorage {
  108740. instancesCount: number;
  108741. matrixBuffer: Nullable<Buffer>;
  108742. matrixBufferSize: number;
  108743. matrixData: Nullable<Float32Array>;
  108744. boundingVectors: Array<Vector3>;
  108745. worldMatrices: Nullable<Matrix[]>;
  108746. }
  108747. /**
  108748. * Class used to represent renderable models
  108749. */
  108750. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108751. /**
  108752. * Mesh side orientation : usually the external or front surface
  108753. */
  108754. static readonly FRONTSIDE: number;
  108755. /**
  108756. * Mesh side orientation : usually the internal or back surface
  108757. */
  108758. static readonly BACKSIDE: number;
  108759. /**
  108760. * Mesh side orientation : both internal and external or front and back surfaces
  108761. */
  108762. static readonly DOUBLESIDE: number;
  108763. /**
  108764. * Mesh side orientation : by default, `FRONTSIDE`
  108765. */
  108766. static readonly DEFAULTSIDE: number;
  108767. /**
  108768. * Mesh cap setting : no cap
  108769. */
  108770. static readonly NO_CAP: number;
  108771. /**
  108772. * Mesh cap setting : one cap at the beginning of the mesh
  108773. */
  108774. static readonly CAP_START: number;
  108775. /**
  108776. * Mesh cap setting : one cap at the end of the mesh
  108777. */
  108778. static readonly CAP_END: number;
  108779. /**
  108780. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108781. */
  108782. static readonly CAP_ALL: number;
  108783. /**
  108784. * Mesh pattern setting : no flip or rotate
  108785. */
  108786. static readonly NO_FLIP: number;
  108787. /**
  108788. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108789. */
  108790. static readonly FLIP_TILE: number;
  108791. /**
  108792. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108793. */
  108794. static readonly ROTATE_TILE: number;
  108795. /**
  108796. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108797. */
  108798. static readonly FLIP_ROW: number;
  108799. /**
  108800. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108801. */
  108802. static readonly ROTATE_ROW: number;
  108803. /**
  108804. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108805. */
  108806. static readonly FLIP_N_ROTATE_TILE: number;
  108807. /**
  108808. * Mesh pattern setting : rotate pattern and rotate
  108809. */
  108810. static readonly FLIP_N_ROTATE_ROW: number;
  108811. /**
  108812. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108813. */
  108814. static readonly CENTER: number;
  108815. /**
  108816. * Mesh tile positioning : part tiles on left
  108817. */
  108818. static readonly LEFT: number;
  108819. /**
  108820. * Mesh tile positioning : part tiles on right
  108821. */
  108822. static readonly RIGHT: number;
  108823. /**
  108824. * Mesh tile positioning : part tiles on top
  108825. */
  108826. static readonly TOP: number;
  108827. /**
  108828. * Mesh tile positioning : part tiles on bottom
  108829. */
  108830. static readonly BOTTOM: number;
  108831. /**
  108832. * Gets the default side orientation.
  108833. * @param orientation the orientation to value to attempt to get
  108834. * @returns the default orientation
  108835. * @hidden
  108836. */
  108837. static _GetDefaultSideOrientation(orientation?: number): number;
  108838. private _internalMeshDataInfo;
  108839. get computeBonesUsingShaders(): boolean;
  108840. set computeBonesUsingShaders(value: boolean);
  108841. /**
  108842. * An event triggered before rendering the mesh
  108843. */
  108844. get onBeforeRenderObservable(): Observable<Mesh>;
  108845. /**
  108846. * An event triggered before binding the mesh
  108847. */
  108848. get onBeforeBindObservable(): Observable<Mesh>;
  108849. /**
  108850. * An event triggered after rendering the mesh
  108851. */
  108852. get onAfterRenderObservable(): Observable<Mesh>;
  108853. /**
  108854. * An event triggered before drawing the mesh
  108855. */
  108856. get onBeforeDrawObservable(): Observable<Mesh>;
  108857. private _onBeforeDrawObserver;
  108858. /**
  108859. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108860. */
  108861. set onBeforeDraw(callback: () => void);
  108862. get hasInstances(): boolean;
  108863. get hasThinInstances(): boolean;
  108864. /**
  108865. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108866. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108867. */
  108868. delayLoadState: number;
  108869. /**
  108870. * Gets the list of instances created from this mesh
  108871. * it is not supposed to be modified manually.
  108872. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108873. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108874. */
  108875. instances: InstancedMesh[];
  108876. /**
  108877. * Gets the file containing delay loading data for this mesh
  108878. */
  108879. delayLoadingFile: string;
  108880. /** @hidden */
  108881. _binaryInfo: any;
  108882. /**
  108883. * User defined function used to change how LOD level selection is done
  108884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108885. */
  108886. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108887. /**
  108888. * Gets or sets the morph target manager
  108889. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108890. */
  108891. get morphTargetManager(): Nullable<MorphTargetManager>;
  108892. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108893. /** @hidden */
  108894. _creationDataStorage: Nullable<_CreationDataStorage>;
  108895. /** @hidden */
  108896. _geometry: Nullable<Geometry>;
  108897. /** @hidden */
  108898. _delayInfo: Array<string>;
  108899. /** @hidden */
  108900. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108901. /** @hidden */
  108902. _instanceDataStorage: _InstanceDataStorage;
  108903. /** @hidden */
  108904. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108905. private _effectiveMaterial;
  108906. /** @hidden */
  108907. _shouldGenerateFlatShading: boolean;
  108908. /** @hidden */
  108909. _originalBuilderSideOrientation: number;
  108910. /**
  108911. * Use this property to change the original side orientation defined at construction time
  108912. */
  108913. overrideMaterialSideOrientation: Nullable<number>;
  108914. /**
  108915. * Gets the source mesh (the one used to clone this one from)
  108916. */
  108917. get source(): Nullable<Mesh>;
  108918. /**
  108919. * Gets the list of clones of this mesh
  108920. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108921. * Note that useClonedMeshMap=true is the default setting
  108922. */
  108923. get cloneMeshMap(): Nullable<{
  108924. [id: string]: Mesh | undefined;
  108925. }>;
  108926. /**
  108927. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108928. */
  108929. get isUnIndexed(): boolean;
  108930. set isUnIndexed(value: boolean);
  108931. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108932. get worldMatrixInstancedBuffer(): Float32Array;
  108933. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108934. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108935. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108936. /**
  108937. * @constructor
  108938. * @param name The value used by scene.getMeshByName() to do a lookup.
  108939. * @param scene The scene to add this mesh to.
  108940. * @param parent The parent of this mesh, if it has one
  108941. * @param source An optional Mesh from which geometry is shared, cloned.
  108942. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108943. * When false, achieved by calling a clone(), also passing False.
  108944. * This will make creation of children, recursive.
  108945. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108946. */
  108947. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108948. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108949. doNotInstantiate: boolean;
  108950. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108951. /**
  108952. * Gets the class name
  108953. * @returns the string "Mesh".
  108954. */
  108955. getClassName(): string;
  108956. /** @hidden */
  108957. get _isMesh(): boolean;
  108958. /**
  108959. * Returns a description of this mesh
  108960. * @param fullDetails define if full details about this mesh must be used
  108961. * @returns a descriptive string representing this mesh
  108962. */
  108963. toString(fullDetails?: boolean): string;
  108964. /** @hidden */
  108965. _unBindEffect(): void;
  108966. /**
  108967. * Gets a boolean indicating if this mesh has LOD
  108968. */
  108969. get hasLODLevels(): boolean;
  108970. /**
  108971. * Gets the list of MeshLODLevel associated with the current mesh
  108972. * @returns an array of MeshLODLevel
  108973. */
  108974. getLODLevels(): MeshLODLevel[];
  108975. private _sortLODLevels;
  108976. /**
  108977. * Add a mesh as LOD level triggered at the given distance.
  108978. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108979. * @param distance The distance from the center of the object to show this level
  108980. * @param mesh The mesh to be added as LOD level (can be null)
  108981. * @return This mesh (for chaining)
  108982. */
  108983. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108984. /**
  108985. * Returns the LOD level mesh at the passed distance or null if not found.
  108986. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108987. * @param distance The distance from the center of the object to show this level
  108988. * @returns a Mesh or `null`
  108989. */
  108990. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108991. /**
  108992. * Remove a mesh from the LOD array
  108993. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108994. * @param mesh defines the mesh to be removed
  108995. * @return This mesh (for chaining)
  108996. */
  108997. removeLODLevel(mesh: Mesh): Mesh;
  108998. /**
  108999. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  109000. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109001. * @param camera defines the camera to use to compute distance
  109002. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  109003. * @return This mesh (for chaining)
  109004. */
  109005. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  109006. /**
  109007. * Gets the mesh internal Geometry object
  109008. */
  109009. get geometry(): Nullable<Geometry>;
  109010. /**
  109011. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  109012. * @returns the total number of vertices
  109013. */
  109014. getTotalVertices(): number;
  109015. /**
  109016. * Returns the content of an associated vertex buffer
  109017. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109018. * - VertexBuffer.PositionKind
  109019. * - VertexBuffer.UVKind
  109020. * - VertexBuffer.UV2Kind
  109021. * - VertexBuffer.UV3Kind
  109022. * - VertexBuffer.UV4Kind
  109023. * - VertexBuffer.UV5Kind
  109024. * - VertexBuffer.UV6Kind
  109025. * - VertexBuffer.ColorKind
  109026. * - VertexBuffer.MatricesIndicesKind
  109027. * - VertexBuffer.MatricesIndicesExtraKind
  109028. * - VertexBuffer.MatricesWeightsKind
  109029. * - VertexBuffer.MatricesWeightsExtraKind
  109030. * @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
  109031. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  109032. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  109033. */
  109034. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  109035. /**
  109036. * Returns the mesh VertexBuffer object from the requested `kind`
  109037. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109038. * - VertexBuffer.PositionKind
  109039. * - VertexBuffer.NormalKind
  109040. * - VertexBuffer.UVKind
  109041. * - VertexBuffer.UV2Kind
  109042. * - VertexBuffer.UV3Kind
  109043. * - VertexBuffer.UV4Kind
  109044. * - VertexBuffer.UV5Kind
  109045. * - VertexBuffer.UV6Kind
  109046. * - VertexBuffer.ColorKind
  109047. * - VertexBuffer.MatricesIndicesKind
  109048. * - VertexBuffer.MatricesIndicesExtraKind
  109049. * - VertexBuffer.MatricesWeightsKind
  109050. * - VertexBuffer.MatricesWeightsExtraKind
  109051. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  109052. */
  109053. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  109054. /**
  109055. * Tests if a specific vertex buffer is associated with this mesh
  109056. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109057. * - VertexBuffer.PositionKind
  109058. * - VertexBuffer.NormalKind
  109059. * - VertexBuffer.UVKind
  109060. * - VertexBuffer.UV2Kind
  109061. * - VertexBuffer.UV3Kind
  109062. * - VertexBuffer.UV4Kind
  109063. * - VertexBuffer.UV5Kind
  109064. * - VertexBuffer.UV6Kind
  109065. * - VertexBuffer.ColorKind
  109066. * - VertexBuffer.MatricesIndicesKind
  109067. * - VertexBuffer.MatricesIndicesExtraKind
  109068. * - VertexBuffer.MatricesWeightsKind
  109069. * - VertexBuffer.MatricesWeightsExtraKind
  109070. * @returns a boolean
  109071. */
  109072. isVerticesDataPresent(kind: string): boolean;
  109073. /**
  109074. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  109075. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109076. * - VertexBuffer.PositionKind
  109077. * - VertexBuffer.UVKind
  109078. * - VertexBuffer.UV2Kind
  109079. * - VertexBuffer.UV3Kind
  109080. * - VertexBuffer.UV4Kind
  109081. * - VertexBuffer.UV5Kind
  109082. * - VertexBuffer.UV6Kind
  109083. * - VertexBuffer.ColorKind
  109084. * - VertexBuffer.MatricesIndicesKind
  109085. * - VertexBuffer.MatricesIndicesExtraKind
  109086. * - VertexBuffer.MatricesWeightsKind
  109087. * - VertexBuffer.MatricesWeightsExtraKind
  109088. * @returns a boolean
  109089. */
  109090. isVertexBufferUpdatable(kind: string): boolean;
  109091. /**
  109092. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  109093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109094. * - VertexBuffer.PositionKind
  109095. * - VertexBuffer.NormalKind
  109096. * - VertexBuffer.UVKind
  109097. * - VertexBuffer.UV2Kind
  109098. * - VertexBuffer.UV3Kind
  109099. * - VertexBuffer.UV4Kind
  109100. * - VertexBuffer.UV5Kind
  109101. * - VertexBuffer.UV6Kind
  109102. * - VertexBuffer.ColorKind
  109103. * - VertexBuffer.MatricesIndicesKind
  109104. * - VertexBuffer.MatricesIndicesExtraKind
  109105. * - VertexBuffer.MatricesWeightsKind
  109106. * - VertexBuffer.MatricesWeightsExtraKind
  109107. * @returns an array of strings
  109108. */
  109109. getVerticesDataKinds(): string[];
  109110. /**
  109111. * Returns a positive integer : the total number of indices in this mesh geometry.
  109112. * @returns the numner of indices or zero if the mesh has no geometry.
  109113. */
  109114. getTotalIndices(): number;
  109115. /**
  109116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109117. * @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.
  109118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  109119. * @returns the indices array or an empty array if the mesh has no geometry
  109120. */
  109121. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  109122. get isBlocked(): boolean;
  109123. /**
  109124. * Determine if the current mesh is ready to be rendered
  109125. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109126. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  109127. * @returns true if all associated assets are ready (material, textures, shaders)
  109128. */
  109129. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  109130. /**
  109131. * 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.
  109132. */
  109133. get areNormalsFrozen(): boolean;
  109134. /**
  109135. * 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.
  109136. * @returns the current mesh
  109137. */
  109138. freezeNormals(): Mesh;
  109139. /**
  109140. * 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
  109141. * @returns the current mesh
  109142. */
  109143. unfreezeNormals(): Mesh;
  109144. /**
  109145. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  109146. */
  109147. set overridenInstanceCount(count: number);
  109148. /** @hidden */
  109149. _preActivate(): Mesh;
  109150. /** @hidden */
  109151. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109152. /** @hidden */
  109153. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  109154. protected _afterComputeWorldMatrix(): void;
  109155. /** @hidden */
  109156. _postActivate(): void;
  109157. /**
  109158. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109159. * This means the mesh underlying bounding box and sphere are recomputed.
  109160. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109161. * @returns the current mesh
  109162. */
  109163. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  109164. /** @hidden */
  109165. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  109166. /**
  109167. * This function will subdivide the mesh into multiple submeshes
  109168. * @param count defines the expected number of submeshes
  109169. */
  109170. subdivide(count: number): void;
  109171. /**
  109172. * Copy a FloatArray into a specific associated vertex buffer
  109173. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109174. * - VertexBuffer.PositionKind
  109175. * - VertexBuffer.UVKind
  109176. * - VertexBuffer.UV2Kind
  109177. * - VertexBuffer.UV3Kind
  109178. * - VertexBuffer.UV4Kind
  109179. * - VertexBuffer.UV5Kind
  109180. * - VertexBuffer.UV6Kind
  109181. * - VertexBuffer.ColorKind
  109182. * - VertexBuffer.MatricesIndicesKind
  109183. * - VertexBuffer.MatricesIndicesExtraKind
  109184. * - VertexBuffer.MatricesWeightsKind
  109185. * - VertexBuffer.MatricesWeightsExtraKind
  109186. * @param data defines the data source
  109187. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109188. * @param stride defines the data stride size (can be null)
  109189. * @returns the current mesh
  109190. */
  109191. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109192. /**
  109193. * Delete a vertex buffer associated with this mesh
  109194. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  109195. * - VertexBuffer.PositionKind
  109196. * - VertexBuffer.UVKind
  109197. * - VertexBuffer.UV2Kind
  109198. * - VertexBuffer.UV3Kind
  109199. * - VertexBuffer.UV4Kind
  109200. * - VertexBuffer.UV5Kind
  109201. * - VertexBuffer.UV6Kind
  109202. * - VertexBuffer.ColorKind
  109203. * - VertexBuffer.MatricesIndicesKind
  109204. * - VertexBuffer.MatricesIndicesExtraKind
  109205. * - VertexBuffer.MatricesWeightsKind
  109206. * - VertexBuffer.MatricesWeightsExtraKind
  109207. */
  109208. removeVerticesData(kind: string): void;
  109209. /**
  109210. * Flags an associated vertex buffer as updatable
  109211. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  109212. * - VertexBuffer.PositionKind
  109213. * - VertexBuffer.UVKind
  109214. * - VertexBuffer.UV2Kind
  109215. * - VertexBuffer.UV3Kind
  109216. * - VertexBuffer.UV4Kind
  109217. * - VertexBuffer.UV5Kind
  109218. * - VertexBuffer.UV6Kind
  109219. * - VertexBuffer.ColorKind
  109220. * - VertexBuffer.MatricesIndicesKind
  109221. * - VertexBuffer.MatricesIndicesExtraKind
  109222. * - VertexBuffer.MatricesWeightsKind
  109223. * - VertexBuffer.MatricesWeightsExtraKind
  109224. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109225. */
  109226. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  109227. /**
  109228. * Sets the mesh global Vertex Buffer
  109229. * @param buffer defines the buffer to use
  109230. * @returns the current mesh
  109231. */
  109232. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  109233. /**
  109234. * Update a specific associated vertex buffer
  109235. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109236. * - VertexBuffer.PositionKind
  109237. * - VertexBuffer.UVKind
  109238. * - VertexBuffer.UV2Kind
  109239. * - VertexBuffer.UV3Kind
  109240. * - VertexBuffer.UV4Kind
  109241. * - VertexBuffer.UV5Kind
  109242. * - VertexBuffer.UV6Kind
  109243. * - VertexBuffer.ColorKind
  109244. * - VertexBuffer.MatricesIndicesKind
  109245. * - VertexBuffer.MatricesIndicesExtraKind
  109246. * - VertexBuffer.MatricesWeightsKind
  109247. * - VertexBuffer.MatricesWeightsExtraKind
  109248. * @param data defines the data source
  109249. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  109250. * @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)
  109251. * @returns the current mesh
  109252. */
  109253. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109254. /**
  109255. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  109256. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  109257. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  109258. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  109259. * @returns the current mesh
  109260. */
  109261. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  109262. /**
  109263. * Creates a un-shared specific occurence of the geometry for the mesh.
  109264. * @returns the current mesh
  109265. */
  109266. makeGeometryUnique(): Mesh;
  109267. /**
  109268. * Set the index buffer of this mesh
  109269. * @param indices defines the source data
  109270. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  109271. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  109272. * @returns the current mesh
  109273. */
  109274. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109275. /**
  109276. * Update the current index buffer
  109277. * @param indices defines the source data
  109278. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109279. * @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)
  109280. * @returns the current mesh
  109281. */
  109282. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109283. /**
  109284. * Invert the geometry to move from a right handed system to a left handed one.
  109285. * @returns the current mesh
  109286. */
  109287. toLeftHanded(): Mesh;
  109288. /** @hidden */
  109289. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109290. /** @hidden */
  109291. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109292. /**
  109293. * Registers for this mesh a javascript function called just before the rendering process
  109294. * @param func defines the function to call before rendering this mesh
  109295. * @returns the current mesh
  109296. */
  109297. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109298. /**
  109299. * Disposes a previously registered javascript function called before the rendering
  109300. * @param func defines the function to remove
  109301. * @returns the current mesh
  109302. */
  109303. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109304. /**
  109305. * Registers for this mesh a javascript function called just after the rendering is complete
  109306. * @param func defines the function to call after rendering this mesh
  109307. * @returns the current mesh
  109308. */
  109309. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109310. /**
  109311. * Disposes a previously registered javascript function called after the rendering.
  109312. * @param func defines the function to remove
  109313. * @returns the current mesh
  109314. */
  109315. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109316. /** @hidden */
  109317. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109318. /** @hidden */
  109319. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109320. /** @hidden */
  109321. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109322. /** @hidden */
  109323. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109324. /** @hidden */
  109325. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109326. /** @hidden */
  109327. _rebuild(): void;
  109328. /** @hidden */
  109329. _freeze(): void;
  109330. /** @hidden */
  109331. _unFreeze(): void;
  109332. /**
  109333. * 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
  109334. * @param subMesh defines the subMesh to render
  109335. * @param enableAlphaMode defines if alpha mode can be changed
  109336. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109337. * @returns the current mesh
  109338. */
  109339. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109340. private _onBeforeDraw;
  109341. /**
  109342. * Renormalize the mesh and patch it up if there are no weights
  109343. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109344. * However in the case of zero weights then we set just a single influence to 1.
  109345. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109346. */
  109347. cleanMatrixWeights(): void;
  109348. private normalizeSkinFourWeights;
  109349. private normalizeSkinWeightsAndExtra;
  109350. /**
  109351. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109352. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109353. * the user know there was an issue with importing the mesh
  109354. * @returns a validation object with skinned, valid and report string
  109355. */
  109356. validateSkinning(): {
  109357. skinned: boolean;
  109358. valid: boolean;
  109359. report: string;
  109360. };
  109361. /** @hidden */
  109362. _checkDelayState(): Mesh;
  109363. private _queueLoad;
  109364. /**
  109365. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109366. * A mesh is in the frustum if its bounding box intersects the frustum
  109367. * @param frustumPlanes defines the frustum to test
  109368. * @returns true if the mesh is in the frustum planes
  109369. */
  109370. isInFrustum(frustumPlanes: Plane[]): boolean;
  109371. /**
  109372. * Sets the mesh material by the material or multiMaterial `id` property
  109373. * @param id is a string identifying the material or the multiMaterial
  109374. * @returns the current mesh
  109375. */
  109376. setMaterialByID(id: string): Mesh;
  109377. /**
  109378. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109379. * @returns an array of IAnimatable
  109380. */
  109381. getAnimatables(): IAnimatable[];
  109382. /**
  109383. * Modifies the mesh geometry according to the passed transformation matrix.
  109384. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109385. * The mesh normals are modified using the same transformation.
  109386. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109387. * @param transform defines the transform matrix to use
  109388. * @see https://doc.babylonjs.com/resources/baking_transformations
  109389. * @returns the current mesh
  109390. */
  109391. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109392. /**
  109393. * Modifies the mesh geometry according to its own current World Matrix.
  109394. * The mesh World Matrix is then reset.
  109395. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109396. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109397. * @see https://doc.babylonjs.com/resources/baking_transformations
  109398. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109399. * @returns the current mesh
  109400. */
  109401. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109402. /** @hidden */
  109403. get _positions(): Nullable<Vector3[]>;
  109404. /** @hidden */
  109405. _resetPointsArrayCache(): Mesh;
  109406. /** @hidden */
  109407. _generatePointsArray(): boolean;
  109408. /**
  109409. * Returns a new Mesh object generated from the current mesh properties.
  109410. * This method must not get confused with createInstance()
  109411. * @param name is a string, the name given to the new mesh
  109412. * @param newParent can be any Node object (default `null`)
  109413. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109414. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109415. * @returns a new mesh
  109416. */
  109417. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109418. /**
  109419. * Releases resources associated with this mesh.
  109420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109422. */
  109423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109424. /** @hidden */
  109425. _disposeInstanceSpecificData(): void;
  109426. /** @hidden */
  109427. _disposeThinInstanceSpecificData(): void;
  109428. /**
  109429. * Modifies the mesh geometry according to a displacement map.
  109430. * 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.
  109431. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109432. * @param url is a string, the URL from the image file is to be downloaded.
  109433. * @param minHeight is the lower limit of the displacement.
  109434. * @param maxHeight is the upper limit of the displacement.
  109435. * @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.
  109436. * @param uvOffset is an optional vector2 used to offset UV.
  109437. * @param uvScale is an optional vector2 used to scale UV.
  109438. * @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.
  109439. * @returns the Mesh.
  109440. */
  109441. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109442. /**
  109443. * Modifies the mesh geometry according to a displacementMap buffer.
  109444. * 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.
  109445. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109446. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109447. * @param heightMapWidth is the width of the buffer image.
  109448. * @param heightMapHeight is the height of the buffer image.
  109449. * @param minHeight is the lower limit of the displacement.
  109450. * @param maxHeight is the upper limit of the displacement.
  109451. * @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.
  109452. * @param uvOffset is an optional vector2 used to offset UV.
  109453. * @param uvScale is an optional vector2 used to scale UV.
  109454. * @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.
  109455. * @returns the Mesh.
  109456. */
  109457. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109458. /**
  109459. * Modify the mesh to get a flat shading rendering.
  109460. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109461. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109462. * @returns current mesh
  109463. */
  109464. convertToFlatShadedMesh(): Mesh;
  109465. /**
  109466. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109467. * In other words, more vertices, no more indices and a single bigger VBO.
  109468. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109469. * @returns current mesh
  109470. */
  109471. convertToUnIndexedMesh(): Mesh;
  109472. /**
  109473. * Inverses facet orientations.
  109474. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109475. * @param flipNormals will also inverts the normals
  109476. * @returns current mesh
  109477. */
  109478. flipFaces(flipNormals?: boolean): Mesh;
  109479. /**
  109480. * Increase the number of facets and hence vertices in a mesh
  109481. * Vertex normals are interpolated from existing vertex normals
  109482. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109483. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109484. */
  109485. increaseVertices(numberPerEdge: number): void;
  109486. /**
  109487. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109488. * This will undo any application of covertToFlatShadedMesh
  109489. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109490. */
  109491. forceSharedVertices(): void;
  109492. /** @hidden */
  109493. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109494. /** @hidden */
  109495. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109496. /**
  109497. * Creates a new InstancedMesh object from the mesh model.
  109498. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109499. * @param name defines the name of the new instance
  109500. * @returns a new InstancedMesh
  109501. */
  109502. createInstance(name: string): InstancedMesh;
  109503. /**
  109504. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109505. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109506. * @returns the current mesh
  109507. */
  109508. synchronizeInstances(): Mesh;
  109509. /**
  109510. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109511. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109512. * This should be used together with the simplification to avoid disappearing triangles.
  109513. * @param successCallback an optional success callback to be called after the optimization finished.
  109514. * @returns the current mesh
  109515. */
  109516. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109517. /**
  109518. * Serialize current mesh
  109519. * @param serializationObject defines the object which will receive the serialization data
  109520. */
  109521. serialize(serializationObject: any): void;
  109522. /** @hidden */
  109523. _syncGeometryWithMorphTargetManager(): void;
  109524. /** @hidden */
  109525. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109526. /**
  109527. * Returns a new Mesh object parsed from the source provided.
  109528. * @param parsedMesh is the source
  109529. * @param scene defines the hosting scene
  109530. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109531. * @returns a new Mesh
  109532. */
  109533. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109534. /**
  109535. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109537. * @param name defines the name of the mesh to create
  109538. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109539. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109540. * @param closePath creates a seam between the first and the last points of each path of the path array
  109541. * @param offset is taken in account only if the `pathArray` is containing a single path
  109542. * @param scene defines the hosting scene
  109543. * @param updatable defines if the mesh must be flagged as updatable
  109544. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109545. * @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)
  109546. * @returns a new Mesh
  109547. */
  109548. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109549. /**
  109550. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109551. * @param name defines the name of the mesh to create
  109552. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109553. * @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
  109554. * @param scene defines the hosting scene
  109555. * @param updatable defines if the mesh must be flagged as updatable
  109556. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109557. * @returns a new Mesh
  109558. */
  109559. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109560. /**
  109561. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109562. * @param name defines the name of the mesh to create
  109563. * @param size sets the size (float) of each box side (default 1)
  109564. * @param scene defines the hosting scene
  109565. * @param updatable defines if the mesh must be flagged as updatable
  109566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109567. * @returns a new Mesh
  109568. */
  109569. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109570. /**
  109571. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109572. * @param name defines the name of the mesh to create
  109573. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109574. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109575. * @param scene defines the hosting scene
  109576. * @param updatable defines if the mesh must be flagged as updatable
  109577. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109578. * @returns a new Mesh
  109579. */
  109580. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109581. /**
  109582. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109583. * @param name defines the name of the mesh to create
  109584. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109585. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109586. * @param scene defines the hosting scene
  109587. * @returns a new Mesh
  109588. */
  109589. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109590. /**
  109591. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109592. * @param name defines the name of the mesh to create
  109593. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109594. * @param diameterTop set the top cap diameter (floats, default 1)
  109595. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109596. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109597. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109598. * @param scene defines the hosting scene
  109599. * @param updatable defines if the mesh must be flagged as updatable
  109600. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109601. * @returns a new Mesh
  109602. */
  109603. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109604. /**
  109605. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109606. * @param name defines the name of the mesh to create
  109607. * @param diameter sets the diameter size (float) of the torus (default 1)
  109608. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109609. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109610. * @param scene defines the hosting scene
  109611. * @param updatable defines if the mesh must be flagged as updatable
  109612. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109613. * @returns a new Mesh
  109614. */
  109615. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109616. /**
  109617. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109618. * @param name defines the name of the mesh to create
  109619. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109620. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109621. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109622. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109623. * @param p the number of windings on X axis (positive integers, default 2)
  109624. * @param q the number of windings on Y axis (positive integers, default 3)
  109625. * @param scene defines the hosting scene
  109626. * @param updatable defines if the mesh must be flagged as updatable
  109627. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109628. * @returns a new Mesh
  109629. */
  109630. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109631. /**
  109632. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109633. * @param name defines the name of the mesh to create
  109634. * @param points is an array successive Vector3
  109635. * @param scene defines the hosting scene
  109636. * @param updatable defines if the mesh must be flagged as updatable
  109637. * @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).
  109638. * @returns a new Mesh
  109639. */
  109640. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109641. /**
  109642. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109643. * @param name defines the name of the mesh to create
  109644. * @param points is an array successive Vector3
  109645. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109646. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109647. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109648. * @param scene defines the hosting scene
  109649. * @param updatable defines if the mesh must be flagged as updatable
  109650. * @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)
  109651. * @returns a new Mesh
  109652. */
  109653. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109654. /**
  109655. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109656. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109657. * 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.
  109658. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109659. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109660. * Remember you can only change the shape positions, not their number when updating a polygon.
  109661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109662. * @param name defines the name of the mesh to create
  109663. * @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
  109664. * @param scene defines the hosting scene
  109665. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109666. * @param updatable defines if the mesh must be flagged as updatable
  109667. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109668. * @param earcutInjection can be used to inject your own earcut reference
  109669. * @returns a new Mesh
  109670. */
  109671. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109672. /**
  109673. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109675. * @param name defines the name of the mesh to create
  109676. * @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
  109677. * @param depth defines the height of extrusion
  109678. * @param scene defines the hosting scene
  109679. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109680. * @param updatable defines if the mesh must be flagged as updatable
  109681. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109682. * @param earcutInjection can be used to inject your own earcut reference
  109683. * @returns a new Mesh
  109684. */
  109685. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109686. /**
  109687. * Creates an extruded shape mesh.
  109688. * 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
  109689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109691. * @param name defines the name of the mesh to create
  109692. * @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
  109693. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109694. * @param scale is the value to scale the shape
  109695. * @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
  109696. * @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
  109697. * @param scene defines the hosting scene
  109698. * @param updatable defines if the mesh must be flagged as updatable
  109699. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109700. * @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)
  109701. * @returns a new Mesh
  109702. */
  109703. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109704. /**
  109705. * Creates an custom extruded shape mesh.
  109706. * The custom extrusion is a parametric shape.
  109707. * It has no predefined shape. Its final shape will depend on the input parameters.
  109708. * Please consider using the same method from the MeshBuilder class instead
  109709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109710. * @param name defines the name of the mesh to create
  109711. * @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
  109712. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109713. * @param scaleFunction is a custom Javascript function called on each path point
  109714. * @param rotationFunction is a custom Javascript function called on each path point
  109715. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109716. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109717. * @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
  109718. * @param scene defines the hosting scene
  109719. * @param updatable defines if the mesh must be flagged as updatable
  109720. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109721. * @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)
  109722. * @returns a new Mesh
  109723. */
  109724. 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;
  109725. /**
  109726. * Creates lathe mesh.
  109727. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109728. * Please consider using the same method from the MeshBuilder class instead
  109729. * @param name defines the name of the mesh to create
  109730. * @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
  109731. * @param radius is the radius value of the lathe
  109732. * @param tessellation is the side number of the lathe.
  109733. * @param scene defines the hosting scene
  109734. * @param updatable defines if the mesh must be flagged as updatable
  109735. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109736. * @returns a new Mesh
  109737. */
  109738. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109739. /**
  109740. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109741. * @param name defines the name of the mesh to create
  109742. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109743. * @param scene defines the hosting scene
  109744. * @param updatable defines if the mesh must be flagged as updatable
  109745. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109746. * @returns a new Mesh
  109747. */
  109748. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109749. /**
  109750. * Creates a ground mesh.
  109751. * Please consider using the same method from the MeshBuilder class instead
  109752. * @param name defines the name of the mesh to create
  109753. * @param width set the width of the ground
  109754. * @param height set the height of the ground
  109755. * @param subdivisions sets the number of subdivisions per side
  109756. * @param scene defines the hosting scene
  109757. * @param updatable defines if the mesh must be flagged as updatable
  109758. * @returns a new Mesh
  109759. */
  109760. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109761. /**
  109762. * Creates a tiled ground mesh.
  109763. * Please consider using the same method from the MeshBuilder class instead
  109764. * @param name defines the name of the mesh to create
  109765. * @param xmin set the ground minimum X coordinate
  109766. * @param zmin set the ground minimum Y coordinate
  109767. * @param xmax set the ground maximum X coordinate
  109768. * @param zmax set the ground maximum Z coordinate
  109769. * @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
  109770. * @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
  109771. * @param scene defines the hosting scene
  109772. * @param updatable defines if the mesh must be flagged as updatable
  109773. * @returns a new Mesh
  109774. */
  109775. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109776. w: number;
  109777. h: number;
  109778. }, precision: {
  109779. w: number;
  109780. h: number;
  109781. }, scene: Scene, updatable?: boolean): Mesh;
  109782. /**
  109783. * Creates a ground mesh from a height map.
  109784. * Please consider using the same method from the MeshBuilder class instead
  109785. * @see https://doc.babylonjs.com/babylon101/height_map
  109786. * @param name defines the name of the mesh to create
  109787. * @param url sets the URL of the height map image resource
  109788. * @param width set the ground width size
  109789. * @param height set the ground height size
  109790. * @param subdivisions sets the number of subdivision per side
  109791. * @param minHeight is the minimum altitude on the ground
  109792. * @param maxHeight is the maximum altitude on the ground
  109793. * @param scene defines the hosting scene
  109794. * @param updatable defines if the mesh must be flagged as updatable
  109795. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109796. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109797. * @returns a new Mesh
  109798. */
  109799. 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;
  109800. /**
  109801. * Creates a tube mesh.
  109802. * The tube is a parametric shape.
  109803. * It has no predefined shape. Its final shape will depend on the input parameters.
  109804. * Please consider using the same method from the MeshBuilder class instead
  109805. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109806. * @param name defines the name of the mesh to create
  109807. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109808. * @param radius sets the tube radius size
  109809. * @param tessellation is the number of sides on the tubular surface
  109810. * @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
  109811. * @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
  109812. * @param scene defines the hosting scene
  109813. * @param updatable defines if the mesh must be flagged as updatable
  109814. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109815. * @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)
  109816. * @returns a new Mesh
  109817. */
  109818. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109819. (i: number, distance: number): number;
  109820. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109821. /**
  109822. * Creates a polyhedron mesh.
  109823. * Please consider using the same method from the MeshBuilder class instead.
  109824. * * 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
  109825. * * The parameter `size` (positive float, default 1) sets the polygon size
  109826. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109827. * * 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`
  109828. * * 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
  109829. * * 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)`)
  109830. * * 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
  109831. * * 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
  109832. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109835. * @param name defines the name of the mesh to create
  109836. * @param options defines the options used to create the mesh
  109837. * @param scene defines the hosting scene
  109838. * @returns a new Mesh
  109839. */
  109840. static CreatePolyhedron(name: string, options: {
  109841. type?: number;
  109842. size?: number;
  109843. sizeX?: number;
  109844. sizeY?: number;
  109845. sizeZ?: number;
  109846. custom?: any;
  109847. faceUV?: Vector4[];
  109848. faceColors?: Color4[];
  109849. updatable?: boolean;
  109850. sideOrientation?: number;
  109851. }, scene: Scene): Mesh;
  109852. /**
  109853. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109854. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109855. * * 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`)
  109856. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109857. * * 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
  109858. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109861. * @param name defines the name of the mesh
  109862. * @param options defines the options used to create the mesh
  109863. * @param scene defines the hosting scene
  109864. * @returns a new Mesh
  109865. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109866. */
  109867. static CreateIcoSphere(name: string, options: {
  109868. radius?: number;
  109869. flat?: boolean;
  109870. subdivisions?: number;
  109871. sideOrientation?: number;
  109872. updatable?: boolean;
  109873. }, scene: Scene): Mesh;
  109874. /**
  109875. * Creates a decal mesh.
  109876. * Please consider using the same method from the MeshBuilder class instead.
  109877. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109878. * @param name defines the name of the mesh
  109879. * @param sourceMesh defines the mesh receiving the decal
  109880. * @param position sets the position of the decal in world coordinates
  109881. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109882. * @param size sets the decal scaling
  109883. * @param angle sets the angle to rotate the decal
  109884. * @returns a new Mesh
  109885. */
  109886. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109887. /** Creates a Capsule Mesh
  109888. * @param name defines the name of the mesh.
  109889. * @param options the constructors options used to shape the mesh.
  109890. * @param scene defines the scene the mesh is scoped to.
  109891. * @returns the capsule mesh
  109892. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109893. */
  109894. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109895. /**
  109896. * Prepare internal position array for software CPU skinning
  109897. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109898. */
  109899. setPositionsForCPUSkinning(): Float32Array;
  109900. /**
  109901. * Prepare internal normal array for software CPU skinning
  109902. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109903. */
  109904. setNormalsForCPUSkinning(): Float32Array;
  109905. /**
  109906. * Updates the vertex buffer by applying transformation from the bones
  109907. * @param skeleton defines the skeleton to apply to current mesh
  109908. * @returns the current mesh
  109909. */
  109910. applySkeleton(skeleton: Skeleton): Mesh;
  109911. /**
  109912. * 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
  109913. * @param meshes defines the list of meshes to scan
  109914. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109915. */
  109916. static MinMax(meshes: AbstractMesh[]): {
  109917. min: Vector3;
  109918. max: Vector3;
  109919. };
  109920. /**
  109921. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109922. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109923. * @returns a vector3
  109924. */
  109925. static Center(meshesOrMinMaxVector: {
  109926. min: Vector3;
  109927. max: Vector3;
  109928. } | AbstractMesh[]): Vector3;
  109929. /**
  109930. * Merge the array of meshes into a single mesh for performance reasons.
  109931. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109932. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109933. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109934. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109935. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109936. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109937. * @returns a new mesh
  109938. */
  109939. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109940. /** @hidden */
  109941. addInstance(instance: InstancedMesh): void;
  109942. /** @hidden */
  109943. removeInstance(instance: InstancedMesh): void;
  109944. }
  109945. }
  109946. declare module BABYLON {
  109947. /**
  109948. * This is the base class of all the camera used in the application.
  109949. * @see https://doc.babylonjs.com/features/cameras
  109950. */
  109951. export class Camera extends Node {
  109952. /** @hidden */
  109953. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109954. /**
  109955. * This is the default projection mode used by the cameras.
  109956. * It helps recreating a feeling of perspective and better appreciate depth.
  109957. * This is the best way to simulate real life cameras.
  109958. */
  109959. static readonly PERSPECTIVE_CAMERA: number;
  109960. /**
  109961. * This helps creating camera with an orthographic mode.
  109962. * 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.
  109963. */
  109964. static readonly ORTHOGRAPHIC_CAMERA: number;
  109965. /**
  109966. * This is the default FOV mode for perspective cameras.
  109967. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109968. */
  109969. static readonly FOVMODE_VERTICAL_FIXED: number;
  109970. /**
  109971. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109972. */
  109973. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109974. /**
  109975. * This specifies ther is no need for a camera rig.
  109976. * Basically only one eye is rendered corresponding to the camera.
  109977. */
  109978. static readonly RIG_MODE_NONE: number;
  109979. /**
  109980. * Simulates a camera Rig with one blue eye and one red eye.
  109981. * This can be use with 3d blue and red glasses.
  109982. */
  109983. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109984. /**
  109985. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109986. */
  109987. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109988. /**
  109989. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109990. */
  109991. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109992. /**
  109993. * Defines that both eyes of the camera will be rendered over under each other.
  109994. */
  109995. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109996. /**
  109997. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109998. */
  109999. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  110000. /**
  110001. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  110002. */
  110003. static readonly RIG_MODE_VR: number;
  110004. /**
  110005. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  110006. */
  110007. static readonly RIG_MODE_WEBVR: number;
  110008. /**
  110009. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  110010. */
  110011. static readonly RIG_MODE_CUSTOM: number;
  110012. /**
  110013. * Defines if by default attaching controls should prevent the default javascript event to continue.
  110014. */
  110015. static ForceAttachControlToAlwaysPreventDefault: boolean;
  110016. /**
  110017. * Define the input manager associated with the camera.
  110018. */
  110019. inputs: CameraInputsManager<Camera>;
  110020. /** @hidden */
  110021. _position: Vector3;
  110022. /**
  110023. * Define the current local position of the camera in the scene
  110024. */
  110025. get position(): Vector3;
  110026. set position(newPosition: Vector3);
  110027. protected _upVector: Vector3;
  110028. /**
  110029. * The vector the camera should consider as up.
  110030. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  110031. */
  110032. set upVector(vec: Vector3);
  110033. get upVector(): Vector3;
  110034. /**
  110035. * Define the current limit on the left side for an orthographic camera
  110036. * In scene unit
  110037. */
  110038. orthoLeft: Nullable<number>;
  110039. /**
  110040. * Define the current limit on the right side for an orthographic camera
  110041. * In scene unit
  110042. */
  110043. orthoRight: Nullable<number>;
  110044. /**
  110045. * Define the current limit on the bottom side for an orthographic camera
  110046. * In scene unit
  110047. */
  110048. orthoBottom: Nullable<number>;
  110049. /**
  110050. * Define the current limit on the top side for an orthographic camera
  110051. * In scene unit
  110052. */
  110053. orthoTop: Nullable<number>;
  110054. /**
  110055. * Field Of View is set in Radians. (default is 0.8)
  110056. */
  110057. fov: number;
  110058. /**
  110059. * Define the minimum distance the camera can see from.
  110060. * This is important to note that the depth buffer are not infinite and the closer it starts
  110061. * the more your scene might encounter depth fighting issue.
  110062. */
  110063. minZ: number;
  110064. /**
  110065. * Define the maximum distance the camera can see to.
  110066. * This is important to note that the depth buffer are not infinite and the further it end
  110067. * the more your scene might encounter depth fighting issue.
  110068. */
  110069. maxZ: number;
  110070. /**
  110071. * Define the default inertia of the camera.
  110072. * This helps giving a smooth feeling to the camera movement.
  110073. */
  110074. inertia: number;
  110075. /**
  110076. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  110077. */
  110078. mode: number;
  110079. /**
  110080. * Define whether the camera is intermediate.
  110081. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  110082. */
  110083. isIntermediate: boolean;
  110084. /**
  110085. * Define the viewport of the camera.
  110086. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  110087. */
  110088. viewport: Viewport;
  110089. /**
  110090. * Restricts the camera to viewing objects with the same layerMask.
  110091. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  110092. */
  110093. layerMask: number;
  110094. /**
  110095. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  110096. */
  110097. fovMode: number;
  110098. /**
  110099. * Rig mode of the camera.
  110100. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  110101. * This is normally controlled byt the camera themselves as internal use.
  110102. */
  110103. cameraRigMode: number;
  110104. /**
  110105. * Defines the distance between both "eyes" in case of a RIG
  110106. */
  110107. interaxialDistance: number;
  110108. /**
  110109. * Defines if stereoscopic rendering is done side by side or over under.
  110110. */
  110111. isStereoscopicSideBySide: boolean;
  110112. /**
  110113. * 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
  110114. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  110115. * else in the scene. (Eg. security camera)
  110116. *
  110117. * 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)
  110118. */
  110119. customRenderTargets: RenderTargetTexture[];
  110120. /**
  110121. * When set, the camera will render to this render target instead of the default canvas
  110122. *
  110123. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  110124. */
  110125. outputRenderTarget: Nullable<RenderTargetTexture>;
  110126. /**
  110127. * Observable triggered when the camera view matrix has changed.
  110128. */
  110129. onViewMatrixChangedObservable: Observable<Camera>;
  110130. /**
  110131. * Observable triggered when the camera Projection matrix has changed.
  110132. */
  110133. onProjectionMatrixChangedObservable: Observable<Camera>;
  110134. /**
  110135. * Observable triggered when the inputs have been processed.
  110136. */
  110137. onAfterCheckInputsObservable: Observable<Camera>;
  110138. /**
  110139. * Observable triggered when reset has been called and applied to the camera.
  110140. */
  110141. onRestoreStateObservable: Observable<Camera>;
  110142. /**
  110143. * Is this camera a part of a rig system?
  110144. */
  110145. isRigCamera: boolean;
  110146. /**
  110147. * If isRigCamera set to true this will be set with the parent camera.
  110148. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  110149. */
  110150. rigParent?: Camera;
  110151. /** @hidden */
  110152. _cameraRigParams: any;
  110153. /** @hidden */
  110154. _rigCameras: Camera[];
  110155. /** @hidden */
  110156. _rigPostProcess: Nullable<PostProcess>;
  110157. protected _webvrViewMatrix: Matrix;
  110158. /** @hidden */
  110159. _skipRendering: boolean;
  110160. /** @hidden */
  110161. _projectionMatrix: Matrix;
  110162. /** @hidden */
  110163. _postProcesses: Nullable<PostProcess>[];
  110164. /** @hidden */
  110165. _activeMeshes: SmartArray<AbstractMesh>;
  110166. protected _globalPosition: Vector3;
  110167. /** @hidden */
  110168. _computedViewMatrix: Matrix;
  110169. private _doNotComputeProjectionMatrix;
  110170. private _transformMatrix;
  110171. private _frustumPlanes;
  110172. private _refreshFrustumPlanes;
  110173. private _storedFov;
  110174. private _stateStored;
  110175. /**
  110176. * Instantiates a new camera object.
  110177. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  110178. * @see https://doc.babylonjs.com/features/cameras
  110179. * @param name Defines the name of the camera in the scene
  110180. * @param position Defines the position of the camera
  110181. * @param scene Defines the scene the camera belongs too
  110182. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  110183. */
  110184. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110185. /**
  110186. * Store current camera state (fov, position, etc..)
  110187. * @returns the camera
  110188. */
  110189. storeState(): Camera;
  110190. /**
  110191. * Restores the camera state values if it has been stored. You must call storeState() first
  110192. */
  110193. protected _restoreStateValues(): boolean;
  110194. /**
  110195. * Restored camera state. You must call storeState() first.
  110196. * @returns true if restored and false otherwise
  110197. */
  110198. restoreState(): boolean;
  110199. /**
  110200. * Gets the class name of the camera.
  110201. * @returns the class name
  110202. */
  110203. getClassName(): string;
  110204. /** @hidden */
  110205. readonly _isCamera: boolean;
  110206. /**
  110207. * Gets a string representation of the camera useful for debug purpose.
  110208. * @param fullDetails Defines that a more verboe level of logging is required
  110209. * @returns the string representation
  110210. */
  110211. toString(fullDetails?: boolean): string;
  110212. /**
  110213. * Gets the current world space position of the camera.
  110214. */
  110215. get globalPosition(): Vector3;
  110216. /**
  110217. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  110218. * @returns the active meshe list
  110219. */
  110220. getActiveMeshes(): SmartArray<AbstractMesh>;
  110221. /**
  110222. * Check whether a mesh is part of the current active mesh list of the camera
  110223. * @param mesh Defines the mesh to check
  110224. * @returns true if active, false otherwise
  110225. */
  110226. isActiveMesh(mesh: Mesh): boolean;
  110227. /**
  110228. * Is this camera ready to be used/rendered
  110229. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  110230. * @return true if the camera is ready
  110231. */
  110232. isReady(completeCheck?: boolean): boolean;
  110233. /** @hidden */
  110234. _initCache(): void;
  110235. /** @hidden */
  110236. _updateCache(ignoreParentClass?: boolean): void;
  110237. /** @hidden */
  110238. _isSynchronized(): boolean;
  110239. /** @hidden */
  110240. _isSynchronizedViewMatrix(): boolean;
  110241. /** @hidden */
  110242. _isSynchronizedProjectionMatrix(): boolean;
  110243. /**
  110244. * Attach the input controls to a specific dom element to get the input from.
  110245. * @param element Defines the element the controls should be listened from
  110246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110247. */
  110248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110249. /**
  110250. * Detach the current controls from the specified dom element.
  110251. * @param element Defines the element to stop listening the inputs from
  110252. */
  110253. detachControl(element: HTMLElement): void;
  110254. /**
  110255. * Update the camera state according to the different inputs gathered during the frame.
  110256. */
  110257. update(): void;
  110258. /** @hidden */
  110259. _checkInputs(): void;
  110260. /** @hidden */
  110261. get rigCameras(): Camera[];
  110262. /**
  110263. * Gets the post process used by the rig cameras
  110264. */
  110265. get rigPostProcess(): Nullable<PostProcess>;
  110266. /**
  110267. * Internal, gets the first post proces.
  110268. * @returns the first post process to be run on this camera.
  110269. */
  110270. _getFirstPostProcess(): Nullable<PostProcess>;
  110271. private _cascadePostProcessesToRigCams;
  110272. /**
  110273. * Attach a post process to the camera.
  110274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110275. * @param postProcess The post process to attach to the camera
  110276. * @param insertAt The position of the post process in case several of them are in use in the scene
  110277. * @returns the position the post process has been inserted at
  110278. */
  110279. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110280. /**
  110281. * Detach a post process to the camera.
  110282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110283. * @param postProcess The post process to detach from the camera
  110284. */
  110285. detachPostProcess(postProcess: PostProcess): void;
  110286. /**
  110287. * Gets the current world matrix of the camera
  110288. */
  110289. getWorldMatrix(): Matrix;
  110290. /** @hidden */
  110291. _getViewMatrix(): Matrix;
  110292. /**
  110293. * Gets the current view matrix of the camera.
  110294. * @param force forces the camera to recompute the matrix without looking at the cached state
  110295. * @returns the view matrix
  110296. */
  110297. getViewMatrix(force?: boolean): Matrix;
  110298. /**
  110299. * Freeze the projection matrix.
  110300. * It will prevent the cache check of the camera projection compute and can speed up perf
  110301. * if no parameter of the camera are meant to change
  110302. * @param projection Defines manually a projection if necessary
  110303. */
  110304. freezeProjectionMatrix(projection?: Matrix): void;
  110305. /**
  110306. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110307. */
  110308. unfreezeProjectionMatrix(): void;
  110309. /**
  110310. * Gets the current projection matrix of the camera.
  110311. * @param force forces the camera to recompute the matrix without looking at the cached state
  110312. * @returns the projection matrix
  110313. */
  110314. getProjectionMatrix(force?: boolean): Matrix;
  110315. /**
  110316. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110317. * @returns a Matrix
  110318. */
  110319. getTransformationMatrix(): Matrix;
  110320. private _updateFrustumPlanes;
  110321. /**
  110322. * Checks if a cullable object (mesh...) is in the camera frustum
  110323. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110324. * @param target The object to check
  110325. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110326. * @returns true if the object is in frustum otherwise false
  110327. */
  110328. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110329. /**
  110330. * Checks if a cullable object (mesh...) is in the camera frustum
  110331. * Unlike isInFrustum this cheks the full bounding box
  110332. * @param target The object to check
  110333. * @returns true if the object is in frustum otherwise false
  110334. */
  110335. isCompletelyInFrustum(target: ICullable): boolean;
  110336. /**
  110337. * Gets a ray in the forward direction from the camera.
  110338. * @param length Defines the length of the ray to create
  110339. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110340. * @param origin Defines the start point of the ray which defaults to the camera position
  110341. * @returns the forward ray
  110342. */
  110343. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110344. /**
  110345. * Gets a ray in the forward direction from the camera.
  110346. * @param refRay the ray to (re)use when setting the values
  110347. * @param length Defines the length of the ray to create
  110348. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110349. * @param origin Defines the start point of the ray which defaults to the camera position
  110350. * @returns the forward ray
  110351. */
  110352. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110353. /**
  110354. * Releases resources associated with this node.
  110355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110357. */
  110358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110359. /** @hidden */
  110360. _isLeftCamera: boolean;
  110361. /**
  110362. * Gets the left camera of a rig setup in case of Rigged Camera
  110363. */
  110364. get isLeftCamera(): boolean;
  110365. /** @hidden */
  110366. _isRightCamera: boolean;
  110367. /**
  110368. * Gets the right camera of a rig setup in case of Rigged Camera
  110369. */
  110370. get isRightCamera(): boolean;
  110371. /**
  110372. * Gets the left camera of a rig setup in case of Rigged Camera
  110373. */
  110374. get leftCamera(): Nullable<FreeCamera>;
  110375. /**
  110376. * Gets the right camera of a rig setup in case of Rigged Camera
  110377. */
  110378. get rightCamera(): Nullable<FreeCamera>;
  110379. /**
  110380. * Gets the left camera target of a rig setup in case of Rigged Camera
  110381. * @returns the target position
  110382. */
  110383. getLeftTarget(): Nullable<Vector3>;
  110384. /**
  110385. * Gets the right camera target of a rig setup in case of Rigged Camera
  110386. * @returns the target position
  110387. */
  110388. getRightTarget(): Nullable<Vector3>;
  110389. /**
  110390. * @hidden
  110391. */
  110392. setCameraRigMode(mode: number, rigParams: any): void;
  110393. /** @hidden */
  110394. static _setStereoscopicRigMode(camera: Camera): void;
  110395. /** @hidden */
  110396. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110397. /** @hidden */
  110398. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110399. /** @hidden */
  110400. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110401. /** @hidden */
  110402. _getVRProjectionMatrix(): Matrix;
  110403. protected _updateCameraRotationMatrix(): void;
  110404. protected _updateWebVRCameraRotationMatrix(): void;
  110405. /**
  110406. * This function MUST be overwritten by the different WebVR cameras available.
  110407. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110408. * @hidden
  110409. */
  110410. _getWebVRProjectionMatrix(): Matrix;
  110411. /**
  110412. * This function MUST be overwritten by the different WebVR cameras available.
  110413. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110414. * @hidden
  110415. */
  110416. _getWebVRViewMatrix(): Matrix;
  110417. /** @hidden */
  110418. setCameraRigParameter(name: string, value: any): void;
  110419. /**
  110420. * needs to be overridden by children so sub has required properties to be copied
  110421. * @hidden
  110422. */
  110423. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110424. /**
  110425. * May need to be overridden by children
  110426. * @hidden
  110427. */
  110428. _updateRigCameras(): void;
  110429. /** @hidden */
  110430. _setupInputs(): void;
  110431. /**
  110432. * Serialiaze the camera setup to a json represention
  110433. * @returns the JSON representation
  110434. */
  110435. serialize(): any;
  110436. /**
  110437. * Clones the current camera.
  110438. * @param name The cloned camera name
  110439. * @returns the cloned camera
  110440. */
  110441. clone(name: string): Camera;
  110442. /**
  110443. * Gets the direction of the camera relative to a given local axis.
  110444. * @param localAxis Defines the reference axis to provide a relative direction.
  110445. * @return the direction
  110446. */
  110447. getDirection(localAxis: Vector3): Vector3;
  110448. /**
  110449. * Returns the current camera absolute rotation
  110450. */
  110451. get absoluteRotation(): Quaternion;
  110452. /**
  110453. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110454. * @param localAxis Defines the reference axis to provide a relative direction.
  110455. * @param result Defines the vector to store the result in
  110456. */
  110457. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110458. /**
  110459. * Gets a camera constructor for a given camera type
  110460. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110461. * @param name The name of the camera the result will be able to instantiate
  110462. * @param scene The scene the result will construct the camera in
  110463. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110464. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110465. * @returns a factory method to construc the camera
  110466. */
  110467. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110468. /**
  110469. * Compute the world matrix of the camera.
  110470. * @returns the camera world matrix
  110471. */
  110472. computeWorldMatrix(): Matrix;
  110473. /**
  110474. * Parse a JSON and creates the camera from the parsed information
  110475. * @param parsedCamera The JSON to parse
  110476. * @param scene The scene to instantiate the camera in
  110477. * @returns the newly constructed camera
  110478. */
  110479. static Parse(parsedCamera: any, scene: Scene): Camera;
  110480. }
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * Class containing static functions to help procedurally build meshes
  110485. */
  110486. export class DiscBuilder {
  110487. /**
  110488. * Creates a plane polygonal mesh. By default, this is a disc
  110489. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110490. * * 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
  110491. * * 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
  110492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110495. * @param name defines the name of the mesh
  110496. * @param options defines the options used to create the mesh
  110497. * @param scene defines the hosting scene
  110498. * @returns the plane polygonal mesh
  110499. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110500. */
  110501. static CreateDisc(name: string, options: {
  110502. radius?: number;
  110503. tessellation?: number;
  110504. arc?: number;
  110505. updatable?: boolean;
  110506. sideOrientation?: number;
  110507. frontUVs?: Vector4;
  110508. backUVs?: Vector4;
  110509. }, scene?: Nullable<Scene>): Mesh;
  110510. }
  110511. }
  110512. declare module BABYLON {
  110513. /**
  110514. * Options to be used when creating a FresnelParameters.
  110515. */
  110516. export type IFresnelParametersCreationOptions = {
  110517. /**
  110518. * Define the color used on edges (grazing angle)
  110519. */
  110520. leftColor?: Color3;
  110521. /**
  110522. * Define the color used on center
  110523. */
  110524. rightColor?: Color3;
  110525. /**
  110526. * Define bias applied to computed fresnel term
  110527. */
  110528. bias?: number;
  110529. /**
  110530. * Defined the power exponent applied to fresnel term
  110531. */
  110532. power?: number;
  110533. /**
  110534. * Define if the fresnel effect is enable or not.
  110535. */
  110536. isEnabled?: boolean;
  110537. };
  110538. /**
  110539. * Serialized format for FresnelParameters.
  110540. */
  110541. export type IFresnelParametersSerialized = {
  110542. /**
  110543. * Define the color used on edges (grazing angle) [as an array]
  110544. */
  110545. leftColor: number[];
  110546. /**
  110547. * Define the color used on center [as an array]
  110548. */
  110549. rightColor: number[];
  110550. /**
  110551. * Define bias applied to computed fresnel term
  110552. */
  110553. bias: number;
  110554. /**
  110555. * Defined the power exponent applied to fresnel term
  110556. */
  110557. power?: number;
  110558. /**
  110559. * Define if the fresnel effect is enable or not.
  110560. */
  110561. isEnabled: boolean;
  110562. };
  110563. /**
  110564. * This represents all the required information to add a fresnel effect on a material:
  110565. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110566. */
  110567. export class FresnelParameters {
  110568. private _isEnabled;
  110569. /**
  110570. * Define if the fresnel effect is enable or not.
  110571. */
  110572. get isEnabled(): boolean;
  110573. set isEnabled(value: boolean);
  110574. /**
  110575. * Define the color used on edges (grazing angle)
  110576. */
  110577. leftColor: Color3;
  110578. /**
  110579. * Define the color used on center
  110580. */
  110581. rightColor: Color3;
  110582. /**
  110583. * Define bias applied to computed fresnel term
  110584. */
  110585. bias: number;
  110586. /**
  110587. * Defined the power exponent applied to fresnel term
  110588. */
  110589. power: number;
  110590. /**
  110591. * Creates a new FresnelParameters object.
  110592. *
  110593. * @param options provide your own settings to optionally to override defaults
  110594. */
  110595. constructor(options?: IFresnelParametersCreationOptions);
  110596. /**
  110597. * Clones the current fresnel and its valuues
  110598. * @returns a clone fresnel configuration
  110599. */
  110600. clone(): FresnelParameters;
  110601. /**
  110602. * Determines equality between FresnelParameters objects
  110603. * @param otherFresnelParameters defines the second operand
  110604. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110605. */
  110606. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110607. /**
  110608. * Serializes the current fresnel parameters to a JSON representation.
  110609. * @return the JSON serialization
  110610. */
  110611. serialize(): IFresnelParametersSerialized;
  110612. /**
  110613. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110614. * @param parsedFresnelParameters Define the JSON representation
  110615. * @returns the parsed parameters
  110616. */
  110617. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110618. }
  110619. }
  110620. declare module BABYLON {
  110621. /**
  110622. * This groups all the flags used to control the materials channel.
  110623. */
  110624. export class MaterialFlags {
  110625. private static _DiffuseTextureEnabled;
  110626. /**
  110627. * Are diffuse textures enabled in the application.
  110628. */
  110629. static get DiffuseTextureEnabled(): boolean;
  110630. static set DiffuseTextureEnabled(value: boolean);
  110631. private static _DetailTextureEnabled;
  110632. /**
  110633. * Are detail textures enabled in the application.
  110634. */
  110635. static get DetailTextureEnabled(): boolean;
  110636. static set DetailTextureEnabled(value: boolean);
  110637. private static _AmbientTextureEnabled;
  110638. /**
  110639. * Are ambient textures enabled in the application.
  110640. */
  110641. static get AmbientTextureEnabled(): boolean;
  110642. static set AmbientTextureEnabled(value: boolean);
  110643. private static _OpacityTextureEnabled;
  110644. /**
  110645. * Are opacity textures enabled in the application.
  110646. */
  110647. static get OpacityTextureEnabled(): boolean;
  110648. static set OpacityTextureEnabled(value: boolean);
  110649. private static _ReflectionTextureEnabled;
  110650. /**
  110651. * Are reflection textures enabled in the application.
  110652. */
  110653. static get ReflectionTextureEnabled(): boolean;
  110654. static set ReflectionTextureEnabled(value: boolean);
  110655. private static _EmissiveTextureEnabled;
  110656. /**
  110657. * Are emissive textures enabled in the application.
  110658. */
  110659. static get EmissiveTextureEnabled(): boolean;
  110660. static set EmissiveTextureEnabled(value: boolean);
  110661. private static _SpecularTextureEnabled;
  110662. /**
  110663. * Are specular textures enabled in the application.
  110664. */
  110665. static get SpecularTextureEnabled(): boolean;
  110666. static set SpecularTextureEnabled(value: boolean);
  110667. private static _BumpTextureEnabled;
  110668. /**
  110669. * Are bump textures enabled in the application.
  110670. */
  110671. static get BumpTextureEnabled(): boolean;
  110672. static set BumpTextureEnabled(value: boolean);
  110673. private static _LightmapTextureEnabled;
  110674. /**
  110675. * Are lightmap textures enabled in the application.
  110676. */
  110677. static get LightmapTextureEnabled(): boolean;
  110678. static set LightmapTextureEnabled(value: boolean);
  110679. private static _RefractionTextureEnabled;
  110680. /**
  110681. * Are refraction textures enabled in the application.
  110682. */
  110683. static get RefractionTextureEnabled(): boolean;
  110684. static set RefractionTextureEnabled(value: boolean);
  110685. private static _ColorGradingTextureEnabled;
  110686. /**
  110687. * Are color grading textures enabled in the application.
  110688. */
  110689. static get ColorGradingTextureEnabled(): boolean;
  110690. static set ColorGradingTextureEnabled(value: boolean);
  110691. private static _FresnelEnabled;
  110692. /**
  110693. * Are fresnels enabled in the application.
  110694. */
  110695. static get FresnelEnabled(): boolean;
  110696. static set FresnelEnabled(value: boolean);
  110697. private static _ClearCoatTextureEnabled;
  110698. /**
  110699. * Are clear coat textures enabled in the application.
  110700. */
  110701. static get ClearCoatTextureEnabled(): boolean;
  110702. static set ClearCoatTextureEnabled(value: boolean);
  110703. private static _ClearCoatBumpTextureEnabled;
  110704. /**
  110705. * Are clear coat bump textures enabled in the application.
  110706. */
  110707. static get ClearCoatBumpTextureEnabled(): boolean;
  110708. static set ClearCoatBumpTextureEnabled(value: boolean);
  110709. private static _ClearCoatTintTextureEnabled;
  110710. /**
  110711. * Are clear coat tint textures enabled in the application.
  110712. */
  110713. static get ClearCoatTintTextureEnabled(): boolean;
  110714. static set ClearCoatTintTextureEnabled(value: boolean);
  110715. private static _SheenTextureEnabled;
  110716. /**
  110717. * Are sheen textures enabled in the application.
  110718. */
  110719. static get SheenTextureEnabled(): boolean;
  110720. static set SheenTextureEnabled(value: boolean);
  110721. private static _AnisotropicTextureEnabled;
  110722. /**
  110723. * Are anisotropic textures enabled in the application.
  110724. */
  110725. static get AnisotropicTextureEnabled(): boolean;
  110726. static set AnisotropicTextureEnabled(value: boolean);
  110727. private static _ThicknessTextureEnabled;
  110728. /**
  110729. * Are thickness textures enabled in the application.
  110730. */
  110731. static get ThicknessTextureEnabled(): boolean;
  110732. static set ThicknessTextureEnabled(value: boolean);
  110733. }
  110734. }
  110735. declare module BABYLON {
  110736. /** @hidden */
  110737. export var defaultFragmentDeclaration: {
  110738. name: string;
  110739. shader: string;
  110740. };
  110741. }
  110742. declare module BABYLON {
  110743. /** @hidden */
  110744. export var defaultUboDeclaration: {
  110745. name: string;
  110746. shader: string;
  110747. };
  110748. }
  110749. declare module BABYLON {
  110750. /** @hidden */
  110751. export var prePassDeclaration: {
  110752. name: string;
  110753. shader: string;
  110754. };
  110755. }
  110756. declare module BABYLON {
  110757. /** @hidden */
  110758. export var lightFragmentDeclaration: {
  110759. name: string;
  110760. shader: string;
  110761. };
  110762. }
  110763. declare module BABYLON {
  110764. /** @hidden */
  110765. export var lightUboDeclaration: {
  110766. name: string;
  110767. shader: string;
  110768. };
  110769. }
  110770. declare module BABYLON {
  110771. /** @hidden */
  110772. export var lightsFragmentFunctions: {
  110773. name: string;
  110774. shader: string;
  110775. };
  110776. }
  110777. declare module BABYLON {
  110778. /** @hidden */
  110779. export var shadowsFragmentFunctions: {
  110780. name: string;
  110781. shader: string;
  110782. };
  110783. }
  110784. declare module BABYLON {
  110785. /** @hidden */
  110786. export var fresnelFunction: {
  110787. name: string;
  110788. shader: string;
  110789. };
  110790. }
  110791. declare module BABYLON {
  110792. /** @hidden */
  110793. export var bumpFragmentMainFunctions: {
  110794. name: string;
  110795. shader: string;
  110796. };
  110797. }
  110798. declare module BABYLON {
  110799. /** @hidden */
  110800. export var bumpFragmentFunctions: {
  110801. name: string;
  110802. shader: string;
  110803. };
  110804. }
  110805. declare module BABYLON {
  110806. /** @hidden */
  110807. export var logDepthDeclaration: {
  110808. name: string;
  110809. shader: string;
  110810. };
  110811. }
  110812. declare module BABYLON {
  110813. /** @hidden */
  110814. export var bumpFragment: {
  110815. name: string;
  110816. shader: string;
  110817. };
  110818. }
  110819. declare module BABYLON {
  110820. /** @hidden */
  110821. export var depthPrePass: {
  110822. name: string;
  110823. shader: string;
  110824. };
  110825. }
  110826. declare module BABYLON {
  110827. /** @hidden */
  110828. export var lightFragment: {
  110829. name: string;
  110830. shader: string;
  110831. };
  110832. }
  110833. declare module BABYLON {
  110834. /** @hidden */
  110835. export var logDepthFragment: {
  110836. name: string;
  110837. shader: string;
  110838. };
  110839. }
  110840. declare module BABYLON {
  110841. /** @hidden */
  110842. export var defaultPixelShader: {
  110843. name: string;
  110844. shader: string;
  110845. };
  110846. }
  110847. declare module BABYLON {
  110848. /** @hidden */
  110849. export var defaultVertexDeclaration: {
  110850. name: string;
  110851. shader: string;
  110852. };
  110853. }
  110854. declare module BABYLON {
  110855. /** @hidden */
  110856. export var prePassVertexDeclaration: {
  110857. name: string;
  110858. shader: string;
  110859. };
  110860. }
  110861. declare module BABYLON {
  110862. /** @hidden */
  110863. export var bumpVertexDeclaration: {
  110864. name: string;
  110865. shader: string;
  110866. };
  110867. }
  110868. declare module BABYLON {
  110869. /** @hidden */
  110870. export var prePassVertex: {
  110871. name: string;
  110872. shader: string;
  110873. };
  110874. }
  110875. declare module BABYLON {
  110876. /** @hidden */
  110877. export var bumpVertex: {
  110878. name: string;
  110879. shader: string;
  110880. };
  110881. }
  110882. declare module BABYLON {
  110883. /** @hidden */
  110884. export var fogVertex: {
  110885. name: string;
  110886. shader: string;
  110887. };
  110888. }
  110889. declare module BABYLON {
  110890. /** @hidden */
  110891. export var shadowsVertex: {
  110892. name: string;
  110893. shader: string;
  110894. };
  110895. }
  110896. declare module BABYLON {
  110897. /** @hidden */
  110898. export var pointCloudVertex: {
  110899. name: string;
  110900. shader: string;
  110901. };
  110902. }
  110903. declare module BABYLON {
  110904. /** @hidden */
  110905. export var logDepthVertex: {
  110906. name: string;
  110907. shader: string;
  110908. };
  110909. }
  110910. declare module BABYLON {
  110911. /** @hidden */
  110912. export var defaultVertexShader: {
  110913. name: string;
  110914. shader: string;
  110915. };
  110916. }
  110917. declare module BABYLON {
  110918. /**
  110919. * @hidden
  110920. */
  110921. export interface IMaterialDetailMapDefines {
  110922. DETAIL: boolean;
  110923. DETAILDIRECTUV: number;
  110924. DETAIL_NORMALBLENDMETHOD: number;
  110925. /** @hidden */
  110926. _areTexturesDirty: boolean;
  110927. }
  110928. /**
  110929. * Define the code related to the detail map parameters of a material
  110930. *
  110931. * Inspired from:
  110932. * 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
  110933. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110934. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110935. */
  110936. export class DetailMapConfiguration {
  110937. private _texture;
  110938. /**
  110939. * The detail texture of the material.
  110940. */
  110941. texture: Nullable<BaseTexture>;
  110942. /**
  110943. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110944. * Bigger values mean stronger blending
  110945. */
  110946. diffuseBlendLevel: number;
  110947. /**
  110948. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110949. * Bigger values mean stronger blending. Only used with PBR materials
  110950. */
  110951. roughnessBlendLevel: number;
  110952. /**
  110953. * Defines how strong the bump effect from the detail map is
  110954. * Bigger values mean stronger effect
  110955. */
  110956. bumpLevel: number;
  110957. private _normalBlendMethod;
  110958. /**
  110959. * The method used to blend the bump and detail normals together
  110960. */
  110961. normalBlendMethod: number;
  110962. private _isEnabled;
  110963. /**
  110964. * Enable or disable the detail map on this material
  110965. */
  110966. isEnabled: boolean;
  110967. /** @hidden */
  110968. private _internalMarkAllSubMeshesAsTexturesDirty;
  110969. /** @hidden */
  110970. _markAllSubMeshesAsTexturesDirty(): void;
  110971. /**
  110972. * Instantiate a new detail map
  110973. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110974. */
  110975. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110976. /**
  110977. * Gets whether the submesh is ready to be used or not.
  110978. * @param defines the list of "defines" to update.
  110979. * @param scene defines the scene the material belongs to.
  110980. * @returns - boolean indicating that the submesh is ready or not.
  110981. */
  110982. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110983. /**
  110984. * Update the defines for detail map usage
  110985. * @param defines the list of "defines" to update.
  110986. * @param scene defines the scene the material belongs to.
  110987. */
  110988. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110989. /**
  110990. * Binds the material data.
  110991. * @param uniformBuffer defines the Uniform buffer to fill in.
  110992. * @param scene defines the scene the material belongs to.
  110993. * @param isFrozen defines whether the material is frozen or not.
  110994. */
  110995. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110996. /**
  110997. * Checks to see if a texture is used in the material.
  110998. * @param texture - Base texture to use.
  110999. * @returns - Boolean specifying if a texture is used in the material.
  111000. */
  111001. hasTexture(texture: BaseTexture): boolean;
  111002. /**
  111003. * Returns an array of the actively used textures.
  111004. * @param activeTextures Array of BaseTextures
  111005. */
  111006. getActiveTextures(activeTextures: BaseTexture[]): void;
  111007. /**
  111008. * Returns the animatable textures.
  111009. * @param animatables Array of animatable textures.
  111010. */
  111011. getAnimatables(animatables: IAnimatable[]): void;
  111012. /**
  111013. * Disposes the resources of the material.
  111014. * @param forceDisposeTextures - Forces the disposal of all textures.
  111015. */
  111016. dispose(forceDisposeTextures?: boolean): void;
  111017. /**
  111018. * Get the current class name useful for serialization or dynamic coding.
  111019. * @returns "DetailMap"
  111020. */
  111021. getClassName(): string;
  111022. /**
  111023. * Add the required uniforms to the current list.
  111024. * @param uniforms defines the current uniform list.
  111025. */
  111026. static AddUniforms(uniforms: string[]): void;
  111027. /**
  111028. * Add the required samplers to the current list.
  111029. * @param samplers defines the current sampler list.
  111030. */
  111031. static AddSamplers(samplers: string[]): void;
  111032. /**
  111033. * Add the required uniforms to the current buffer.
  111034. * @param uniformBuffer defines the current uniform buffer.
  111035. */
  111036. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111037. /**
  111038. * Makes a duplicate of the current instance into another one.
  111039. * @param detailMap define the instance where to copy the info
  111040. */
  111041. copyTo(detailMap: DetailMapConfiguration): void;
  111042. /**
  111043. * Serializes this detail map instance
  111044. * @returns - An object with the serialized instance.
  111045. */
  111046. serialize(): any;
  111047. /**
  111048. * Parses a detail map setting from a serialized object.
  111049. * @param source - Serialized object.
  111050. * @param scene Defines the scene we are parsing for
  111051. * @param rootUrl Defines the rootUrl to load from
  111052. */
  111053. parse(source: any, scene: Scene, rootUrl: string): void;
  111054. }
  111055. }
  111056. declare module BABYLON {
  111057. /** @hidden */
  111058. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  111059. MAINUV1: boolean;
  111060. MAINUV2: boolean;
  111061. DIFFUSE: boolean;
  111062. DIFFUSEDIRECTUV: number;
  111063. DETAIL: boolean;
  111064. DETAILDIRECTUV: number;
  111065. DETAIL_NORMALBLENDMETHOD: number;
  111066. AMBIENT: boolean;
  111067. AMBIENTDIRECTUV: number;
  111068. OPACITY: boolean;
  111069. OPACITYDIRECTUV: number;
  111070. OPACITYRGB: boolean;
  111071. REFLECTION: boolean;
  111072. EMISSIVE: boolean;
  111073. EMISSIVEDIRECTUV: number;
  111074. SPECULAR: boolean;
  111075. SPECULARDIRECTUV: number;
  111076. BUMP: boolean;
  111077. BUMPDIRECTUV: number;
  111078. PARALLAX: boolean;
  111079. PARALLAXOCCLUSION: boolean;
  111080. SPECULAROVERALPHA: boolean;
  111081. CLIPPLANE: boolean;
  111082. CLIPPLANE2: boolean;
  111083. CLIPPLANE3: boolean;
  111084. CLIPPLANE4: boolean;
  111085. CLIPPLANE5: boolean;
  111086. CLIPPLANE6: boolean;
  111087. ALPHATEST: boolean;
  111088. DEPTHPREPASS: boolean;
  111089. ALPHAFROMDIFFUSE: boolean;
  111090. POINTSIZE: boolean;
  111091. FOG: boolean;
  111092. SPECULARTERM: boolean;
  111093. DIFFUSEFRESNEL: boolean;
  111094. OPACITYFRESNEL: boolean;
  111095. REFLECTIONFRESNEL: boolean;
  111096. REFRACTIONFRESNEL: boolean;
  111097. EMISSIVEFRESNEL: boolean;
  111098. FRESNEL: boolean;
  111099. NORMAL: boolean;
  111100. UV1: boolean;
  111101. UV2: boolean;
  111102. VERTEXCOLOR: boolean;
  111103. VERTEXALPHA: boolean;
  111104. NUM_BONE_INFLUENCERS: number;
  111105. BonesPerMesh: number;
  111106. BONETEXTURE: boolean;
  111107. BONES_VELOCITY_ENABLED: boolean;
  111108. INSTANCES: boolean;
  111109. THIN_INSTANCES: boolean;
  111110. GLOSSINESS: boolean;
  111111. ROUGHNESS: boolean;
  111112. EMISSIVEASILLUMINATION: boolean;
  111113. LINKEMISSIVEWITHDIFFUSE: boolean;
  111114. REFLECTIONFRESNELFROMSPECULAR: boolean;
  111115. LIGHTMAP: boolean;
  111116. LIGHTMAPDIRECTUV: number;
  111117. OBJECTSPACE_NORMALMAP: boolean;
  111118. USELIGHTMAPASSHADOWMAP: boolean;
  111119. REFLECTIONMAP_3D: boolean;
  111120. REFLECTIONMAP_SPHERICAL: boolean;
  111121. REFLECTIONMAP_PLANAR: boolean;
  111122. REFLECTIONMAP_CUBIC: boolean;
  111123. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111124. REFLECTIONMAP_PROJECTION: boolean;
  111125. REFLECTIONMAP_SKYBOX: boolean;
  111126. REFLECTIONMAP_EXPLICIT: boolean;
  111127. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111128. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111129. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111130. INVERTCUBICMAP: boolean;
  111131. LOGARITHMICDEPTH: boolean;
  111132. REFRACTION: boolean;
  111133. REFRACTIONMAP_3D: boolean;
  111134. REFLECTIONOVERALPHA: boolean;
  111135. TWOSIDEDLIGHTING: boolean;
  111136. SHADOWFLOAT: boolean;
  111137. MORPHTARGETS: boolean;
  111138. MORPHTARGETS_NORMAL: boolean;
  111139. MORPHTARGETS_TANGENT: boolean;
  111140. MORPHTARGETS_UV: boolean;
  111141. NUM_MORPH_INFLUENCERS: number;
  111142. NONUNIFORMSCALING: boolean;
  111143. PREMULTIPLYALPHA: boolean;
  111144. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  111145. ALPHABLEND: boolean;
  111146. PREPASS: boolean;
  111147. PREPASS_IRRADIANCE: boolean;
  111148. PREPASS_IRRADIANCE_INDEX: number;
  111149. PREPASS_ALBEDO: boolean;
  111150. PREPASS_ALBEDO_INDEX: number;
  111151. PREPASS_DEPTHNORMAL: boolean;
  111152. PREPASS_DEPTHNORMAL_INDEX: number;
  111153. PREPASS_POSITION: boolean;
  111154. PREPASS_POSITION_INDEX: number;
  111155. PREPASS_VELOCITY: boolean;
  111156. PREPASS_VELOCITY_INDEX: number;
  111157. PREPASS_REFLECTIVITY: boolean;
  111158. PREPASS_REFLECTIVITY_INDEX: number;
  111159. SCENE_MRT_COUNT: number;
  111160. RGBDLIGHTMAP: boolean;
  111161. RGBDREFLECTION: boolean;
  111162. RGBDREFRACTION: boolean;
  111163. IMAGEPROCESSING: boolean;
  111164. VIGNETTE: boolean;
  111165. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111166. VIGNETTEBLENDMODEOPAQUE: boolean;
  111167. TONEMAPPING: boolean;
  111168. TONEMAPPING_ACES: boolean;
  111169. CONTRAST: boolean;
  111170. COLORCURVES: boolean;
  111171. COLORGRADING: boolean;
  111172. COLORGRADING3D: boolean;
  111173. SAMPLER3DGREENDEPTH: boolean;
  111174. SAMPLER3DBGRMAP: boolean;
  111175. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111176. MULTIVIEW: boolean;
  111177. /**
  111178. * If the reflection texture on this material is in linear color space
  111179. * @hidden
  111180. */
  111181. IS_REFLECTION_LINEAR: boolean;
  111182. /**
  111183. * If the refraction texture on this material is in linear color space
  111184. * @hidden
  111185. */
  111186. IS_REFRACTION_LINEAR: boolean;
  111187. EXPOSURE: boolean;
  111188. constructor();
  111189. setReflectionMode(modeToEnable: string): void;
  111190. }
  111191. /**
  111192. * This is the default material used in Babylon. It is the best trade off between quality
  111193. * and performances.
  111194. * @see https://doc.babylonjs.com/babylon101/materials
  111195. */
  111196. export class StandardMaterial extends PushMaterial {
  111197. private _diffuseTexture;
  111198. /**
  111199. * The basic texture of the material as viewed under a light.
  111200. */
  111201. diffuseTexture: Nullable<BaseTexture>;
  111202. private _ambientTexture;
  111203. /**
  111204. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  111205. */
  111206. ambientTexture: Nullable<BaseTexture>;
  111207. private _opacityTexture;
  111208. /**
  111209. * Define the transparency of the material from a texture.
  111210. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  111211. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  111212. */
  111213. opacityTexture: Nullable<BaseTexture>;
  111214. private _reflectionTexture;
  111215. /**
  111216. * Define the texture used to display the reflection.
  111217. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111218. */
  111219. reflectionTexture: Nullable<BaseTexture>;
  111220. private _emissiveTexture;
  111221. /**
  111222. * Define texture of the material as if self lit.
  111223. * This will be mixed in the final result even in the absence of light.
  111224. */
  111225. emissiveTexture: Nullable<BaseTexture>;
  111226. private _specularTexture;
  111227. /**
  111228. * Define how the color and intensity of the highlight given by the light in the material.
  111229. */
  111230. specularTexture: Nullable<BaseTexture>;
  111231. private _bumpTexture;
  111232. /**
  111233. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  111234. * 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.
  111235. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  111236. */
  111237. bumpTexture: Nullable<BaseTexture>;
  111238. private _lightmapTexture;
  111239. /**
  111240. * Complex lighting can be computationally expensive to compute at runtime.
  111241. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  111242. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  111243. */
  111244. lightmapTexture: Nullable<BaseTexture>;
  111245. private _refractionTexture;
  111246. /**
  111247. * Define the texture used to display the refraction.
  111248. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111249. */
  111250. refractionTexture: Nullable<BaseTexture>;
  111251. /**
  111252. * The color of the material lit by the environmental background lighting.
  111253. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  111254. */
  111255. ambientColor: Color3;
  111256. /**
  111257. * The basic color of the material as viewed under a light.
  111258. */
  111259. diffuseColor: Color3;
  111260. /**
  111261. * Define how the color and intensity of the highlight given by the light in the material.
  111262. */
  111263. specularColor: Color3;
  111264. /**
  111265. * Define the color of the material as if self lit.
  111266. * This will be mixed in the final result even in the absence of light.
  111267. */
  111268. emissiveColor: Color3;
  111269. /**
  111270. * Defines how sharp are the highlights in the material.
  111271. * The bigger the value the sharper giving a more glossy feeling to the result.
  111272. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  111273. */
  111274. specularPower: number;
  111275. private _useAlphaFromDiffuseTexture;
  111276. /**
  111277. * Does the transparency come from the diffuse texture alpha channel.
  111278. */
  111279. useAlphaFromDiffuseTexture: boolean;
  111280. private _useEmissiveAsIllumination;
  111281. /**
  111282. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  111283. */
  111284. useEmissiveAsIllumination: boolean;
  111285. private _linkEmissiveWithDiffuse;
  111286. /**
  111287. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  111288. * the emissive level when the final color is close to one.
  111289. */
  111290. linkEmissiveWithDiffuse: boolean;
  111291. private _useSpecularOverAlpha;
  111292. /**
  111293. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111294. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111295. */
  111296. useSpecularOverAlpha: boolean;
  111297. private _useReflectionOverAlpha;
  111298. /**
  111299. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111300. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111301. */
  111302. useReflectionOverAlpha: boolean;
  111303. private _disableLighting;
  111304. /**
  111305. * Does lights from the scene impacts this material.
  111306. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111307. */
  111308. disableLighting: boolean;
  111309. private _useObjectSpaceNormalMap;
  111310. /**
  111311. * Allows using an object space normal map (instead of tangent space).
  111312. */
  111313. useObjectSpaceNormalMap: boolean;
  111314. private _useParallax;
  111315. /**
  111316. * Is parallax enabled or not.
  111317. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111318. */
  111319. useParallax: boolean;
  111320. private _useParallaxOcclusion;
  111321. /**
  111322. * Is parallax occlusion enabled or not.
  111323. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111324. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111325. */
  111326. useParallaxOcclusion: boolean;
  111327. /**
  111328. * 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.
  111329. */
  111330. parallaxScaleBias: number;
  111331. private _roughness;
  111332. /**
  111333. * Helps to define how blurry the reflections should appears in the material.
  111334. */
  111335. roughness: number;
  111336. /**
  111337. * In case of refraction, define the value of the index of refraction.
  111338. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111339. */
  111340. indexOfRefraction: number;
  111341. /**
  111342. * Invert the refraction texture alongside the y axis.
  111343. * It can be useful with procedural textures or probe for instance.
  111344. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111345. */
  111346. invertRefractionY: boolean;
  111347. /**
  111348. * Defines the alpha limits in alpha test mode.
  111349. */
  111350. alphaCutOff: number;
  111351. private _useLightmapAsShadowmap;
  111352. /**
  111353. * In case of light mapping, define whether the map contains light or shadow informations.
  111354. */
  111355. useLightmapAsShadowmap: boolean;
  111356. private _diffuseFresnelParameters;
  111357. /**
  111358. * Define the diffuse fresnel parameters of the material.
  111359. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111360. */
  111361. diffuseFresnelParameters: FresnelParameters;
  111362. private _opacityFresnelParameters;
  111363. /**
  111364. * Define the opacity fresnel parameters of the material.
  111365. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111366. */
  111367. opacityFresnelParameters: FresnelParameters;
  111368. private _reflectionFresnelParameters;
  111369. /**
  111370. * Define the reflection fresnel parameters of the material.
  111371. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111372. */
  111373. reflectionFresnelParameters: FresnelParameters;
  111374. private _refractionFresnelParameters;
  111375. /**
  111376. * Define the refraction fresnel parameters of the material.
  111377. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111378. */
  111379. refractionFresnelParameters: FresnelParameters;
  111380. private _emissiveFresnelParameters;
  111381. /**
  111382. * Define the emissive fresnel parameters of the material.
  111383. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111384. */
  111385. emissiveFresnelParameters: FresnelParameters;
  111386. private _useReflectionFresnelFromSpecular;
  111387. /**
  111388. * If true automatically deducts the fresnels values from the material specularity.
  111389. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111390. */
  111391. useReflectionFresnelFromSpecular: boolean;
  111392. private _useGlossinessFromSpecularMapAlpha;
  111393. /**
  111394. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111395. */
  111396. useGlossinessFromSpecularMapAlpha: boolean;
  111397. private _maxSimultaneousLights;
  111398. /**
  111399. * Defines the maximum number of lights that can be used in the material
  111400. */
  111401. maxSimultaneousLights: number;
  111402. private _invertNormalMapX;
  111403. /**
  111404. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111405. */
  111406. invertNormalMapX: boolean;
  111407. private _invertNormalMapY;
  111408. /**
  111409. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111410. */
  111411. invertNormalMapY: boolean;
  111412. private _twoSidedLighting;
  111413. /**
  111414. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111415. */
  111416. twoSidedLighting: boolean;
  111417. /**
  111418. * Default configuration related to image processing available in the standard Material.
  111419. */
  111420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111421. /**
  111422. * Gets the image processing configuration used either in this material.
  111423. */
  111424. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111425. /**
  111426. * Sets the Default image processing configuration used either in the this material.
  111427. *
  111428. * If sets to null, the scene one is in use.
  111429. */
  111430. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111431. /**
  111432. * Keep track of the image processing observer to allow dispose and replace.
  111433. */
  111434. private _imageProcessingObserver;
  111435. /**
  111436. * Attaches a new image processing configuration to the Standard Material.
  111437. * @param configuration
  111438. */
  111439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111440. /**
  111441. * Defines additionnal PrePass parameters for the material.
  111442. */
  111443. readonly prePassConfiguration: PrePassConfiguration;
  111444. /**
  111445. * Gets wether the color curves effect is enabled.
  111446. */
  111447. get cameraColorCurvesEnabled(): boolean;
  111448. /**
  111449. * Sets wether the color curves effect is enabled.
  111450. */
  111451. set cameraColorCurvesEnabled(value: boolean);
  111452. /**
  111453. * Gets wether the color grading effect is enabled.
  111454. */
  111455. get cameraColorGradingEnabled(): boolean;
  111456. /**
  111457. * Gets wether the color grading effect is enabled.
  111458. */
  111459. set cameraColorGradingEnabled(value: boolean);
  111460. /**
  111461. * Gets wether tonemapping is enabled or not.
  111462. */
  111463. get cameraToneMappingEnabled(): boolean;
  111464. /**
  111465. * Sets wether tonemapping is enabled or not
  111466. */
  111467. set cameraToneMappingEnabled(value: boolean);
  111468. /**
  111469. * The camera exposure used on this material.
  111470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111471. * This corresponds to a photographic exposure.
  111472. */
  111473. get cameraExposure(): number;
  111474. /**
  111475. * The camera exposure used on this material.
  111476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111477. * This corresponds to a photographic exposure.
  111478. */
  111479. set cameraExposure(value: number);
  111480. /**
  111481. * Gets The camera contrast used on this material.
  111482. */
  111483. get cameraContrast(): number;
  111484. /**
  111485. * Sets The camera contrast used on this material.
  111486. */
  111487. set cameraContrast(value: number);
  111488. /**
  111489. * Gets the Color Grading 2D Lookup Texture.
  111490. */
  111491. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111492. /**
  111493. * Sets the Color Grading 2D Lookup Texture.
  111494. */
  111495. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111496. /**
  111497. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111498. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111499. * 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;
  111500. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111501. */
  111502. get cameraColorCurves(): Nullable<ColorCurves>;
  111503. /**
  111504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111506. * 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;
  111507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111508. */
  111509. set cameraColorCurves(value: Nullable<ColorCurves>);
  111510. /**
  111511. * Can this material render to several textures at once
  111512. */
  111513. get canRenderToMRT(): boolean;
  111514. /**
  111515. * Defines the detail map parameters for the material.
  111516. */
  111517. readonly detailMap: DetailMapConfiguration;
  111518. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111519. protected _worldViewProjectionMatrix: Matrix;
  111520. protected _globalAmbientColor: Color3;
  111521. protected _useLogarithmicDepth: boolean;
  111522. protected _rebuildInParallel: boolean;
  111523. /**
  111524. * Instantiates a new standard material.
  111525. * This is the default material used in Babylon. It is the best trade off between quality
  111526. * and performances.
  111527. * @see https://doc.babylonjs.com/babylon101/materials
  111528. * @param name Define the name of the material in the scene
  111529. * @param scene Define the scene the material belong to
  111530. */
  111531. constructor(name: string, scene: Scene);
  111532. /**
  111533. * Gets a boolean indicating that current material needs to register RTT
  111534. */
  111535. get hasRenderTargetTextures(): boolean;
  111536. /**
  111537. * Gets the current class name of the material e.g. "StandardMaterial"
  111538. * Mainly use in serialization.
  111539. * @returns the class name
  111540. */
  111541. getClassName(): string;
  111542. /**
  111543. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111544. * You can try switching to logarithmic depth.
  111545. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111546. */
  111547. get useLogarithmicDepth(): boolean;
  111548. set useLogarithmicDepth(value: boolean);
  111549. /**
  111550. * Specifies if the material will require alpha blending
  111551. * @returns a boolean specifying if alpha blending is needed
  111552. */
  111553. needAlphaBlending(): boolean;
  111554. /**
  111555. * Specifies if this material should be rendered in alpha test mode
  111556. * @returns a boolean specifying if an alpha test is needed.
  111557. */
  111558. needAlphaTesting(): boolean;
  111559. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111560. /**
  111561. * Get the texture used for alpha test purpose.
  111562. * @returns the diffuse texture in case of the standard material.
  111563. */
  111564. getAlphaTestTexture(): Nullable<BaseTexture>;
  111565. /**
  111566. * Get if the submesh is ready to be used and all its information available.
  111567. * Child classes can use it to update shaders
  111568. * @param mesh defines the mesh to check
  111569. * @param subMesh defines which submesh to check
  111570. * @param useInstances specifies that instances should be used
  111571. * @returns a boolean indicating that the submesh is ready or not
  111572. */
  111573. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111574. /**
  111575. * Builds the material UBO layouts.
  111576. * Used internally during the effect preparation.
  111577. */
  111578. buildUniformLayout(): void;
  111579. /**
  111580. * Unbinds the material from the mesh
  111581. */
  111582. unbind(): void;
  111583. /**
  111584. * Binds the submesh to this material by preparing the effect and shader to draw
  111585. * @param world defines the world transformation matrix
  111586. * @param mesh defines the mesh containing the submesh
  111587. * @param subMesh defines the submesh to bind the material to
  111588. */
  111589. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111590. /**
  111591. * Get the list of animatables in the material.
  111592. * @returns the list of animatables object used in the material
  111593. */
  111594. getAnimatables(): IAnimatable[];
  111595. /**
  111596. * Gets the active textures from the material
  111597. * @returns an array of textures
  111598. */
  111599. getActiveTextures(): BaseTexture[];
  111600. /**
  111601. * Specifies if the material uses a texture
  111602. * @param texture defines the texture to check against the material
  111603. * @returns a boolean specifying if the material uses the texture
  111604. */
  111605. hasTexture(texture: BaseTexture): boolean;
  111606. /**
  111607. * Disposes the material
  111608. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111609. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111610. */
  111611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111612. /**
  111613. * Makes a duplicate of the material, and gives it a new name
  111614. * @param name defines the new name for the duplicated material
  111615. * @returns the cloned material
  111616. */
  111617. clone(name: string): StandardMaterial;
  111618. /**
  111619. * Serializes this material in a JSON representation
  111620. * @returns the serialized material object
  111621. */
  111622. serialize(): any;
  111623. /**
  111624. * Creates a standard material from parsed material data
  111625. * @param source defines the JSON representation of the material
  111626. * @param scene defines the hosting scene
  111627. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111628. * @returns a new standard material
  111629. */
  111630. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111631. /**
  111632. * Are diffuse textures enabled in the application.
  111633. */
  111634. static get DiffuseTextureEnabled(): boolean;
  111635. static set DiffuseTextureEnabled(value: boolean);
  111636. /**
  111637. * Are detail textures enabled in the application.
  111638. */
  111639. static get DetailTextureEnabled(): boolean;
  111640. static set DetailTextureEnabled(value: boolean);
  111641. /**
  111642. * Are ambient textures enabled in the application.
  111643. */
  111644. static get AmbientTextureEnabled(): boolean;
  111645. static set AmbientTextureEnabled(value: boolean);
  111646. /**
  111647. * Are opacity textures enabled in the application.
  111648. */
  111649. static get OpacityTextureEnabled(): boolean;
  111650. static set OpacityTextureEnabled(value: boolean);
  111651. /**
  111652. * Are reflection textures enabled in the application.
  111653. */
  111654. static get ReflectionTextureEnabled(): boolean;
  111655. static set ReflectionTextureEnabled(value: boolean);
  111656. /**
  111657. * Are emissive textures enabled in the application.
  111658. */
  111659. static get EmissiveTextureEnabled(): boolean;
  111660. static set EmissiveTextureEnabled(value: boolean);
  111661. /**
  111662. * Are specular textures enabled in the application.
  111663. */
  111664. static get SpecularTextureEnabled(): boolean;
  111665. static set SpecularTextureEnabled(value: boolean);
  111666. /**
  111667. * Are bump textures enabled in the application.
  111668. */
  111669. static get BumpTextureEnabled(): boolean;
  111670. static set BumpTextureEnabled(value: boolean);
  111671. /**
  111672. * Are lightmap textures enabled in the application.
  111673. */
  111674. static get LightmapTextureEnabled(): boolean;
  111675. static set LightmapTextureEnabled(value: boolean);
  111676. /**
  111677. * Are refraction textures enabled in the application.
  111678. */
  111679. static get RefractionTextureEnabled(): boolean;
  111680. static set RefractionTextureEnabled(value: boolean);
  111681. /**
  111682. * Are color grading textures enabled in the application.
  111683. */
  111684. static get ColorGradingTextureEnabled(): boolean;
  111685. static set ColorGradingTextureEnabled(value: boolean);
  111686. /**
  111687. * Are fresnels enabled in the application.
  111688. */
  111689. static get FresnelEnabled(): boolean;
  111690. static set FresnelEnabled(value: boolean);
  111691. }
  111692. }
  111693. declare module BABYLON {
  111694. /**
  111695. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111696. *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.
  111697. * The SPS is also a particle system. It provides some methods to manage the particles.
  111698. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111699. *
  111700. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111701. */
  111702. export class SolidParticleSystem implements IDisposable {
  111703. /**
  111704. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111705. * Example : var p = SPS.particles[i];
  111706. */
  111707. particles: SolidParticle[];
  111708. /**
  111709. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111710. */
  111711. nbParticles: number;
  111712. /**
  111713. * If the particles must ever face the camera (default false). Useful for planar particles.
  111714. */
  111715. billboard: boolean;
  111716. /**
  111717. * Recompute normals when adding a shape
  111718. */
  111719. recomputeNormals: boolean;
  111720. /**
  111721. * This a counter ofr your own usage. It's not set by any SPS functions.
  111722. */
  111723. counter: number;
  111724. /**
  111725. * The SPS name. This name is also given to the underlying mesh.
  111726. */
  111727. name: string;
  111728. /**
  111729. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111730. */
  111731. mesh: Mesh;
  111732. /**
  111733. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111734. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111735. */
  111736. vars: any;
  111737. /**
  111738. * This array is populated when the SPS is set as 'pickable'.
  111739. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111740. * Each element of this array is an object `{idx: int, faceId: int}`.
  111741. * `idx` is the picked particle index in the `SPS.particles` array
  111742. * `faceId` is the picked face index counted within this particle.
  111743. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111744. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111745. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111746. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111747. */
  111748. pickedParticles: {
  111749. idx: number;
  111750. faceId: number;
  111751. }[];
  111752. /**
  111753. * This array is populated when the SPS is set as 'pickable'
  111754. * Each key of this array is a submesh index.
  111755. * Each element of this array is a second array defined like this :
  111756. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111757. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111758. * `idx` is the picked particle index in the `SPS.particles` array
  111759. * `faceId` is the picked face index counted within this particle.
  111760. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111761. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111762. */
  111763. pickedBySubMesh: {
  111764. idx: number;
  111765. faceId: number;
  111766. }[][];
  111767. /**
  111768. * This array is populated when `enableDepthSort` is set to true.
  111769. * Each element of this array is an instance of the class DepthSortedParticle.
  111770. */
  111771. depthSortedParticles: DepthSortedParticle[];
  111772. /**
  111773. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111774. * @hidden
  111775. */
  111776. _bSphereOnly: boolean;
  111777. /**
  111778. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111779. * @hidden
  111780. */
  111781. _bSphereRadiusFactor: number;
  111782. private _scene;
  111783. private _positions;
  111784. private _indices;
  111785. private _normals;
  111786. private _colors;
  111787. private _uvs;
  111788. private _indices32;
  111789. private _positions32;
  111790. private _normals32;
  111791. private _fixedNormal32;
  111792. private _colors32;
  111793. private _uvs32;
  111794. private _index;
  111795. private _updatable;
  111796. private _pickable;
  111797. private _isVisibilityBoxLocked;
  111798. private _alwaysVisible;
  111799. private _depthSort;
  111800. private _expandable;
  111801. private _shapeCounter;
  111802. private _copy;
  111803. private _color;
  111804. private _computeParticleColor;
  111805. private _computeParticleTexture;
  111806. private _computeParticleRotation;
  111807. private _computeParticleVertex;
  111808. private _computeBoundingBox;
  111809. private _depthSortParticles;
  111810. private _camera;
  111811. private _mustUnrotateFixedNormals;
  111812. private _particlesIntersect;
  111813. private _needs32Bits;
  111814. private _isNotBuilt;
  111815. private _lastParticleId;
  111816. private _idxOfId;
  111817. private _multimaterialEnabled;
  111818. private _useModelMaterial;
  111819. private _indicesByMaterial;
  111820. private _materialIndexes;
  111821. private _depthSortFunction;
  111822. private _materialSortFunction;
  111823. private _materials;
  111824. private _multimaterial;
  111825. private _materialIndexesById;
  111826. private _defaultMaterial;
  111827. private _autoUpdateSubMeshes;
  111828. private _tmpVertex;
  111829. /**
  111830. * Creates a SPS (Solid Particle System) object.
  111831. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111832. * @param scene (Scene) is the scene in which the SPS is added.
  111833. * @param options defines the options of the sps e.g.
  111834. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111835. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111836. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111837. * * 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.
  111838. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111839. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111840. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111841. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111842. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111843. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111844. */
  111845. constructor(name: string, scene: Scene, options?: {
  111846. updatable?: boolean;
  111847. isPickable?: boolean;
  111848. enableDepthSort?: boolean;
  111849. particleIntersection?: boolean;
  111850. boundingSphereOnly?: boolean;
  111851. bSphereRadiusFactor?: number;
  111852. expandable?: boolean;
  111853. useModelMaterial?: boolean;
  111854. enableMultiMaterial?: boolean;
  111855. });
  111856. /**
  111857. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111858. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111859. * @returns the created mesh
  111860. */
  111861. buildMesh(): Mesh;
  111862. /**
  111863. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111864. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111865. * Thus the particles generated from `digest()` have their property `position` set yet.
  111866. * @param mesh ( Mesh ) is the mesh to be digested
  111867. * @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
  111868. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111869. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111870. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111871. * @returns the current SPS
  111872. */
  111873. digest(mesh: Mesh, options?: {
  111874. facetNb?: number;
  111875. number?: number;
  111876. delta?: number;
  111877. storage?: [];
  111878. }): SolidParticleSystem;
  111879. /**
  111880. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111881. * @hidden
  111882. */
  111883. private _unrotateFixedNormals;
  111884. /**
  111885. * Resets the temporary working copy particle
  111886. * @hidden
  111887. */
  111888. private _resetCopy;
  111889. /**
  111890. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111891. * @param p the current index in the positions array to be updated
  111892. * @param ind the current index in the indices array
  111893. * @param shape a Vector3 array, the shape geometry
  111894. * @param positions the positions array to be updated
  111895. * @param meshInd the shape indices array
  111896. * @param indices the indices array to be updated
  111897. * @param meshUV the shape uv array
  111898. * @param uvs the uv array to be updated
  111899. * @param meshCol the shape color array
  111900. * @param colors the color array to be updated
  111901. * @param meshNor the shape normals array
  111902. * @param normals the normals array to be updated
  111903. * @param idx the particle index
  111904. * @param idxInShape the particle index in its shape
  111905. * @param options the addShape() method passed options
  111906. * @model the particle model
  111907. * @hidden
  111908. */
  111909. private _meshBuilder;
  111910. /**
  111911. * Returns a shape Vector3 array from positions float array
  111912. * @param positions float array
  111913. * @returns a vector3 array
  111914. * @hidden
  111915. */
  111916. private _posToShape;
  111917. /**
  111918. * Returns a shapeUV array from a float uvs (array deep copy)
  111919. * @param uvs as a float array
  111920. * @returns a shapeUV array
  111921. * @hidden
  111922. */
  111923. private _uvsToShapeUV;
  111924. /**
  111925. * Adds a new particle object in the particles array
  111926. * @param idx particle index in particles array
  111927. * @param id particle id
  111928. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111929. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111930. * @param model particle ModelShape object
  111931. * @param shapeId model shape identifier
  111932. * @param idxInShape index of the particle in the current model
  111933. * @param bInfo model bounding info object
  111934. * @param storage target storage array, if any
  111935. * @hidden
  111936. */
  111937. private _addParticle;
  111938. /**
  111939. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111940. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111941. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111942. * @param nb (positive integer) the number of particles to be created from this model
  111943. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111944. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111945. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111946. * @returns the number of shapes in the system
  111947. */
  111948. addShape(mesh: Mesh, nb: number, options?: {
  111949. positionFunction?: any;
  111950. vertexFunction?: any;
  111951. storage?: [];
  111952. }): number;
  111953. /**
  111954. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111955. * @hidden
  111956. */
  111957. private _rebuildParticle;
  111958. /**
  111959. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111960. * @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.
  111961. * @returns the SPS.
  111962. */
  111963. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111964. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111965. * Returns an array with the removed particles.
  111966. * 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.
  111967. * The SPS can't be empty so at least one particle needs to remain in place.
  111968. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111969. * @param start index of the first particle to remove
  111970. * @param end index of the last particle to remove (included)
  111971. * @returns an array populated with the removed particles
  111972. */
  111973. removeParticles(start: number, end: number): SolidParticle[];
  111974. /**
  111975. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111976. * @param solidParticleArray an array populated with Solid Particles objects
  111977. * @returns the SPS
  111978. */
  111979. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111980. /**
  111981. * Creates a new particle and modifies the SPS mesh geometry :
  111982. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111983. * - calls _addParticle() to populate the particle array
  111984. * factorized code from addShape() and insertParticlesFromArray()
  111985. * @param idx particle index in the particles array
  111986. * @param i particle index in its shape
  111987. * @param modelShape particle ModelShape object
  111988. * @param shape shape vertex array
  111989. * @param meshInd shape indices array
  111990. * @param meshUV shape uv array
  111991. * @param meshCol shape color array
  111992. * @param meshNor shape normals array
  111993. * @param bbInfo shape bounding info
  111994. * @param storage target particle storage
  111995. * @options addShape() passed options
  111996. * @hidden
  111997. */
  111998. private _insertNewParticle;
  111999. /**
  112000. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  112001. * This method calls `updateParticle()` for each particle of the SPS.
  112002. * For an animated SPS, it is usually called within the render loop.
  112003. * 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.
  112004. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  112005. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  112006. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  112007. * @returns the SPS.
  112008. */
  112009. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  112010. /**
  112011. * Disposes the SPS.
  112012. */
  112013. dispose(): void;
  112014. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  112015. * idx is the particle index in the SPS
  112016. * faceId is the picked face index counted within this particle.
  112017. * Returns null if the pickInfo can't identify a picked particle.
  112018. * @param pickingInfo (PickingInfo object)
  112019. * @returns {idx: number, faceId: number} or null
  112020. */
  112021. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  112022. idx: number;
  112023. faceId: number;
  112024. }>;
  112025. /**
  112026. * Returns a SolidParticle object from its identifier : particle.id
  112027. * @param id (integer) the particle Id
  112028. * @returns the searched particle or null if not found in the SPS.
  112029. */
  112030. getParticleById(id: number): Nullable<SolidParticle>;
  112031. /**
  112032. * Returns a new array populated with the particles having the passed shapeId.
  112033. * @param shapeId (integer) the shape identifier
  112034. * @returns a new solid particle array
  112035. */
  112036. getParticlesByShapeId(shapeId: number): SolidParticle[];
  112037. /**
  112038. * Populates the passed array "ref" with the particles having the passed shapeId.
  112039. * @param shapeId the shape identifier
  112040. * @returns the SPS
  112041. * @param ref
  112042. */
  112043. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  112044. /**
  112045. * Computes the required SubMeshes according the materials assigned to the particles.
  112046. * @returns the solid particle system.
  112047. * Does nothing if called before the SPS mesh is built.
  112048. */
  112049. computeSubMeshes(): SolidParticleSystem;
  112050. /**
  112051. * Sorts the solid particles by material when MultiMaterial is enabled.
  112052. * Updates the indices32 array.
  112053. * Updates the indicesByMaterial array.
  112054. * Updates the mesh indices array.
  112055. * @returns the SPS
  112056. * @hidden
  112057. */
  112058. private _sortParticlesByMaterial;
  112059. /**
  112060. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  112061. * @hidden
  112062. */
  112063. private _setMaterialIndexesById;
  112064. /**
  112065. * Returns an array with unique values of Materials from the passed array
  112066. * @param array the material array to be checked and filtered
  112067. * @hidden
  112068. */
  112069. private _filterUniqueMaterialId;
  112070. /**
  112071. * Sets a new Standard Material as _defaultMaterial if not already set.
  112072. * @hidden
  112073. */
  112074. private _setDefaultMaterial;
  112075. /**
  112076. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  112077. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112078. * @returns the SPS.
  112079. */
  112080. refreshVisibleSize(): SolidParticleSystem;
  112081. /**
  112082. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  112083. * @param size the size (float) of the visibility box
  112084. * note : this doesn't lock the SPS mesh bounding box.
  112085. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112086. */
  112087. setVisibilityBox(size: number): void;
  112088. /**
  112089. * Gets whether the SPS as always visible or not
  112090. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112091. */
  112092. get isAlwaysVisible(): boolean;
  112093. /**
  112094. * Sets the SPS as always visible or not
  112095. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112096. */
  112097. set isAlwaysVisible(val: boolean);
  112098. /**
  112099. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112100. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112101. */
  112102. set isVisibilityBoxLocked(val: boolean);
  112103. /**
  112104. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112105. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112106. */
  112107. get isVisibilityBoxLocked(): boolean;
  112108. /**
  112109. * Tells to `setParticles()` to compute the particle rotations or not.
  112110. * Default value : true. The SPS is faster when it's set to false.
  112111. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112112. */
  112113. set computeParticleRotation(val: boolean);
  112114. /**
  112115. * Tells to `setParticles()` to compute the particle colors or not.
  112116. * Default value : true. The SPS is faster when it's set to false.
  112117. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112118. */
  112119. set computeParticleColor(val: boolean);
  112120. set computeParticleTexture(val: boolean);
  112121. /**
  112122. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  112123. * Default value : false. The SPS is faster when it's set to false.
  112124. * Note : the particle custom vertex positions aren't stored values.
  112125. */
  112126. set computeParticleVertex(val: boolean);
  112127. /**
  112128. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  112129. */
  112130. set computeBoundingBox(val: boolean);
  112131. /**
  112132. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  112133. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112134. * Default : `true`
  112135. */
  112136. set depthSortParticles(val: boolean);
  112137. /**
  112138. * Gets if `setParticles()` computes the particle rotations or not.
  112139. * Default value : true. The SPS is faster when it's set to false.
  112140. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112141. */
  112142. get computeParticleRotation(): boolean;
  112143. /**
  112144. * Gets if `setParticles()` computes the particle colors or not.
  112145. * Default value : true. The SPS is faster when it's set to false.
  112146. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112147. */
  112148. get computeParticleColor(): boolean;
  112149. /**
  112150. * Gets if `setParticles()` computes the particle textures or not.
  112151. * Default value : true. The SPS is faster when it's set to false.
  112152. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  112153. */
  112154. get computeParticleTexture(): boolean;
  112155. /**
  112156. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  112157. * Default value : false. The SPS is faster when it's set to false.
  112158. * Note : the particle custom vertex positions aren't stored values.
  112159. */
  112160. get computeParticleVertex(): boolean;
  112161. /**
  112162. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  112163. */
  112164. get computeBoundingBox(): boolean;
  112165. /**
  112166. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  112167. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112168. * Default : `true`
  112169. */
  112170. get depthSortParticles(): boolean;
  112171. /**
  112172. * Gets if the SPS is created as expandable at construction time.
  112173. * Default : `false`
  112174. */
  112175. get expandable(): boolean;
  112176. /**
  112177. * Gets if the SPS supports the Multi Materials
  112178. */
  112179. get multimaterialEnabled(): boolean;
  112180. /**
  112181. * Gets if the SPS uses the model materials for its own multimaterial.
  112182. */
  112183. get useModelMaterial(): boolean;
  112184. /**
  112185. * The SPS used material array.
  112186. */
  112187. get materials(): Material[];
  112188. /**
  112189. * Sets the SPS MultiMaterial from the passed materials.
  112190. * Note : the passed array is internally copied and not used then by reference.
  112191. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  112192. */
  112193. setMultiMaterial(materials: Material[]): void;
  112194. /**
  112195. * The SPS computed multimaterial object
  112196. */
  112197. get multimaterial(): MultiMaterial;
  112198. set multimaterial(mm: MultiMaterial);
  112199. /**
  112200. * If the subMeshes must be updated on the next call to setParticles()
  112201. */
  112202. get autoUpdateSubMeshes(): boolean;
  112203. set autoUpdateSubMeshes(val: boolean);
  112204. /**
  112205. * This function does nothing. It may be overwritten to set all the particle first values.
  112206. * The SPS doesn't call this function, you may have to call it by your own.
  112207. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112208. */
  112209. initParticles(): void;
  112210. /**
  112211. * This function does nothing. It may be overwritten to recycle a particle.
  112212. * The SPS doesn't call this function, you may have to call it by your own.
  112213. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112214. * @param particle The particle to recycle
  112215. * @returns the recycled particle
  112216. */
  112217. recycleParticle(particle: SolidParticle): SolidParticle;
  112218. /**
  112219. * Updates a particle : this function should be overwritten by the user.
  112220. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  112221. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112222. * @example : just set a particle position or velocity and recycle conditions
  112223. * @param particle The particle to update
  112224. * @returns the updated particle
  112225. */
  112226. updateParticle(particle: SolidParticle): SolidParticle;
  112227. /**
  112228. * Updates a vertex of a particle : it can be overwritten by the user.
  112229. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  112230. * @param particle the current particle
  112231. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  112232. * @param pt the index of the current vertex in the particle shape
  112233. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  112234. * @example : just set a vertex particle position or color
  112235. * @returns the sps
  112236. */
  112237. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  112238. /**
  112239. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  112240. * This does nothing and may be overwritten by the user.
  112241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112243. * @param update the boolean update value actually passed to setParticles()
  112244. */
  112245. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112246. /**
  112247. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  112248. * This will be passed three parameters.
  112249. * This does nothing and may be overwritten by the user.
  112250. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112251. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112252. * @param update the boolean update value actually passed to setParticles()
  112253. */
  112254. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112255. }
  112256. }
  112257. declare module BABYLON {
  112258. /**
  112259. * Represents one particle of a solid particle system.
  112260. */
  112261. export class SolidParticle {
  112262. /**
  112263. * particle global index
  112264. */
  112265. idx: number;
  112266. /**
  112267. * particle identifier
  112268. */
  112269. id: number;
  112270. /**
  112271. * The color of the particle
  112272. */
  112273. color: Nullable<Color4>;
  112274. /**
  112275. * The world space position of the particle.
  112276. */
  112277. position: Vector3;
  112278. /**
  112279. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112280. */
  112281. rotation: Vector3;
  112282. /**
  112283. * The world space rotation quaternion of the particle.
  112284. */
  112285. rotationQuaternion: Nullable<Quaternion>;
  112286. /**
  112287. * The scaling of the particle.
  112288. */
  112289. scaling: Vector3;
  112290. /**
  112291. * The uvs of the particle.
  112292. */
  112293. uvs: Vector4;
  112294. /**
  112295. * The current speed of the particle.
  112296. */
  112297. velocity: Vector3;
  112298. /**
  112299. * The pivot point in the particle local space.
  112300. */
  112301. pivot: Vector3;
  112302. /**
  112303. * Must the particle be translated from its pivot point in its local space ?
  112304. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112305. * Default : false
  112306. */
  112307. translateFromPivot: boolean;
  112308. /**
  112309. * Is the particle active or not ?
  112310. */
  112311. alive: boolean;
  112312. /**
  112313. * Is the particle visible or not ?
  112314. */
  112315. isVisible: boolean;
  112316. /**
  112317. * Index of this particle in the global "positions" array (Internal use)
  112318. * @hidden
  112319. */
  112320. _pos: number;
  112321. /**
  112322. * @hidden Index of this particle in the global "indices" array (Internal use)
  112323. */
  112324. _ind: number;
  112325. /**
  112326. * @hidden ModelShape of this particle (Internal use)
  112327. */
  112328. _model: ModelShape;
  112329. /**
  112330. * ModelShape id of this particle
  112331. */
  112332. shapeId: number;
  112333. /**
  112334. * Index of the particle in its shape id
  112335. */
  112336. idxInShape: number;
  112337. /**
  112338. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112339. */
  112340. _modelBoundingInfo: BoundingInfo;
  112341. /**
  112342. * @hidden Particle BoundingInfo object (Internal use)
  112343. */
  112344. _boundingInfo: BoundingInfo;
  112345. /**
  112346. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112347. */
  112348. _sps: SolidParticleSystem;
  112349. /**
  112350. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112351. */
  112352. _stillInvisible: boolean;
  112353. /**
  112354. * @hidden Last computed particle rotation matrix
  112355. */
  112356. _rotationMatrix: number[];
  112357. /**
  112358. * Parent particle Id, if any.
  112359. * Default null.
  112360. */
  112361. parentId: Nullable<number>;
  112362. /**
  112363. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112364. */
  112365. materialIndex: Nullable<number>;
  112366. /**
  112367. * Custom object or properties.
  112368. */
  112369. props: Nullable<any>;
  112370. /**
  112371. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112372. * The possible values are :
  112373. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112374. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112375. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112376. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112377. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112378. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112379. * */
  112380. cullingStrategy: number;
  112381. /**
  112382. * @hidden Internal global position in the SPS.
  112383. */
  112384. _globalPosition: Vector3;
  112385. /**
  112386. * Creates a Solid Particle object.
  112387. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112388. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112389. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112390. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112391. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112392. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112393. * @param shapeId (integer) is the model shape identifier in the SPS.
  112394. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112395. * @param sps defines the sps it is associated to
  112396. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112397. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112398. */
  112399. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112400. /**
  112401. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112402. * @param target the particle target
  112403. * @returns the current particle
  112404. */
  112405. copyToRef(target: SolidParticle): SolidParticle;
  112406. /**
  112407. * Legacy support, changed scale to scaling
  112408. */
  112409. get scale(): Vector3;
  112410. /**
  112411. * Legacy support, changed scale to scaling
  112412. */
  112413. set scale(scale: Vector3);
  112414. /**
  112415. * Legacy support, changed quaternion to rotationQuaternion
  112416. */
  112417. get quaternion(): Nullable<Quaternion>;
  112418. /**
  112419. * Legacy support, changed quaternion to rotationQuaternion
  112420. */
  112421. set quaternion(q: Nullable<Quaternion>);
  112422. /**
  112423. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112424. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112425. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112426. * @returns true if it intersects
  112427. */
  112428. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112429. /**
  112430. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112431. * A particle is in the frustum if its bounding box intersects the frustum
  112432. * @param frustumPlanes defines the frustum to test
  112433. * @returns true if the particle is in the frustum planes
  112434. */
  112435. isInFrustum(frustumPlanes: Plane[]): boolean;
  112436. /**
  112437. * get the rotation matrix of the particle
  112438. * @hidden
  112439. */
  112440. getRotationMatrix(m: Matrix): void;
  112441. }
  112442. /**
  112443. * Represents the shape of the model used by one particle of a solid particle system.
  112444. * SPS internal tool, don't use it manually.
  112445. */
  112446. export class ModelShape {
  112447. /**
  112448. * The shape id
  112449. * @hidden
  112450. */
  112451. shapeID: number;
  112452. /**
  112453. * flat array of model positions (internal use)
  112454. * @hidden
  112455. */
  112456. _shape: Vector3[];
  112457. /**
  112458. * flat array of model UVs (internal use)
  112459. * @hidden
  112460. */
  112461. _shapeUV: number[];
  112462. /**
  112463. * color array of the model
  112464. * @hidden
  112465. */
  112466. _shapeColors: number[];
  112467. /**
  112468. * indices array of the model
  112469. * @hidden
  112470. */
  112471. _indices: number[];
  112472. /**
  112473. * normals array of the model
  112474. * @hidden
  112475. */
  112476. _normals: number[];
  112477. /**
  112478. * length of the shape in the model indices array (internal use)
  112479. * @hidden
  112480. */
  112481. _indicesLength: number;
  112482. /**
  112483. * Custom position function (internal use)
  112484. * @hidden
  112485. */
  112486. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112487. /**
  112488. * Custom vertex function (internal use)
  112489. * @hidden
  112490. */
  112491. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112492. /**
  112493. * Model material (internal use)
  112494. * @hidden
  112495. */
  112496. _material: Nullable<Material>;
  112497. /**
  112498. * 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.
  112499. * SPS internal tool, don't use it manually.
  112500. * @hidden
  112501. */
  112502. 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>);
  112503. }
  112504. /**
  112505. * Represents a Depth Sorted Particle in the solid particle system.
  112506. * @hidden
  112507. */
  112508. export class DepthSortedParticle {
  112509. /**
  112510. * Particle index
  112511. */
  112512. idx: number;
  112513. /**
  112514. * Index of the particle in the "indices" array
  112515. */
  112516. ind: number;
  112517. /**
  112518. * Length of the particle shape in the "indices" array
  112519. */
  112520. indicesLength: number;
  112521. /**
  112522. * Squared distance from the particle to the camera
  112523. */
  112524. sqDistance: number;
  112525. /**
  112526. * Material index when used with MultiMaterials
  112527. */
  112528. materialIndex: number;
  112529. /**
  112530. * Creates a new sorted particle
  112531. * @param materialIndex
  112532. */
  112533. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112534. }
  112535. /**
  112536. * Represents a solid particle vertex
  112537. */
  112538. export class SolidParticleVertex {
  112539. /**
  112540. * Vertex position
  112541. */
  112542. position: Vector3;
  112543. /**
  112544. * Vertex color
  112545. */
  112546. color: Color4;
  112547. /**
  112548. * Vertex UV
  112549. */
  112550. uv: Vector2;
  112551. /**
  112552. * Creates a new solid particle vertex
  112553. */
  112554. constructor();
  112555. /** Vertex x coordinate */
  112556. get x(): number;
  112557. set x(val: number);
  112558. /** Vertex y coordinate */
  112559. get y(): number;
  112560. set y(val: number);
  112561. /** Vertex z coordinate */
  112562. get z(): number;
  112563. set z(val: number);
  112564. }
  112565. }
  112566. declare module BABYLON {
  112567. /**
  112568. * @hidden
  112569. */
  112570. export class _MeshCollisionData {
  112571. _checkCollisions: boolean;
  112572. _collisionMask: number;
  112573. _collisionGroup: number;
  112574. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112575. _collider: Nullable<Collider>;
  112576. _oldPositionForCollisions: Vector3;
  112577. _diffPositionForCollisions: Vector3;
  112578. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112579. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112580. _collisionResponse: boolean;
  112581. }
  112582. }
  112583. declare module BABYLON {
  112584. /** @hidden */
  112585. class _FacetDataStorage {
  112586. facetPositions: Vector3[];
  112587. facetNormals: Vector3[];
  112588. facetPartitioning: number[][];
  112589. facetNb: number;
  112590. partitioningSubdivisions: number;
  112591. partitioningBBoxRatio: number;
  112592. facetDataEnabled: boolean;
  112593. facetParameters: any;
  112594. bbSize: Vector3;
  112595. subDiv: {
  112596. max: number;
  112597. X: number;
  112598. Y: number;
  112599. Z: number;
  112600. };
  112601. facetDepthSort: boolean;
  112602. facetDepthSortEnabled: boolean;
  112603. depthSortedIndices: IndicesArray;
  112604. depthSortedFacets: {
  112605. ind: number;
  112606. sqDistance: number;
  112607. }[];
  112608. facetDepthSortFunction: (f1: {
  112609. ind: number;
  112610. sqDistance: number;
  112611. }, f2: {
  112612. ind: number;
  112613. sqDistance: number;
  112614. }) => number;
  112615. facetDepthSortFrom: Vector3;
  112616. facetDepthSortOrigin: Vector3;
  112617. invertedMatrix: Matrix;
  112618. }
  112619. /**
  112620. * @hidden
  112621. **/
  112622. class _InternalAbstractMeshDataInfo {
  112623. _hasVertexAlpha: boolean;
  112624. _useVertexColors: boolean;
  112625. _numBoneInfluencers: number;
  112626. _applyFog: boolean;
  112627. _receiveShadows: boolean;
  112628. _facetData: _FacetDataStorage;
  112629. _visibility: number;
  112630. _skeleton: Nullable<Skeleton>;
  112631. _layerMask: number;
  112632. _computeBonesUsingShaders: boolean;
  112633. _isActive: boolean;
  112634. _onlyForInstances: boolean;
  112635. _isActiveIntermediate: boolean;
  112636. _onlyForInstancesIntermediate: boolean;
  112637. _actAsRegularMesh: boolean;
  112638. }
  112639. /**
  112640. * Class used to store all common mesh properties
  112641. */
  112642. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112643. /** No occlusion */
  112644. static OCCLUSION_TYPE_NONE: number;
  112645. /** Occlusion set to optimisitic */
  112646. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112647. /** Occlusion set to strict */
  112648. static OCCLUSION_TYPE_STRICT: number;
  112649. /** Use an accurante occlusion algorithm */
  112650. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112651. /** Use a conservative occlusion algorithm */
  112652. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112653. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112654. * Test order :
  112655. * Is the bounding sphere outside the frustum ?
  112656. * If not, are the bounding box vertices outside the frustum ?
  112657. * It not, then the cullable object is in the frustum.
  112658. */
  112659. static readonly CULLINGSTRATEGY_STANDARD: number;
  112660. /** Culling strategy : Bounding Sphere Only.
  112661. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112662. * It's also less accurate than the standard because some not visible objects can still be selected.
  112663. * Test : is the bounding sphere outside the frustum ?
  112664. * If not, then the cullable object is in the frustum.
  112665. */
  112666. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112667. /** Culling strategy : Optimistic Inclusion.
  112668. * This in an inclusion test first, then the standard exclusion test.
  112669. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112670. * 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.
  112671. * Anyway, it's as accurate as the standard strategy.
  112672. * Test :
  112673. * Is the cullable object bounding sphere center in the frustum ?
  112674. * If not, apply the default culling strategy.
  112675. */
  112676. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112677. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112678. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112679. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112680. * 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.
  112681. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112682. * Test :
  112683. * Is the cullable object bounding sphere center in the frustum ?
  112684. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112685. */
  112686. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112687. /**
  112688. * No billboard
  112689. */
  112690. static get BILLBOARDMODE_NONE(): number;
  112691. /** Billboard on X axis */
  112692. static get BILLBOARDMODE_X(): number;
  112693. /** Billboard on Y axis */
  112694. static get BILLBOARDMODE_Y(): number;
  112695. /** Billboard on Z axis */
  112696. static get BILLBOARDMODE_Z(): number;
  112697. /** Billboard on all axes */
  112698. static get BILLBOARDMODE_ALL(): number;
  112699. /** Billboard on using position instead of orientation */
  112700. static get BILLBOARDMODE_USE_POSITION(): number;
  112701. /** @hidden */
  112702. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112703. /**
  112704. * The culling strategy to use to check whether the mesh must be rendered or not.
  112705. * This value can be changed at any time and will be used on the next render mesh selection.
  112706. * The possible values are :
  112707. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112708. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112709. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112710. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112711. * Please read each static variable documentation to get details about the culling process.
  112712. * */
  112713. cullingStrategy: number;
  112714. /**
  112715. * Gets the number of facets in the mesh
  112716. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112717. */
  112718. get facetNb(): number;
  112719. /**
  112720. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112722. */
  112723. get partitioningSubdivisions(): number;
  112724. set partitioningSubdivisions(nb: number);
  112725. /**
  112726. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112727. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112728. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112729. */
  112730. get partitioningBBoxRatio(): number;
  112731. set partitioningBBoxRatio(ratio: number);
  112732. /**
  112733. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112734. * Works only for updatable meshes.
  112735. * Doesn't work with multi-materials
  112736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112737. */
  112738. get mustDepthSortFacets(): boolean;
  112739. set mustDepthSortFacets(sort: boolean);
  112740. /**
  112741. * The location (Vector3) where the facet depth sort must be computed from.
  112742. * By default, the active camera position.
  112743. * Used only when facet depth sort is enabled
  112744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112745. */
  112746. get facetDepthSortFrom(): Vector3;
  112747. set facetDepthSortFrom(location: Vector3);
  112748. /**
  112749. * gets a boolean indicating if facetData is enabled
  112750. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112751. */
  112752. get isFacetDataEnabled(): boolean;
  112753. /** @hidden */
  112754. _updateNonUniformScalingState(value: boolean): boolean;
  112755. /**
  112756. * An event triggered when this mesh collides with another one
  112757. */
  112758. onCollideObservable: Observable<AbstractMesh>;
  112759. /** Set a function to call when this mesh collides with another one */
  112760. set onCollide(callback: () => void);
  112761. /**
  112762. * An event triggered when the collision's position changes
  112763. */
  112764. onCollisionPositionChangeObservable: Observable<Vector3>;
  112765. /** Set a function to call when the collision's position changes */
  112766. set onCollisionPositionChange(callback: () => void);
  112767. /**
  112768. * An event triggered when material is changed
  112769. */
  112770. onMaterialChangedObservable: Observable<AbstractMesh>;
  112771. /**
  112772. * Gets or sets the orientation for POV movement & rotation
  112773. */
  112774. definedFacingForward: boolean;
  112775. /** @hidden */
  112776. _occlusionQuery: Nullable<WebGLQuery>;
  112777. /** @hidden */
  112778. _renderingGroup: Nullable<RenderingGroup>;
  112779. /**
  112780. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112781. */
  112782. get visibility(): number;
  112783. /**
  112784. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112785. */
  112786. set visibility(value: number);
  112787. /** Gets or sets the alpha index used to sort transparent meshes
  112788. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112789. */
  112790. alphaIndex: number;
  112791. /**
  112792. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112793. */
  112794. isVisible: boolean;
  112795. /**
  112796. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112797. */
  112798. isPickable: boolean;
  112799. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112800. showSubMeshesBoundingBox: boolean;
  112801. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112802. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112803. */
  112804. isBlocker: boolean;
  112805. /**
  112806. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112807. */
  112808. enablePointerMoveEvents: boolean;
  112809. private _renderingGroupId;
  112810. /**
  112811. * Specifies the rendering group id for this mesh (0 by default)
  112812. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112813. */
  112814. get renderingGroupId(): number;
  112815. set renderingGroupId(value: number);
  112816. private _material;
  112817. /** Gets or sets current material */
  112818. get material(): Nullable<Material>;
  112819. set material(value: Nullable<Material>);
  112820. /**
  112821. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112822. * @see https://doc.babylonjs.com/babylon101/shadows
  112823. */
  112824. get receiveShadows(): boolean;
  112825. set receiveShadows(value: boolean);
  112826. /** Defines color to use when rendering outline */
  112827. outlineColor: Color3;
  112828. /** Define width to use when rendering outline */
  112829. outlineWidth: number;
  112830. /** Defines color to use when rendering overlay */
  112831. overlayColor: Color3;
  112832. /** Defines alpha to use when rendering overlay */
  112833. overlayAlpha: number;
  112834. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112835. get hasVertexAlpha(): boolean;
  112836. set hasVertexAlpha(value: boolean);
  112837. /** 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) */
  112838. get useVertexColors(): boolean;
  112839. set useVertexColors(value: boolean);
  112840. /**
  112841. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112842. */
  112843. get computeBonesUsingShaders(): boolean;
  112844. set computeBonesUsingShaders(value: boolean);
  112845. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112846. get numBoneInfluencers(): number;
  112847. set numBoneInfluencers(value: number);
  112848. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112849. get applyFog(): boolean;
  112850. set applyFog(value: boolean);
  112851. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112852. useOctreeForRenderingSelection: boolean;
  112853. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112854. useOctreeForPicking: boolean;
  112855. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112856. useOctreeForCollisions: boolean;
  112857. /**
  112858. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112859. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112860. */
  112861. get layerMask(): number;
  112862. set layerMask(value: number);
  112863. /**
  112864. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112865. */
  112866. alwaysSelectAsActiveMesh: boolean;
  112867. /**
  112868. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112869. */
  112870. doNotSyncBoundingInfo: boolean;
  112871. /**
  112872. * Gets or sets the current action manager
  112873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112874. */
  112875. actionManager: Nullable<AbstractActionManager>;
  112876. private _meshCollisionData;
  112877. /**
  112878. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112879. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112880. */
  112881. ellipsoid: Vector3;
  112882. /**
  112883. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112884. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112885. */
  112886. ellipsoidOffset: Vector3;
  112887. /**
  112888. * Gets or sets a collision mask used to mask collisions (default is -1).
  112889. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112890. */
  112891. get collisionMask(): number;
  112892. set collisionMask(mask: number);
  112893. /**
  112894. * Gets or sets a collision response flag (default is true).
  112895. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112896. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112897. * to respond to the collision.
  112898. */
  112899. get collisionResponse(): boolean;
  112900. set collisionResponse(response: boolean);
  112901. /**
  112902. * Gets or sets the current collision group mask (-1 by default).
  112903. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112904. */
  112905. get collisionGroup(): number;
  112906. set collisionGroup(mask: number);
  112907. /**
  112908. * Gets or sets current surrounding meshes (null by default).
  112909. *
  112910. * By default collision detection is tested against every mesh in the scene.
  112911. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112912. * meshes will be tested for the collision.
  112913. *
  112914. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112915. */
  112916. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112917. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112918. /**
  112919. * Defines edge width used when edgesRenderer is enabled
  112920. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112921. */
  112922. edgesWidth: number;
  112923. /**
  112924. * Defines edge color used when edgesRenderer is enabled
  112925. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112926. */
  112927. edgesColor: Color4;
  112928. /** @hidden */
  112929. _edgesRenderer: Nullable<IEdgesRenderer>;
  112930. /** @hidden */
  112931. _masterMesh: Nullable<AbstractMesh>;
  112932. /** @hidden */
  112933. _boundingInfo: Nullable<BoundingInfo>;
  112934. /** @hidden */
  112935. _renderId: number;
  112936. /**
  112937. * Gets or sets the list of subMeshes
  112938. * @see https://doc.babylonjs.com/how_to/multi_materials
  112939. */
  112940. subMeshes: SubMesh[];
  112941. /** @hidden */
  112942. _intersectionsInProgress: AbstractMesh[];
  112943. /** @hidden */
  112944. _unIndexed: boolean;
  112945. /** @hidden */
  112946. _lightSources: Light[];
  112947. /** Gets the list of lights affecting that mesh */
  112948. get lightSources(): Light[];
  112949. /** @hidden */
  112950. get _positions(): Nullable<Vector3[]>;
  112951. /** @hidden */
  112952. _waitingData: {
  112953. lods: Nullable<any>;
  112954. actions: Nullable<any>;
  112955. freezeWorldMatrix: Nullable<boolean>;
  112956. };
  112957. /** @hidden */
  112958. _bonesTransformMatrices: Nullable<Float32Array>;
  112959. /** @hidden */
  112960. _transformMatrixTexture: Nullable<RawTexture>;
  112961. /**
  112962. * Gets or sets a skeleton to apply skining transformations
  112963. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112964. */
  112965. set skeleton(value: Nullable<Skeleton>);
  112966. get skeleton(): Nullable<Skeleton>;
  112967. /**
  112968. * An event triggered when the mesh is rebuilt.
  112969. */
  112970. onRebuildObservable: Observable<AbstractMesh>;
  112971. /**
  112972. * Creates a new AbstractMesh
  112973. * @param name defines the name of the mesh
  112974. * @param scene defines the hosting scene
  112975. */
  112976. constructor(name: string, scene?: Nullable<Scene>);
  112977. /**
  112978. * Returns the string "AbstractMesh"
  112979. * @returns "AbstractMesh"
  112980. */
  112981. getClassName(): string;
  112982. /**
  112983. * Gets a string representation of the current mesh
  112984. * @param fullDetails defines a boolean indicating if full details must be included
  112985. * @returns a string representation of the current mesh
  112986. */
  112987. toString(fullDetails?: boolean): string;
  112988. /**
  112989. * @hidden
  112990. */
  112991. protected _getEffectiveParent(): Nullable<Node>;
  112992. /** @hidden */
  112993. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112994. /** @hidden */
  112995. _rebuild(): void;
  112996. /** @hidden */
  112997. _resyncLightSources(): void;
  112998. /** @hidden */
  112999. _resyncLightSource(light: Light): void;
  113000. /** @hidden */
  113001. _unBindEffect(): void;
  113002. /** @hidden */
  113003. _removeLightSource(light: Light, dispose: boolean): void;
  113004. private _markSubMeshesAsDirty;
  113005. /** @hidden */
  113006. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  113007. /** @hidden */
  113008. _markSubMeshesAsAttributesDirty(): void;
  113009. /** @hidden */
  113010. _markSubMeshesAsMiscDirty(): void;
  113011. /**
  113012. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  113013. */
  113014. get scaling(): Vector3;
  113015. set scaling(newScaling: Vector3);
  113016. /**
  113017. * Returns true if the mesh is blocked. Implemented by child classes
  113018. */
  113019. get isBlocked(): boolean;
  113020. /**
  113021. * Returns the mesh itself by default. Implemented by child classes
  113022. * @param camera defines the camera to use to pick the right LOD level
  113023. * @returns the currentAbstractMesh
  113024. */
  113025. getLOD(camera: Camera): Nullable<AbstractMesh>;
  113026. /**
  113027. * Returns 0 by default. Implemented by child classes
  113028. * @returns an integer
  113029. */
  113030. getTotalVertices(): number;
  113031. /**
  113032. * Returns a positive integer : the total number of indices in this mesh geometry.
  113033. * @returns the numner of indices or zero if the mesh has no geometry.
  113034. */
  113035. getTotalIndices(): number;
  113036. /**
  113037. * Returns null by default. Implemented by child classes
  113038. * @returns null
  113039. */
  113040. getIndices(): Nullable<IndicesArray>;
  113041. /**
  113042. * Returns the array of the requested vertex data kind. Implemented by child classes
  113043. * @param kind defines the vertex data kind to use
  113044. * @returns null
  113045. */
  113046. getVerticesData(kind: string): Nullable<FloatArray>;
  113047. /**
  113048. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113049. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113050. * Note that a new underlying VertexBuffer object is created each call.
  113051. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113052. * @param kind defines vertex data kind:
  113053. * * VertexBuffer.PositionKind
  113054. * * VertexBuffer.UVKind
  113055. * * VertexBuffer.UV2Kind
  113056. * * VertexBuffer.UV3Kind
  113057. * * VertexBuffer.UV4Kind
  113058. * * VertexBuffer.UV5Kind
  113059. * * VertexBuffer.UV6Kind
  113060. * * VertexBuffer.ColorKind
  113061. * * VertexBuffer.MatricesIndicesKind
  113062. * * VertexBuffer.MatricesIndicesExtraKind
  113063. * * VertexBuffer.MatricesWeightsKind
  113064. * * VertexBuffer.MatricesWeightsExtraKind
  113065. * @param data defines the data source
  113066. * @param updatable defines if the data must be flagged as updatable (or static)
  113067. * @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
  113068. * @returns the current mesh
  113069. */
  113070. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113071. /**
  113072. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  113073. * If the mesh has no geometry, it is simply returned as it is.
  113074. * @param kind defines vertex data kind:
  113075. * * VertexBuffer.PositionKind
  113076. * * VertexBuffer.UVKind
  113077. * * VertexBuffer.UV2Kind
  113078. * * VertexBuffer.UV3Kind
  113079. * * VertexBuffer.UV4Kind
  113080. * * VertexBuffer.UV5Kind
  113081. * * VertexBuffer.UV6Kind
  113082. * * VertexBuffer.ColorKind
  113083. * * VertexBuffer.MatricesIndicesKind
  113084. * * VertexBuffer.MatricesIndicesExtraKind
  113085. * * VertexBuffer.MatricesWeightsKind
  113086. * * VertexBuffer.MatricesWeightsExtraKind
  113087. * @param data defines the data source
  113088. * @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
  113089. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  113090. * @returns the current mesh
  113091. */
  113092. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113093. /**
  113094. * Sets the mesh indices,
  113095. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  113096. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  113097. * @param totalVertices Defines the total number of vertices
  113098. * @returns the current mesh
  113099. */
  113100. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  113101. /**
  113102. * Gets a boolean indicating if specific vertex data is present
  113103. * @param kind defines the vertex data kind to use
  113104. * @returns true is data kind is present
  113105. */
  113106. isVerticesDataPresent(kind: string): boolean;
  113107. /**
  113108. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  113109. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  113110. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  113111. * @returns a BoundingInfo
  113112. */
  113113. getBoundingInfo(): BoundingInfo;
  113114. /**
  113115. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  113116. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  113117. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  113118. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  113119. * @returns the current mesh
  113120. */
  113121. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  113122. /**
  113123. * Overwrite the current bounding info
  113124. * @param boundingInfo defines the new bounding info
  113125. * @returns the current mesh
  113126. */
  113127. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  113128. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  113129. get useBones(): boolean;
  113130. /** @hidden */
  113131. _preActivate(): void;
  113132. /** @hidden */
  113133. _preActivateForIntermediateRendering(renderId: number): void;
  113134. /** @hidden */
  113135. _activate(renderId: number, intermediateRendering: boolean): boolean;
  113136. /** @hidden */
  113137. _postActivate(): void;
  113138. /** @hidden */
  113139. _freeze(): void;
  113140. /** @hidden */
  113141. _unFreeze(): void;
  113142. /**
  113143. * Gets the current world matrix
  113144. * @returns a Matrix
  113145. */
  113146. getWorldMatrix(): Matrix;
  113147. /** @hidden */
  113148. _getWorldMatrixDeterminant(): number;
  113149. /**
  113150. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  113151. */
  113152. get isAnInstance(): boolean;
  113153. /**
  113154. * Gets a boolean indicating if this mesh has instances
  113155. */
  113156. get hasInstances(): boolean;
  113157. /**
  113158. * Gets a boolean indicating if this mesh has thin instances
  113159. */
  113160. get hasThinInstances(): boolean;
  113161. /**
  113162. * Perform relative position change from the point of view of behind the front of the mesh.
  113163. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113164. * Supports definition of mesh facing forward or backward
  113165. * @param amountRight defines the distance on the right axis
  113166. * @param amountUp defines the distance on the up axis
  113167. * @param amountForward defines the distance on the forward axis
  113168. * @returns the current mesh
  113169. */
  113170. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  113171. /**
  113172. * Calculate relative position change from the point of view of behind the front of the mesh.
  113173. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113174. * Supports definition of mesh facing forward or backward
  113175. * @param amountRight defines the distance on the right axis
  113176. * @param amountUp defines the distance on the up axis
  113177. * @param amountForward defines the distance on the forward axis
  113178. * @returns the new displacement vector
  113179. */
  113180. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  113181. /**
  113182. * Perform relative rotation change from the point of view of behind the front of the mesh.
  113183. * Supports definition of mesh facing forward or backward
  113184. * @param flipBack defines the flip
  113185. * @param twirlClockwise defines the twirl
  113186. * @param tiltRight defines the tilt
  113187. * @returns the current mesh
  113188. */
  113189. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  113190. /**
  113191. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  113192. * Supports definition of mesh facing forward or backward.
  113193. * @param flipBack defines the flip
  113194. * @param twirlClockwise defines the twirl
  113195. * @param tiltRight defines the tilt
  113196. * @returns the new rotation vector
  113197. */
  113198. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  113199. /**
  113200. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113201. * This means the mesh underlying bounding box and sphere are recomputed.
  113202. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113203. * @returns the current mesh
  113204. */
  113205. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  113206. /** @hidden */
  113207. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  113208. /** @hidden */
  113209. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  113210. /** @hidden */
  113211. _updateBoundingInfo(): AbstractMesh;
  113212. /** @hidden */
  113213. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  113214. /** @hidden */
  113215. protected _afterComputeWorldMatrix(): void;
  113216. /** @hidden */
  113217. get _effectiveMesh(): AbstractMesh;
  113218. /**
  113219. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113220. * A mesh is in the frustum if its bounding box intersects the frustum
  113221. * @param frustumPlanes defines the frustum to test
  113222. * @returns true if the mesh is in the frustum planes
  113223. */
  113224. isInFrustum(frustumPlanes: Plane[]): boolean;
  113225. /**
  113226. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  113227. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  113228. * @param frustumPlanes defines the frustum to test
  113229. * @returns true if the mesh is completely in the frustum planes
  113230. */
  113231. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  113232. /**
  113233. * True if the mesh intersects another mesh or a SolidParticle object
  113234. * @param mesh defines a target mesh or SolidParticle to test
  113235. * @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)
  113236. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  113237. * @returns true if there is an intersection
  113238. */
  113239. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  113240. /**
  113241. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  113242. * @param point defines the point to test
  113243. * @returns true if there is an intersection
  113244. */
  113245. intersectsPoint(point: Vector3): boolean;
  113246. /**
  113247. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  113248. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113249. */
  113250. get checkCollisions(): boolean;
  113251. set checkCollisions(collisionEnabled: boolean);
  113252. /**
  113253. * Gets Collider object used to compute collisions (not physics)
  113254. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113255. */
  113256. get collider(): Nullable<Collider>;
  113257. /**
  113258. * Move the mesh using collision engine
  113259. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113260. * @param displacement defines the requested displacement vector
  113261. * @returns the current mesh
  113262. */
  113263. moveWithCollisions(displacement: Vector3): AbstractMesh;
  113264. private _onCollisionPositionChange;
  113265. /** @hidden */
  113266. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  113267. /** @hidden */
  113268. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  113269. /** @hidden */
  113270. _checkCollision(collider: Collider): AbstractMesh;
  113271. /** @hidden */
  113272. _generatePointsArray(): boolean;
  113273. /**
  113274. * Checks if the passed Ray intersects with the mesh
  113275. * @param ray defines the ray to use
  113276. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  113277. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113278. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  113279. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  113280. * @returns the picking info
  113281. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  113282. */
  113283. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  113284. /**
  113285. * Clones the current mesh
  113286. * @param name defines the mesh name
  113287. * @param newParent defines the new mesh parent
  113288. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  113289. * @returns the new mesh
  113290. */
  113291. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  113292. /**
  113293. * Disposes all the submeshes of the current meshnp
  113294. * @returns the current mesh
  113295. */
  113296. releaseSubMeshes(): AbstractMesh;
  113297. /**
  113298. * Releases resources associated with this abstract mesh.
  113299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113301. */
  113302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113303. /**
  113304. * Adds the passed mesh as a child to the current mesh
  113305. * @param mesh defines the child mesh
  113306. * @returns the current mesh
  113307. */
  113308. addChild(mesh: AbstractMesh): AbstractMesh;
  113309. /**
  113310. * Removes the passed mesh from the current mesh children list
  113311. * @param mesh defines the child mesh
  113312. * @returns the current mesh
  113313. */
  113314. removeChild(mesh: AbstractMesh): AbstractMesh;
  113315. /** @hidden */
  113316. private _initFacetData;
  113317. /**
  113318. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113319. * This method can be called within the render loop.
  113320. * 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
  113321. * @returns the current mesh
  113322. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113323. */
  113324. updateFacetData(): AbstractMesh;
  113325. /**
  113326. * Returns the facetLocalNormals array.
  113327. * The normals are expressed in the mesh local spac
  113328. * @returns an array of Vector3
  113329. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113330. */
  113331. getFacetLocalNormals(): Vector3[];
  113332. /**
  113333. * Returns the facetLocalPositions array.
  113334. * The facet positions are expressed in the mesh local space
  113335. * @returns an array of Vector3
  113336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113337. */
  113338. getFacetLocalPositions(): Vector3[];
  113339. /**
  113340. * Returns the facetLocalPartioning array
  113341. * @returns an array of array of numbers
  113342. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113343. */
  113344. getFacetLocalPartitioning(): number[][];
  113345. /**
  113346. * Returns the i-th facet position in the world system.
  113347. * This method allocates a new Vector3 per call
  113348. * @param i defines the facet index
  113349. * @returns a new Vector3
  113350. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113351. */
  113352. getFacetPosition(i: number): Vector3;
  113353. /**
  113354. * Sets the reference Vector3 with the i-th facet position in the world system
  113355. * @param i defines the facet index
  113356. * @param ref defines the target vector
  113357. * @returns the current mesh
  113358. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113359. */
  113360. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113361. /**
  113362. * Returns the i-th facet normal in the world system.
  113363. * This method allocates a new Vector3 per call
  113364. * @param i defines the facet index
  113365. * @returns a new Vector3
  113366. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113367. */
  113368. getFacetNormal(i: number): Vector3;
  113369. /**
  113370. * Sets the reference Vector3 with the i-th facet normal in the world system
  113371. * @param i defines the facet index
  113372. * @param ref defines the target vector
  113373. * @returns the current mesh
  113374. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113375. */
  113376. getFacetNormalToRef(i: number, ref: Vector3): this;
  113377. /**
  113378. * 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)
  113379. * @param x defines x coordinate
  113380. * @param y defines y coordinate
  113381. * @param z defines z coordinate
  113382. * @returns the array of facet indexes
  113383. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113384. */
  113385. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113386. /**
  113387. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113388. * @param projected sets as the (x,y,z) world projection on the facet
  113389. * @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
  113390. * @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
  113391. * @param x defines x coordinate
  113392. * @param y defines y coordinate
  113393. * @param z defines z coordinate
  113394. * @returns the face index if found (or null instead)
  113395. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113396. */
  113397. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113398. /**
  113399. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113400. * @param projected sets as the (x,y,z) local projection on the facet
  113401. * @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
  113402. * @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
  113403. * @param x defines x coordinate
  113404. * @param y defines y coordinate
  113405. * @param z defines z coordinate
  113406. * @returns the face index if found (or null instead)
  113407. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113408. */
  113409. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113410. /**
  113411. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113412. * @returns the parameters
  113413. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113414. */
  113415. getFacetDataParameters(): any;
  113416. /**
  113417. * Disables the feature FacetData and frees the related memory
  113418. * @returns the current mesh
  113419. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113420. */
  113421. disableFacetData(): AbstractMesh;
  113422. /**
  113423. * Updates the AbstractMesh indices array
  113424. * @param indices defines the data source
  113425. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113426. * @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)
  113427. * @returns the current mesh
  113428. */
  113429. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113430. /**
  113431. * Creates new normals data for the mesh
  113432. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113433. * @returns the current mesh
  113434. */
  113435. createNormals(updatable: boolean): AbstractMesh;
  113436. /**
  113437. * Align the mesh with a normal
  113438. * @param normal defines the normal to use
  113439. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113440. * @returns the current mesh
  113441. */
  113442. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113443. /** @hidden */
  113444. _checkOcclusionQuery(): boolean;
  113445. /**
  113446. * Disables the mesh edge rendering mode
  113447. * @returns the currentAbstractMesh
  113448. */
  113449. disableEdgesRendering(): AbstractMesh;
  113450. /**
  113451. * Enables the edge rendering mode on the mesh.
  113452. * This mode makes the mesh edges visible
  113453. * @param epsilon defines the maximal distance between two angles to detect a face
  113454. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113455. * @returns the currentAbstractMesh
  113456. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113457. */
  113458. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113459. /**
  113460. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113461. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113462. */
  113463. getConnectedParticleSystems(): IParticleSystem[];
  113464. }
  113465. }
  113466. declare module BABYLON {
  113467. /**
  113468. * Interface used to define ActionEvent
  113469. */
  113470. export interface IActionEvent {
  113471. /** The mesh or sprite that triggered the action */
  113472. source: any;
  113473. /** The X mouse cursor position at the time of the event */
  113474. pointerX: number;
  113475. /** The Y mouse cursor position at the time of the event */
  113476. pointerY: number;
  113477. /** The mesh that is currently pointed at (can be null) */
  113478. meshUnderPointer: Nullable<AbstractMesh>;
  113479. /** the original (browser) event that triggered the ActionEvent */
  113480. sourceEvent?: any;
  113481. /** additional data for the event */
  113482. additionalData?: any;
  113483. }
  113484. /**
  113485. * ActionEvent is the event being sent when an action is triggered.
  113486. */
  113487. export class ActionEvent implements IActionEvent {
  113488. /** The mesh or sprite that triggered the action */
  113489. source: any;
  113490. /** The X mouse cursor position at the time of the event */
  113491. pointerX: number;
  113492. /** The Y mouse cursor position at the time of the event */
  113493. pointerY: number;
  113494. /** The mesh that is currently pointed at (can be null) */
  113495. meshUnderPointer: Nullable<AbstractMesh>;
  113496. /** the original (browser) event that triggered the ActionEvent */
  113497. sourceEvent?: any;
  113498. /** additional data for the event */
  113499. additionalData?: any;
  113500. /**
  113501. * Creates a new ActionEvent
  113502. * @param source The mesh or sprite that triggered the action
  113503. * @param pointerX The X mouse cursor position at the time of the event
  113504. * @param pointerY The Y mouse cursor position at the time of the event
  113505. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113506. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113507. * @param additionalData additional data for the event
  113508. */
  113509. constructor(
  113510. /** The mesh or sprite that triggered the action */
  113511. source: any,
  113512. /** The X mouse cursor position at the time of the event */
  113513. pointerX: number,
  113514. /** The Y mouse cursor position at the time of the event */
  113515. pointerY: number,
  113516. /** The mesh that is currently pointed at (can be null) */
  113517. meshUnderPointer: Nullable<AbstractMesh>,
  113518. /** the original (browser) event that triggered the ActionEvent */
  113519. sourceEvent?: any,
  113520. /** additional data for the event */
  113521. additionalData?: any);
  113522. /**
  113523. * Helper function to auto-create an ActionEvent from a source mesh.
  113524. * @param source The source mesh that triggered the event
  113525. * @param evt The original (browser) event
  113526. * @param additionalData additional data for the event
  113527. * @returns the new ActionEvent
  113528. */
  113529. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113530. /**
  113531. * Helper function to auto-create an ActionEvent from a source sprite
  113532. * @param source The source sprite that triggered the event
  113533. * @param scene Scene associated with the sprite
  113534. * @param evt The original (browser) event
  113535. * @param additionalData additional data for the event
  113536. * @returns the new ActionEvent
  113537. */
  113538. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113539. /**
  113540. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113541. * @param scene the scene where the event occurred
  113542. * @param evt The original (browser) event
  113543. * @returns the new ActionEvent
  113544. */
  113545. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113546. /**
  113547. * Helper function to auto-create an ActionEvent from a primitive
  113548. * @param prim defines the target primitive
  113549. * @param pointerPos defines the pointer position
  113550. * @param evt The original (browser) event
  113551. * @param additionalData additional data for the event
  113552. * @returns the new ActionEvent
  113553. */
  113554. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113555. }
  113556. }
  113557. declare module BABYLON {
  113558. /**
  113559. * Abstract class used to decouple action Manager from scene and meshes.
  113560. * Do not instantiate.
  113561. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113562. */
  113563. export abstract class AbstractActionManager implements IDisposable {
  113564. /** Gets the list of active triggers */
  113565. static Triggers: {
  113566. [key: string]: number;
  113567. };
  113568. /** Gets the cursor to use when hovering items */
  113569. hoverCursor: string;
  113570. /** Gets the list of actions */
  113571. actions: IAction[];
  113572. /**
  113573. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113574. */
  113575. isRecursive: boolean;
  113576. /**
  113577. * Releases all associated resources
  113578. */
  113579. abstract dispose(): void;
  113580. /**
  113581. * Does this action manager has pointer triggers
  113582. */
  113583. abstract get hasPointerTriggers(): boolean;
  113584. /**
  113585. * Does this action manager has pick triggers
  113586. */
  113587. abstract get hasPickTriggers(): boolean;
  113588. /**
  113589. * Process a specific trigger
  113590. * @param trigger defines the trigger to process
  113591. * @param evt defines the event details to be processed
  113592. */
  113593. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113594. /**
  113595. * Does this action manager handles actions of any of the given triggers
  113596. * @param triggers defines the triggers to be tested
  113597. * @return a boolean indicating whether one (or more) of the triggers is handled
  113598. */
  113599. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113600. /**
  113601. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113602. * speed.
  113603. * @param triggerA defines the trigger to be tested
  113604. * @param triggerB defines the trigger to be tested
  113605. * @return a boolean indicating whether one (or more) of the triggers is handled
  113606. */
  113607. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113608. /**
  113609. * Does this action manager handles actions of a given trigger
  113610. * @param trigger defines the trigger to be tested
  113611. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113612. * @return whether the trigger is handled
  113613. */
  113614. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113615. /**
  113616. * Serialize this manager to a JSON object
  113617. * @param name defines the property name to store this manager
  113618. * @returns a JSON representation of this manager
  113619. */
  113620. abstract serialize(name: string): any;
  113621. /**
  113622. * Registers an action to this action manager
  113623. * @param action defines the action to be registered
  113624. * @return the action amended (prepared) after registration
  113625. */
  113626. abstract registerAction(action: IAction): Nullable<IAction>;
  113627. /**
  113628. * Unregisters an action to this action manager
  113629. * @param action defines the action to be unregistered
  113630. * @return a boolean indicating whether the action has been unregistered
  113631. */
  113632. abstract unregisterAction(action: IAction): Boolean;
  113633. /**
  113634. * Does exist one action manager with at least one trigger
  113635. **/
  113636. static get HasTriggers(): boolean;
  113637. /**
  113638. * Does exist one action manager with at least one pick trigger
  113639. **/
  113640. static get HasPickTriggers(): boolean;
  113641. /**
  113642. * Does exist one action manager that handles actions of a given trigger
  113643. * @param trigger defines the trigger to be tested
  113644. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113645. **/
  113646. static HasSpecificTrigger(trigger: number): boolean;
  113647. }
  113648. }
  113649. declare module BABYLON {
  113650. /**
  113651. * Defines how a node can be built from a string name.
  113652. */
  113653. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113654. /**
  113655. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113656. */
  113657. export class Node implements IBehaviorAware<Node> {
  113658. /** @hidden */
  113659. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113660. private static _NodeConstructors;
  113661. /**
  113662. * Add a new node constructor
  113663. * @param type defines the type name of the node to construct
  113664. * @param constructorFunc defines the constructor function
  113665. */
  113666. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113667. /**
  113668. * Returns a node constructor based on type name
  113669. * @param type defines the type name
  113670. * @param name defines the new node name
  113671. * @param scene defines the hosting scene
  113672. * @param options defines optional options to transmit to constructors
  113673. * @returns the new constructor or null
  113674. */
  113675. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113676. /**
  113677. * Gets or sets the name of the node
  113678. */
  113679. name: string;
  113680. /**
  113681. * Gets or sets the id of the node
  113682. */
  113683. id: string;
  113684. /**
  113685. * Gets or sets the unique id of the node
  113686. */
  113687. uniqueId: number;
  113688. /**
  113689. * Gets or sets a string used to store user defined state for the node
  113690. */
  113691. state: string;
  113692. /**
  113693. * Gets or sets an object used to store user defined information for the node
  113694. */
  113695. metadata: any;
  113696. /**
  113697. * For internal use only. Please do not use.
  113698. */
  113699. reservedDataStore: any;
  113700. /**
  113701. * List of inspectable custom properties (used by the Inspector)
  113702. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113703. */
  113704. inspectableCustomProperties: IInspectable[];
  113705. private _doNotSerialize;
  113706. /**
  113707. * Gets or sets a boolean used to define if the node must be serialized
  113708. */
  113709. get doNotSerialize(): boolean;
  113710. set doNotSerialize(value: boolean);
  113711. /** @hidden */
  113712. _isDisposed: boolean;
  113713. /**
  113714. * Gets a list of Animations associated with the node
  113715. */
  113716. animations: Animation[];
  113717. protected _ranges: {
  113718. [name: string]: Nullable<AnimationRange>;
  113719. };
  113720. /**
  113721. * Callback raised when the node is ready to be used
  113722. */
  113723. onReady: Nullable<(node: Node) => void>;
  113724. private _isEnabled;
  113725. private _isParentEnabled;
  113726. private _isReady;
  113727. /** @hidden */
  113728. _currentRenderId: number;
  113729. private _parentUpdateId;
  113730. /** @hidden */
  113731. _childUpdateId: number;
  113732. /** @hidden */
  113733. _waitingParentId: Nullable<string>;
  113734. /** @hidden */
  113735. _scene: Scene;
  113736. /** @hidden */
  113737. _cache: any;
  113738. private _parentNode;
  113739. private _children;
  113740. /** @hidden */
  113741. _worldMatrix: Matrix;
  113742. /** @hidden */
  113743. _worldMatrixDeterminant: number;
  113744. /** @hidden */
  113745. _worldMatrixDeterminantIsDirty: boolean;
  113746. /** @hidden */
  113747. private _sceneRootNodesIndex;
  113748. /**
  113749. * Gets a boolean indicating if the node has been disposed
  113750. * @returns true if the node was disposed
  113751. */
  113752. isDisposed(): boolean;
  113753. /**
  113754. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113755. * @see https://doc.babylonjs.com/how_to/parenting
  113756. */
  113757. set parent(parent: Nullable<Node>);
  113758. get parent(): Nullable<Node>;
  113759. /** @hidden */
  113760. _addToSceneRootNodes(): void;
  113761. /** @hidden */
  113762. _removeFromSceneRootNodes(): void;
  113763. private _animationPropertiesOverride;
  113764. /**
  113765. * Gets or sets the animation properties override
  113766. */
  113767. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113768. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113769. /**
  113770. * Gets a string identifying the name of the class
  113771. * @returns "Node" string
  113772. */
  113773. getClassName(): string;
  113774. /** @hidden */
  113775. readonly _isNode: boolean;
  113776. /**
  113777. * An event triggered when the mesh is disposed
  113778. */
  113779. onDisposeObservable: Observable<Node>;
  113780. private _onDisposeObserver;
  113781. /**
  113782. * Sets a callback that will be raised when the node will be disposed
  113783. */
  113784. set onDispose(callback: () => void);
  113785. /**
  113786. * Creates a new Node
  113787. * @param name the name and id to be given to this node
  113788. * @param scene the scene this node will be added to
  113789. */
  113790. constructor(name: string, scene?: Nullable<Scene>);
  113791. /**
  113792. * Gets the scene of the node
  113793. * @returns a scene
  113794. */
  113795. getScene(): Scene;
  113796. /**
  113797. * Gets the engine of the node
  113798. * @returns a Engine
  113799. */
  113800. getEngine(): Engine;
  113801. private _behaviors;
  113802. /**
  113803. * Attach a behavior to the node
  113804. * @see https://doc.babylonjs.com/features/behaviour
  113805. * @param behavior defines the behavior to attach
  113806. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113807. * @returns the current Node
  113808. */
  113809. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113810. /**
  113811. * Remove an attached behavior
  113812. * @see https://doc.babylonjs.com/features/behaviour
  113813. * @param behavior defines the behavior to attach
  113814. * @returns the current Node
  113815. */
  113816. removeBehavior(behavior: Behavior<Node>): Node;
  113817. /**
  113818. * Gets the list of attached behaviors
  113819. * @see https://doc.babylonjs.com/features/behaviour
  113820. */
  113821. get behaviors(): Behavior<Node>[];
  113822. /**
  113823. * Gets an attached behavior by name
  113824. * @param name defines the name of the behavior to look for
  113825. * @see https://doc.babylonjs.com/features/behaviour
  113826. * @returns null if behavior was not found else the requested behavior
  113827. */
  113828. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113829. /**
  113830. * Returns the latest update of the World matrix
  113831. * @returns a Matrix
  113832. */
  113833. getWorldMatrix(): Matrix;
  113834. /** @hidden */
  113835. _getWorldMatrixDeterminant(): number;
  113836. /**
  113837. * Returns directly the latest state of the mesh World matrix.
  113838. * A Matrix is returned.
  113839. */
  113840. get worldMatrixFromCache(): Matrix;
  113841. /** @hidden */
  113842. _initCache(): void;
  113843. /** @hidden */
  113844. updateCache(force?: boolean): void;
  113845. /** @hidden */
  113846. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113847. /** @hidden */
  113848. _updateCache(ignoreParentClass?: boolean): void;
  113849. /** @hidden */
  113850. _isSynchronized(): boolean;
  113851. /** @hidden */
  113852. _markSyncedWithParent(): void;
  113853. /** @hidden */
  113854. isSynchronizedWithParent(): boolean;
  113855. /** @hidden */
  113856. isSynchronized(): boolean;
  113857. /**
  113858. * Is this node ready to be used/rendered
  113859. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113860. * @return true if the node is ready
  113861. */
  113862. isReady(completeCheck?: boolean): boolean;
  113863. /**
  113864. * Is this node enabled?
  113865. * 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
  113866. * @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
  113867. * @return whether this node (and its parent) is enabled
  113868. */
  113869. isEnabled(checkAncestors?: boolean): boolean;
  113870. /** @hidden */
  113871. protected _syncParentEnabledState(): void;
  113872. /**
  113873. * Set the enabled state of this node
  113874. * @param value defines the new enabled state
  113875. */
  113876. setEnabled(value: boolean): void;
  113877. /**
  113878. * Is this node a descendant of the given node?
  113879. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113880. * @param ancestor defines the parent node to inspect
  113881. * @returns a boolean indicating if this node is a descendant of the given node
  113882. */
  113883. isDescendantOf(ancestor: Node): boolean;
  113884. /** @hidden */
  113885. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113886. /**
  113887. * Will return all nodes that have this node as ascendant
  113888. * @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
  113889. * @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
  113890. * @return all children nodes of all types
  113891. */
  113892. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113893. /**
  113894. * Get all child-meshes of this node
  113895. * @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)
  113896. * @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
  113897. * @returns an array of AbstractMesh
  113898. */
  113899. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113900. /**
  113901. * Get all direct children of this node
  113902. * @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
  113903. * @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)
  113904. * @returns an array of Node
  113905. */
  113906. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113907. /** @hidden */
  113908. _setReady(state: boolean): void;
  113909. /**
  113910. * Get an animation by name
  113911. * @param name defines the name of the animation to look for
  113912. * @returns null if not found else the requested animation
  113913. */
  113914. getAnimationByName(name: string): Nullable<Animation>;
  113915. /**
  113916. * Creates an animation range for this node
  113917. * @param name defines the name of the range
  113918. * @param from defines the starting key
  113919. * @param to defines the end key
  113920. */
  113921. createAnimationRange(name: string, from: number, to: number): void;
  113922. /**
  113923. * Delete a specific animation range
  113924. * @param name defines the name of the range to delete
  113925. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113926. */
  113927. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113928. /**
  113929. * Get an animation range by name
  113930. * @param name defines the name of the animation range to look for
  113931. * @returns null if not found else the requested animation range
  113932. */
  113933. getAnimationRange(name: string): Nullable<AnimationRange>;
  113934. /**
  113935. * Gets the list of all animation ranges defined on this node
  113936. * @returns an array
  113937. */
  113938. getAnimationRanges(): Nullable<AnimationRange>[];
  113939. /**
  113940. * Will start the animation sequence
  113941. * @param name defines the range frames for animation sequence
  113942. * @param loop defines if the animation should loop (false by default)
  113943. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113944. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113945. * @returns the object created for this animation. If range does not exist, it will return null
  113946. */
  113947. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113948. /**
  113949. * Serialize animation ranges into a JSON compatible object
  113950. * @returns serialization object
  113951. */
  113952. serializeAnimationRanges(): any;
  113953. /**
  113954. * Computes the world matrix of the node
  113955. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113956. * @returns the world matrix
  113957. */
  113958. computeWorldMatrix(force?: boolean): Matrix;
  113959. /**
  113960. * Releases resources associated with this node.
  113961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113963. */
  113964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113965. /**
  113966. * Parse animation range data from a serialization object and store them into a given node
  113967. * @param node defines where to store the animation ranges
  113968. * @param parsedNode defines the serialization object to read data from
  113969. * @param scene defines the hosting scene
  113970. */
  113971. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113972. /**
  113973. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113974. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113975. * @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
  113976. * @returns the new bounding vectors
  113977. */
  113978. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113979. min: Vector3;
  113980. max: Vector3;
  113981. };
  113982. }
  113983. }
  113984. declare module BABYLON {
  113985. /**
  113986. * @hidden
  113987. */
  113988. export class _IAnimationState {
  113989. key: number;
  113990. repeatCount: number;
  113991. workValue?: any;
  113992. loopMode?: number;
  113993. offsetValue?: any;
  113994. highLimitValue?: any;
  113995. }
  113996. /**
  113997. * Class used to store any kind of animation
  113998. */
  113999. export class Animation {
  114000. /**Name of the animation */
  114001. name: string;
  114002. /**Property to animate */
  114003. targetProperty: string;
  114004. /**The frames per second of the animation */
  114005. framePerSecond: number;
  114006. /**The data type of the animation */
  114007. dataType: number;
  114008. /**The loop mode of the animation */
  114009. loopMode?: number | undefined;
  114010. /**Specifies if blending should be enabled */
  114011. enableBlending?: boolean | undefined;
  114012. /**
  114013. * Use matrix interpolation instead of using direct key value when animating matrices
  114014. */
  114015. static AllowMatricesInterpolation: boolean;
  114016. /**
  114017. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  114018. */
  114019. static AllowMatrixDecomposeForInterpolation: boolean;
  114020. /** Define the Url to load snippets */
  114021. static SnippetUrl: string;
  114022. /** Snippet ID if the animation was created from the snippet server */
  114023. snippetId: string;
  114024. /**
  114025. * Stores the key frames of the animation
  114026. */
  114027. private _keys;
  114028. /**
  114029. * Stores the easing function of the animation
  114030. */
  114031. private _easingFunction;
  114032. /**
  114033. * @hidden Internal use only
  114034. */
  114035. _runtimeAnimations: RuntimeAnimation[];
  114036. /**
  114037. * The set of event that will be linked to this animation
  114038. */
  114039. private _events;
  114040. /**
  114041. * Stores an array of target property paths
  114042. */
  114043. targetPropertyPath: string[];
  114044. /**
  114045. * Stores the blending speed of the animation
  114046. */
  114047. blendingSpeed: number;
  114048. /**
  114049. * Stores the animation ranges for the animation
  114050. */
  114051. private _ranges;
  114052. /**
  114053. * @hidden Internal use
  114054. */
  114055. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  114056. /**
  114057. * Sets up an animation
  114058. * @param property The property to animate
  114059. * @param animationType The animation type to apply
  114060. * @param framePerSecond The frames per second of the animation
  114061. * @param easingFunction The easing function used in the animation
  114062. * @returns The created animation
  114063. */
  114064. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  114065. /**
  114066. * Create and start an animation on a node
  114067. * @param name defines the name of the global animation that will be run on all nodes
  114068. * @param node defines the root node where the animation will take place
  114069. * @param targetProperty defines property to animate
  114070. * @param framePerSecond defines the number of frame per second yo use
  114071. * @param totalFrame defines the number of frames in total
  114072. * @param from defines the initial value
  114073. * @param to defines the final value
  114074. * @param loopMode defines which loop mode you want to use (off by default)
  114075. * @param easingFunction defines the easing function to use (linear by default)
  114076. * @param onAnimationEnd defines the callback to call when animation end
  114077. * @returns the animatable created for this animation
  114078. */
  114079. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114080. /**
  114081. * Create and start an animation on a node and its descendants
  114082. * @param name defines the name of the global animation that will be run on all nodes
  114083. * @param node defines the root node where the animation will take place
  114084. * @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
  114085. * @param targetProperty defines property to animate
  114086. * @param framePerSecond defines the number of frame per second to use
  114087. * @param totalFrame defines the number of frames in total
  114088. * @param from defines the initial value
  114089. * @param to defines the final value
  114090. * @param loopMode defines which loop mode you want to use (off by default)
  114091. * @param easingFunction defines the easing function to use (linear by default)
  114092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  114093. * @returns the list of animatables created for all nodes
  114094. * @example https://www.babylonjs-playground.com/#MH0VLI
  114095. */
  114096. 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[]>;
  114097. /**
  114098. * Creates a new animation, merges it with the existing animations and starts it
  114099. * @param name Name of the animation
  114100. * @param node Node which contains the scene that begins the animations
  114101. * @param targetProperty Specifies which property to animate
  114102. * @param framePerSecond The frames per second of the animation
  114103. * @param totalFrame The total number of frames
  114104. * @param from The frame at the beginning of the animation
  114105. * @param to The frame at the end of the animation
  114106. * @param loopMode Specifies the loop mode of the animation
  114107. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  114108. * @param onAnimationEnd Callback to run once the animation is complete
  114109. * @returns Nullable animation
  114110. */
  114111. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114112. /**
  114113. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  114114. * @param sourceAnimation defines the Animation containing keyframes to convert
  114115. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  114116. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  114117. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  114118. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  114119. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  114120. */
  114121. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  114122. /**
  114123. * Transition property of an host to the target Value
  114124. * @param property The property to transition
  114125. * @param targetValue The target Value of the property
  114126. * @param host The object where the property to animate belongs
  114127. * @param scene Scene used to run the animation
  114128. * @param frameRate Framerate (in frame/s) to use
  114129. * @param transition The transition type we want to use
  114130. * @param duration The duration of the animation, in milliseconds
  114131. * @param onAnimationEnd Callback trigger at the end of the animation
  114132. * @returns Nullable animation
  114133. */
  114134. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  114135. /**
  114136. * Return the array of runtime animations currently using this animation
  114137. */
  114138. get runtimeAnimations(): RuntimeAnimation[];
  114139. /**
  114140. * Specifies if any of the runtime animations are currently running
  114141. */
  114142. get hasRunningRuntimeAnimations(): boolean;
  114143. /**
  114144. * Initializes the animation
  114145. * @param name Name of the animation
  114146. * @param targetProperty Property to animate
  114147. * @param framePerSecond The frames per second of the animation
  114148. * @param dataType The data type of the animation
  114149. * @param loopMode The loop mode of the animation
  114150. * @param enableBlending Specifies if blending should be enabled
  114151. */
  114152. constructor(
  114153. /**Name of the animation */
  114154. name: string,
  114155. /**Property to animate */
  114156. targetProperty: string,
  114157. /**The frames per second of the animation */
  114158. framePerSecond: number,
  114159. /**The data type of the animation */
  114160. dataType: number,
  114161. /**The loop mode of the animation */
  114162. loopMode?: number | undefined,
  114163. /**Specifies if blending should be enabled */
  114164. enableBlending?: boolean | undefined);
  114165. /**
  114166. * Converts the animation to a string
  114167. * @param fullDetails support for multiple levels of logging within scene loading
  114168. * @returns String form of the animation
  114169. */
  114170. toString(fullDetails?: boolean): string;
  114171. /**
  114172. * Add an event to this animation
  114173. * @param event Event to add
  114174. */
  114175. addEvent(event: AnimationEvent): void;
  114176. /**
  114177. * Remove all events found at the given frame
  114178. * @param frame The frame to remove events from
  114179. */
  114180. removeEvents(frame: number): void;
  114181. /**
  114182. * Retrieves all the events from the animation
  114183. * @returns Events from the animation
  114184. */
  114185. getEvents(): AnimationEvent[];
  114186. /**
  114187. * Creates an animation range
  114188. * @param name Name of the animation range
  114189. * @param from Starting frame of the animation range
  114190. * @param to Ending frame of the animation
  114191. */
  114192. createRange(name: string, from: number, to: number): void;
  114193. /**
  114194. * Deletes an animation range by name
  114195. * @param name Name of the animation range to delete
  114196. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  114197. */
  114198. deleteRange(name: string, deleteFrames?: boolean): void;
  114199. /**
  114200. * Gets the animation range by name, or null if not defined
  114201. * @param name Name of the animation range
  114202. * @returns Nullable animation range
  114203. */
  114204. getRange(name: string): Nullable<AnimationRange>;
  114205. /**
  114206. * Gets the key frames from the animation
  114207. * @returns The key frames of the animation
  114208. */
  114209. getKeys(): Array<IAnimationKey>;
  114210. /**
  114211. * Gets the highest frame rate of the animation
  114212. * @returns Highest frame rate of the animation
  114213. */
  114214. getHighestFrame(): number;
  114215. /**
  114216. * Gets the easing function of the animation
  114217. * @returns Easing function of the animation
  114218. */
  114219. getEasingFunction(): IEasingFunction;
  114220. /**
  114221. * Sets the easing function of the animation
  114222. * @param easingFunction A custom mathematical formula for animation
  114223. */
  114224. setEasingFunction(easingFunction: EasingFunction): void;
  114225. /**
  114226. * Interpolates a scalar linearly
  114227. * @param startValue Start value of the animation curve
  114228. * @param endValue End value of the animation curve
  114229. * @param gradient Scalar amount to interpolate
  114230. * @returns Interpolated scalar value
  114231. */
  114232. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  114233. /**
  114234. * Interpolates a scalar cubically
  114235. * @param startValue Start value of the animation curve
  114236. * @param outTangent End tangent of the animation
  114237. * @param endValue End value of the animation curve
  114238. * @param inTangent Start tangent of the animation curve
  114239. * @param gradient Scalar amount to interpolate
  114240. * @returns Interpolated scalar value
  114241. */
  114242. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  114243. /**
  114244. * Interpolates a quaternion using a spherical linear interpolation
  114245. * @param startValue Start value of the animation curve
  114246. * @param endValue End value of the animation curve
  114247. * @param gradient Scalar amount to interpolate
  114248. * @returns Interpolated quaternion value
  114249. */
  114250. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  114251. /**
  114252. * Interpolates a quaternion cubically
  114253. * @param startValue Start value of the animation curve
  114254. * @param outTangent End tangent of the animation curve
  114255. * @param endValue End value of the animation curve
  114256. * @param inTangent Start tangent of the animation curve
  114257. * @param gradient Scalar amount to interpolate
  114258. * @returns Interpolated quaternion value
  114259. */
  114260. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  114261. /**
  114262. * Interpolates a Vector3 linearl
  114263. * @param startValue Start value of the animation curve
  114264. * @param endValue End value of the animation curve
  114265. * @param gradient Scalar amount to interpolate
  114266. * @returns Interpolated scalar value
  114267. */
  114268. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  114269. /**
  114270. * Interpolates a Vector3 cubically
  114271. * @param startValue Start value of the animation curve
  114272. * @param outTangent End tangent of the animation
  114273. * @param endValue End value of the animation curve
  114274. * @param inTangent Start tangent of the animation curve
  114275. * @param gradient Scalar amount to interpolate
  114276. * @returns InterpolatedVector3 value
  114277. */
  114278. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  114279. /**
  114280. * Interpolates a Vector2 linearly
  114281. * @param startValue Start value of the animation curve
  114282. * @param endValue End value of the animation curve
  114283. * @param gradient Scalar amount to interpolate
  114284. * @returns Interpolated Vector2 value
  114285. */
  114286. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  114287. /**
  114288. * Interpolates a Vector2 cubically
  114289. * @param startValue Start value of the animation curve
  114290. * @param outTangent End tangent of the animation
  114291. * @param endValue End value of the animation curve
  114292. * @param inTangent Start tangent of the animation curve
  114293. * @param gradient Scalar amount to interpolate
  114294. * @returns Interpolated Vector2 value
  114295. */
  114296. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  114297. /**
  114298. * Interpolates a size linearly
  114299. * @param startValue Start value of the animation curve
  114300. * @param endValue End value of the animation curve
  114301. * @param gradient Scalar amount to interpolate
  114302. * @returns Interpolated Size value
  114303. */
  114304. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114305. /**
  114306. * Interpolates a Color3 linearly
  114307. * @param startValue Start value of the animation curve
  114308. * @param endValue End value of the animation curve
  114309. * @param gradient Scalar amount to interpolate
  114310. * @returns Interpolated Color3 value
  114311. */
  114312. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114313. /**
  114314. * Interpolates a Color4 linearly
  114315. * @param startValue Start value of the animation curve
  114316. * @param endValue End value of the animation curve
  114317. * @param gradient Scalar amount to interpolate
  114318. * @returns Interpolated Color3 value
  114319. */
  114320. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114321. /**
  114322. * @hidden Internal use only
  114323. */
  114324. _getKeyValue(value: any): any;
  114325. /**
  114326. * @hidden Internal use only
  114327. */
  114328. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114329. /**
  114330. * Defines the function to use to interpolate matrices
  114331. * @param startValue defines the start matrix
  114332. * @param endValue defines the end matrix
  114333. * @param gradient defines the gradient between both matrices
  114334. * @param result defines an optional target matrix where to store the interpolation
  114335. * @returns the interpolated matrix
  114336. */
  114337. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114338. /**
  114339. * Makes a copy of the animation
  114340. * @returns Cloned animation
  114341. */
  114342. clone(): Animation;
  114343. /**
  114344. * Sets the key frames of the animation
  114345. * @param values The animation key frames to set
  114346. */
  114347. setKeys(values: Array<IAnimationKey>): void;
  114348. /**
  114349. * Serializes the animation to an object
  114350. * @returns Serialized object
  114351. */
  114352. serialize(): any;
  114353. /**
  114354. * Float animation type
  114355. */
  114356. static readonly ANIMATIONTYPE_FLOAT: number;
  114357. /**
  114358. * Vector3 animation type
  114359. */
  114360. static readonly ANIMATIONTYPE_VECTOR3: number;
  114361. /**
  114362. * Quaternion animation type
  114363. */
  114364. static readonly ANIMATIONTYPE_QUATERNION: number;
  114365. /**
  114366. * Matrix animation type
  114367. */
  114368. static readonly ANIMATIONTYPE_MATRIX: number;
  114369. /**
  114370. * Color3 animation type
  114371. */
  114372. static readonly ANIMATIONTYPE_COLOR3: number;
  114373. /**
  114374. * Color3 animation type
  114375. */
  114376. static readonly ANIMATIONTYPE_COLOR4: number;
  114377. /**
  114378. * Vector2 animation type
  114379. */
  114380. static readonly ANIMATIONTYPE_VECTOR2: number;
  114381. /**
  114382. * Size animation type
  114383. */
  114384. static readonly ANIMATIONTYPE_SIZE: number;
  114385. /**
  114386. * Relative Loop Mode
  114387. */
  114388. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114389. /**
  114390. * Cycle Loop Mode
  114391. */
  114392. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114393. /**
  114394. * Constant Loop Mode
  114395. */
  114396. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114397. /** @hidden */
  114398. static _UniversalLerp(left: any, right: any, amount: number): any;
  114399. /**
  114400. * Parses an animation object and creates an animation
  114401. * @param parsedAnimation Parsed animation object
  114402. * @returns Animation object
  114403. */
  114404. static Parse(parsedAnimation: any): Animation;
  114405. /**
  114406. * Appends the serialized animations from the source animations
  114407. * @param source Source containing the animations
  114408. * @param destination Target to store the animations
  114409. */
  114410. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114411. /**
  114412. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114413. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114414. * @param url defines the url to load from
  114415. * @returns a promise that will resolve to the new animation or an array of animations
  114416. */
  114417. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114418. /**
  114419. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114420. * @param snippetId defines the snippet to load
  114421. * @returns a promise that will resolve to the new animation or a new array of animations
  114422. */
  114423. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114424. }
  114425. }
  114426. declare module BABYLON {
  114427. /**
  114428. * Interface containing an array of animations
  114429. */
  114430. export interface IAnimatable {
  114431. /**
  114432. * Array of animations
  114433. */
  114434. animations: Nullable<Array<Animation>>;
  114435. }
  114436. }
  114437. declare module BABYLON {
  114438. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114439. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114440. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114441. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114442. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114443. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114444. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114445. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114446. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114447. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114448. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114449. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114450. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114451. /**
  114452. * Decorator used to define property that can be serialized as reference to a camera
  114453. * @param sourceName defines the name of the property to decorate
  114454. */
  114455. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114456. /**
  114457. * Class used to help serialization objects
  114458. */
  114459. export class SerializationHelper {
  114460. /** @hidden */
  114461. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114462. /** @hidden */
  114463. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114464. /** @hidden */
  114465. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114466. /** @hidden */
  114467. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114468. /**
  114469. * Appends the serialized animations from the source animations
  114470. * @param source Source containing the animations
  114471. * @param destination Target to store the animations
  114472. */
  114473. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114474. /**
  114475. * Static function used to serialized a specific entity
  114476. * @param entity defines the entity to serialize
  114477. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114478. * @returns a JSON compatible object representing the serialization of the entity
  114479. */
  114480. static Serialize<T>(entity: T, serializationObject?: any): any;
  114481. /**
  114482. * Creates a new entity from a serialization data object
  114483. * @param creationFunction defines a function used to instanciated the new entity
  114484. * @param source defines the source serialization data
  114485. * @param scene defines the hosting scene
  114486. * @param rootUrl defines the root url for resources
  114487. * @returns a new entity
  114488. */
  114489. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114490. /**
  114491. * Clones an object
  114492. * @param creationFunction defines the function used to instanciate the new object
  114493. * @param source defines the source object
  114494. * @returns the cloned object
  114495. */
  114496. static Clone<T>(creationFunction: () => T, source: T): T;
  114497. /**
  114498. * Instanciates a new object based on a source one (some data will be shared between both object)
  114499. * @param creationFunction defines the function used to instanciate the new object
  114500. * @param source defines the source object
  114501. * @returns the new object
  114502. */
  114503. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114504. }
  114505. }
  114506. declare module BABYLON {
  114507. /**
  114508. * Base class of all the textures in babylon.
  114509. * It groups all the common properties the materials, post process, lights... might need
  114510. * in order to make a correct use of the texture.
  114511. */
  114512. export class BaseTexture implements IAnimatable {
  114513. /**
  114514. * Default anisotropic filtering level for the application.
  114515. * It is set to 4 as a good tradeoff between perf and quality.
  114516. */
  114517. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114518. /**
  114519. * Gets or sets the unique id of the texture
  114520. */
  114521. uniqueId: number;
  114522. /**
  114523. * Define the name of the texture.
  114524. */
  114525. name: string;
  114526. /**
  114527. * Gets or sets an object used to store user defined information.
  114528. */
  114529. metadata: any;
  114530. /**
  114531. * For internal use only. Please do not use.
  114532. */
  114533. reservedDataStore: any;
  114534. private _hasAlpha;
  114535. /**
  114536. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114537. */
  114538. set hasAlpha(value: boolean);
  114539. get hasAlpha(): boolean;
  114540. /**
  114541. * Defines if the alpha value should be determined via the rgb values.
  114542. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114543. */
  114544. getAlphaFromRGB: boolean;
  114545. /**
  114546. * Intensity or strength of the texture.
  114547. * It is commonly used by materials to fine tune the intensity of the texture
  114548. */
  114549. level: number;
  114550. /**
  114551. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114552. * This is part of the texture as textures usually maps to one uv set.
  114553. */
  114554. coordinatesIndex: number;
  114555. protected _coordinatesMode: number;
  114556. /**
  114557. * How a texture is mapped.
  114558. *
  114559. * | Value | Type | Description |
  114560. * | ----- | ----------------------------------- | ----------- |
  114561. * | 0 | EXPLICIT_MODE | |
  114562. * | 1 | SPHERICAL_MODE | |
  114563. * | 2 | PLANAR_MODE | |
  114564. * | 3 | CUBIC_MODE | |
  114565. * | 4 | PROJECTION_MODE | |
  114566. * | 5 | SKYBOX_MODE | |
  114567. * | 6 | INVCUBIC_MODE | |
  114568. * | 7 | EQUIRECTANGULAR_MODE | |
  114569. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114570. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114571. */
  114572. set coordinatesMode(value: number);
  114573. get coordinatesMode(): number;
  114574. private _wrapU;
  114575. /**
  114576. * | Value | Type | Description |
  114577. * | ----- | ------------------ | ----------- |
  114578. * | 0 | CLAMP_ADDRESSMODE | |
  114579. * | 1 | WRAP_ADDRESSMODE | |
  114580. * | 2 | MIRROR_ADDRESSMODE | |
  114581. */
  114582. get wrapU(): number;
  114583. set wrapU(value: number);
  114584. private _wrapV;
  114585. /**
  114586. * | Value | Type | Description |
  114587. * | ----- | ------------------ | ----------- |
  114588. * | 0 | CLAMP_ADDRESSMODE | |
  114589. * | 1 | WRAP_ADDRESSMODE | |
  114590. * | 2 | MIRROR_ADDRESSMODE | |
  114591. */
  114592. get wrapV(): number;
  114593. set wrapV(value: number);
  114594. /**
  114595. * | Value | Type | Description |
  114596. * | ----- | ------------------ | ----------- |
  114597. * | 0 | CLAMP_ADDRESSMODE | |
  114598. * | 1 | WRAP_ADDRESSMODE | |
  114599. * | 2 | MIRROR_ADDRESSMODE | |
  114600. */
  114601. wrapR: number;
  114602. /**
  114603. * With compliant hardware and browser (supporting anisotropic filtering)
  114604. * this defines the level of anisotropic filtering in the texture.
  114605. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114606. */
  114607. anisotropicFilteringLevel: number;
  114608. /**
  114609. * Define if the texture is a cube texture or if false a 2d texture.
  114610. */
  114611. get isCube(): boolean;
  114612. set isCube(value: boolean);
  114613. /**
  114614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114615. */
  114616. get is3D(): boolean;
  114617. set is3D(value: boolean);
  114618. /**
  114619. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114620. */
  114621. get is2DArray(): boolean;
  114622. set is2DArray(value: boolean);
  114623. private _gammaSpace;
  114624. /**
  114625. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114626. * HDR texture are usually stored in linear space.
  114627. * This only impacts the PBR and Background materials
  114628. */
  114629. get gammaSpace(): boolean;
  114630. set gammaSpace(gamma: boolean);
  114631. /**
  114632. * Gets or sets whether or not the texture contains RGBD data.
  114633. */
  114634. get isRGBD(): boolean;
  114635. set isRGBD(value: boolean);
  114636. /**
  114637. * Is Z inverted in the texture (useful in a cube texture).
  114638. */
  114639. invertZ: boolean;
  114640. /**
  114641. * Are mip maps generated for this texture or not.
  114642. */
  114643. get noMipmap(): boolean;
  114644. /**
  114645. * @hidden
  114646. */
  114647. lodLevelInAlpha: boolean;
  114648. /**
  114649. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114650. */
  114651. get lodGenerationOffset(): number;
  114652. set lodGenerationOffset(value: number);
  114653. /**
  114654. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114655. */
  114656. get lodGenerationScale(): number;
  114657. set lodGenerationScale(value: number);
  114658. /**
  114659. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114660. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114661. * average roughness values.
  114662. */
  114663. get linearSpecularLOD(): boolean;
  114664. set linearSpecularLOD(value: boolean);
  114665. /**
  114666. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114667. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114668. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114669. */
  114670. get irradianceTexture(): Nullable<BaseTexture>;
  114671. set irradianceTexture(value: Nullable<BaseTexture>);
  114672. /**
  114673. * Define if the texture is a render target.
  114674. */
  114675. isRenderTarget: boolean;
  114676. /**
  114677. * Define the unique id of the texture in the scene.
  114678. */
  114679. get uid(): string;
  114680. /** @hidden */
  114681. _prefiltered: boolean;
  114682. /**
  114683. * Return a string representation of the texture.
  114684. * @returns the texture as a string
  114685. */
  114686. toString(): string;
  114687. /**
  114688. * Get the class name of the texture.
  114689. * @returns "BaseTexture"
  114690. */
  114691. getClassName(): string;
  114692. /**
  114693. * Define the list of animation attached to the texture.
  114694. */
  114695. animations: Animation[];
  114696. /**
  114697. * An event triggered when the texture is disposed.
  114698. */
  114699. onDisposeObservable: Observable<BaseTexture>;
  114700. private _onDisposeObserver;
  114701. /**
  114702. * Callback triggered when the texture has been disposed.
  114703. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114704. */
  114705. set onDispose(callback: () => void);
  114706. /**
  114707. * Define the current state of the loading sequence when in delayed load mode.
  114708. */
  114709. delayLoadState: number;
  114710. protected _scene: Nullable<Scene>;
  114711. protected _engine: Nullable<ThinEngine>;
  114712. /** @hidden */
  114713. _texture: Nullable<InternalTexture>;
  114714. private _uid;
  114715. /**
  114716. * Define if the texture is preventinga material to render or not.
  114717. * If not and the texture is not ready, the engine will use a default black texture instead.
  114718. */
  114719. get isBlocking(): boolean;
  114720. /**
  114721. * Instantiates a new BaseTexture.
  114722. * Base class of all the textures in babylon.
  114723. * It groups all the common properties the materials, post process, lights... might need
  114724. * in order to make a correct use of the texture.
  114725. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114726. */
  114727. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114728. /**
  114729. * Get the scene the texture belongs to.
  114730. * @returns the scene or null if undefined
  114731. */
  114732. getScene(): Nullable<Scene>;
  114733. /** @hidden */
  114734. protected _getEngine(): Nullable<ThinEngine>;
  114735. /**
  114736. * Get the texture transform matrix used to offset tile the texture for istance.
  114737. * @returns the transformation matrix
  114738. */
  114739. getTextureMatrix(): Matrix;
  114740. /**
  114741. * Get the texture reflection matrix used to rotate/transform the reflection.
  114742. * @returns the reflection matrix
  114743. */
  114744. getReflectionTextureMatrix(): Matrix;
  114745. /**
  114746. * Get the underlying lower level texture from Babylon.
  114747. * @returns the insternal texture
  114748. */
  114749. getInternalTexture(): Nullable<InternalTexture>;
  114750. /**
  114751. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114752. * @returns true if ready or not blocking
  114753. */
  114754. isReadyOrNotBlocking(): boolean;
  114755. /**
  114756. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114757. * @returns true if fully ready
  114758. */
  114759. isReady(): boolean;
  114760. private _cachedSize;
  114761. /**
  114762. * Get the size of the texture.
  114763. * @returns the texture size.
  114764. */
  114765. getSize(): ISize;
  114766. /**
  114767. * Get the base size of the texture.
  114768. * It can be different from the size if the texture has been resized for POT for instance
  114769. * @returns the base size
  114770. */
  114771. getBaseSize(): ISize;
  114772. /**
  114773. * Update the sampling mode of the texture.
  114774. * Default is Trilinear mode.
  114775. *
  114776. * | Value | Type | Description |
  114777. * | ----- | ------------------ | ----------- |
  114778. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114779. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114780. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114781. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114782. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114783. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114784. * | 7 | NEAREST_LINEAR | |
  114785. * | 8 | NEAREST_NEAREST | |
  114786. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114787. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114788. * | 11 | LINEAR_LINEAR | |
  114789. * | 12 | LINEAR_NEAREST | |
  114790. *
  114791. * > _mag_: magnification filter (close to the viewer)
  114792. * > _min_: minification filter (far from the viewer)
  114793. * > _mip_: filter used between mip map levels
  114794. *@param samplingMode Define the new sampling mode of the texture
  114795. */
  114796. updateSamplingMode(samplingMode: number): void;
  114797. /**
  114798. * Scales the texture if is `canRescale()`
  114799. * @param ratio the resize factor we want to use to rescale
  114800. */
  114801. scale(ratio: number): void;
  114802. /**
  114803. * Get if the texture can rescale.
  114804. */
  114805. get canRescale(): boolean;
  114806. /** @hidden */
  114807. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114808. /** @hidden */
  114809. _rebuild(): void;
  114810. /**
  114811. * Triggers the load sequence in delayed load mode.
  114812. */
  114813. delayLoad(): void;
  114814. /**
  114815. * Clones the texture.
  114816. * @returns the cloned texture
  114817. */
  114818. clone(): Nullable<BaseTexture>;
  114819. /**
  114820. * Get the texture underlying type (INT, FLOAT...)
  114821. */
  114822. get textureType(): number;
  114823. /**
  114824. * Get the texture underlying format (RGB, RGBA...)
  114825. */
  114826. get textureFormat(): number;
  114827. /**
  114828. * Indicates that textures need to be re-calculated for all materials
  114829. */
  114830. protected _markAllSubMeshesAsTexturesDirty(): void;
  114831. /**
  114832. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114833. * This will returns an RGBA array buffer containing either in values (0-255) or
  114834. * float values (0-1) depending of the underlying buffer type.
  114835. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114836. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114837. * @param buffer defines a user defined buffer to fill with data (can be null)
  114838. * @returns The Array buffer containing the pixels data.
  114839. */
  114840. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114841. /**
  114842. * Release and destroy the underlying lower level texture aka internalTexture.
  114843. */
  114844. releaseInternalTexture(): void;
  114845. /** @hidden */
  114846. get _lodTextureHigh(): Nullable<BaseTexture>;
  114847. /** @hidden */
  114848. get _lodTextureMid(): Nullable<BaseTexture>;
  114849. /** @hidden */
  114850. get _lodTextureLow(): Nullable<BaseTexture>;
  114851. /**
  114852. * Dispose the texture and release its associated resources.
  114853. */
  114854. dispose(): void;
  114855. /**
  114856. * Serialize the texture into a JSON representation that can be parsed later on.
  114857. * @returns the JSON representation of the texture
  114858. */
  114859. serialize(): any;
  114860. /**
  114861. * Helper function to be called back once a list of texture contains only ready textures.
  114862. * @param textures Define the list of textures to wait for
  114863. * @param callback Define the callback triggered once the entire list will be ready
  114864. */
  114865. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114866. private static _isScene;
  114867. }
  114868. }
  114869. declare module BABYLON {
  114870. /**
  114871. * Options to be used when creating an effect.
  114872. */
  114873. export interface IEffectCreationOptions {
  114874. /**
  114875. * Atrributes that will be used in the shader.
  114876. */
  114877. attributes: string[];
  114878. /**
  114879. * Uniform varible names that will be set in the shader.
  114880. */
  114881. uniformsNames: string[];
  114882. /**
  114883. * Uniform buffer variable names that will be set in the shader.
  114884. */
  114885. uniformBuffersNames: string[];
  114886. /**
  114887. * Sampler texture variable names that will be set in the shader.
  114888. */
  114889. samplers: string[];
  114890. /**
  114891. * Define statements that will be set in the shader.
  114892. */
  114893. defines: any;
  114894. /**
  114895. * Possible fallbacks for this effect to improve performance when needed.
  114896. */
  114897. fallbacks: Nullable<IEffectFallbacks>;
  114898. /**
  114899. * Callback that will be called when the shader is compiled.
  114900. */
  114901. onCompiled: Nullable<(effect: Effect) => void>;
  114902. /**
  114903. * Callback that will be called if an error occurs during shader compilation.
  114904. */
  114905. onError: Nullable<(effect: Effect, errors: string) => void>;
  114906. /**
  114907. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114908. */
  114909. indexParameters?: any;
  114910. /**
  114911. * Max number of lights that can be used in the shader.
  114912. */
  114913. maxSimultaneousLights?: number;
  114914. /**
  114915. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114916. */
  114917. transformFeedbackVaryings?: Nullable<string[]>;
  114918. /**
  114919. * 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
  114920. */
  114921. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114922. /**
  114923. * Is this effect rendering to several color attachments ?
  114924. */
  114925. multiTarget?: boolean;
  114926. }
  114927. /**
  114928. * Effect containing vertex and fragment shader that can be executed on an object.
  114929. */
  114930. export class Effect implements IDisposable {
  114931. /**
  114932. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114933. */
  114934. static ShadersRepository: string;
  114935. /**
  114936. * Enable logging of the shader code when a compilation error occurs
  114937. */
  114938. static LogShaderCodeOnCompilationError: boolean;
  114939. /**
  114940. * Name of the effect.
  114941. */
  114942. name: any;
  114943. /**
  114944. * String container all the define statements that should be set on the shader.
  114945. */
  114946. defines: string;
  114947. /**
  114948. * Callback that will be called when the shader is compiled.
  114949. */
  114950. onCompiled: Nullable<(effect: Effect) => void>;
  114951. /**
  114952. * Callback that will be called if an error occurs during shader compilation.
  114953. */
  114954. onError: Nullable<(effect: Effect, errors: string) => void>;
  114955. /**
  114956. * Callback that will be called when effect is bound.
  114957. */
  114958. onBind: Nullable<(effect: Effect) => void>;
  114959. /**
  114960. * Unique ID of the effect.
  114961. */
  114962. uniqueId: number;
  114963. /**
  114964. * Observable that will be called when the shader is compiled.
  114965. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114966. */
  114967. onCompileObservable: Observable<Effect>;
  114968. /**
  114969. * Observable that will be called if an error occurs during shader compilation.
  114970. */
  114971. onErrorObservable: Observable<Effect>;
  114972. /** @hidden */
  114973. _onBindObservable: Nullable<Observable<Effect>>;
  114974. /**
  114975. * @hidden
  114976. * Specifies if the effect was previously ready
  114977. */
  114978. _wasPreviouslyReady: boolean;
  114979. /**
  114980. * Observable that will be called when effect is bound.
  114981. */
  114982. get onBindObservable(): Observable<Effect>;
  114983. /** @hidden */
  114984. _bonesComputationForcedToCPU: boolean;
  114985. /** @hidden */
  114986. _multiTarget: boolean;
  114987. private static _uniqueIdSeed;
  114988. private _engine;
  114989. private _uniformBuffersNames;
  114990. private _uniformBuffersNamesList;
  114991. private _uniformsNames;
  114992. private _samplerList;
  114993. private _samplers;
  114994. private _isReady;
  114995. private _compilationError;
  114996. private _allFallbacksProcessed;
  114997. private _attributesNames;
  114998. private _attributes;
  114999. private _attributeLocationByName;
  115000. private _uniforms;
  115001. /**
  115002. * Key for the effect.
  115003. * @hidden
  115004. */
  115005. _key: string;
  115006. private _indexParameters;
  115007. private _fallbacks;
  115008. private _vertexSourceCode;
  115009. private _fragmentSourceCode;
  115010. private _vertexSourceCodeOverride;
  115011. private _fragmentSourceCodeOverride;
  115012. private _transformFeedbackVaryings;
  115013. /**
  115014. * Compiled shader to webGL program.
  115015. * @hidden
  115016. */
  115017. _pipelineContext: Nullable<IPipelineContext>;
  115018. private _valueCache;
  115019. private static _baseCache;
  115020. /**
  115021. * Instantiates an effect.
  115022. * An effect can be used to create/manage/execute vertex and fragment shaders.
  115023. * @param baseName Name of the effect.
  115024. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  115025. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  115026. * @param samplers List of sampler variables that will be passed to the shader.
  115027. * @param engine Engine to be used to render the effect
  115028. * @param defines Define statements to be added to the shader.
  115029. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  115030. * @param onCompiled Callback that will be called when the shader is compiled.
  115031. * @param onError Callback that will be called if an error occurs during shader compilation.
  115032. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  115033. */
  115034. 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);
  115035. private _useFinalCode;
  115036. /**
  115037. * Unique key for this effect
  115038. */
  115039. get key(): string;
  115040. /**
  115041. * If the effect has been compiled and prepared.
  115042. * @returns if the effect is compiled and prepared.
  115043. */
  115044. isReady(): boolean;
  115045. private _isReadyInternal;
  115046. /**
  115047. * The engine the effect was initialized with.
  115048. * @returns the engine.
  115049. */
  115050. getEngine(): Engine;
  115051. /**
  115052. * The pipeline context for this effect
  115053. * @returns the associated pipeline context
  115054. */
  115055. getPipelineContext(): Nullable<IPipelineContext>;
  115056. /**
  115057. * The set of names of attribute variables for the shader.
  115058. * @returns An array of attribute names.
  115059. */
  115060. getAttributesNames(): string[];
  115061. /**
  115062. * Returns the attribute at the given index.
  115063. * @param index The index of the attribute.
  115064. * @returns The location of the attribute.
  115065. */
  115066. getAttributeLocation(index: number): number;
  115067. /**
  115068. * Returns the attribute based on the name of the variable.
  115069. * @param name of the attribute to look up.
  115070. * @returns the attribute location.
  115071. */
  115072. getAttributeLocationByName(name: string): number;
  115073. /**
  115074. * The number of attributes.
  115075. * @returns the numnber of attributes.
  115076. */
  115077. getAttributesCount(): number;
  115078. /**
  115079. * Gets the index of a uniform variable.
  115080. * @param uniformName of the uniform to look up.
  115081. * @returns the index.
  115082. */
  115083. getUniformIndex(uniformName: string): number;
  115084. /**
  115085. * Returns the attribute based on the name of the variable.
  115086. * @param uniformName of the uniform to look up.
  115087. * @returns the location of the uniform.
  115088. */
  115089. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  115090. /**
  115091. * Returns an array of sampler variable names
  115092. * @returns The array of sampler variable names.
  115093. */
  115094. getSamplers(): string[];
  115095. /**
  115096. * Returns an array of uniform variable names
  115097. * @returns The array of uniform variable names.
  115098. */
  115099. getUniformNames(): string[];
  115100. /**
  115101. * Returns an array of uniform buffer variable names
  115102. * @returns The array of uniform buffer variable names.
  115103. */
  115104. getUniformBuffersNames(): string[];
  115105. /**
  115106. * Returns the index parameters used to create the effect
  115107. * @returns The index parameters object
  115108. */
  115109. getIndexParameters(): any;
  115110. /**
  115111. * The error from the last compilation.
  115112. * @returns the error string.
  115113. */
  115114. getCompilationError(): string;
  115115. /**
  115116. * Gets a boolean indicating that all fallbacks were used during compilation
  115117. * @returns true if all fallbacks were used
  115118. */
  115119. allFallbacksProcessed(): boolean;
  115120. /**
  115121. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  115122. * @param func The callback to be used.
  115123. */
  115124. executeWhenCompiled(func: (effect: Effect) => void): void;
  115125. private _checkIsReady;
  115126. private _loadShader;
  115127. /**
  115128. * Gets the vertex shader source code of this effect
  115129. */
  115130. get vertexSourceCode(): string;
  115131. /**
  115132. * Gets the fragment shader source code of this effect
  115133. */
  115134. get fragmentSourceCode(): string;
  115135. /**
  115136. * Recompiles the webGL program
  115137. * @param vertexSourceCode The source code for the vertex shader.
  115138. * @param fragmentSourceCode The source code for the fragment shader.
  115139. * @param onCompiled Callback called when completed.
  115140. * @param onError Callback called on error.
  115141. * @hidden
  115142. */
  115143. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  115144. /**
  115145. * Prepares the effect
  115146. * @hidden
  115147. */
  115148. _prepareEffect(): void;
  115149. private _getShaderCodeAndErrorLine;
  115150. private _processCompilationErrors;
  115151. /**
  115152. * Checks if the effect is supported. (Must be called after compilation)
  115153. */
  115154. get isSupported(): boolean;
  115155. /**
  115156. * Binds a texture to the engine to be used as output of the shader.
  115157. * @param channel Name of the output variable.
  115158. * @param texture Texture to bind.
  115159. * @hidden
  115160. */
  115161. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  115162. /**
  115163. * Sets a texture on the engine to be used in the shader.
  115164. * @param channel Name of the sampler variable.
  115165. * @param texture Texture to set.
  115166. */
  115167. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  115168. /**
  115169. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  115170. * @param channel Name of the sampler variable.
  115171. * @param texture Texture to set.
  115172. */
  115173. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  115174. /**
  115175. * Sets an array of textures on the engine to be used in the shader.
  115176. * @param channel Name of the variable.
  115177. * @param textures Textures to set.
  115178. */
  115179. setTextureArray(channel: string, textures: BaseTexture[]): void;
  115180. /**
  115181. * 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)
  115182. * @param channel Name of the sampler variable.
  115183. * @param postProcess Post process to get the input texture from.
  115184. */
  115185. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  115186. /**
  115187. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  115188. * 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)
  115189. * @param channel Name of the sampler variable.
  115190. * @param postProcess Post process to get the output texture from.
  115191. */
  115192. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  115193. /** @hidden */
  115194. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  115195. /** @hidden */
  115196. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  115197. /** @hidden */
  115198. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  115199. /** @hidden */
  115200. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  115201. /**
  115202. * Binds a buffer to a uniform.
  115203. * @param buffer Buffer to bind.
  115204. * @param name Name of the uniform variable to bind to.
  115205. */
  115206. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  115207. /**
  115208. * Binds block to a uniform.
  115209. * @param blockName Name of the block to bind.
  115210. * @param index Index to bind.
  115211. */
  115212. bindUniformBlock(blockName: string, index: number): void;
  115213. /**
  115214. * Sets an interger value on a uniform variable.
  115215. * @param uniformName Name of the variable.
  115216. * @param value Value to be set.
  115217. * @returns this effect.
  115218. */
  115219. setInt(uniformName: string, value: number): Effect;
  115220. /**
  115221. * Sets an int array on a uniform variable.
  115222. * @param uniformName Name of the variable.
  115223. * @param array array to be set.
  115224. * @returns this effect.
  115225. */
  115226. setIntArray(uniformName: string, array: Int32Array): Effect;
  115227. /**
  115228. * 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)
  115229. * @param uniformName Name of the variable.
  115230. * @param array array to be set.
  115231. * @returns this effect.
  115232. */
  115233. setIntArray2(uniformName: string, array: Int32Array): Effect;
  115234. /**
  115235. * 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)
  115236. * @param uniformName Name of the variable.
  115237. * @param array array to be set.
  115238. * @returns this effect.
  115239. */
  115240. setIntArray3(uniformName: string, array: Int32Array): Effect;
  115241. /**
  115242. * 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)
  115243. * @param uniformName Name of the variable.
  115244. * @param array array to be set.
  115245. * @returns this effect.
  115246. */
  115247. setIntArray4(uniformName: string, array: Int32Array): Effect;
  115248. /**
  115249. * Sets an float array on a uniform variable.
  115250. * @param uniformName Name of the variable.
  115251. * @param array array to be set.
  115252. * @returns this effect.
  115253. */
  115254. setFloatArray(uniformName: string, array: Float32Array): Effect;
  115255. /**
  115256. * 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)
  115257. * @param uniformName Name of the variable.
  115258. * @param array array to be set.
  115259. * @returns this effect.
  115260. */
  115261. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  115262. /**
  115263. * 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)
  115264. * @param uniformName Name of the variable.
  115265. * @param array array to be set.
  115266. * @returns this effect.
  115267. */
  115268. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  115269. /**
  115270. * 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)
  115271. * @param uniformName Name of the variable.
  115272. * @param array array to be set.
  115273. * @returns this effect.
  115274. */
  115275. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  115276. /**
  115277. * Sets an array on a uniform variable.
  115278. * @param uniformName Name of the variable.
  115279. * @param array array to be set.
  115280. * @returns this effect.
  115281. */
  115282. setArray(uniformName: string, array: number[]): Effect;
  115283. /**
  115284. * 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)
  115285. * @param uniformName Name of the variable.
  115286. * @param array array to be set.
  115287. * @returns this effect.
  115288. */
  115289. setArray2(uniformName: string, array: number[]): Effect;
  115290. /**
  115291. * 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)
  115292. * @param uniformName Name of the variable.
  115293. * @param array array to be set.
  115294. * @returns this effect.
  115295. */
  115296. setArray3(uniformName: string, array: number[]): Effect;
  115297. /**
  115298. * 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)
  115299. * @param uniformName Name of the variable.
  115300. * @param array array to be set.
  115301. * @returns this effect.
  115302. */
  115303. setArray4(uniformName: string, array: number[]): Effect;
  115304. /**
  115305. * Sets matrices on a uniform variable.
  115306. * @param uniformName Name of the variable.
  115307. * @param matrices matrices to be set.
  115308. * @returns this effect.
  115309. */
  115310. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115311. /**
  115312. * Sets matrix on a uniform variable.
  115313. * @param uniformName Name of the variable.
  115314. * @param matrix matrix to be set.
  115315. * @returns this effect.
  115316. */
  115317. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115318. /**
  115319. * 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)
  115320. * @param uniformName Name of the variable.
  115321. * @param matrix matrix to be set.
  115322. * @returns this effect.
  115323. */
  115324. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115325. /**
  115326. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115327. * @param uniformName Name of the variable.
  115328. * @param matrix matrix to be set.
  115329. * @returns this effect.
  115330. */
  115331. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115332. /**
  115333. * Sets a float on a uniform variable.
  115334. * @param uniformName Name of the variable.
  115335. * @param value value to be set.
  115336. * @returns this effect.
  115337. */
  115338. setFloat(uniformName: string, value: number): Effect;
  115339. /**
  115340. * Sets a boolean on a uniform variable.
  115341. * @param uniformName Name of the variable.
  115342. * @param bool value to be set.
  115343. * @returns this effect.
  115344. */
  115345. setBool(uniformName: string, bool: boolean): Effect;
  115346. /**
  115347. * Sets a Vector2 on a uniform variable.
  115348. * @param uniformName Name of the variable.
  115349. * @param vector2 vector2 to be set.
  115350. * @returns this effect.
  115351. */
  115352. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115353. /**
  115354. * Sets a float2 on a uniform variable.
  115355. * @param uniformName Name of the variable.
  115356. * @param x First float in float2.
  115357. * @param y Second float in float2.
  115358. * @returns this effect.
  115359. */
  115360. setFloat2(uniformName: string, x: number, y: number): Effect;
  115361. /**
  115362. * Sets a Vector3 on a uniform variable.
  115363. * @param uniformName Name of the variable.
  115364. * @param vector3 Value to be set.
  115365. * @returns this effect.
  115366. */
  115367. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115368. /**
  115369. * Sets a float3 on a uniform variable.
  115370. * @param uniformName Name of the variable.
  115371. * @param x First float in float3.
  115372. * @param y Second float in float3.
  115373. * @param z Third float in float3.
  115374. * @returns this effect.
  115375. */
  115376. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115377. /**
  115378. * Sets a Vector4 on a uniform variable.
  115379. * @param uniformName Name of the variable.
  115380. * @param vector4 Value to be set.
  115381. * @returns this effect.
  115382. */
  115383. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115384. /**
  115385. * Sets a float4 on a uniform variable.
  115386. * @param uniformName Name of the variable.
  115387. * @param x First float in float4.
  115388. * @param y Second float in float4.
  115389. * @param z Third float in float4.
  115390. * @param w Fourth float in float4.
  115391. * @returns this effect.
  115392. */
  115393. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115394. /**
  115395. * Sets a Color3 on a uniform variable.
  115396. * @param uniformName Name of the variable.
  115397. * @param color3 Value to be set.
  115398. * @returns this effect.
  115399. */
  115400. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115401. /**
  115402. * Sets a Color4 on a uniform variable.
  115403. * @param uniformName Name of the variable.
  115404. * @param color3 Value to be set.
  115405. * @param alpha Alpha value to be set.
  115406. * @returns this effect.
  115407. */
  115408. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115409. /**
  115410. * Sets a Color4 on a uniform variable
  115411. * @param uniformName defines the name of the variable
  115412. * @param color4 defines the value to be set
  115413. * @returns this effect.
  115414. */
  115415. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115416. /** Release all associated resources */
  115417. dispose(): void;
  115418. /**
  115419. * This function will add a new shader to the shader store
  115420. * @param name the name of the shader
  115421. * @param pixelShader optional pixel shader content
  115422. * @param vertexShader optional vertex shader content
  115423. */
  115424. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115425. /**
  115426. * Store of each shader (The can be looked up using effect.key)
  115427. */
  115428. static ShadersStore: {
  115429. [key: string]: string;
  115430. };
  115431. /**
  115432. * Store of each included file for a shader (The can be looked up using effect.key)
  115433. */
  115434. static IncludesShadersStore: {
  115435. [key: string]: string;
  115436. };
  115437. /**
  115438. * Resets the cache of effects.
  115439. */
  115440. static ResetCache(): void;
  115441. }
  115442. }
  115443. declare module BABYLON {
  115444. /**
  115445. * Interface used to describe the capabilities of the engine relatively to the current browser
  115446. */
  115447. export interface EngineCapabilities {
  115448. /** Maximum textures units per fragment shader */
  115449. maxTexturesImageUnits: number;
  115450. /** Maximum texture units per vertex shader */
  115451. maxVertexTextureImageUnits: number;
  115452. /** Maximum textures units in the entire pipeline */
  115453. maxCombinedTexturesImageUnits: number;
  115454. /** Maximum texture size */
  115455. maxTextureSize: number;
  115456. /** Maximum texture samples */
  115457. maxSamples?: number;
  115458. /** Maximum cube texture size */
  115459. maxCubemapTextureSize: number;
  115460. /** Maximum render texture size */
  115461. maxRenderTextureSize: number;
  115462. /** Maximum number of vertex attributes */
  115463. maxVertexAttribs: number;
  115464. /** Maximum number of varyings */
  115465. maxVaryingVectors: number;
  115466. /** Maximum number of uniforms per vertex shader */
  115467. maxVertexUniformVectors: number;
  115468. /** Maximum number of uniforms per fragment shader */
  115469. maxFragmentUniformVectors: number;
  115470. /** Defines if standard derivates (dx/dy) are supported */
  115471. standardDerivatives: boolean;
  115472. /** Defines if s3tc texture compression is supported */
  115473. s3tc?: WEBGL_compressed_texture_s3tc;
  115474. /** Defines if pvrtc texture compression is supported */
  115475. pvrtc: any;
  115476. /** Defines if etc1 texture compression is supported */
  115477. etc1: any;
  115478. /** Defines if etc2 texture compression is supported */
  115479. etc2: any;
  115480. /** Defines if astc texture compression is supported */
  115481. astc: any;
  115482. /** Defines if bptc texture compression is supported */
  115483. bptc: any;
  115484. /** Defines if float textures are supported */
  115485. textureFloat: boolean;
  115486. /** Defines if vertex array objects are supported */
  115487. vertexArrayObject: boolean;
  115488. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115489. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115490. /** Gets the maximum level of anisotropy supported */
  115491. maxAnisotropy: number;
  115492. /** Defines if instancing is supported */
  115493. instancedArrays: boolean;
  115494. /** Defines if 32 bits indices are supported */
  115495. uintIndices: boolean;
  115496. /** Defines if high precision shaders are supported */
  115497. highPrecisionShaderSupported: boolean;
  115498. /** Defines if depth reading in the fragment shader is supported */
  115499. fragmentDepthSupported: boolean;
  115500. /** Defines if float texture linear filtering is supported*/
  115501. textureFloatLinearFiltering: boolean;
  115502. /** Defines if rendering to float textures is supported */
  115503. textureFloatRender: boolean;
  115504. /** Defines if half float textures are supported*/
  115505. textureHalfFloat: boolean;
  115506. /** Defines if half float texture linear filtering is supported*/
  115507. textureHalfFloatLinearFiltering: boolean;
  115508. /** Defines if rendering to half float textures is supported */
  115509. textureHalfFloatRender: boolean;
  115510. /** Defines if textureLOD shader command is supported */
  115511. textureLOD: boolean;
  115512. /** Defines if draw buffers extension is supported */
  115513. drawBuffersExtension: boolean;
  115514. /** Defines if depth textures are supported */
  115515. depthTextureExtension: boolean;
  115516. /** Defines if float color buffer are supported */
  115517. colorBufferFloat: boolean;
  115518. /** Gets disjoint timer query extension (null if not supported) */
  115519. timerQuery?: EXT_disjoint_timer_query;
  115520. /** Defines if timestamp can be used with timer query */
  115521. canUseTimestampForTimerQuery: boolean;
  115522. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115523. multiview?: any;
  115524. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115525. oculusMultiview?: any;
  115526. /** Function used to let the system compiles shaders in background */
  115527. parallelShaderCompile?: {
  115528. COMPLETION_STATUS_KHR: number;
  115529. };
  115530. /** Max number of texture samples for MSAA */
  115531. maxMSAASamples: number;
  115532. /** Defines if the blend min max extension is supported */
  115533. blendMinMax: boolean;
  115534. }
  115535. }
  115536. declare module BABYLON {
  115537. /**
  115538. * @hidden
  115539. **/
  115540. export class DepthCullingState {
  115541. private _isDepthTestDirty;
  115542. private _isDepthMaskDirty;
  115543. private _isDepthFuncDirty;
  115544. private _isCullFaceDirty;
  115545. private _isCullDirty;
  115546. private _isZOffsetDirty;
  115547. private _isFrontFaceDirty;
  115548. private _depthTest;
  115549. private _depthMask;
  115550. private _depthFunc;
  115551. private _cull;
  115552. private _cullFace;
  115553. private _zOffset;
  115554. private _frontFace;
  115555. /**
  115556. * Initializes the state.
  115557. */
  115558. constructor();
  115559. get isDirty(): boolean;
  115560. get zOffset(): number;
  115561. set zOffset(value: number);
  115562. get cullFace(): Nullable<number>;
  115563. set cullFace(value: Nullable<number>);
  115564. get cull(): Nullable<boolean>;
  115565. set cull(value: Nullable<boolean>);
  115566. get depthFunc(): Nullable<number>;
  115567. set depthFunc(value: Nullable<number>);
  115568. get depthMask(): boolean;
  115569. set depthMask(value: boolean);
  115570. get depthTest(): boolean;
  115571. set depthTest(value: boolean);
  115572. get frontFace(): Nullable<number>;
  115573. set frontFace(value: Nullable<number>);
  115574. reset(): void;
  115575. apply(gl: WebGLRenderingContext): void;
  115576. }
  115577. }
  115578. declare module BABYLON {
  115579. /**
  115580. * @hidden
  115581. **/
  115582. export class StencilState {
  115583. /** 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 */
  115584. static readonly ALWAYS: number;
  115585. /** Passed to stencilOperation to specify that stencil value must be kept */
  115586. static readonly KEEP: number;
  115587. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115588. static readonly REPLACE: number;
  115589. private _isStencilTestDirty;
  115590. private _isStencilMaskDirty;
  115591. private _isStencilFuncDirty;
  115592. private _isStencilOpDirty;
  115593. private _stencilTest;
  115594. private _stencilMask;
  115595. private _stencilFunc;
  115596. private _stencilFuncRef;
  115597. private _stencilFuncMask;
  115598. private _stencilOpStencilFail;
  115599. private _stencilOpDepthFail;
  115600. private _stencilOpStencilDepthPass;
  115601. get isDirty(): boolean;
  115602. get stencilFunc(): number;
  115603. set stencilFunc(value: number);
  115604. get stencilFuncRef(): number;
  115605. set stencilFuncRef(value: number);
  115606. get stencilFuncMask(): number;
  115607. set stencilFuncMask(value: number);
  115608. get stencilOpStencilFail(): number;
  115609. set stencilOpStencilFail(value: number);
  115610. get stencilOpDepthFail(): number;
  115611. set stencilOpDepthFail(value: number);
  115612. get stencilOpStencilDepthPass(): number;
  115613. set stencilOpStencilDepthPass(value: number);
  115614. get stencilMask(): number;
  115615. set stencilMask(value: number);
  115616. get stencilTest(): boolean;
  115617. set stencilTest(value: boolean);
  115618. constructor();
  115619. reset(): void;
  115620. apply(gl: WebGLRenderingContext): void;
  115621. }
  115622. }
  115623. declare module BABYLON {
  115624. /**
  115625. * @hidden
  115626. **/
  115627. export class AlphaState {
  115628. private _isAlphaBlendDirty;
  115629. private _isBlendFunctionParametersDirty;
  115630. private _isBlendEquationParametersDirty;
  115631. private _isBlendConstantsDirty;
  115632. private _alphaBlend;
  115633. private _blendFunctionParameters;
  115634. private _blendEquationParameters;
  115635. private _blendConstants;
  115636. /**
  115637. * Initializes the state.
  115638. */
  115639. constructor();
  115640. get isDirty(): boolean;
  115641. get alphaBlend(): boolean;
  115642. set alphaBlend(value: boolean);
  115643. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115644. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115645. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115646. reset(): void;
  115647. apply(gl: WebGLRenderingContext): void;
  115648. }
  115649. }
  115650. declare module BABYLON {
  115651. /** @hidden */
  115652. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115653. attributeProcessor(attribute: string): string;
  115654. varyingProcessor(varying: string, isFragment: boolean): string;
  115655. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115656. }
  115657. }
  115658. declare module BABYLON {
  115659. /**
  115660. * Interface for attribute information associated with buffer instanciation
  115661. */
  115662. export interface InstancingAttributeInfo {
  115663. /**
  115664. * Name of the GLSL attribute
  115665. * if attribute index is not specified, this is used to retrieve the index from the effect
  115666. */
  115667. attributeName: string;
  115668. /**
  115669. * Index/offset of the attribute in the vertex shader
  115670. * if not specified, this will be computes from the name.
  115671. */
  115672. index?: number;
  115673. /**
  115674. * size of the attribute, 1, 2, 3 or 4
  115675. */
  115676. attributeSize: number;
  115677. /**
  115678. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115679. */
  115680. offset: number;
  115681. /**
  115682. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115683. * default to 1
  115684. */
  115685. divisor?: number;
  115686. /**
  115687. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115688. * default is FLOAT
  115689. */
  115690. attributeType?: number;
  115691. /**
  115692. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115693. */
  115694. normalized?: boolean;
  115695. }
  115696. }
  115697. declare module BABYLON {
  115698. interface ThinEngine {
  115699. /**
  115700. * Update a video texture
  115701. * @param texture defines the texture to update
  115702. * @param video defines the video element to use
  115703. * @param invertY defines if data must be stored with Y axis inverted
  115704. */
  115705. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115706. }
  115707. }
  115708. declare module BABYLON {
  115709. interface ThinEngine {
  115710. /**
  115711. * Creates a dynamic texture
  115712. * @param width defines the width of the texture
  115713. * @param height defines the height of the texture
  115714. * @param generateMipMaps defines if the engine should generate the mip levels
  115715. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115716. * @returns the dynamic texture inside an InternalTexture
  115717. */
  115718. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115719. /**
  115720. * Update the content of a dynamic texture
  115721. * @param texture defines the texture to update
  115722. * @param canvas defines the canvas containing the source
  115723. * @param invertY defines if data must be stored with Y axis inverted
  115724. * @param premulAlpha defines if alpha is stored as premultiplied
  115725. * @param format defines the format of the data
  115726. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115727. */
  115728. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115729. }
  115730. }
  115731. declare module BABYLON {
  115732. /**
  115733. * Settings for finer control over video usage
  115734. */
  115735. export interface VideoTextureSettings {
  115736. /**
  115737. * Applies `autoplay` to video, if specified
  115738. */
  115739. autoPlay?: boolean;
  115740. /**
  115741. * Applies `loop` to video, if specified
  115742. */
  115743. loop?: boolean;
  115744. /**
  115745. * Automatically updates internal texture from video at every frame in the render loop
  115746. */
  115747. autoUpdateTexture: boolean;
  115748. /**
  115749. * Image src displayed during the video loading or until the user interacts with the video.
  115750. */
  115751. poster?: string;
  115752. }
  115753. /**
  115754. * If you want to display a video in your scene, this is the special texture for that.
  115755. * This special texture works similar to other textures, with the exception of a few parameters.
  115756. * @see https://doc.babylonjs.com/how_to/video_texture
  115757. */
  115758. export class VideoTexture extends Texture {
  115759. /**
  115760. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115761. */
  115762. readonly autoUpdateTexture: boolean;
  115763. /**
  115764. * The video instance used by the texture internally
  115765. */
  115766. readonly video: HTMLVideoElement;
  115767. private _onUserActionRequestedObservable;
  115768. /**
  115769. * Event triggerd when a dom action is required by the user to play the video.
  115770. * This happens due to recent changes in browser policies preventing video to auto start.
  115771. */
  115772. get onUserActionRequestedObservable(): Observable<Texture>;
  115773. private _generateMipMaps;
  115774. private _stillImageCaptured;
  115775. private _displayingPosterTexture;
  115776. private _settings;
  115777. private _createInternalTextureOnEvent;
  115778. private _frameId;
  115779. private _currentSrc;
  115780. /**
  115781. * Creates a video texture.
  115782. * If you want to display a video in your scene, this is the special texture for that.
  115783. * This special texture works similar to other textures, with the exception of a few parameters.
  115784. * @see https://doc.babylonjs.com/how_to/video_texture
  115785. * @param name optional name, will detect from video source, if not defined
  115786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115787. * @param scene is obviously the current scene.
  115788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115789. * @param invertY is false by default but can be used to invert video on Y axis
  115790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115791. * @param settings allows finer control over video usage
  115792. */
  115793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115794. private _getName;
  115795. private _getVideo;
  115796. private _createInternalTexture;
  115797. private reset;
  115798. /**
  115799. * @hidden Internal method to initiate `update`.
  115800. */
  115801. _rebuild(): void;
  115802. /**
  115803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115804. */
  115805. update(): void;
  115806. /**
  115807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115809. */
  115810. updateTexture(isVisible: boolean): void;
  115811. protected _updateInternalTexture: () => void;
  115812. /**
  115813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115814. * @param url New url.
  115815. */
  115816. updateURL(url: string): void;
  115817. /**
  115818. * Clones the texture.
  115819. * @returns the cloned texture
  115820. */
  115821. clone(): VideoTexture;
  115822. /**
  115823. * Dispose the texture and release its associated resources.
  115824. */
  115825. dispose(): void;
  115826. /**
  115827. * Creates a video texture straight from a stream.
  115828. * @param scene Define the scene the texture should be created in
  115829. * @param stream Define the stream the texture should be created from
  115830. * @returns The created video texture as a promise
  115831. */
  115832. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115833. /**
  115834. * Creates a video texture straight from your WebCam video feed.
  115835. * @param scene Define the scene the texture should be created in
  115836. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115837. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115838. * @returns The created video texture as a promise
  115839. */
  115840. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115841. minWidth: number;
  115842. maxWidth: number;
  115843. minHeight: number;
  115844. maxHeight: number;
  115845. deviceId: string;
  115846. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115847. /**
  115848. * Creates a video texture straight from your WebCam video feed.
  115849. * @param scene Define the scene the texture should be created in
  115850. * @param onReady Define a callback to triggered once the texture will be ready
  115851. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115852. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115853. */
  115854. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115855. minWidth: number;
  115856. maxWidth: number;
  115857. minHeight: number;
  115858. maxHeight: number;
  115859. deviceId: string;
  115860. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115861. }
  115862. }
  115863. declare module BABYLON {
  115864. /**
  115865. * Defines the interface used by objects working like Scene
  115866. * @hidden
  115867. */
  115868. export interface ISceneLike {
  115869. _addPendingData(data: any): void;
  115870. _removePendingData(data: any): void;
  115871. offlineProvider: IOfflineProvider;
  115872. }
  115873. /**
  115874. * Information about the current host
  115875. */
  115876. export interface HostInformation {
  115877. /**
  115878. * Defines if the current host is a mobile
  115879. */
  115880. isMobile: boolean;
  115881. }
  115882. /** Interface defining initialization parameters for Engine class */
  115883. export interface EngineOptions extends WebGLContextAttributes {
  115884. /**
  115885. * Defines if the engine should no exceed a specified device ratio
  115886. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115887. */
  115888. limitDeviceRatio?: number;
  115889. /**
  115890. * Defines if webvr should be enabled automatically
  115891. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115892. */
  115893. autoEnableWebVR?: boolean;
  115894. /**
  115895. * Defines if webgl2 should be turned off even if supported
  115896. * @see https://doc.babylonjs.com/features/webgl2
  115897. */
  115898. disableWebGL2Support?: boolean;
  115899. /**
  115900. * Defines if webaudio should be initialized as well
  115901. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115902. */
  115903. audioEngine?: boolean;
  115904. /**
  115905. * Defines if animations should run using a deterministic lock step
  115906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115907. */
  115908. deterministicLockstep?: boolean;
  115909. /** Defines the maximum steps to use with deterministic lock step mode */
  115910. lockstepMaxSteps?: number;
  115911. /** Defines the seconds between each deterministic lock step */
  115912. timeStep?: number;
  115913. /**
  115914. * Defines that engine should ignore context lost events
  115915. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115916. */
  115917. doNotHandleContextLost?: boolean;
  115918. /**
  115919. * Defines that engine should ignore modifying touch action attribute and style
  115920. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115921. */
  115922. doNotHandleTouchAction?: boolean;
  115923. /**
  115924. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115925. */
  115926. useHighPrecisionFloats?: boolean;
  115927. /**
  115928. * Make the canvas XR Compatible for XR sessions
  115929. */
  115930. xrCompatible?: boolean;
  115931. /**
  115932. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115933. */
  115934. useHighPrecisionMatrix?: boolean;
  115935. /**
  115936. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  115937. */
  115938. failIfMajorPerformanceCaveat?: boolean;
  115939. }
  115940. /**
  115941. * The base engine class (root of all engines)
  115942. */
  115943. export class ThinEngine {
  115944. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115945. static ExceptionList: ({
  115946. key: string;
  115947. capture: string;
  115948. captureConstraint: number;
  115949. targets: string[];
  115950. } | {
  115951. key: string;
  115952. capture: null;
  115953. captureConstraint: null;
  115954. targets: string[];
  115955. })[];
  115956. /** @hidden */
  115957. static _TextureLoaders: IInternalTextureLoader[];
  115958. /**
  115959. * Returns the current npm package of the sdk
  115960. */
  115961. static get NpmPackage(): string;
  115962. /**
  115963. * Returns the current version of the framework
  115964. */
  115965. static get Version(): string;
  115966. /**
  115967. * Returns a string describing the current engine
  115968. */
  115969. get description(): string;
  115970. /**
  115971. * Gets or sets the epsilon value used by collision engine
  115972. */
  115973. static CollisionsEpsilon: number;
  115974. /**
  115975. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115976. */
  115977. static get ShadersRepository(): string;
  115978. static set ShadersRepository(value: string);
  115979. /** @hidden */
  115980. _shaderProcessor: IShaderProcessor;
  115981. /**
  115982. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115983. */
  115984. forcePOTTextures: boolean;
  115985. /**
  115986. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115987. */
  115988. isFullscreen: boolean;
  115989. /**
  115990. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115991. */
  115992. cullBackFaces: boolean;
  115993. /**
  115994. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115995. */
  115996. renderEvenInBackground: boolean;
  115997. /**
  115998. * Gets or sets a boolean indicating that cache can be kept between frames
  115999. */
  116000. preventCacheWipeBetweenFrames: boolean;
  116001. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  116002. validateShaderPrograms: boolean;
  116003. /**
  116004. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  116005. * This can provide greater z depth for distant objects.
  116006. */
  116007. useReverseDepthBuffer: boolean;
  116008. /**
  116009. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  116010. */
  116011. disableUniformBuffers: boolean;
  116012. /** @hidden */
  116013. _uniformBuffers: UniformBuffer[];
  116014. /**
  116015. * Gets a boolean indicating that the engine supports uniform buffers
  116016. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  116017. */
  116018. get supportsUniformBuffers(): boolean;
  116019. /** @hidden */
  116020. _gl: WebGLRenderingContext;
  116021. /** @hidden */
  116022. _webGLVersion: number;
  116023. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  116024. protected _windowIsBackground: boolean;
  116025. protected _creationOptions: EngineOptions;
  116026. protected _highPrecisionShadersAllowed: boolean;
  116027. /** @hidden */
  116028. get _shouldUseHighPrecisionShader(): boolean;
  116029. /**
  116030. * Gets a boolean indicating that only power of 2 textures are supported
  116031. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  116032. */
  116033. get needPOTTextures(): boolean;
  116034. /** @hidden */
  116035. _badOS: boolean;
  116036. /** @hidden */
  116037. _badDesktopOS: boolean;
  116038. private _hardwareScalingLevel;
  116039. /** @hidden */
  116040. _caps: EngineCapabilities;
  116041. private _isStencilEnable;
  116042. private _glVersion;
  116043. private _glRenderer;
  116044. private _glVendor;
  116045. /** @hidden */
  116046. _videoTextureSupported: boolean;
  116047. protected _renderingQueueLaunched: boolean;
  116048. protected _activeRenderLoops: (() => void)[];
  116049. /**
  116050. * Observable signaled when a context lost event is raised
  116051. */
  116052. onContextLostObservable: Observable<ThinEngine>;
  116053. /**
  116054. * Observable signaled when a context restored event is raised
  116055. */
  116056. onContextRestoredObservable: Observable<ThinEngine>;
  116057. private _onContextLost;
  116058. private _onContextRestored;
  116059. protected _contextWasLost: boolean;
  116060. /** @hidden */
  116061. _doNotHandleContextLost: boolean;
  116062. /**
  116063. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  116064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  116065. */
  116066. get doNotHandleContextLost(): boolean;
  116067. set doNotHandleContextLost(value: boolean);
  116068. /**
  116069. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  116070. */
  116071. disableVertexArrayObjects: boolean;
  116072. /** @hidden */
  116073. protected _colorWrite: boolean;
  116074. /** @hidden */
  116075. protected _colorWriteChanged: boolean;
  116076. /** @hidden */
  116077. protected _depthCullingState: DepthCullingState;
  116078. /** @hidden */
  116079. protected _stencilState: StencilState;
  116080. /** @hidden */
  116081. _alphaState: AlphaState;
  116082. /** @hidden */
  116083. _alphaMode: number;
  116084. /** @hidden */
  116085. _alphaEquation: number;
  116086. /** @hidden */
  116087. _internalTexturesCache: InternalTexture[];
  116088. /** @hidden */
  116089. protected _activeChannel: number;
  116090. private _currentTextureChannel;
  116091. /** @hidden */
  116092. protected _boundTexturesCache: {
  116093. [key: string]: Nullable<InternalTexture>;
  116094. };
  116095. /** @hidden */
  116096. protected _currentEffect: Nullable<Effect>;
  116097. /** @hidden */
  116098. protected _currentProgram: Nullable<WebGLProgram>;
  116099. private _compiledEffects;
  116100. private _vertexAttribArraysEnabled;
  116101. /** @hidden */
  116102. protected _cachedViewport: Nullable<IViewportLike>;
  116103. private _cachedVertexArrayObject;
  116104. /** @hidden */
  116105. protected _cachedVertexBuffers: any;
  116106. /** @hidden */
  116107. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  116108. /** @hidden */
  116109. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  116110. /** @hidden */
  116111. _currentRenderTarget: Nullable<InternalTexture>;
  116112. private _uintIndicesCurrentlySet;
  116113. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  116114. /** @hidden */
  116115. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  116116. /** @hidden */
  116117. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  116118. private _currentBufferPointers;
  116119. private _currentInstanceLocations;
  116120. private _currentInstanceBuffers;
  116121. private _textureUnits;
  116122. /** @hidden */
  116123. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116124. /** @hidden */
  116125. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116126. /** @hidden */
  116127. _boundRenderFunction: any;
  116128. private _vaoRecordInProgress;
  116129. private _mustWipeVertexAttributes;
  116130. private _emptyTexture;
  116131. private _emptyCubeTexture;
  116132. private _emptyTexture3D;
  116133. private _emptyTexture2DArray;
  116134. /** @hidden */
  116135. _frameHandler: number;
  116136. private _nextFreeTextureSlots;
  116137. private _maxSimultaneousTextures;
  116138. private _activeRequests;
  116139. /** @hidden */
  116140. _transformTextureUrl: Nullable<(url: string) => string>;
  116141. /**
  116142. * Gets information about the current host
  116143. */
  116144. hostInformation: HostInformation;
  116145. protected get _supportsHardwareTextureRescaling(): boolean;
  116146. private _framebufferDimensionsObject;
  116147. /**
  116148. * sets the object from which width and height will be taken from when getting render width and height
  116149. * Will fallback to the gl object
  116150. * @param dimensions the framebuffer width and height that will be used.
  116151. */
  116152. set framebufferDimensionsObject(dimensions: Nullable<{
  116153. framebufferWidth: number;
  116154. framebufferHeight: number;
  116155. }>);
  116156. /**
  116157. * Gets the current viewport
  116158. */
  116159. get currentViewport(): Nullable<IViewportLike>;
  116160. /**
  116161. * Gets the default empty texture
  116162. */
  116163. get emptyTexture(): InternalTexture;
  116164. /**
  116165. * Gets the default empty 3D texture
  116166. */
  116167. get emptyTexture3D(): InternalTexture;
  116168. /**
  116169. * Gets the default empty 2D array texture
  116170. */
  116171. get emptyTexture2DArray(): InternalTexture;
  116172. /**
  116173. * Gets the default empty cube texture
  116174. */
  116175. get emptyCubeTexture(): InternalTexture;
  116176. /**
  116177. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  116178. */
  116179. readonly premultipliedAlpha: boolean;
  116180. /**
  116181. * Observable event triggered before each texture is initialized
  116182. */
  116183. onBeforeTextureInitObservable: Observable<Texture>;
  116184. /**
  116185. * Creates a new engine
  116186. * @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
  116187. * @param antialias defines enable antialiasing (default: false)
  116188. * @param options defines further options to be sent to the getContext() function
  116189. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116190. */
  116191. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116192. private _rebuildInternalTextures;
  116193. private _rebuildEffects;
  116194. /**
  116195. * Gets a boolean indicating if all created effects are ready
  116196. * @returns true if all effects are ready
  116197. */
  116198. areAllEffectsReady(): boolean;
  116199. protected _rebuildBuffers(): void;
  116200. protected _initGLContext(): void;
  116201. /**
  116202. * Gets version of the current webGL context
  116203. */
  116204. get webGLVersion(): number;
  116205. /**
  116206. * Gets a string identifying the name of the class
  116207. * @returns "Engine" string
  116208. */
  116209. getClassName(): string;
  116210. /**
  116211. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  116212. */
  116213. get isStencilEnable(): boolean;
  116214. /** @hidden */
  116215. _prepareWorkingCanvas(): void;
  116216. /**
  116217. * Reset the texture cache to empty state
  116218. */
  116219. resetTextureCache(): void;
  116220. /**
  116221. * Gets an object containing information about the current webGL context
  116222. * @returns an object containing the vender, the renderer and the version of the current webGL context
  116223. */
  116224. getGlInfo(): {
  116225. vendor: string;
  116226. renderer: string;
  116227. version: string;
  116228. };
  116229. /**
  116230. * Defines the hardware scaling level.
  116231. * By default the hardware scaling level is computed from the window device ratio.
  116232. * 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.
  116233. * @param level defines the level to use
  116234. */
  116235. setHardwareScalingLevel(level: number): void;
  116236. /**
  116237. * Gets the current hardware scaling level.
  116238. * By default the hardware scaling level is computed from the window device ratio.
  116239. * 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.
  116240. * @returns a number indicating the current hardware scaling level
  116241. */
  116242. getHardwareScalingLevel(): number;
  116243. /**
  116244. * Gets the list of loaded textures
  116245. * @returns an array containing all loaded textures
  116246. */
  116247. getLoadedTexturesCache(): InternalTexture[];
  116248. /**
  116249. * Gets the object containing all engine capabilities
  116250. * @returns the EngineCapabilities object
  116251. */
  116252. getCaps(): EngineCapabilities;
  116253. /**
  116254. * stop executing a render loop function and remove it from the execution array
  116255. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  116256. */
  116257. stopRenderLoop(renderFunction?: () => void): void;
  116258. /** @hidden */
  116259. _renderLoop(): void;
  116260. /**
  116261. * Gets the HTML canvas attached with the current webGL context
  116262. * @returns a HTML canvas
  116263. */
  116264. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  116265. /**
  116266. * Gets host window
  116267. * @returns the host window object
  116268. */
  116269. getHostWindow(): Nullable<Window>;
  116270. /**
  116271. * Gets the current render width
  116272. * @param useScreen defines if screen size must be used (or the current render target if any)
  116273. * @returns a number defining the current render width
  116274. */
  116275. getRenderWidth(useScreen?: boolean): number;
  116276. /**
  116277. * Gets the current render height
  116278. * @param useScreen defines if screen size must be used (or the current render target if any)
  116279. * @returns a number defining the current render height
  116280. */
  116281. getRenderHeight(useScreen?: boolean): number;
  116282. /**
  116283. * Can be used to override the current requestAnimationFrame requester.
  116284. * @hidden
  116285. */
  116286. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  116287. /**
  116288. * Register and execute a render loop. The engine can have more than one render function
  116289. * @param renderFunction defines the function to continuously execute
  116290. */
  116291. runRenderLoop(renderFunction: () => void): void;
  116292. /**
  116293. * Clear the current render buffer or the current render target (if any is set up)
  116294. * @param color defines the color to use
  116295. * @param backBuffer defines if the back buffer must be cleared
  116296. * @param depth defines if the depth buffer must be cleared
  116297. * @param stencil defines if the stencil buffer must be cleared
  116298. */
  116299. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116300. private _viewportCached;
  116301. /** @hidden */
  116302. _viewport(x: number, y: number, width: number, height: number): void;
  116303. /**
  116304. * Set the WebGL's viewport
  116305. * @param viewport defines the viewport element to be used
  116306. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116307. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116308. */
  116309. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116310. /**
  116311. * Begin a new frame
  116312. */
  116313. beginFrame(): void;
  116314. /**
  116315. * Enf the current frame
  116316. */
  116317. endFrame(): void;
  116318. /**
  116319. * Resize the view according to the canvas' size
  116320. */
  116321. resize(): void;
  116322. /**
  116323. * Force a specific size of the canvas
  116324. * @param width defines the new canvas' width
  116325. * @param height defines the new canvas' height
  116326. * @returns true if the size was changed
  116327. */
  116328. setSize(width: number, height: number): boolean;
  116329. /**
  116330. * Binds the frame buffer to the specified texture.
  116331. * @param texture The texture to render to or null for the default canvas
  116332. * @param faceIndex The face of the texture to render to in case of cube texture
  116333. * @param requiredWidth The width of the target to render to
  116334. * @param requiredHeight The height of the target to render to
  116335. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116336. * @param lodLevel defines the lod level to bind to the frame buffer
  116337. * @param layer defines the 2d array index to bind to frame buffer to
  116338. */
  116339. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116340. /** @hidden */
  116341. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116342. /**
  116343. * Unbind the current render target texture from the webGL context
  116344. * @param texture defines the render target texture to unbind
  116345. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116346. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116347. */
  116348. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116349. /**
  116350. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116351. */
  116352. flushFramebuffer(): void;
  116353. /**
  116354. * Unbind the current render target and bind the default framebuffer
  116355. */
  116356. restoreDefaultFramebuffer(): void;
  116357. /** @hidden */
  116358. protected _resetVertexBufferBinding(): void;
  116359. /**
  116360. * Creates a vertex buffer
  116361. * @param data the data for the vertex buffer
  116362. * @returns the new WebGL static buffer
  116363. */
  116364. createVertexBuffer(data: DataArray): DataBuffer;
  116365. private _createVertexBuffer;
  116366. /**
  116367. * Creates a dynamic vertex buffer
  116368. * @param data the data for the dynamic vertex buffer
  116369. * @returns the new WebGL dynamic buffer
  116370. */
  116371. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116372. protected _resetIndexBufferBinding(): void;
  116373. /**
  116374. * Creates a new index buffer
  116375. * @param indices defines the content of the index buffer
  116376. * @param updatable defines if the index buffer must be updatable
  116377. * @returns a new webGL buffer
  116378. */
  116379. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116380. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116381. /**
  116382. * Bind a webGL buffer to the webGL context
  116383. * @param buffer defines the buffer to bind
  116384. */
  116385. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116386. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116387. private bindBuffer;
  116388. /**
  116389. * update the bound buffer with the given data
  116390. * @param data defines the data to update
  116391. */
  116392. updateArrayBuffer(data: Float32Array): void;
  116393. private _vertexAttribPointer;
  116394. /** @hidden */
  116395. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116396. private _bindVertexBuffersAttributes;
  116397. /**
  116398. * Records a vertex array object
  116399. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116400. * @param vertexBuffers defines the list of vertex buffers to store
  116401. * @param indexBuffer defines the index buffer to store
  116402. * @param effect defines the effect to store
  116403. * @returns the new vertex array object
  116404. */
  116405. recordVertexArrayObject(vertexBuffers: {
  116406. [key: string]: VertexBuffer;
  116407. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116408. /**
  116409. * Bind a specific vertex array object
  116410. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116411. * @param vertexArrayObject defines the vertex array object to bind
  116412. * @param indexBuffer defines the index buffer to bind
  116413. */
  116414. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116415. /**
  116416. * Bind webGl buffers directly to the webGL context
  116417. * @param vertexBuffer defines the vertex buffer to bind
  116418. * @param indexBuffer defines the index buffer to bind
  116419. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116420. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116421. * @param effect defines the effect associated with the vertex buffer
  116422. */
  116423. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116424. private _unbindVertexArrayObject;
  116425. /**
  116426. * Bind a list of vertex buffers to the webGL context
  116427. * @param vertexBuffers defines the list of vertex buffers to bind
  116428. * @param indexBuffer defines the index buffer to bind
  116429. * @param effect defines the effect associated with the vertex buffers
  116430. */
  116431. bindBuffers(vertexBuffers: {
  116432. [key: string]: Nullable<VertexBuffer>;
  116433. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116434. /**
  116435. * Unbind all instance attributes
  116436. */
  116437. unbindInstanceAttributes(): void;
  116438. /**
  116439. * Release and free the memory of a vertex array object
  116440. * @param vao defines the vertex array object to delete
  116441. */
  116442. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116443. /** @hidden */
  116444. _releaseBuffer(buffer: DataBuffer): boolean;
  116445. protected _deleteBuffer(buffer: DataBuffer): void;
  116446. /**
  116447. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116448. * @param instancesBuffer defines the webGL buffer to update and bind
  116449. * @param data defines the data to store in the buffer
  116450. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116451. */
  116452. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116453. /**
  116454. * Bind the content of a webGL buffer used with instantiation
  116455. * @param instancesBuffer defines the webGL buffer to bind
  116456. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116457. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116458. */
  116459. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116460. /**
  116461. * Disable the instance attribute corresponding to the name in parameter
  116462. * @param name defines the name of the attribute to disable
  116463. */
  116464. disableInstanceAttributeByName(name: string): void;
  116465. /**
  116466. * Disable the instance attribute corresponding to the location in parameter
  116467. * @param attributeLocation defines the attribute location of the attribute to disable
  116468. */
  116469. disableInstanceAttribute(attributeLocation: number): void;
  116470. /**
  116471. * Disable the attribute corresponding to the location in parameter
  116472. * @param attributeLocation defines the attribute location of the attribute to disable
  116473. */
  116474. disableAttributeByIndex(attributeLocation: number): void;
  116475. /**
  116476. * Send a draw order
  116477. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116478. * @param indexStart defines the starting index
  116479. * @param indexCount defines the number of index to draw
  116480. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116481. */
  116482. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116483. /**
  116484. * Draw a list of points
  116485. * @param verticesStart defines the index of first vertex to draw
  116486. * @param verticesCount defines the count of vertices to draw
  116487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116488. */
  116489. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116490. /**
  116491. * Draw a list of unindexed primitives
  116492. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116493. * @param verticesStart defines the index of first vertex to draw
  116494. * @param verticesCount defines the count of vertices to draw
  116495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116496. */
  116497. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116498. /**
  116499. * Draw a list of indexed primitives
  116500. * @param fillMode defines the primitive to use
  116501. * @param indexStart defines the starting index
  116502. * @param indexCount defines the number of index to draw
  116503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116504. */
  116505. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116506. /**
  116507. * Draw a list of unindexed primitives
  116508. * @param fillMode defines the primitive to use
  116509. * @param verticesStart defines the index of first vertex to draw
  116510. * @param verticesCount defines the count of vertices to draw
  116511. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116512. */
  116513. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116514. private _drawMode;
  116515. /** @hidden */
  116516. protected _reportDrawCall(): void;
  116517. /** @hidden */
  116518. _releaseEffect(effect: Effect): void;
  116519. /** @hidden */
  116520. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116521. /**
  116522. * Create a new effect (used to store vertex/fragment shaders)
  116523. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116524. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116525. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116526. * @param samplers defines an array of string used to represent textures
  116527. * @param defines defines the string containing the defines to use to compile the shaders
  116528. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116529. * @param onCompiled defines a function to call when the effect creation is successful
  116530. * @param onError defines a function to call when the effect creation has failed
  116531. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116532. * @returns the new Effect
  116533. */
  116534. 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;
  116535. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116536. private _compileShader;
  116537. private _compileRawShader;
  116538. /** @hidden */
  116539. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116540. /**
  116541. * Directly creates a webGL program
  116542. * @param pipelineContext defines the pipeline context to attach to
  116543. * @param vertexCode defines the vertex shader code to use
  116544. * @param fragmentCode defines the fragment shader code to use
  116545. * @param context defines the webGL context to use (if not set, the current one will be used)
  116546. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116547. * @returns the new webGL program
  116548. */
  116549. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116550. /**
  116551. * Creates a webGL program
  116552. * @param pipelineContext defines the pipeline context to attach to
  116553. * @param vertexCode defines the vertex shader code to use
  116554. * @param fragmentCode defines the fragment shader code to use
  116555. * @param defines defines the string containing the defines to use to compile the shaders
  116556. * @param context defines the webGL context to use (if not set, the current one will be used)
  116557. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116558. * @returns the new webGL program
  116559. */
  116560. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116561. /**
  116562. * Creates a new pipeline context
  116563. * @returns the new pipeline
  116564. */
  116565. createPipelineContext(): IPipelineContext;
  116566. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116567. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116568. /** @hidden */
  116569. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116570. /** @hidden */
  116571. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116572. /** @hidden */
  116573. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116574. /**
  116575. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116576. * @param pipelineContext defines the pipeline context to use
  116577. * @param uniformsNames defines the list of uniform names
  116578. * @returns an array of webGL uniform locations
  116579. */
  116580. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116581. /**
  116582. * Gets the lsit of active attributes for a given webGL program
  116583. * @param pipelineContext defines the pipeline context to use
  116584. * @param attributesNames defines the list of attribute names to get
  116585. * @returns an array of indices indicating the offset of each attribute
  116586. */
  116587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116588. /**
  116589. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116590. * @param effect defines the effect to activate
  116591. */
  116592. enableEffect(effect: Nullable<Effect>): void;
  116593. /**
  116594. * Set the value of an uniform to a number (int)
  116595. * @param uniform defines the webGL uniform location where to store the value
  116596. * @param value defines the int number to store
  116597. * @returns true if the value was set
  116598. */
  116599. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116600. /**
  116601. * Set the value of an uniform to an array of int32
  116602. * @param uniform defines the webGL uniform location where to store the value
  116603. * @param array defines the array of int32 to store
  116604. * @returns true if the value was set
  116605. */
  116606. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116607. /**
  116608. * Set the value of an uniform to an array of int32 (stored as vec2)
  116609. * @param uniform defines the webGL uniform location where to store the value
  116610. * @param array defines the array of int32 to store
  116611. * @returns true if the value was set
  116612. */
  116613. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116614. /**
  116615. * Set the value of an uniform to an array of int32 (stored as vec3)
  116616. * @param uniform defines the webGL uniform location where to store the value
  116617. * @param array defines the array of int32 to store
  116618. * @returns true if the value was set
  116619. */
  116620. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116621. /**
  116622. * Set the value of an uniform to an array of int32 (stored as vec4)
  116623. * @param uniform defines the webGL uniform location where to store the value
  116624. * @param array defines the array of int32 to store
  116625. * @returns true if the value was set
  116626. */
  116627. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116628. /**
  116629. * Set the value of an uniform to an array of number
  116630. * @param uniform defines the webGL uniform location where to store the value
  116631. * @param array defines the array of number to store
  116632. * @returns true if the value was set
  116633. */
  116634. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116635. /**
  116636. * Set the value of an uniform to an array of number (stored as vec2)
  116637. * @param uniform defines the webGL uniform location where to store the value
  116638. * @param array defines the array of number to store
  116639. * @returns true if the value was set
  116640. */
  116641. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116642. /**
  116643. * Set the value of an uniform to an array of number (stored as vec3)
  116644. * @param uniform defines the webGL uniform location where to store the value
  116645. * @param array defines the array of number to store
  116646. * @returns true if the value was set
  116647. */
  116648. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116649. /**
  116650. * Set the value of an uniform to an array of number (stored as vec4)
  116651. * @param uniform defines the webGL uniform location where to store the value
  116652. * @param array defines the array of number to store
  116653. * @returns true if the value was set
  116654. */
  116655. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116656. /**
  116657. * Set the value of an uniform to an array of float32 (stored as matrices)
  116658. * @param uniform defines the webGL uniform location where to store the value
  116659. * @param matrices defines the array of float32 to store
  116660. * @returns true if the value was set
  116661. */
  116662. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116663. /**
  116664. * Set the value of an uniform to a matrix (3x3)
  116665. * @param uniform defines the webGL uniform location where to store the value
  116666. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116667. * @returns true if the value was set
  116668. */
  116669. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116670. /**
  116671. * Set the value of an uniform to a matrix (2x2)
  116672. * @param uniform defines the webGL uniform location where to store the value
  116673. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116674. * @returns true if the value was set
  116675. */
  116676. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116677. /**
  116678. * Set the value of an uniform to a number (float)
  116679. * @param uniform defines the webGL uniform location where to store the value
  116680. * @param value defines the float number to store
  116681. * @returns true if the value was transfered
  116682. */
  116683. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116684. /**
  116685. * Set the value of an uniform to a vec2
  116686. * @param uniform defines the webGL uniform location where to store the value
  116687. * @param x defines the 1st component of the value
  116688. * @param y defines the 2nd component of the value
  116689. * @returns true if the value was set
  116690. */
  116691. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116692. /**
  116693. * Set the value of an uniform to a vec3
  116694. * @param uniform defines the webGL uniform location where to store the value
  116695. * @param x defines the 1st component of the value
  116696. * @param y defines the 2nd component of the value
  116697. * @param z defines the 3rd component of the value
  116698. * @returns true if the value was set
  116699. */
  116700. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116701. /**
  116702. * Set the value of an uniform to a vec4
  116703. * @param uniform defines the webGL uniform location where to store the value
  116704. * @param x defines the 1st component of the value
  116705. * @param y defines the 2nd component of the value
  116706. * @param z defines the 3rd component of the value
  116707. * @param w defines the 4th component of the value
  116708. * @returns true if the value was set
  116709. */
  116710. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116711. /**
  116712. * Apply all cached states (depth, culling, stencil and alpha)
  116713. */
  116714. applyStates(): void;
  116715. /**
  116716. * Enable or disable color writing
  116717. * @param enable defines the state to set
  116718. */
  116719. setColorWrite(enable: boolean): void;
  116720. /**
  116721. * Gets a boolean indicating if color writing is enabled
  116722. * @returns the current color writing state
  116723. */
  116724. getColorWrite(): boolean;
  116725. /**
  116726. * Gets the depth culling state manager
  116727. */
  116728. get depthCullingState(): DepthCullingState;
  116729. /**
  116730. * Gets the alpha state manager
  116731. */
  116732. get alphaState(): AlphaState;
  116733. /**
  116734. * Gets the stencil state manager
  116735. */
  116736. get stencilState(): StencilState;
  116737. /**
  116738. * Clears the list of texture accessible through engine.
  116739. * This can help preventing texture load conflict due to name collision.
  116740. */
  116741. clearInternalTexturesCache(): void;
  116742. /**
  116743. * Force the entire cache to be cleared
  116744. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116745. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116746. */
  116747. wipeCaches(bruteForce?: boolean): void;
  116748. /** @hidden */
  116749. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116750. min: number;
  116751. mag: number;
  116752. };
  116753. /** @hidden */
  116754. _createTexture(): WebGLTexture;
  116755. /**
  116756. * Usually called from Texture.ts.
  116757. * Passed information to create a WebGLTexture
  116758. * @param url defines a value which contains one of the following:
  116759. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116760. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116761. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116763. * @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)
  116764. * @param scene needed for loading to the correct scene
  116765. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116766. * @param onLoad optional callback to be called upon successful completion
  116767. * @param onError optional callback to be called upon failure
  116768. * @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
  116769. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116770. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116771. * @param forcedExtension defines the extension to use to pick the right loader
  116772. * @param mimeType defines an optional mime type
  116773. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116774. */
  116775. 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;
  116776. /**
  116777. * Loads an image as an HTMLImageElement.
  116778. * @param input url string, ArrayBuffer, or Blob to load
  116779. * @param onLoad callback called when the image successfully loads
  116780. * @param onError callback called when the image fails to load
  116781. * @param offlineProvider offline provider for caching
  116782. * @param mimeType optional mime type
  116783. * @returns the HTMLImageElement of the loaded image
  116784. * @hidden
  116785. */
  116786. 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>;
  116787. /**
  116788. * @hidden
  116789. */
  116790. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116791. private _unpackFlipYCached;
  116792. /**
  116793. * In case you are sharing the context with other applications, it might
  116794. * be interested to not cache the unpack flip y state to ensure a consistent
  116795. * value would be set.
  116796. */
  116797. enableUnpackFlipYCached: boolean;
  116798. /** @hidden */
  116799. _unpackFlipY(value: boolean): void;
  116800. /** @hidden */
  116801. _getUnpackAlignement(): number;
  116802. private _getTextureTarget;
  116803. /**
  116804. * Update the sampling mode of a given texture
  116805. * @param samplingMode defines the required sampling mode
  116806. * @param texture defines the texture to update
  116807. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116808. */
  116809. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116810. /**
  116811. * Update the sampling mode of a given texture
  116812. * @param texture defines the texture to update
  116813. * @param wrapU defines the texture wrap mode of the u coordinates
  116814. * @param wrapV defines the texture wrap mode of the v coordinates
  116815. * @param wrapR defines the texture wrap mode of the r coordinates
  116816. */
  116817. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116818. /** @hidden */
  116819. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116820. width: number;
  116821. height: number;
  116822. layers?: number;
  116823. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116824. /** @hidden */
  116825. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116826. /** @hidden */
  116827. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116828. /**
  116829. * Update a portion of an internal texture
  116830. * @param texture defines the texture to update
  116831. * @param imageData defines the data to store into the texture
  116832. * @param xOffset defines the x coordinates of the update rectangle
  116833. * @param yOffset defines the y coordinates of the update rectangle
  116834. * @param width defines the width of the update rectangle
  116835. * @param height defines the height of the update rectangle
  116836. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116837. * @param lod defines the lod level to update (0 by default)
  116838. */
  116839. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116840. /** @hidden */
  116841. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116842. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116843. private _prepareWebGLTexture;
  116844. /** @hidden */
  116845. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116846. private _getDepthStencilBuffer;
  116847. /** @hidden */
  116848. _releaseFramebufferObjects(texture: InternalTexture): void;
  116849. /** @hidden */
  116850. _releaseTexture(texture: InternalTexture): void;
  116851. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116852. protected _setProgram(program: WebGLProgram): void;
  116853. protected _boundUniforms: {
  116854. [key: number]: WebGLUniformLocation;
  116855. };
  116856. /**
  116857. * Binds an effect to the webGL context
  116858. * @param effect defines the effect to bind
  116859. */
  116860. bindSamplers(effect: Effect): void;
  116861. private _activateCurrentTexture;
  116862. /** @hidden */
  116863. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116864. /** @hidden */
  116865. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116866. /**
  116867. * Unbind all textures from the webGL context
  116868. */
  116869. unbindAllTextures(): void;
  116870. /**
  116871. * Sets a texture to the according uniform.
  116872. * @param channel The texture channel
  116873. * @param uniform The uniform to set
  116874. * @param texture The texture to apply
  116875. */
  116876. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116877. private _bindSamplerUniformToChannel;
  116878. private _getTextureWrapMode;
  116879. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116880. /**
  116881. * Sets an array of texture to the webGL context
  116882. * @param channel defines the channel where the texture array must be set
  116883. * @param uniform defines the associated uniform location
  116884. * @param textures defines the array of textures to bind
  116885. */
  116886. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116887. /** @hidden */
  116888. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116889. private _setTextureParameterFloat;
  116890. private _setTextureParameterInteger;
  116891. /**
  116892. * Unbind all vertex attributes from the webGL context
  116893. */
  116894. unbindAllAttributes(): void;
  116895. /**
  116896. * 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
  116897. */
  116898. releaseEffects(): void;
  116899. /**
  116900. * Dispose and release all associated resources
  116901. */
  116902. dispose(): void;
  116903. /**
  116904. * Attach a new callback raised when context lost event is fired
  116905. * @param callback defines the callback to call
  116906. */
  116907. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116908. /**
  116909. * Attach a new callback raised when context restored event is fired
  116910. * @param callback defines the callback to call
  116911. */
  116912. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116913. /**
  116914. * Get the current error code of the webGL context
  116915. * @returns the error code
  116916. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116917. */
  116918. getError(): number;
  116919. private _canRenderToFloatFramebuffer;
  116920. private _canRenderToHalfFloatFramebuffer;
  116921. private _canRenderToFramebuffer;
  116922. /** @hidden */
  116923. _getWebGLTextureType(type: number): number;
  116924. /** @hidden */
  116925. _getInternalFormat(format: number): number;
  116926. /** @hidden */
  116927. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116928. /** @hidden */
  116929. _getRGBAMultiSampleBufferFormat(type: number): number;
  116930. /** @hidden */
  116931. _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;
  116932. /**
  116933. * Loads a file from a url
  116934. * @param url url to load
  116935. * @param onSuccess callback called when the file successfully loads
  116936. * @param onProgress callback called while file is loading (if the server supports this mode)
  116937. * @param offlineProvider defines the offline provider for caching
  116938. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116939. * @param onError callback called when the file fails to load
  116940. * @returns a file request object
  116941. * @hidden
  116942. */
  116943. 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;
  116944. /**
  116945. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116946. * @param x defines the x coordinate of the rectangle where pixels must be read
  116947. * @param y defines the y coordinate of the rectangle where pixels must be read
  116948. * @param width defines the width of the rectangle where pixels must be read
  116949. * @param height defines the height of the rectangle where pixels must be read
  116950. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116951. * @returns a Uint8Array containing RGBA colors
  116952. */
  116953. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116954. private static _IsSupported;
  116955. private static _HasMajorPerformanceCaveat;
  116956. /**
  116957. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116958. */
  116959. static get IsSupported(): boolean;
  116960. /**
  116961. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116962. * @returns true if the engine can be created
  116963. * @ignorenaming
  116964. */
  116965. static isSupported(): boolean;
  116966. /**
  116967. * 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)
  116968. */
  116969. static get HasMajorPerformanceCaveat(): boolean;
  116970. /**
  116971. * Find the next highest power of two.
  116972. * @param x Number to start search from.
  116973. * @return Next highest power of two.
  116974. */
  116975. static CeilingPOT(x: number): number;
  116976. /**
  116977. * Find the next lowest power of two.
  116978. * @param x Number to start search from.
  116979. * @return Next lowest power of two.
  116980. */
  116981. static FloorPOT(x: number): number;
  116982. /**
  116983. * Find the nearest power of two.
  116984. * @param x Number to start search from.
  116985. * @return Next nearest power of two.
  116986. */
  116987. static NearestPOT(x: number): number;
  116988. /**
  116989. * Get the closest exponent of two
  116990. * @param value defines the value to approximate
  116991. * @param max defines the maximum value to return
  116992. * @param mode defines how to define the closest value
  116993. * @returns closest exponent of two of the given value
  116994. */
  116995. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116996. /**
  116997. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116998. * @param func - the function to be called
  116999. * @param requester - the object that will request the next frame. Falls back to window.
  117000. * @returns frame number
  117001. */
  117002. static QueueNewFrame(func: () => void, requester?: any): number;
  117003. /**
  117004. * Gets host document
  117005. * @returns the host document object
  117006. */
  117007. getHostDocument(): Nullable<Document>;
  117008. }
  117009. }
  117010. declare module BABYLON {
  117011. /**
  117012. * Class representing spherical harmonics coefficients to the 3rd degree
  117013. */
  117014. export class SphericalHarmonics {
  117015. /**
  117016. * Defines whether or not the harmonics have been prescaled for rendering.
  117017. */
  117018. preScaled: boolean;
  117019. /**
  117020. * The l0,0 coefficients of the spherical harmonics
  117021. */
  117022. l00: Vector3;
  117023. /**
  117024. * The l1,-1 coefficients of the spherical harmonics
  117025. */
  117026. l1_1: Vector3;
  117027. /**
  117028. * The l1,0 coefficients of the spherical harmonics
  117029. */
  117030. l10: Vector3;
  117031. /**
  117032. * The l1,1 coefficients of the spherical harmonics
  117033. */
  117034. l11: Vector3;
  117035. /**
  117036. * The l2,-2 coefficients of the spherical harmonics
  117037. */
  117038. l2_2: Vector3;
  117039. /**
  117040. * The l2,-1 coefficients of the spherical harmonics
  117041. */
  117042. l2_1: Vector3;
  117043. /**
  117044. * The l2,0 coefficients of the spherical harmonics
  117045. */
  117046. l20: Vector3;
  117047. /**
  117048. * The l2,1 coefficients of the spherical harmonics
  117049. */
  117050. l21: Vector3;
  117051. /**
  117052. * The l2,2 coefficients of the spherical harmonics
  117053. */
  117054. l22: Vector3;
  117055. /**
  117056. * Adds a light to the spherical harmonics
  117057. * @param direction the direction of the light
  117058. * @param color the color of the light
  117059. * @param deltaSolidAngle the delta solid angle of the light
  117060. */
  117061. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  117062. /**
  117063. * Scales the spherical harmonics by the given amount
  117064. * @param scale the amount to scale
  117065. */
  117066. scaleInPlace(scale: number): void;
  117067. /**
  117068. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  117069. *
  117070. * ```
  117071. * E_lm = A_l * L_lm
  117072. * ```
  117073. *
  117074. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  117075. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  117076. * the scaling factors are given in equation 9.
  117077. */
  117078. convertIncidentRadianceToIrradiance(): void;
  117079. /**
  117080. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  117081. *
  117082. * ```
  117083. * L = (1/pi) * E * rho
  117084. * ```
  117085. *
  117086. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  117087. */
  117088. convertIrradianceToLambertianRadiance(): void;
  117089. /**
  117090. * Integrates the reconstruction coefficients directly in to the SH preventing further
  117091. * required operations at run time.
  117092. *
  117093. * This is simply done by scaling back the SH with Ylm constants parameter.
  117094. * The trigonometric part being applied by the shader at run time.
  117095. */
  117096. preScaleForRendering(): void;
  117097. /**
  117098. * Constructs a spherical harmonics from an array.
  117099. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  117100. * @returns the spherical harmonics
  117101. */
  117102. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  117103. /**
  117104. * Gets the spherical harmonics from polynomial
  117105. * @param polynomial the spherical polynomial
  117106. * @returns the spherical harmonics
  117107. */
  117108. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  117109. }
  117110. /**
  117111. * Class representing spherical polynomial coefficients to the 3rd degree
  117112. */
  117113. export class SphericalPolynomial {
  117114. private _harmonics;
  117115. /**
  117116. * The spherical harmonics used to create the polynomials.
  117117. */
  117118. get preScaledHarmonics(): SphericalHarmonics;
  117119. /**
  117120. * The x coefficients of the spherical polynomial
  117121. */
  117122. x: Vector3;
  117123. /**
  117124. * The y coefficients of the spherical polynomial
  117125. */
  117126. y: Vector3;
  117127. /**
  117128. * The z coefficients of the spherical polynomial
  117129. */
  117130. z: Vector3;
  117131. /**
  117132. * The xx coefficients of the spherical polynomial
  117133. */
  117134. xx: Vector3;
  117135. /**
  117136. * The yy coefficients of the spherical polynomial
  117137. */
  117138. yy: Vector3;
  117139. /**
  117140. * The zz coefficients of the spherical polynomial
  117141. */
  117142. zz: Vector3;
  117143. /**
  117144. * The xy coefficients of the spherical polynomial
  117145. */
  117146. xy: Vector3;
  117147. /**
  117148. * The yz coefficients of the spherical polynomial
  117149. */
  117150. yz: Vector3;
  117151. /**
  117152. * The zx coefficients of the spherical polynomial
  117153. */
  117154. zx: Vector3;
  117155. /**
  117156. * Adds an ambient color to the spherical polynomial
  117157. * @param color the color to add
  117158. */
  117159. addAmbient(color: Color3): void;
  117160. /**
  117161. * Scales the spherical polynomial by the given amount
  117162. * @param scale the amount to scale
  117163. */
  117164. scaleInPlace(scale: number): void;
  117165. /**
  117166. * Gets the spherical polynomial from harmonics
  117167. * @param harmonics the spherical harmonics
  117168. * @returns the spherical polynomial
  117169. */
  117170. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  117171. /**
  117172. * Constructs a spherical polynomial from an array.
  117173. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  117174. * @returns the spherical polynomial
  117175. */
  117176. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  117177. }
  117178. }
  117179. declare module BABYLON {
  117180. /**
  117181. * Defines the source of the internal texture
  117182. */
  117183. export enum InternalTextureSource {
  117184. /**
  117185. * The source of the texture data is unknown
  117186. */
  117187. Unknown = 0,
  117188. /**
  117189. * Texture data comes from an URL
  117190. */
  117191. Url = 1,
  117192. /**
  117193. * Texture data is only used for temporary storage
  117194. */
  117195. Temp = 2,
  117196. /**
  117197. * Texture data comes from raw data (ArrayBuffer)
  117198. */
  117199. Raw = 3,
  117200. /**
  117201. * Texture content is dynamic (video or dynamic texture)
  117202. */
  117203. Dynamic = 4,
  117204. /**
  117205. * Texture content is generated by rendering to it
  117206. */
  117207. RenderTarget = 5,
  117208. /**
  117209. * Texture content is part of a multi render target process
  117210. */
  117211. MultiRenderTarget = 6,
  117212. /**
  117213. * Texture data comes from a cube data file
  117214. */
  117215. Cube = 7,
  117216. /**
  117217. * Texture data comes from a raw cube data
  117218. */
  117219. CubeRaw = 8,
  117220. /**
  117221. * Texture data come from a prefiltered cube data file
  117222. */
  117223. CubePrefiltered = 9,
  117224. /**
  117225. * Texture content is raw 3D data
  117226. */
  117227. Raw3D = 10,
  117228. /**
  117229. * Texture content is raw 2D array data
  117230. */
  117231. Raw2DArray = 11,
  117232. /**
  117233. * Texture content is a depth texture
  117234. */
  117235. Depth = 12,
  117236. /**
  117237. * Texture data comes from a raw cube data encoded with RGBD
  117238. */
  117239. CubeRawRGBD = 13
  117240. }
  117241. /**
  117242. * Class used to store data associated with WebGL texture data for the engine
  117243. * This class should not be used directly
  117244. */
  117245. export class InternalTexture {
  117246. /** @hidden */
  117247. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  117248. /**
  117249. * Defines if the texture is ready
  117250. */
  117251. isReady: boolean;
  117252. /**
  117253. * Defines if the texture is a cube texture
  117254. */
  117255. isCube: boolean;
  117256. /**
  117257. * Defines if the texture contains 3D data
  117258. */
  117259. is3D: boolean;
  117260. /**
  117261. * Defines if the texture contains 2D array data
  117262. */
  117263. is2DArray: boolean;
  117264. /**
  117265. * Defines if the texture contains multiview data
  117266. */
  117267. isMultiview: boolean;
  117268. /**
  117269. * Gets the URL used to load this texture
  117270. */
  117271. url: string;
  117272. /**
  117273. * Gets the sampling mode of the texture
  117274. */
  117275. samplingMode: number;
  117276. /**
  117277. * Gets a boolean indicating if the texture needs mipmaps generation
  117278. */
  117279. generateMipMaps: boolean;
  117280. /**
  117281. * Gets the number of samples used by the texture (WebGL2+ only)
  117282. */
  117283. samples: number;
  117284. /**
  117285. * Gets the type of the texture (int, float...)
  117286. */
  117287. type: number;
  117288. /**
  117289. * Gets the format of the texture (RGB, RGBA...)
  117290. */
  117291. format: number;
  117292. /**
  117293. * Observable called when the texture is loaded
  117294. */
  117295. onLoadedObservable: Observable<InternalTexture>;
  117296. /**
  117297. * Gets the width of the texture
  117298. */
  117299. width: number;
  117300. /**
  117301. * Gets the height of the texture
  117302. */
  117303. height: number;
  117304. /**
  117305. * Gets the depth of the texture
  117306. */
  117307. depth: number;
  117308. /**
  117309. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  117310. */
  117311. baseWidth: number;
  117312. /**
  117313. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117314. */
  117315. baseHeight: number;
  117316. /**
  117317. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117318. */
  117319. baseDepth: number;
  117320. /**
  117321. * Gets a boolean indicating if the texture is inverted on Y axis
  117322. */
  117323. invertY: boolean;
  117324. /** @hidden */
  117325. _invertVScale: boolean;
  117326. /** @hidden */
  117327. _associatedChannel: number;
  117328. /** @hidden */
  117329. _source: InternalTextureSource;
  117330. /** @hidden */
  117331. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117332. /** @hidden */
  117333. _bufferView: Nullable<ArrayBufferView>;
  117334. /** @hidden */
  117335. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117336. /** @hidden */
  117337. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117338. /** @hidden */
  117339. _size: number;
  117340. /** @hidden */
  117341. _extension: string;
  117342. /** @hidden */
  117343. _files: Nullable<string[]>;
  117344. /** @hidden */
  117345. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117346. /** @hidden */
  117347. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117348. /** @hidden */
  117349. _framebuffer: Nullable<WebGLFramebuffer>;
  117350. /** @hidden */
  117351. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117352. /** @hidden */
  117353. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117354. /** @hidden */
  117355. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117356. /** @hidden */
  117357. _attachments: Nullable<number[]>;
  117358. /** @hidden */
  117359. _textureArray: Nullable<InternalTexture[]>;
  117360. /** @hidden */
  117361. _cachedCoordinatesMode: Nullable<number>;
  117362. /** @hidden */
  117363. _cachedWrapU: Nullable<number>;
  117364. /** @hidden */
  117365. _cachedWrapV: Nullable<number>;
  117366. /** @hidden */
  117367. _cachedWrapR: Nullable<number>;
  117368. /** @hidden */
  117369. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117370. /** @hidden */
  117371. _isDisabled: boolean;
  117372. /** @hidden */
  117373. _compression: Nullable<string>;
  117374. /** @hidden */
  117375. _generateStencilBuffer: boolean;
  117376. /** @hidden */
  117377. _generateDepthBuffer: boolean;
  117378. /** @hidden */
  117379. _comparisonFunction: number;
  117380. /** @hidden */
  117381. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117382. /** @hidden */
  117383. _lodGenerationScale: number;
  117384. /** @hidden */
  117385. _lodGenerationOffset: number;
  117386. /** @hidden */
  117387. _depthStencilTexture: Nullable<InternalTexture>;
  117388. /** @hidden */
  117389. _colorTextureArray: Nullable<WebGLTexture>;
  117390. /** @hidden */
  117391. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117392. /** @hidden */
  117393. _lodTextureHigh: Nullable<BaseTexture>;
  117394. /** @hidden */
  117395. _lodTextureMid: Nullable<BaseTexture>;
  117396. /** @hidden */
  117397. _lodTextureLow: Nullable<BaseTexture>;
  117398. /** @hidden */
  117399. _isRGBD: boolean;
  117400. /** @hidden */
  117401. _linearSpecularLOD: boolean;
  117402. /** @hidden */
  117403. _irradianceTexture: Nullable<BaseTexture>;
  117404. /** @hidden */
  117405. _webGLTexture: Nullable<WebGLTexture>;
  117406. /** @hidden */
  117407. _references: number;
  117408. /** @hidden */
  117409. _gammaSpace: Nullable<boolean>;
  117410. private _engine;
  117411. /**
  117412. * Gets the Engine the texture belongs to.
  117413. * @returns The babylon engine
  117414. */
  117415. getEngine(): ThinEngine;
  117416. /**
  117417. * Gets the data source type of the texture
  117418. */
  117419. get source(): InternalTextureSource;
  117420. /**
  117421. * Creates a new InternalTexture
  117422. * @param engine defines the engine to use
  117423. * @param source defines the type of data that will be used
  117424. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117425. */
  117426. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117427. /**
  117428. * Increments the number of references (ie. the number of Texture that point to it)
  117429. */
  117430. incrementReferences(): void;
  117431. /**
  117432. * Change the size of the texture (not the size of the content)
  117433. * @param width defines the new width
  117434. * @param height defines the new height
  117435. * @param depth defines the new depth (1 by default)
  117436. */
  117437. updateSize(width: int, height: int, depth?: int): void;
  117438. /** @hidden */
  117439. _rebuild(): void;
  117440. /** @hidden */
  117441. _swapAndDie(target: InternalTexture): void;
  117442. /**
  117443. * Dispose the current allocated resources
  117444. */
  117445. dispose(): void;
  117446. }
  117447. }
  117448. declare module BABYLON {
  117449. /**
  117450. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117451. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117452. */
  117453. export class Analyser {
  117454. /**
  117455. * Gets or sets the smoothing
  117456. * @ignorenaming
  117457. */
  117458. SMOOTHING: number;
  117459. /**
  117460. * Gets or sets the FFT table size
  117461. * @ignorenaming
  117462. */
  117463. FFT_SIZE: number;
  117464. /**
  117465. * Gets or sets the bar graph amplitude
  117466. * @ignorenaming
  117467. */
  117468. BARGRAPHAMPLITUDE: number;
  117469. /**
  117470. * Gets or sets the position of the debug canvas
  117471. * @ignorenaming
  117472. */
  117473. DEBUGCANVASPOS: {
  117474. x: number;
  117475. y: number;
  117476. };
  117477. /**
  117478. * Gets or sets the debug canvas size
  117479. * @ignorenaming
  117480. */
  117481. DEBUGCANVASSIZE: {
  117482. width: number;
  117483. height: number;
  117484. };
  117485. private _byteFreqs;
  117486. private _byteTime;
  117487. private _floatFreqs;
  117488. private _webAudioAnalyser;
  117489. private _debugCanvas;
  117490. private _debugCanvasContext;
  117491. private _scene;
  117492. private _registerFunc;
  117493. private _audioEngine;
  117494. /**
  117495. * Creates a new analyser
  117496. * @param scene defines hosting scene
  117497. */
  117498. constructor(scene: Scene);
  117499. /**
  117500. * Get the number of data values you will have to play with for the visualization
  117501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117502. * @returns a number
  117503. */
  117504. getFrequencyBinCount(): number;
  117505. /**
  117506. * Gets the current frequency data as a byte array
  117507. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117508. * @returns a Uint8Array
  117509. */
  117510. getByteFrequencyData(): Uint8Array;
  117511. /**
  117512. * Gets the current waveform as a byte array
  117513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117514. * @returns a Uint8Array
  117515. */
  117516. getByteTimeDomainData(): Uint8Array;
  117517. /**
  117518. * Gets the current frequency data as a float array
  117519. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117520. * @returns a Float32Array
  117521. */
  117522. getFloatFrequencyData(): Float32Array;
  117523. /**
  117524. * Renders the debug canvas
  117525. */
  117526. drawDebugCanvas(): void;
  117527. /**
  117528. * Stops rendering the debug canvas and removes it
  117529. */
  117530. stopDebugCanvas(): void;
  117531. /**
  117532. * Connects two audio nodes
  117533. * @param inputAudioNode defines first node to connect
  117534. * @param outputAudioNode defines second node to connect
  117535. */
  117536. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117537. /**
  117538. * Releases all associated resources
  117539. */
  117540. dispose(): void;
  117541. }
  117542. }
  117543. declare module BABYLON {
  117544. /**
  117545. * This represents an audio engine and it is responsible
  117546. * to play, synchronize and analyse sounds throughout the application.
  117547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117548. */
  117549. export interface IAudioEngine extends IDisposable {
  117550. /**
  117551. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117552. */
  117553. readonly canUseWebAudio: boolean;
  117554. /**
  117555. * Gets the current AudioContext if available.
  117556. */
  117557. readonly audioContext: Nullable<AudioContext>;
  117558. /**
  117559. * The master gain node defines the global audio volume of your audio engine.
  117560. */
  117561. readonly masterGain: GainNode;
  117562. /**
  117563. * Gets whether or not mp3 are supported by your browser.
  117564. */
  117565. readonly isMP3supported: boolean;
  117566. /**
  117567. * Gets whether or not ogg are supported by your browser.
  117568. */
  117569. readonly isOGGsupported: boolean;
  117570. /**
  117571. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117572. * @ignoreNaming
  117573. */
  117574. WarnedWebAudioUnsupported: boolean;
  117575. /**
  117576. * Defines if the audio engine relies on a custom unlocked button.
  117577. * In this case, the embedded button will not be displayed.
  117578. */
  117579. useCustomUnlockedButton: boolean;
  117580. /**
  117581. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117582. */
  117583. readonly unlocked: boolean;
  117584. /**
  117585. * Event raised when audio has been unlocked on the browser.
  117586. */
  117587. onAudioUnlockedObservable: Observable<AudioEngine>;
  117588. /**
  117589. * Event raised when audio has been locked on the browser.
  117590. */
  117591. onAudioLockedObservable: Observable<AudioEngine>;
  117592. /**
  117593. * Flags the audio engine in Locked state.
  117594. * This happens due to new browser policies preventing audio to autoplay.
  117595. */
  117596. lock(): void;
  117597. /**
  117598. * Unlocks the audio engine once a user action has been done on the dom.
  117599. * This is helpful to resume play once browser policies have been satisfied.
  117600. */
  117601. unlock(): void;
  117602. /**
  117603. * Gets the global volume sets on the master gain.
  117604. * @returns the global volume if set or -1 otherwise
  117605. */
  117606. getGlobalVolume(): number;
  117607. /**
  117608. * Sets the global volume of your experience (sets on the master gain).
  117609. * @param newVolume Defines the new global volume of the application
  117610. */
  117611. setGlobalVolume(newVolume: number): void;
  117612. /**
  117613. * Connect the audio engine to an audio analyser allowing some amazing
  117614. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117616. * @param analyser The analyser to connect to the engine
  117617. */
  117618. connectToAnalyser(analyser: Analyser): void;
  117619. }
  117620. /**
  117621. * This represents the default audio engine used in babylon.
  117622. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117623. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117624. */
  117625. export class AudioEngine implements IAudioEngine {
  117626. private _audioContext;
  117627. private _audioContextInitialized;
  117628. private _muteButton;
  117629. private _hostElement;
  117630. /**
  117631. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117632. */
  117633. canUseWebAudio: boolean;
  117634. /**
  117635. * The master gain node defines the global audio volume of your audio engine.
  117636. */
  117637. masterGain: GainNode;
  117638. /**
  117639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117640. * @ignoreNaming
  117641. */
  117642. WarnedWebAudioUnsupported: boolean;
  117643. /**
  117644. * Gets whether or not mp3 are supported by your browser.
  117645. */
  117646. isMP3supported: boolean;
  117647. /**
  117648. * Gets whether or not ogg are supported by your browser.
  117649. */
  117650. isOGGsupported: boolean;
  117651. /**
  117652. * Gets whether audio has been unlocked on the device.
  117653. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117654. * a user interaction has happened.
  117655. */
  117656. unlocked: boolean;
  117657. /**
  117658. * Defines if the audio engine relies on a custom unlocked button.
  117659. * In this case, the embedded button will not be displayed.
  117660. */
  117661. useCustomUnlockedButton: boolean;
  117662. /**
  117663. * Event raised when audio has been unlocked on the browser.
  117664. */
  117665. onAudioUnlockedObservable: Observable<AudioEngine>;
  117666. /**
  117667. * Event raised when audio has been locked on the browser.
  117668. */
  117669. onAudioLockedObservable: Observable<AudioEngine>;
  117670. /**
  117671. * Gets the current AudioContext if available.
  117672. */
  117673. get audioContext(): Nullable<AudioContext>;
  117674. private _connectedAnalyser;
  117675. /**
  117676. * Instantiates a new audio engine.
  117677. *
  117678. * There should be only one per page as some browsers restrict the number
  117679. * of audio contexts you can create.
  117680. * @param hostElement defines the host element where to display the mute icon if necessary
  117681. */
  117682. constructor(hostElement?: Nullable<HTMLElement>);
  117683. /**
  117684. * Flags the audio engine in Locked state.
  117685. * This happens due to new browser policies preventing audio to autoplay.
  117686. */
  117687. lock(): void;
  117688. /**
  117689. * Unlocks the audio engine once a user action has been done on the dom.
  117690. * This is helpful to resume play once browser policies have been satisfied.
  117691. */
  117692. unlock(): void;
  117693. private _resumeAudioContext;
  117694. private _initializeAudioContext;
  117695. private _tryToRun;
  117696. private _triggerRunningState;
  117697. private _triggerSuspendedState;
  117698. private _displayMuteButton;
  117699. private _moveButtonToTopLeft;
  117700. private _onResize;
  117701. private _hideMuteButton;
  117702. /**
  117703. * Destroy and release the resources associated with the audio ccontext.
  117704. */
  117705. dispose(): void;
  117706. /**
  117707. * Gets the global volume sets on the master gain.
  117708. * @returns the global volume if set or -1 otherwise
  117709. */
  117710. getGlobalVolume(): number;
  117711. /**
  117712. * Sets the global volume of your experience (sets on the master gain).
  117713. * @param newVolume Defines the new global volume of the application
  117714. */
  117715. setGlobalVolume(newVolume: number): void;
  117716. /**
  117717. * Connect the audio engine to an audio analyser allowing some amazing
  117718. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117720. * @param analyser The analyser to connect to the engine
  117721. */
  117722. connectToAnalyser(analyser: Analyser): void;
  117723. }
  117724. }
  117725. declare module BABYLON {
  117726. /**
  117727. * Interface used to present a loading screen while loading a scene
  117728. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117729. */
  117730. export interface ILoadingScreen {
  117731. /**
  117732. * Function called to display the loading screen
  117733. */
  117734. displayLoadingUI: () => void;
  117735. /**
  117736. * Function called to hide the loading screen
  117737. */
  117738. hideLoadingUI: () => void;
  117739. /**
  117740. * Gets or sets the color to use for the background
  117741. */
  117742. loadingUIBackgroundColor: string;
  117743. /**
  117744. * Gets or sets the text to display while loading
  117745. */
  117746. loadingUIText: string;
  117747. }
  117748. /**
  117749. * Class used for the default loading screen
  117750. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117751. */
  117752. export class DefaultLoadingScreen implements ILoadingScreen {
  117753. private _renderingCanvas;
  117754. private _loadingText;
  117755. private _loadingDivBackgroundColor;
  117756. private _loadingDiv;
  117757. private _loadingTextDiv;
  117758. /** Gets or sets the logo url to use for the default loading screen */
  117759. static DefaultLogoUrl: string;
  117760. /** Gets or sets the spinner url to use for the default loading screen */
  117761. static DefaultSpinnerUrl: string;
  117762. /**
  117763. * Creates a new default loading screen
  117764. * @param _renderingCanvas defines the canvas used to render the scene
  117765. * @param _loadingText defines the default text to display
  117766. * @param _loadingDivBackgroundColor defines the default background color
  117767. */
  117768. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117769. /**
  117770. * Function called to display the loading screen
  117771. */
  117772. displayLoadingUI(): void;
  117773. /**
  117774. * Function called to hide the loading screen
  117775. */
  117776. hideLoadingUI(): void;
  117777. /**
  117778. * Gets or sets the text to display while loading
  117779. */
  117780. set loadingUIText(text: string);
  117781. get loadingUIText(): string;
  117782. /**
  117783. * Gets or sets the color to use for the background
  117784. */
  117785. get loadingUIBackgroundColor(): string;
  117786. set loadingUIBackgroundColor(color: string);
  117787. private _resizeLoadingUI;
  117788. }
  117789. }
  117790. declare module BABYLON {
  117791. /**
  117792. * Interface for any object that can request an animation frame
  117793. */
  117794. export interface ICustomAnimationFrameRequester {
  117795. /**
  117796. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117797. */
  117798. renderFunction?: Function;
  117799. /**
  117800. * Called to request the next frame to render to
  117801. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117802. */
  117803. requestAnimationFrame: Function;
  117804. /**
  117805. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117806. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117807. */
  117808. requestID?: number;
  117809. }
  117810. }
  117811. declare module BABYLON {
  117812. /**
  117813. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117814. */
  117815. export class PerformanceMonitor {
  117816. private _enabled;
  117817. private _rollingFrameTime;
  117818. private _lastFrameTimeMs;
  117819. /**
  117820. * constructor
  117821. * @param frameSampleSize The number of samples required to saturate the sliding window
  117822. */
  117823. constructor(frameSampleSize?: number);
  117824. /**
  117825. * Samples current frame
  117826. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117827. */
  117828. sampleFrame(timeMs?: number): void;
  117829. /**
  117830. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117831. */
  117832. get averageFrameTime(): number;
  117833. /**
  117834. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117835. */
  117836. get averageFrameTimeVariance(): number;
  117837. /**
  117838. * Returns the frame time of the most recent frame
  117839. */
  117840. get instantaneousFrameTime(): number;
  117841. /**
  117842. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117843. */
  117844. get averageFPS(): number;
  117845. /**
  117846. * Returns the average framerate in frames per second using the most recent frame time
  117847. */
  117848. get instantaneousFPS(): number;
  117849. /**
  117850. * Returns true if enough samples have been taken to completely fill the sliding window
  117851. */
  117852. get isSaturated(): boolean;
  117853. /**
  117854. * Enables contributions to the sliding window sample set
  117855. */
  117856. enable(): void;
  117857. /**
  117858. * Disables contributions to the sliding window sample set
  117859. * Samples will not be interpolated over the disabled period
  117860. */
  117861. disable(): void;
  117862. /**
  117863. * Returns true if sampling is enabled
  117864. */
  117865. get isEnabled(): boolean;
  117866. /**
  117867. * Resets performance monitor
  117868. */
  117869. reset(): void;
  117870. }
  117871. /**
  117872. * RollingAverage
  117873. *
  117874. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117875. */
  117876. export class RollingAverage {
  117877. /**
  117878. * Current average
  117879. */
  117880. average: number;
  117881. /**
  117882. * Current variance
  117883. */
  117884. variance: number;
  117885. protected _samples: Array<number>;
  117886. protected _sampleCount: number;
  117887. protected _pos: number;
  117888. protected _m2: number;
  117889. /**
  117890. * constructor
  117891. * @param length The number of samples required to saturate the sliding window
  117892. */
  117893. constructor(length: number);
  117894. /**
  117895. * Adds a sample to the sample set
  117896. * @param v The sample value
  117897. */
  117898. add(v: number): void;
  117899. /**
  117900. * Returns previously added values or null if outside of history or outside the sliding window domain
  117901. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117902. * @return Value previously recorded with add() or null if outside of range
  117903. */
  117904. history(i: number): number;
  117905. /**
  117906. * Returns true if enough samples have been taken to completely fill the sliding window
  117907. * @return true if sample-set saturated
  117908. */
  117909. isSaturated(): boolean;
  117910. /**
  117911. * Resets the rolling average (equivalent to 0 samples taken so far)
  117912. */
  117913. reset(): void;
  117914. /**
  117915. * Wraps a value around the sample range boundaries
  117916. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117917. * @return Wrapped position in sample range
  117918. */
  117919. protected _wrapPosition(i: number): number;
  117920. }
  117921. }
  117922. declare module BABYLON {
  117923. /**
  117924. * This class is used to track a performance counter which is number based.
  117925. * The user has access to many properties which give statistics of different nature.
  117926. *
  117927. * The implementer can track two kinds of Performance Counter: time and count.
  117928. * 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.
  117929. * 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.
  117930. */
  117931. export class PerfCounter {
  117932. /**
  117933. * Gets or sets a global boolean to turn on and off all the counters
  117934. */
  117935. static Enabled: boolean;
  117936. /**
  117937. * Returns the smallest value ever
  117938. */
  117939. get min(): number;
  117940. /**
  117941. * Returns the biggest value ever
  117942. */
  117943. get max(): number;
  117944. /**
  117945. * Returns the average value since the performance counter is running
  117946. */
  117947. get average(): number;
  117948. /**
  117949. * Returns the average value of the last second the counter was monitored
  117950. */
  117951. get lastSecAverage(): number;
  117952. /**
  117953. * Returns the current value
  117954. */
  117955. get current(): number;
  117956. /**
  117957. * Gets the accumulated total
  117958. */
  117959. get total(): number;
  117960. /**
  117961. * Gets the total value count
  117962. */
  117963. get count(): number;
  117964. /**
  117965. * Creates a new counter
  117966. */
  117967. constructor();
  117968. /**
  117969. * Call this method to start monitoring a new frame.
  117970. * 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.
  117971. */
  117972. fetchNewFrame(): void;
  117973. /**
  117974. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117975. * @param newCount the count value to add to the monitored count
  117976. * @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.
  117977. */
  117978. addCount(newCount: number, fetchResult: boolean): void;
  117979. /**
  117980. * Start monitoring this performance counter
  117981. */
  117982. beginMonitoring(): void;
  117983. /**
  117984. * Compute the time lapsed since the previous beginMonitoring() call.
  117985. * @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
  117986. */
  117987. endMonitoring(newFrame?: boolean): void;
  117988. private _fetchResult;
  117989. private _startMonitoringTime;
  117990. private _min;
  117991. private _max;
  117992. private _average;
  117993. private _current;
  117994. private _totalValueCount;
  117995. private _totalAccumulated;
  117996. private _lastSecAverage;
  117997. private _lastSecAccumulated;
  117998. private _lastSecTime;
  117999. private _lastSecValueCount;
  118000. }
  118001. }
  118002. declare module BABYLON {
  118003. interface ThinEngine {
  118004. /** @hidden */
  118005. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  118006. }
  118007. }
  118008. declare module BABYLON {
  118009. /**
  118010. * Defines the interface used by display changed events
  118011. */
  118012. export interface IDisplayChangedEventArgs {
  118013. /** Gets the vrDisplay object (if any) */
  118014. vrDisplay: Nullable<any>;
  118015. /** Gets a boolean indicating if webVR is supported */
  118016. vrSupported: boolean;
  118017. }
  118018. /**
  118019. * Defines the interface used by objects containing a viewport (like a camera)
  118020. */
  118021. interface IViewportOwnerLike {
  118022. /**
  118023. * Gets or sets the viewport
  118024. */
  118025. viewport: IViewportLike;
  118026. }
  118027. /**
  118028. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  118029. */
  118030. export class Engine extends ThinEngine {
  118031. /** Defines that alpha blending is disabled */
  118032. static readonly ALPHA_DISABLE: number;
  118033. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  118034. static readonly ALPHA_ADD: number;
  118035. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  118036. static readonly ALPHA_COMBINE: number;
  118037. /** Defines that alpha blending to DEST - SRC * DEST */
  118038. static readonly ALPHA_SUBTRACT: number;
  118039. /** Defines that alpha blending to SRC * DEST */
  118040. static readonly ALPHA_MULTIPLY: number;
  118041. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  118042. static readonly ALPHA_MAXIMIZED: number;
  118043. /** Defines that alpha blending to SRC + DEST */
  118044. static readonly ALPHA_ONEONE: number;
  118045. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  118046. static readonly ALPHA_PREMULTIPLIED: number;
  118047. /**
  118048. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  118049. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  118050. */
  118051. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  118052. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  118053. static readonly ALPHA_INTERPOLATE: number;
  118054. /**
  118055. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  118056. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  118057. */
  118058. static readonly ALPHA_SCREENMODE: number;
  118059. /** Defines that the ressource is not delayed*/
  118060. static readonly DELAYLOADSTATE_NONE: number;
  118061. /** Defines that the ressource was successfully delay loaded */
  118062. static readonly DELAYLOADSTATE_LOADED: number;
  118063. /** Defines that the ressource is currently delay loading */
  118064. static readonly DELAYLOADSTATE_LOADING: number;
  118065. /** Defines that the ressource is delayed and has not started loading */
  118066. static readonly DELAYLOADSTATE_NOTLOADED: number;
  118067. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  118068. static readonly NEVER: number;
  118069. /** 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 */
  118070. static readonly ALWAYS: number;
  118071. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  118072. static readonly LESS: number;
  118073. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  118074. static readonly EQUAL: number;
  118075. /** 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 */
  118076. static readonly LEQUAL: number;
  118077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  118078. static readonly GREATER: number;
  118079. /** 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 */
  118080. static readonly GEQUAL: number;
  118081. /** 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 */
  118082. static readonly NOTEQUAL: number;
  118083. /** Passed to stencilOperation to specify that stencil value must be kept */
  118084. static readonly KEEP: number;
  118085. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118086. static readonly REPLACE: number;
  118087. /** Passed to stencilOperation to specify that stencil value must be incremented */
  118088. static readonly INCR: number;
  118089. /** Passed to stencilOperation to specify that stencil value must be decremented */
  118090. static readonly DECR: number;
  118091. /** Passed to stencilOperation to specify that stencil value must be inverted */
  118092. static readonly INVERT: number;
  118093. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  118094. static readonly INCR_WRAP: number;
  118095. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  118096. static readonly DECR_WRAP: number;
  118097. /** Texture is not repeating outside of 0..1 UVs */
  118098. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  118099. /** Texture is repeating outside of 0..1 UVs */
  118100. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  118101. /** Texture is repeating and mirrored */
  118102. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  118103. /** ALPHA */
  118104. static readonly TEXTUREFORMAT_ALPHA: number;
  118105. /** LUMINANCE */
  118106. static readonly TEXTUREFORMAT_LUMINANCE: number;
  118107. /** LUMINANCE_ALPHA */
  118108. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  118109. /** RGB */
  118110. static readonly TEXTUREFORMAT_RGB: number;
  118111. /** RGBA */
  118112. static readonly TEXTUREFORMAT_RGBA: number;
  118113. /** RED */
  118114. static readonly TEXTUREFORMAT_RED: number;
  118115. /** RED (2nd reference) */
  118116. static readonly TEXTUREFORMAT_R: number;
  118117. /** RG */
  118118. static readonly TEXTUREFORMAT_RG: number;
  118119. /** RED_INTEGER */
  118120. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  118121. /** RED_INTEGER (2nd reference) */
  118122. static readonly TEXTUREFORMAT_R_INTEGER: number;
  118123. /** RG_INTEGER */
  118124. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  118125. /** RGB_INTEGER */
  118126. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  118127. /** RGBA_INTEGER */
  118128. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  118129. /** UNSIGNED_BYTE */
  118130. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  118131. /** UNSIGNED_BYTE (2nd reference) */
  118132. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  118133. /** FLOAT */
  118134. static readonly TEXTURETYPE_FLOAT: number;
  118135. /** HALF_FLOAT */
  118136. static readonly TEXTURETYPE_HALF_FLOAT: number;
  118137. /** BYTE */
  118138. static readonly TEXTURETYPE_BYTE: number;
  118139. /** SHORT */
  118140. static readonly TEXTURETYPE_SHORT: number;
  118141. /** UNSIGNED_SHORT */
  118142. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  118143. /** INT */
  118144. static readonly TEXTURETYPE_INT: number;
  118145. /** UNSIGNED_INT */
  118146. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  118147. /** UNSIGNED_SHORT_4_4_4_4 */
  118148. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  118149. /** UNSIGNED_SHORT_5_5_5_1 */
  118150. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  118151. /** UNSIGNED_SHORT_5_6_5 */
  118152. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  118153. /** UNSIGNED_INT_2_10_10_10_REV */
  118154. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  118155. /** UNSIGNED_INT_24_8 */
  118156. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  118157. /** UNSIGNED_INT_10F_11F_11F_REV */
  118158. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  118159. /** UNSIGNED_INT_5_9_9_9_REV */
  118160. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  118161. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  118162. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  118163. /** nearest is mag = nearest and min = nearest and mip = linear */
  118164. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  118165. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118166. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  118167. /** Trilinear is mag = linear and min = linear and mip = linear */
  118168. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  118169. /** nearest is mag = nearest and min = nearest and mip = linear */
  118170. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  118171. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118172. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  118173. /** Trilinear is mag = linear and min = linear and mip = linear */
  118174. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  118175. /** mag = nearest and min = nearest and mip = nearest */
  118176. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  118177. /** mag = nearest and min = linear and mip = nearest */
  118178. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  118179. /** mag = nearest and min = linear and mip = linear */
  118180. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  118181. /** mag = nearest and min = linear and mip = none */
  118182. static readonly TEXTURE_NEAREST_LINEAR: number;
  118183. /** mag = nearest and min = nearest and mip = none */
  118184. static readonly TEXTURE_NEAREST_NEAREST: number;
  118185. /** mag = linear and min = nearest and mip = nearest */
  118186. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  118187. /** mag = linear and min = nearest and mip = linear */
  118188. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  118189. /** mag = linear and min = linear and mip = none */
  118190. static readonly TEXTURE_LINEAR_LINEAR: number;
  118191. /** mag = linear and min = nearest and mip = none */
  118192. static readonly TEXTURE_LINEAR_NEAREST: number;
  118193. /** Explicit coordinates mode */
  118194. static readonly TEXTURE_EXPLICIT_MODE: number;
  118195. /** Spherical coordinates mode */
  118196. static readonly TEXTURE_SPHERICAL_MODE: number;
  118197. /** Planar coordinates mode */
  118198. static readonly TEXTURE_PLANAR_MODE: number;
  118199. /** Cubic coordinates mode */
  118200. static readonly TEXTURE_CUBIC_MODE: number;
  118201. /** Projection coordinates mode */
  118202. static readonly TEXTURE_PROJECTION_MODE: number;
  118203. /** Skybox coordinates mode */
  118204. static readonly TEXTURE_SKYBOX_MODE: number;
  118205. /** Inverse Cubic coordinates mode */
  118206. static readonly TEXTURE_INVCUBIC_MODE: number;
  118207. /** Equirectangular coordinates mode */
  118208. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  118209. /** Equirectangular Fixed coordinates mode */
  118210. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  118211. /** Equirectangular Fixed Mirrored coordinates mode */
  118212. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  118213. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  118214. static readonly SCALEMODE_FLOOR: number;
  118215. /** Defines that texture rescaling will look for the nearest power of 2 size */
  118216. static readonly SCALEMODE_NEAREST: number;
  118217. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  118218. static readonly SCALEMODE_CEILING: number;
  118219. /**
  118220. * Returns the current npm package of the sdk
  118221. */
  118222. static get NpmPackage(): string;
  118223. /**
  118224. * Returns the current version of the framework
  118225. */
  118226. static get Version(): string;
  118227. /** Gets the list of created engines */
  118228. static get Instances(): Engine[];
  118229. /**
  118230. * Gets the latest created engine
  118231. */
  118232. static get LastCreatedEngine(): Nullable<Engine>;
  118233. /**
  118234. * Gets the latest created scene
  118235. */
  118236. static get LastCreatedScene(): Nullable<Scene>;
  118237. /**
  118238. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  118239. * @param flag defines which part of the materials must be marked as dirty
  118240. * @param predicate defines a predicate used to filter which materials should be affected
  118241. */
  118242. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118243. /**
  118244. * Method called to create the default loading screen.
  118245. * This can be overriden in your own app.
  118246. * @param canvas The rendering canvas element
  118247. * @returns The loading screen
  118248. */
  118249. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  118250. /**
  118251. * Method called to create the default rescale post process on each engine.
  118252. */
  118253. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  118254. /**
  118255. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  118256. **/
  118257. enableOfflineSupport: boolean;
  118258. /**
  118259. * 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)
  118260. **/
  118261. disableManifestCheck: boolean;
  118262. /**
  118263. * Gets the list of created scenes
  118264. */
  118265. scenes: Scene[];
  118266. /**
  118267. * Event raised when a new scene is created
  118268. */
  118269. onNewSceneAddedObservable: Observable<Scene>;
  118270. /**
  118271. * Gets the list of created postprocesses
  118272. */
  118273. postProcesses: PostProcess[];
  118274. /**
  118275. * Gets a boolean indicating if the pointer is currently locked
  118276. */
  118277. isPointerLock: boolean;
  118278. /**
  118279. * Observable event triggered each time the rendering canvas is resized
  118280. */
  118281. onResizeObservable: Observable<Engine>;
  118282. /**
  118283. * Observable event triggered each time the canvas loses focus
  118284. */
  118285. onCanvasBlurObservable: Observable<Engine>;
  118286. /**
  118287. * Observable event triggered each time the canvas gains focus
  118288. */
  118289. onCanvasFocusObservable: Observable<Engine>;
  118290. /**
  118291. * Observable event triggered each time the canvas receives pointerout event
  118292. */
  118293. onCanvasPointerOutObservable: Observable<PointerEvent>;
  118294. /**
  118295. * Observable raised when the engine begins a new frame
  118296. */
  118297. onBeginFrameObservable: Observable<Engine>;
  118298. /**
  118299. * If set, will be used to request the next animation frame for the render loop
  118300. */
  118301. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  118302. /**
  118303. * Observable raised when the engine ends the current frame
  118304. */
  118305. onEndFrameObservable: Observable<Engine>;
  118306. /**
  118307. * Observable raised when the engine is about to compile a shader
  118308. */
  118309. onBeforeShaderCompilationObservable: Observable<Engine>;
  118310. /**
  118311. * Observable raised when the engine has jsut compiled a shader
  118312. */
  118313. onAfterShaderCompilationObservable: Observable<Engine>;
  118314. /**
  118315. * Gets the audio engine
  118316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118317. * @ignorenaming
  118318. */
  118319. static audioEngine: IAudioEngine;
  118320. /**
  118321. * Default AudioEngine factory responsible of creating the Audio Engine.
  118322. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118323. */
  118324. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118325. /**
  118326. * Default offline support factory responsible of creating a tool used to store data locally.
  118327. * By default, this will create a Database object if the workload has been embedded.
  118328. */
  118329. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118330. private _loadingScreen;
  118331. private _pointerLockRequested;
  118332. private _rescalePostProcess;
  118333. private _deterministicLockstep;
  118334. private _lockstepMaxSteps;
  118335. private _timeStep;
  118336. protected get _supportsHardwareTextureRescaling(): boolean;
  118337. private _fps;
  118338. private _deltaTime;
  118339. /** @hidden */
  118340. _drawCalls: PerfCounter;
  118341. /** 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 */
  118342. canvasTabIndex: number;
  118343. /**
  118344. * Turn this value on if you want to pause FPS computation when in background
  118345. */
  118346. disablePerformanceMonitorInBackground: boolean;
  118347. private _performanceMonitor;
  118348. /**
  118349. * Gets the performance monitor attached to this engine
  118350. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118351. */
  118352. get performanceMonitor(): PerformanceMonitor;
  118353. private _onFocus;
  118354. private _onBlur;
  118355. private _onCanvasPointerOut;
  118356. private _onCanvasBlur;
  118357. private _onCanvasFocus;
  118358. private _onFullscreenChange;
  118359. private _onPointerLockChange;
  118360. /**
  118361. * Gets the HTML element used to attach event listeners
  118362. * @returns a HTML element
  118363. */
  118364. getInputElement(): Nullable<HTMLElement>;
  118365. /**
  118366. * Creates a new engine
  118367. * @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
  118368. * @param antialias defines enable antialiasing (default: false)
  118369. * @param options defines further options to be sent to the getContext() function
  118370. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118371. */
  118372. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118373. /**
  118374. * Gets current aspect ratio
  118375. * @param viewportOwner defines the camera to use to get the aspect ratio
  118376. * @param useScreen defines if screen size must be used (or the current render target if any)
  118377. * @returns a number defining the aspect ratio
  118378. */
  118379. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118380. /**
  118381. * Gets current screen aspect ratio
  118382. * @returns a number defining the aspect ratio
  118383. */
  118384. getScreenAspectRatio(): number;
  118385. /**
  118386. * Gets the client rect of the HTML canvas attached with the current webGL context
  118387. * @returns a client rectanglee
  118388. */
  118389. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118390. /**
  118391. * Gets the client rect of the HTML element used for events
  118392. * @returns a client rectanglee
  118393. */
  118394. getInputElementClientRect(): Nullable<ClientRect>;
  118395. /**
  118396. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118397. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118398. * @returns true if engine is in deterministic lock step mode
  118399. */
  118400. isDeterministicLockStep(): boolean;
  118401. /**
  118402. * Gets the max steps when engine is running in deterministic lock step
  118403. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118404. * @returns the max steps
  118405. */
  118406. getLockstepMaxSteps(): number;
  118407. /**
  118408. * Returns the time in ms between steps when using deterministic lock step.
  118409. * @returns time step in (ms)
  118410. */
  118411. getTimeStep(): number;
  118412. /**
  118413. * Force the mipmap generation for the given render target texture
  118414. * @param texture defines the render target texture to use
  118415. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118416. */
  118417. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118418. /** States */
  118419. /**
  118420. * Set various states to the webGL context
  118421. * @param culling defines backface culling state
  118422. * @param zOffset defines the value to apply to zOffset (0 by default)
  118423. * @param force defines if states must be applied even if cache is up to date
  118424. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118425. */
  118426. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118427. /**
  118428. * Set the z offset to apply to current rendering
  118429. * @param value defines the offset to apply
  118430. */
  118431. setZOffset(value: number): void;
  118432. /**
  118433. * Gets the current value of the zOffset
  118434. * @returns the current zOffset state
  118435. */
  118436. getZOffset(): number;
  118437. /**
  118438. * Enable or disable depth buffering
  118439. * @param enable defines the state to set
  118440. */
  118441. setDepthBuffer(enable: boolean): void;
  118442. /**
  118443. * Gets a boolean indicating if depth writing is enabled
  118444. * @returns the current depth writing state
  118445. */
  118446. getDepthWrite(): boolean;
  118447. /**
  118448. * Enable or disable depth writing
  118449. * @param enable defines the state to set
  118450. */
  118451. setDepthWrite(enable: boolean): void;
  118452. /**
  118453. * Gets a boolean indicating if stencil buffer is enabled
  118454. * @returns the current stencil buffer state
  118455. */
  118456. getStencilBuffer(): boolean;
  118457. /**
  118458. * Enable or disable the stencil buffer
  118459. * @param enable defines if the stencil buffer must be enabled or disabled
  118460. */
  118461. setStencilBuffer(enable: boolean): void;
  118462. /**
  118463. * Gets the current stencil mask
  118464. * @returns a number defining the new stencil mask to use
  118465. */
  118466. getStencilMask(): number;
  118467. /**
  118468. * Sets the current stencil mask
  118469. * @param mask defines the new stencil mask to use
  118470. */
  118471. setStencilMask(mask: number): void;
  118472. /**
  118473. * Gets the current stencil function
  118474. * @returns a number defining the stencil function to use
  118475. */
  118476. getStencilFunction(): number;
  118477. /**
  118478. * Gets the current stencil reference value
  118479. * @returns a number defining the stencil reference value to use
  118480. */
  118481. getStencilFunctionReference(): number;
  118482. /**
  118483. * Gets the current stencil mask
  118484. * @returns a number defining the stencil mask to use
  118485. */
  118486. getStencilFunctionMask(): number;
  118487. /**
  118488. * Sets the current stencil function
  118489. * @param stencilFunc defines the new stencil function to use
  118490. */
  118491. setStencilFunction(stencilFunc: number): void;
  118492. /**
  118493. * Sets the current stencil reference
  118494. * @param reference defines the new stencil reference to use
  118495. */
  118496. setStencilFunctionReference(reference: number): void;
  118497. /**
  118498. * Sets the current stencil mask
  118499. * @param mask defines the new stencil mask to use
  118500. */
  118501. setStencilFunctionMask(mask: number): void;
  118502. /**
  118503. * Gets the current stencil operation when stencil fails
  118504. * @returns a number defining stencil operation to use when stencil fails
  118505. */
  118506. getStencilOperationFail(): number;
  118507. /**
  118508. * Gets the current stencil operation when depth fails
  118509. * @returns a number defining stencil operation to use when depth fails
  118510. */
  118511. getStencilOperationDepthFail(): number;
  118512. /**
  118513. * Gets the current stencil operation when stencil passes
  118514. * @returns a number defining stencil operation to use when stencil passes
  118515. */
  118516. getStencilOperationPass(): number;
  118517. /**
  118518. * Sets the stencil operation to use when stencil fails
  118519. * @param operation defines the stencil operation to use when stencil fails
  118520. */
  118521. setStencilOperationFail(operation: number): void;
  118522. /**
  118523. * Sets the stencil operation to use when depth fails
  118524. * @param operation defines the stencil operation to use when depth fails
  118525. */
  118526. setStencilOperationDepthFail(operation: number): void;
  118527. /**
  118528. * Sets the stencil operation to use when stencil passes
  118529. * @param operation defines the stencil operation to use when stencil passes
  118530. */
  118531. setStencilOperationPass(operation: number): void;
  118532. /**
  118533. * Sets a boolean indicating if the dithering state is enabled or disabled
  118534. * @param value defines the dithering state
  118535. */
  118536. setDitheringState(value: boolean): void;
  118537. /**
  118538. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118539. * @param value defines the rasterizer state
  118540. */
  118541. setRasterizerState(value: boolean): void;
  118542. /**
  118543. * Gets the current depth function
  118544. * @returns a number defining the depth function
  118545. */
  118546. getDepthFunction(): Nullable<number>;
  118547. /**
  118548. * Sets the current depth function
  118549. * @param depthFunc defines the function to use
  118550. */
  118551. setDepthFunction(depthFunc: number): void;
  118552. /**
  118553. * Sets the current depth function to GREATER
  118554. */
  118555. setDepthFunctionToGreater(): void;
  118556. /**
  118557. * Sets the current depth function to GEQUAL
  118558. */
  118559. setDepthFunctionToGreaterOrEqual(): void;
  118560. /**
  118561. * Sets the current depth function to LESS
  118562. */
  118563. setDepthFunctionToLess(): void;
  118564. /**
  118565. * Sets the current depth function to LEQUAL
  118566. */
  118567. setDepthFunctionToLessOrEqual(): void;
  118568. private _cachedStencilBuffer;
  118569. private _cachedStencilFunction;
  118570. private _cachedStencilMask;
  118571. private _cachedStencilOperationPass;
  118572. private _cachedStencilOperationFail;
  118573. private _cachedStencilOperationDepthFail;
  118574. private _cachedStencilReference;
  118575. /**
  118576. * Caches the the state of the stencil buffer
  118577. */
  118578. cacheStencilState(): void;
  118579. /**
  118580. * Restores the state of the stencil buffer
  118581. */
  118582. restoreStencilState(): void;
  118583. /**
  118584. * Directly set the WebGL Viewport
  118585. * @param x defines the x coordinate of the viewport (in screen space)
  118586. * @param y defines the y coordinate of the viewport (in screen space)
  118587. * @param width defines the width of the viewport (in screen space)
  118588. * @param height defines the height of the viewport (in screen space)
  118589. * @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
  118590. */
  118591. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118592. /**
  118593. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118594. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118595. * @param y defines the y-coordinate of the corner of the clear rectangle
  118596. * @param width defines the width of the clear rectangle
  118597. * @param height defines the height of the clear rectangle
  118598. * @param clearColor defines the clear color
  118599. */
  118600. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118601. /**
  118602. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118603. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118604. * @param y defines the y-coordinate of the corner of the clear rectangle
  118605. * @param width defines the width of the clear rectangle
  118606. * @param height defines the height of the clear rectangle
  118607. */
  118608. enableScissor(x: number, y: number, width: number, height: number): void;
  118609. /**
  118610. * Disable previously set scissor test rectangle
  118611. */
  118612. disableScissor(): void;
  118613. protected _reportDrawCall(): void;
  118614. /**
  118615. * Initializes a webVR display and starts listening to display change events
  118616. * The onVRDisplayChangedObservable will be notified upon these changes
  118617. * @returns The onVRDisplayChangedObservable
  118618. */
  118619. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118620. /** @hidden */
  118621. _prepareVRComponent(): void;
  118622. /** @hidden */
  118623. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118624. /** @hidden */
  118625. _submitVRFrame(): void;
  118626. /**
  118627. * Call this function to leave webVR mode
  118628. * Will do nothing if webVR is not supported or if there is no webVR device
  118629. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118630. */
  118631. disableVR(): void;
  118632. /**
  118633. * Gets a boolean indicating that the system is in VR mode and is presenting
  118634. * @returns true if VR mode is engaged
  118635. */
  118636. isVRPresenting(): boolean;
  118637. /** @hidden */
  118638. _requestVRFrame(): void;
  118639. /** @hidden */
  118640. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118641. /**
  118642. * Gets the source code of the vertex shader associated with a specific webGL program
  118643. * @param program defines the program to use
  118644. * @returns a string containing the source code of the vertex shader associated with the program
  118645. */
  118646. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118647. /**
  118648. * Gets the source code of the fragment shader associated with a specific webGL program
  118649. * @param program defines the program to use
  118650. * @returns a string containing the source code of the fragment shader associated with the program
  118651. */
  118652. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118653. /**
  118654. * Sets a depth stencil texture from a render target to the according uniform.
  118655. * @param channel The texture channel
  118656. * @param uniform The uniform to set
  118657. * @param texture The render target texture containing the depth stencil texture to apply
  118658. */
  118659. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118660. /**
  118661. * Sets a texture to the webGL context from a postprocess
  118662. * @param channel defines the channel to use
  118663. * @param postProcess defines the source postprocess
  118664. */
  118665. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118666. /**
  118667. * Binds the output of the passed in post process to the texture channel specified
  118668. * @param channel The channel the texture should be bound to
  118669. * @param postProcess The post process which's output should be bound
  118670. */
  118671. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118672. protected _rebuildBuffers(): void;
  118673. /** @hidden */
  118674. _renderFrame(): void;
  118675. _renderLoop(): void;
  118676. /** @hidden */
  118677. _renderViews(): boolean;
  118678. /**
  118679. * Toggle full screen mode
  118680. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118681. */
  118682. switchFullscreen(requestPointerLock: boolean): void;
  118683. /**
  118684. * Enters full screen mode
  118685. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118686. */
  118687. enterFullscreen(requestPointerLock: boolean): void;
  118688. /**
  118689. * Exits full screen mode
  118690. */
  118691. exitFullscreen(): void;
  118692. /**
  118693. * Enters Pointerlock mode
  118694. */
  118695. enterPointerlock(): void;
  118696. /**
  118697. * Exits Pointerlock mode
  118698. */
  118699. exitPointerlock(): void;
  118700. /**
  118701. * Begin a new frame
  118702. */
  118703. beginFrame(): void;
  118704. /**
  118705. * Enf the current frame
  118706. */
  118707. endFrame(): void;
  118708. resize(): void;
  118709. /**
  118710. * Force a specific size of the canvas
  118711. * @param width defines the new canvas' width
  118712. * @param height defines the new canvas' height
  118713. * @returns true if the size was changed
  118714. */
  118715. setSize(width: number, height: number): boolean;
  118716. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118717. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118718. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118719. _releaseTexture(texture: InternalTexture): void;
  118720. /**
  118721. * @hidden
  118722. * Rescales a texture
  118723. * @param source input texutre
  118724. * @param destination destination texture
  118725. * @param scene scene to use to render the resize
  118726. * @param internalFormat format to use when resizing
  118727. * @param onComplete callback to be called when resize has completed
  118728. */
  118729. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118730. /**
  118731. * Gets the current framerate
  118732. * @returns a number representing the framerate
  118733. */
  118734. getFps(): number;
  118735. /**
  118736. * Gets the time spent between current and previous frame
  118737. * @returns a number representing the delta time in ms
  118738. */
  118739. getDeltaTime(): number;
  118740. private _measureFps;
  118741. /** @hidden */
  118742. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118743. /**
  118744. * Updates the sample count of a render target texture
  118745. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118746. * @param texture defines the texture to update
  118747. * @param samples defines the sample count to set
  118748. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118749. */
  118750. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118751. /**
  118752. * Updates a depth texture Comparison Mode and Function.
  118753. * If the comparison Function is equal to 0, the mode will be set to none.
  118754. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118755. * @param texture The texture to set the comparison function for
  118756. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118757. */
  118758. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118759. /**
  118760. * Creates a webGL buffer to use with instanciation
  118761. * @param capacity defines the size of the buffer
  118762. * @returns the webGL buffer
  118763. */
  118764. createInstancesBuffer(capacity: number): DataBuffer;
  118765. /**
  118766. * Delete a webGL buffer used with instanciation
  118767. * @param buffer defines the webGL buffer to delete
  118768. */
  118769. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118770. private _clientWaitAsync;
  118771. /** @hidden */
  118772. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118773. dispose(): void;
  118774. private _disableTouchAction;
  118775. /**
  118776. * Display the loading screen
  118777. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118778. */
  118779. displayLoadingUI(): void;
  118780. /**
  118781. * Hide the loading screen
  118782. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118783. */
  118784. hideLoadingUI(): void;
  118785. /**
  118786. * Gets the current loading screen object
  118787. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118788. */
  118789. get loadingScreen(): ILoadingScreen;
  118790. /**
  118791. * Sets the current loading screen object
  118792. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118793. */
  118794. set loadingScreen(loadingScreen: ILoadingScreen);
  118795. /**
  118796. * Sets the current loading screen text
  118797. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118798. */
  118799. set loadingUIText(text: string);
  118800. /**
  118801. * Sets the current loading screen background color
  118802. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118803. */
  118804. set loadingUIBackgroundColor(color: string);
  118805. /** Pointerlock and fullscreen */
  118806. /**
  118807. * Ask the browser to promote the current element to pointerlock mode
  118808. * @param element defines the DOM element to promote
  118809. */
  118810. static _RequestPointerlock(element: HTMLElement): void;
  118811. /**
  118812. * Asks the browser to exit pointerlock mode
  118813. */
  118814. static _ExitPointerlock(): void;
  118815. /**
  118816. * Ask the browser to promote the current element to fullscreen rendering mode
  118817. * @param element defines the DOM element to promote
  118818. */
  118819. static _RequestFullscreen(element: HTMLElement): void;
  118820. /**
  118821. * Asks the browser to exit fullscreen mode
  118822. */
  118823. static _ExitFullscreen(): void;
  118824. }
  118825. }
  118826. declare module BABYLON {
  118827. /**
  118828. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118829. * during the life time of the application.
  118830. */
  118831. export class EngineStore {
  118832. /** Gets the list of created engines */
  118833. static Instances: Engine[];
  118834. /** @hidden */
  118835. static _LastCreatedScene: Nullable<Scene>;
  118836. /**
  118837. * Gets the latest created engine
  118838. */
  118839. static get LastCreatedEngine(): Nullable<Engine>;
  118840. /**
  118841. * Gets the latest created scene
  118842. */
  118843. static get LastCreatedScene(): Nullable<Scene>;
  118844. /**
  118845. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118846. * @ignorenaming
  118847. */
  118848. static UseFallbackTexture: boolean;
  118849. /**
  118850. * Texture content used if a texture cannot loaded
  118851. * @ignorenaming
  118852. */
  118853. static FallbackTexture: string;
  118854. }
  118855. }
  118856. declare module BABYLON {
  118857. /**
  118858. * Helper class that provides a small promise polyfill
  118859. */
  118860. export class PromisePolyfill {
  118861. /**
  118862. * Static function used to check if the polyfill is required
  118863. * If this is the case then the function will inject the polyfill to window.Promise
  118864. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118865. */
  118866. static Apply(force?: boolean): void;
  118867. }
  118868. }
  118869. declare module BABYLON {
  118870. /**
  118871. * Interface for screenshot methods with describe argument called `size` as object with options
  118872. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118873. */
  118874. export interface IScreenshotSize {
  118875. /**
  118876. * number in pixels for canvas height
  118877. */
  118878. height?: number;
  118879. /**
  118880. * multiplier allowing render at a higher or lower resolution
  118881. * If value is defined then height and width will be ignored and taken from camera
  118882. */
  118883. precision?: number;
  118884. /**
  118885. * number in pixels for canvas width
  118886. */
  118887. width?: number;
  118888. }
  118889. }
  118890. declare module BABYLON {
  118891. interface IColor4Like {
  118892. r: float;
  118893. g: float;
  118894. b: float;
  118895. a: float;
  118896. }
  118897. /**
  118898. * Class containing a set of static utilities functions
  118899. */
  118900. export class Tools {
  118901. /**
  118902. * Gets or sets the base URL to use to load assets
  118903. */
  118904. static get BaseUrl(): string;
  118905. static set BaseUrl(value: string);
  118906. /**
  118907. * Enable/Disable Custom HTTP Request Headers globally.
  118908. * default = false
  118909. * @see CustomRequestHeaders
  118910. */
  118911. static UseCustomRequestHeaders: boolean;
  118912. /**
  118913. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118914. * i.e. when loading files, where the server/service expects an Authorization header
  118915. */
  118916. static CustomRequestHeaders: {
  118917. [key: string]: string;
  118918. };
  118919. /**
  118920. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118921. */
  118922. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118923. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118924. /**
  118925. * Default behaviour for cors in the application.
  118926. * It can be a string if the expected behavior is identical in the entire app.
  118927. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118928. */
  118929. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118930. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118931. /**
  118932. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118933. * @ignorenaming
  118934. */
  118935. static get UseFallbackTexture(): boolean;
  118936. static set UseFallbackTexture(value: boolean);
  118937. /**
  118938. * Use this object to register external classes like custom textures or material
  118939. * to allow the laoders to instantiate them
  118940. */
  118941. static get RegisteredExternalClasses(): {
  118942. [key: string]: Object;
  118943. };
  118944. static set RegisteredExternalClasses(classes: {
  118945. [key: string]: Object;
  118946. });
  118947. /**
  118948. * Texture content used if a texture cannot loaded
  118949. * @ignorenaming
  118950. */
  118951. static get fallbackTexture(): string;
  118952. static set fallbackTexture(value: string);
  118953. /**
  118954. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118955. * @param u defines the coordinate on X axis
  118956. * @param v defines the coordinate on Y axis
  118957. * @param width defines the width of the source data
  118958. * @param height defines the height of the source data
  118959. * @param pixels defines the source byte array
  118960. * @param color defines the output color
  118961. */
  118962. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118963. /**
  118964. * Interpolates between a and b via alpha
  118965. * @param a The lower value (returned when alpha = 0)
  118966. * @param b The upper value (returned when alpha = 1)
  118967. * @param alpha The interpolation-factor
  118968. * @return The mixed value
  118969. */
  118970. static Mix(a: number, b: number, alpha: number): number;
  118971. /**
  118972. * Tries to instantiate a new object from a given class name
  118973. * @param className defines the class name to instantiate
  118974. * @returns the new object or null if the system was not able to do the instantiation
  118975. */
  118976. static Instantiate(className: string): any;
  118977. /**
  118978. * Provides a slice function that will work even on IE
  118979. * @param data defines the array to slice
  118980. * @param start defines the start of the data (optional)
  118981. * @param end defines the end of the data (optional)
  118982. * @returns the new sliced array
  118983. */
  118984. static Slice<T>(data: T, start?: number, end?: number): T;
  118985. /**
  118986. * Polyfill for setImmediate
  118987. * @param action defines the action to execute after the current execution block
  118988. */
  118989. static SetImmediate(action: () => void): void;
  118990. /**
  118991. * Function indicating if a number is an exponent of 2
  118992. * @param value defines the value to test
  118993. * @returns true if the value is an exponent of 2
  118994. */
  118995. static IsExponentOfTwo(value: number): boolean;
  118996. private static _tmpFloatArray;
  118997. /**
  118998. * Returns the nearest 32-bit single precision float representation of a Number
  118999. * @param value A Number. If the parameter is of a different type, it will get converted
  119000. * to a number or to NaN if it cannot be converted
  119001. * @returns number
  119002. */
  119003. static FloatRound(value: number): number;
  119004. /**
  119005. * Extracts the filename from a path
  119006. * @param path defines the path to use
  119007. * @returns the filename
  119008. */
  119009. static GetFilename(path: string): string;
  119010. /**
  119011. * Extracts the "folder" part of a path (everything before the filename).
  119012. * @param uri The URI to extract the info from
  119013. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  119014. * @returns The "folder" part of the path
  119015. */
  119016. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  119017. /**
  119018. * Extracts text content from a DOM element hierarchy
  119019. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  119020. */
  119021. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  119022. /**
  119023. * Convert an angle in radians to degrees
  119024. * @param angle defines the angle to convert
  119025. * @returns the angle in degrees
  119026. */
  119027. static ToDegrees(angle: number): number;
  119028. /**
  119029. * Convert an angle in degrees to radians
  119030. * @param angle defines the angle to convert
  119031. * @returns the angle in radians
  119032. */
  119033. static ToRadians(angle: number): number;
  119034. /**
  119035. * Returns an array if obj is not an array
  119036. * @param obj defines the object to evaluate as an array
  119037. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  119038. * @returns either obj directly if obj is an array or a new array containing obj
  119039. */
  119040. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  119041. /**
  119042. * Gets the pointer prefix to use
  119043. * @param engine defines the engine we are finding the prefix for
  119044. * @returns "pointer" if touch is enabled. Else returns "mouse"
  119045. */
  119046. static GetPointerPrefix(engine: Engine): string;
  119047. /**
  119048. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  119049. * @param url define the url we are trying
  119050. * @param element define the dom element where to configure the cors policy
  119051. */
  119052. static SetCorsBehavior(url: string | string[], element: {
  119053. crossOrigin: string | null;
  119054. }): void;
  119055. /**
  119056. * Removes unwanted characters from an url
  119057. * @param url defines the url to clean
  119058. * @returns the cleaned url
  119059. */
  119060. static CleanUrl(url: string): string;
  119061. /**
  119062. * Gets or sets a function used to pre-process url before using them to load assets
  119063. */
  119064. static get PreprocessUrl(): (url: string) => string;
  119065. static set PreprocessUrl(processor: (url: string) => string);
  119066. /**
  119067. * Loads an image as an HTMLImageElement.
  119068. * @param input url string, ArrayBuffer, or Blob to load
  119069. * @param onLoad callback called when the image successfully loads
  119070. * @param onError callback called when the image fails to load
  119071. * @param offlineProvider offline provider for caching
  119072. * @param mimeType optional mime type
  119073. * @returns the HTMLImageElement of the loaded image
  119074. */
  119075. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  119076. /**
  119077. * Loads a file from a url
  119078. * @param url url string, ArrayBuffer, or Blob to load
  119079. * @param onSuccess callback called when the file successfully loads
  119080. * @param onProgress callback called while file is loading (if the server supports this mode)
  119081. * @param offlineProvider defines the offline provider for caching
  119082. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119083. * @param onError callback called when the file fails to load
  119084. * @returns a file request object
  119085. */
  119086. 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;
  119087. /**
  119088. * Loads a file from a url
  119089. * @param url the file url to load
  119090. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119091. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  119092. */
  119093. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  119094. /**
  119095. * Load a script (identified by an url). When the url returns, the
  119096. * content of this file is added into a new script element, attached to the DOM (body element)
  119097. * @param scriptUrl defines the url of the script to laod
  119098. * @param onSuccess defines the callback called when the script is loaded
  119099. * @param onError defines the callback to call if an error occurs
  119100. * @param scriptId defines the id of the script element
  119101. */
  119102. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  119103. /**
  119104. * Load an asynchronous script (identified by an url). When the url returns, the
  119105. * content of this file is added into a new script element, attached to the DOM (body element)
  119106. * @param scriptUrl defines the url of the script to laod
  119107. * @param scriptId defines the id of the script element
  119108. * @returns a promise request object
  119109. */
  119110. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  119111. /**
  119112. * Loads a file from a blob
  119113. * @param fileToLoad defines the blob to use
  119114. * @param callback defines the callback to call when data is loaded
  119115. * @param progressCallback defines the callback to call during loading process
  119116. * @returns a file request object
  119117. */
  119118. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  119119. /**
  119120. * Reads a file from a File object
  119121. * @param file defines the file to load
  119122. * @param onSuccess defines the callback to call when data is loaded
  119123. * @param onProgress defines the callback to call during loading process
  119124. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119125. * @param onError defines the callback to call when an error occurs
  119126. * @returns a file request object
  119127. */
  119128. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119129. /**
  119130. * Creates a data url from a given string content
  119131. * @param content defines the content to convert
  119132. * @returns the new data url link
  119133. */
  119134. static FileAsURL(content: string): string;
  119135. /**
  119136. * Format the given number to a specific decimal format
  119137. * @param value defines the number to format
  119138. * @param decimals defines the number of decimals to use
  119139. * @returns the formatted string
  119140. */
  119141. static Format(value: number, decimals?: number): string;
  119142. /**
  119143. * Tries to copy an object by duplicating every property
  119144. * @param source defines the source object
  119145. * @param destination defines the target object
  119146. * @param doNotCopyList defines a list of properties to avoid
  119147. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  119148. */
  119149. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  119150. /**
  119151. * Gets a boolean indicating if the given object has no own property
  119152. * @param obj defines the object to test
  119153. * @returns true if object has no own property
  119154. */
  119155. static IsEmpty(obj: any): boolean;
  119156. /**
  119157. * Function used to register events at window level
  119158. * @param windowElement defines the Window object to use
  119159. * @param events defines the events to register
  119160. */
  119161. static RegisterTopRootEvents(windowElement: Window, events: {
  119162. name: string;
  119163. handler: Nullable<(e: FocusEvent) => any>;
  119164. }[]): void;
  119165. /**
  119166. * Function used to unregister events from window level
  119167. * @param windowElement defines the Window object to use
  119168. * @param events defines the events to unregister
  119169. */
  119170. static UnregisterTopRootEvents(windowElement: Window, events: {
  119171. name: string;
  119172. handler: Nullable<(e: FocusEvent) => any>;
  119173. }[]): void;
  119174. /**
  119175. * @ignore
  119176. */
  119177. static _ScreenshotCanvas: HTMLCanvasElement;
  119178. /**
  119179. * Dumps the current bound framebuffer
  119180. * @param width defines the rendering width
  119181. * @param height defines the rendering height
  119182. * @param engine defines the hosting engine
  119183. * @param successCallback defines the callback triggered once the data are available
  119184. * @param mimeType defines the mime type of the result
  119185. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  119186. */
  119187. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119188. /**
  119189. * Converts the canvas data to blob.
  119190. * This acts as a polyfill for browsers not supporting the to blob function.
  119191. * @param canvas Defines the canvas to extract the data from
  119192. * @param successCallback Defines the callback triggered once the data are available
  119193. * @param mimeType Defines the mime type of the result
  119194. */
  119195. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  119196. /**
  119197. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  119198. * @param successCallback defines the callback triggered once the data are available
  119199. * @param mimeType defines the mime type of the result
  119200. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  119201. */
  119202. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119203. /**
  119204. * Downloads a blob in the browser
  119205. * @param blob defines the blob to download
  119206. * @param fileName defines the name of the downloaded file
  119207. */
  119208. static Download(blob: Blob, fileName: string): void;
  119209. /**
  119210. * Captures a screenshot of the current rendering
  119211. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119212. * @param engine defines the rendering engine
  119213. * @param camera defines the source camera
  119214. * @param size This parameter can be set to a single number or to an object with the
  119215. * following (optional) properties: precision, width, height. If a single number is passed,
  119216. * it will be used for both width and height. If an object is passed, the screenshot size
  119217. * will be derived from the parameters. The precision property is a multiplier allowing
  119218. * rendering at a higher or lower resolution
  119219. * @param successCallback defines the callback receives a single parameter which contains the
  119220. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119221. * src parameter of an <img> to display it
  119222. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119223. * Check your browser for supported MIME types
  119224. */
  119225. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  119226. /**
  119227. * Captures a screenshot of the current rendering
  119228. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119229. * @param engine defines the rendering engine
  119230. * @param camera defines the source camera
  119231. * @param size This parameter can be set to a single number or to an object with the
  119232. * following (optional) properties: precision, width, height. If a single number is passed,
  119233. * it will be used for both width and height. If an object is passed, the screenshot size
  119234. * will be derived from the parameters. The precision property is a multiplier allowing
  119235. * rendering at a higher or lower resolution
  119236. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119237. * Check your browser for supported MIME types
  119238. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119239. * to the src parameter of an <img> to display it
  119240. */
  119241. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  119242. /**
  119243. * Generates an image screenshot from the specified camera.
  119244. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119245. * @param engine The engine to use for rendering
  119246. * @param camera The camera to use for rendering
  119247. * @param size This parameter can be set to a single number or to an object with the
  119248. * following (optional) properties: precision, width, height. If a single number is passed,
  119249. * it will be used for both width and height. If an object is passed, the screenshot size
  119250. * will be derived from the parameters. The precision property is a multiplier allowing
  119251. * rendering at a higher or lower resolution
  119252. * @param successCallback The callback receives a single parameter which contains the
  119253. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119254. * src parameter of an <img> to display it
  119255. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119256. * Check your browser for supported MIME types
  119257. * @param samples Texture samples (default: 1)
  119258. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119259. * @param fileName A name for for the downloaded file.
  119260. */
  119261. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  119262. /**
  119263. * Generates an image screenshot from the specified camera.
  119264. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119265. * @param engine The engine to use for rendering
  119266. * @param camera The camera to use for rendering
  119267. * @param size This parameter can be set to a single number or to an object with the
  119268. * following (optional) properties: precision, width, height. If a single number is passed,
  119269. * it will be used for both width and height. If an object is passed, the screenshot size
  119270. * will be derived from the parameters. The precision property is a multiplier allowing
  119271. * rendering at a higher or lower resolution
  119272. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119273. * Check your browser for supported MIME types
  119274. * @param samples Texture samples (default: 1)
  119275. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119276. * @param fileName A name for for the downloaded file.
  119277. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119278. * to the src parameter of an <img> to display it
  119279. */
  119280. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  119281. /**
  119282. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  119283. * Be aware Math.random() could cause collisions, but:
  119284. * "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"
  119285. * @returns a pseudo random id
  119286. */
  119287. static RandomId(): string;
  119288. /**
  119289. * Test if the given uri is a base64 string
  119290. * @param uri The uri to test
  119291. * @return True if the uri is a base64 string or false otherwise
  119292. */
  119293. static IsBase64(uri: string): boolean;
  119294. /**
  119295. * Decode the given base64 uri.
  119296. * @param uri The uri to decode
  119297. * @return The decoded base64 data.
  119298. */
  119299. static DecodeBase64(uri: string): ArrayBuffer;
  119300. /**
  119301. * Gets the absolute url.
  119302. * @param url the input url
  119303. * @return the absolute url
  119304. */
  119305. static GetAbsoluteUrl(url: string): string;
  119306. /**
  119307. * No log
  119308. */
  119309. static readonly NoneLogLevel: number;
  119310. /**
  119311. * Only message logs
  119312. */
  119313. static readonly MessageLogLevel: number;
  119314. /**
  119315. * Only warning logs
  119316. */
  119317. static readonly WarningLogLevel: number;
  119318. /**
  119319. * Only error logs
  119320. */
  119321. static readonly ErrorLogLevel: number;
  119322. /**
  119323. * All logs
  119324. */
  119325. static readonly AllLogLevel: number;
  119326. /**
  119327. * Gets a value indicating the number of loading errors
  119328. * @ignorenaming
  119329. */
  119330. static get errorsCount(): number;
  119331. /**
  119332. * Callback called when a new log is added
  119333. */
  119334. static OnNewCacheEntry: (entry: string) => void;
  119335. /**
  119336. * Log a message to the console
  119337. * @param message defines the message to log
  119338. */
  119339. static Log(message: string): void;
  119340. /**
  119341. * Write a warning message to the console
  119342. * @param message defines the message to log
  119343. */
  119344. static Warn(message: string): void;
  119345. /**
  119346. * Write an error message to the console
  119347. * @param message defines the message to log
  119348. */
  119349. static Error(message: string): void;
  119350. /**
  119351. * Gets current log cache (list of logs)
  119352. */
  119353. static get LogCache(): string;
  119354. /**
  119355. * Clears the log cache
  119356. */
  119357. static ClearLogCache(): void;
  119358. /**
  119359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119360. */
  119361. static set LogLevels(level: number);
  119362. /**
  119363. * Checks if the window object exists
  119364. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119365. */
  119366. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119367. /**
  119368. * No performance log
  119369. */
  119370. static readonly PerformanceNoneLogLevel: number;
  119371. /**
  119372. * Use user marks to log performance
  119373. */
  119374. static readonly PerformanceUserMarkLogLevel: number;
  119375. /**
  119376. * Log performance to the console
  119377. */
  119378. static readonly PerformanceConsoleLogLevel: number;
  119379. private static _performance;
  119380. /**
  119381. * Sets the current performance log level
  119382. */
  119383. static set PerformanceLogLevel(level: number);
  119384. private static _StartPerformanceCounterDisabled;
  119385. private static _EndPerformanceCounterDisabled;
  119386. private static _StartUserMark;
  119387. private static _EndUserMark;
  119388. private static _StartPerformanceConsole;
  119389. private static _EndPerformanceConsole;
  119390. /**
  119391. * Starts a performance counter
  119392. */
  119393. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119394. /**
  119395. * Ends a specific performance coutner
  119396. */
  119397. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119398. /**
  119399. * Gets either window.performance.now() if supported or Date.now() else
  119400. */
  119401. static get Now(): number;
  119402. /**
  119403. * This method will return the name of the class used to create the instance of the given object.
  119404. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119405. * @param object the object to get the class name from
  119406. * @param isType defines if the object is actually a type
  119407. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119408. */
  119409. static GetClassName(object: any, isType?: boolean): string;
  119410. /**
  119411. * Gets the first element of an array satisfying a given predicate
  119412. * @param array defines the array to browse
  119413. * @param predicate defines the predicate to use
  119414. * @returns null if not found or the element
  119415. */
  119416. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119417. /**
  119418. * This method will return the name of the full name of the class, including its owning module (if any).
  119419. * 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).
  119420. * @param object the object to get the class name from
  119421. * @param isType defines if the object is actually a type
  119422. * @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.
  119423. * @ignorenaming
  119424. */
  119425. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119426. /**
  119427. * Returns a promise that resolves after the given amount of time.
  119428. * @param delay Number of milliseconds to delay
  119429. * @returns Promise that resolves after the given amount of time
  119430. */
  119431. static DelayAsync(delay: number): Promise<void>;
  119432. /**
  119433. * Utility function to detect if the current user agent is Safari
  119434. * @returns whether or not the current user agent is safari
  119435. */
  119436. static IsSafari(): boolean;
  119437. }
  119438. /**
  119439. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119440. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119441. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119442. * @param name The name of the class, case should be preserved
  119443. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119444. */
  119445. export function className(name: string, module?: string): (target: Object) => void;
  119446. /**
  119447. * An implementation of a loop for asynchronous functions.
  119448. */
  119449. export class AsyncLoop {
  119450. /**
  119451. * Defines the number of iterations for the loop
  119452. */
  119453. iterations: number;
  119454. /**
  119455. * Defines the current index of the loop.
  119456. */
  119457. index: number;
  119458. private _done;
  119459. private _fn;
  119460. private _successCallback;
  119461. /**
  119462. * Constructor.
  119463. * @param iterations the number of iterations.
  119464. * @param func the function to run each iteration
  119465. * @param successCallback the callback that will be called upon succesful execution
  119466. * @param offset starting offset.
  119467. */
  119468. constructor(
  119469. /**
  119470. * Defines the number of iterations for the loop
  119471. */
  119472. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119473. /**
  119474. * Execute the next iteration. Must be called after the last iteration was finished.
  119475. */
  119476. executeNext(): void;
  119477. /**
  119478. * Break the loop and run the success callback.
  119479. */
  119480. breakLoop(): void;
  119481. /**
  119482. * Create and run an async loop.
  119483. * @param iterations the number of iterations.
  119484. * @param fn the function to run each iteration
  119485. * @param successCallback the callback that will be called upon succesful execution
  119486. * @param offset starting offset.
  119487. * @returns the created async loop object
  119488. */
  119489. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119490. /**
  119491. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119492. * @param iterations total number of iterations
  119493. * @param syncedIterations number of synchronous iterations in each async iteration.
  119494. * @param fn the function to call each iteration.
  119495. * @param callback a success call back that will be called when iterating stops.
  119496. * @param breakFunction a break condition (optional)
  119497. * @param timeout timeout settings for the setTimeout function. default - 0.
  119498. * @returns the created async loop object
  119499. */
  119500. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119501. }
  119502. }
  119503. declare module BABYLON {
  119504. /**
  119505. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119506. * The underlying implementation relies on an associative array to ensure the best performances.
  119507. * The value can be anything including 'null' but except 'undefined'
  119508. */
  119509. export class StringDictionary<T> {
  119510. /**
  119511. * This will clear this dictionary and copy the content from the 'source' one.
  119512. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119513. * @param source the dictionary to take the content from and copy to this dictionary
  119514. */
  119515. copyFrom(source: StringDictionary<T>): void;
  119516. /**
  119517. * Get a value based from its key
  119518. * @param key the given key to get the matching value from
  119519. * @return the value if found, otherwise undefined is returned
  119520. */
  119521. get(key: string): T | undefined;
  119522. /**
  119523. * Get a value from its key or add it if it doesn't exist.
  119524. * This method will ensure you that a given key/data will be present in the dictionary.
  119525. * @param key the given key to get the matching value from
  119526. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119527. * The factory will only be invoked if there's no data for the given key.
  119528. * @return the value corresponding to the key.
  119529. */
  119530. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119531. /**
  119532. * Get a value from its key if present in the dictionary otherwise add it
  119533. * @param key the key to get the value from
  119534. * @param val if there's no such key/value pair in the dictionary add it with this value
  119535. * @return the value corresponding to the key
  119536. */
  119537. getOrAdd(key: string, val: T): T;
  119538. /**
  119539. * Check if there's a given key in the dictionary
  119540. * @param key the key to check for
  119541. * @return true if the key is present, false otherwise
  119542. */
  119543. contains(key: string): boolean;
  119544. /**
  119545. * Add a new key and its corresponding value
  119546. * @param key the key to add
  119547. * @param value the value corresponding to the key
  119548. * @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
  119549. */
  119550. add(key: string, value: T): boolean;
  119551. /**
  119552. * Update a specific value associated to a key
  119553. * @param key defines the key to use
  119554. * @param value defines the value to store
  119555. * @returns true if the value was updated (or false if the key was not found)
  119556. */
  119557. set(key: string, value: T): boolean;
  119558. /**
  119559. * Get the element of the given key and remove it from the dictionary
  119560. * @param key defines the key to search
  119561. * @returns the value associated with the key or null if not found
  119562. */
  119563. getAndRemove(key: string): Nullable<T>;
  119564. /**
  119565. * Remove a key/value from the dictionary.
  119566. * @param key the key to remove
  119567. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119568. */
  119569. remove(key: string): boolean;
  119570. /**
  119571. * Clear the whole content of the dictionary
  119572. */
  119573. clear(): void;
  119574. /**
  119575. * Gets the current count
  119576. */
  119577. get count(): number;
  119578. /**
  119579. * Execute a callback on each key/val of the dictionary.
  119580. * Note that you can remove any element in this dictionary in the callback implementation
  119581. * @param callback the callback to execute on a given key/value pair
  119582. */
  119583. forEach(callback: (key: string, val: T) => void): void;
  119584. /**
  119585. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119586. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119587. * Note that you can remove any element in this dictionary in the callback implementation
  119588. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119589. * @returns the first item
  119590. */
  119591. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119592. private _count;
  119593. private _data;
  119594. }
  119595. }
  119596. declare module BABYLON {
  119597. /** @hidden */
  119598. export interface ICollisionCoordinator {
  119599. createCollider(): Collider;
  119600. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119601. init(scene: Scene): void;
  119602. }
  119603. /** @hidden */
  119604. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119605. private _scene;
  119606. private _scaledPosition;
  119607. private _scaledVelocity;
  119608. private _finalPosition;
  119609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119610. createCollider(): Collider;
  119611. init(scene: Scene): void;
  119612. private _collideWithWorld;
  119613. }
  119614. }
  119615. declare module BABYLON {
  119616. /**
  119617. * Class used to manage all inputs for the scene.
  119618. */
  119619. export class InputManager {
  119620. /** The distance in pixel that you have to move to prevent some events */
  119621. static DragMovementThreshold: number;
  119622. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119623. static LongPressDelay: number;
  119624. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119625. static DoubleClickDelay: number;
  119626. /** If you need to check double click without raising a single click at first click, enable this flag */
  119627. static ExclusiveDoubleClickMode: boolean;
  119628. /** 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. */
  119629. private _alreadyAttached;
  119630. private _wheelEventName;
  119631. private _onPointerMove;
  119632. private _onPointerDown;
  119633. private _onPointerUp;
  119634. private _initClickEvent;
  119635. private _initActionManager;
  119636. private _delayedSimpleClick;
  119637. private _delayedSimpleClickTimeout;
  119638. private _previousDelayedSimpleClickTimeout;
  119639. private _meshPickProceed;
  119640. private _previousButtonPressed;
  119641. private _currentPickResult;
  119642. private _previousPickResult;
  119643. private _totalPointersPressed;
  119644. private _doubleClickOccured;
  119645. private _pointerOverMesh;
  119646. private _pickedDownMesh;
  119647. private _pickedUpMesh;
  119648. private _pointerX;
  119649. private _pointerY;
  119650. private _unTranslatedPointerX;
  119651. private _unTranslatedPointerY;
  119652. private _startingPointerPosition;
  119653. private _previousStartingPointerPosition;
  119654. private _startingPointerTime;
  119655. private _previousStartingPointerTime;
  119656. private _pointerCaptures;
  119657. private _meshUnderPointerId;
  119658. private _onKeyDown;
  119659. private _onKeyUp;
  119660. private _onCanvasFocusObserver;
  119661. private _onCanvasBlurObserver;
  119662. private _scene;
  119663. /**
  119664. * Creates a new InputManager
  119665. * @param scene defines the hosting scene
  119666. */
  119667. constructor(scene: Scene);
  119668. /**
  119669. * Gets the mesh that is currently under the pointer
  119670. */
  119671. get meshUnderPointer(): Nullable<AbstractMesh>;
  119672. /**
  119673. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119674. * @param pointerId the pointer id to use
  119675. * @returns The mesh under this pointer id or null if not found
  119676. */
  119677. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119678. /**
  119679. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119680. */
  119681. get unTranslatedPointer(): Vector2;
  119682. /**
  119683. * Gets or sets the current on-screen X position of the pointer
  119684. */
  119685. get pointerX(): number;
  119686. set pointerX(value: number);
  119687. /**
  119688. * Gets or sets the current on-screen Y position of the pointer
  119689. */
  119690. get pointerY(): number;
  119691. set pointerY(value: number);
  119692. private _updatePointerPosition;
  119693. private _processPointerMove;
  119694. private _setRayOnPointerInfo;
  119695. private _checkPrePointerObservable;
  119696. /**
  119697. * Use this method to simulate a pointer move on a mesh
  119698. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119699. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119700. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119701. */
  119702. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119703. /**
  119704. * Use this method to simulate a pointer down on a mesh
  119705. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119706. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119707. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119708. */
  119709. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119710. private _processPointerDown;
  119711. /** @hidden */
  119712. _isPointerSwiping(): boolean;
  119713. /**
  119714. * Use this method to simulate a pointer up on a mesh
  119715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119718. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119719. */
  119720. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119721. private _processPointerUp;
  119722. /**
  119723. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119724. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119725. * @returns true if the pointer was captured
  119726. */
  119727. isPointerCaptured(pointerId?: number): boolean;
  119728. /**
  119729. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119730. * @param attachUp defines if you want to attach events to pointerup
  119731. * @param attachDown defines if you want to attach events to pointerdown
  119732. * @param attachMove defines if you want to attach events to pointermove
  119733. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119734. */
  119735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119736. /**
  119737. * Detaches all event handlers
  119738. */
  119739. detachControl(): void;
  119740. /**
  119741. * Force the value of meshUnderPointer
  119742. * @param mesh defines the mesh to use
  119743. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119744. */
  119745. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119746. /**
  119747. * Gets the mesh under the pointer
  119748. * @returns a Mesh or null if no mesh is under the pointer
  119749. */
  119750. getPointerOverMesh(): Nullable<AbstractMesh>;
  119751. }
  119752. }
  119753. declare module BABYLON {
  119754. /**
  119755. * This class defines the direct association between an animation and a target
  119756. */
  119757. export class TargetedAnimation {
  119758. /**
  119759. * Animation to perform
  119760. */
  119761. animation: Animation;
  119762. /**
  119763. * Target to animate
  119764. */
  119765. target: any;
  119766. /**
  119767. * Returns the string "TargetedAnimation"
  119768. * @returns "TargetedAnimation"
  119769. */
  119770. getClassName(): string;
  119771. /**
  119772. * Serialize the object
  119773. * @returns the JSON object representing the current entity
  119774. */
  119775. serialize(): any;
  119776. }
  119777. /**
  119778. * Use this class to create coordinated animations on multiple targets
  119779. */
  119780. export class AnimationGroup implements IDisposable {
  119781. /** The name of the animation group */
  119782. name: string;
  119783. private _scene;
  119784. private _targetedAnimations;
  119785. private _animatables;
  119786. private _from;
  119787. private _to;
  119788. private _isStarted;
  119789. private _isPaused;
  119790. private _speedRatio;
  119791. private _loopAnimation;
  119792. private _isAdditive;
  119793. /**
  119794. * Gets or sets the unique id of the node
  119795. */
  119796. uniqueId: number;
  119797. /**
  119798. * This observable will notify when one animation have ended
  119799. */
  119800. onAnimationEndObservable: Observable<TargetedAnimation>;
  119801. /**
  119802. * Observer raised when one animation loops
  119803. */
  119804. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119805. /**
  119806. * Observer raised when all animations have looped
  119807. */
  119808. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119809. /**
  119810. * This observable will notify when all animations have ended.
  119811. */
  119812. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119813. /**
  119814. * This observable will notify when all animations have paused.
  119815. */
  119816. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119817. /**
  119818. * This observable will notify when all animations are playing.
  119819. */
  119820. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119821. /**
  119822. * Gets the first frame
  119823. */
  119824. get from(): number;
  119825. /**
  119826. * Gets the last frame
  119827. */
  119828. get to(): number;
  119829. /**
  119830. * Define if the animations are started
  119831. */
  119832. get isStarted(): boolean;
  119833. /**
  119834. * Gets a value indicating that the current group is playing
  119835. */
  119836. get isPlaying(): boolean;
  119837. /**
  119838. * Gets or sets the speed ratio to use for all animations
  119839. */
  119840. get speedRatio(): number;
  119841. /**
  119842. * Gets or sets the speed ratio to use for all animations
  119843. */
  119844. set speedRatio(value: number);
  119845. /**
  119846. * Gets or sets if all animations should loop or not
  119847. */
  119848. get loopAnimation(): boolean;
  119849. set loopAnimation(value: boolean);
  119850. /**
  119851. * Gets or sets if all animations should be evaluated additively
  119852. */
  119853. get isAdditive(): boolean;
  119854. set isAdditive(value: boolean);
  119855. /**
  119856. * Gets the targeted animations for this animation group
  119857. */
  119858. get targetedAnimations(): Array<TargetedAnimation>;
  119859. /**
  119860. * returning the list of animatables controlled by this animation group.
  119861. */
  119862. get animatables(): Array<Animatable>;
  119863. /**
  119864. * Gets the list of target animations
  119865. */
  119866. get children(): TargetedAnimation[];
  119867. /**
  119868. * Instantiates a new Animation Group.
  119869. * This helps managing several animations at once.
  119870. * @see https://doc.babylonjs.com/how_to/group
  119871. * @param name Defines the name of the group
  119872. * @param scene Defines the scene the group belongs to
  119873. */
  119874. constructor(
  119875. /** The name of the animation group */
  119876. name: string, scene?: Nullable<Scene>);
  119877. /**
  119878. * Add an animation (with its target) in the group
  119879. * @param animation defines the animation we want to add
  119880. * @param target defines the target of the animation
  119881. * @returns the TargetedAnimation object
  119882. */
  119883. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119884. /**
  119885. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119886. * It can add constant keys at begin or end
  119887. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119888. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119889. * @returns the animation group
  119890. */
  119891. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119892. private _animationLoopCount;
  119893. private _animationLoopFlags;
  119894. private _processLoop;
  119895. /**
  119896. * Start all animations on given targets
  119897. * @param loop defines if animations must loop
  119898. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119899. * @param from defines the from key (optional)
  119900. * @param to defines the to key (optional)
  119901. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119902. * @returns the current animation group
  119903. */
  119904. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119905. /**
  119906. * Pause all animations
  119907. * @returns the animation group
  119908. */
  119909. pause(): AnimationGroup;
  119910. /**
  119911. * Play all animations to initial state
  119912. * This function will start() the animations if they were not started or will restart() them if they were paused
  119913. * @param loop defines if animations must loop
  119914. * @returns the animation group
  119915. */
  119916. play(loop?: boolean): AnimationGroup;
  119917. /**
  119918. * Reset all animations to initial state
  119919. * @returns the animation group
  119920. */
  119921. reset(): AnimationGroup;
  119922. /**
  119923. * Restart animations from key 0
  119924. * @returns the animation group
  119925. */
  119926. restart(): AnimationGroup;
  119927. /**
  119928. * Stop all animations
  119929. * @returns the animation group
  119930. */
  119931. stop(): AnimationGroup;
  119932. /**
  119933. * Set animation weight for all animatables
  119934. * @param weight defines the weight to use
  119935. * @return the animationGroup
  119936. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119937. */
  119938. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119939. /**
  119940. * Synchronize and normalize all animatables with a source animatable
  119941. * @param root defines the root animatable to synchronize with
  119942. * @return the animationGroup
  119943. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119944. */
  119945. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119946. /**
  119947. * Goes to a specific frame in this animation group
  119948. * @param frame the frame number to go to
  119949. * @return the animationGroup
  119950. */
  119951. goToFrame(frame: number): AnimationGroup;
  119952. /**
  119953. * Dispose all associated resources
  119954. */
  119955. dispose(): void;
  119956. private _checkAnimationGroupEnded;
  119957. /**
  119958. * Clone the current animation group and returns a copy
  119959. * @param newName defines the name of the new group
  119960. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119961. * @returns the new aniamtion group
  119962. */
  119963. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119964. /**
  119965. * Serializes the animationGroup to an object
  119966. * @returns Serialized object
  119967. */
  119968. serialize(): any;
  119969. /**
  119970. * Returns a new AnimationGroup object parsed from the source provided.
  119971. * @param parsedAnimationGroup defines the source
  119972. * @param scene defines the scene that will receive the animationGroup
  119973. * @returns a new AnimationGroup
  119974. */
  119975. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119976. /**
  119977. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119978. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119979. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119980. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119981. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119982. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119983. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119984. */
  119985. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119986. /**
  119987. * Returns the string "AnimationGroup"
  119988. * @returns "AnimationGroup"
  119989. */
  119990. getClassName(): string;
  119991. /**
  119992. * Creates a detailled string about the object
  119993. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119994. * @returns a string representing the object
  119995. */
  119996. toString(fullDetails?: boolean): string;
  119997. }
  119998. }
  119999. declare module BABYLON {
  120000. /**
  120001. * Define an interface for all classes that will hold resources
  120002. */
  120003. export interface IDisposable {
  120004. /**
  120005. * Releases all held resources
  120006. */
  120007. dispose(): void;
  120008. }
  120009. /** Interface defining initialization parameters for Scene class */
  120010. export interface SceneOptions {
  120011. /**
  120012. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  120013. * It will improve performance when the number of geometries becomes important.
  120014. */
  120015. useGeometryUniqueIdsMap?: boolean;
  120016. /**
  120017. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  120018. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120019. */
  120020. useMaterialMeshMap?: boolean;
  120021. /**
  120022. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  120023. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120024. */
  120025. useClonedMeshMap?: boolean;
  120026. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  120027. virtual?: boolean;
  120028. }
  120029. /**
  120030. * Represents a scene to be rendered by the engine.
  120031. * @see https://doc.babylonjs.com/features/scene
  120032. */
  120033. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  120034. /** The fog is deactivated */
  120035. static readonly FOGMODE_NONE: number;
  120036. /** The fog density is following an exponential function */
  120037. static readonly FOGMODE_EXP: number;
  120038. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  120039. static readonly FOGMODE_EXP2: number;
  120040. /** The fog density is following a linear function. */
  120041. static readonly FOGMODE_LINEAR: number;
  120042. /**
  120043. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  120044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120045. */
  120046. static MinDeltaTime: number;
  120047. /**
  120048. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  120049. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120050. */
  120051. static MaxDeltaTime: number;
  120052. /**
  120053. * Factory used to create the default material.
  120054. * @param name The name of the material to create
  120055. * @param scene The scene to create the material for
  120056. * @returns The default material
  120057. */
  120058. static DefaultMaterialFactory(scene: Scene): Material;
  120059. /**
  120060. * Factory used to create the a collision coordinator.
  120061. * @returns The collision coordinator
  120062. */
  120063. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  120064. /** @hidden */
  120065. _inputManager: InputManager;
  120066. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  120067. cameraToUseForPointers: Nullable<Camera>;
  120068. /** @hidden */
  120069. readonly _isScene: boolean;
  120070. /** @hidden */
  120071. _blockEntityCollection: boolean;
  120072. /**
  120073. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  120074. */
  120075. autoClear: boolean;
  120076. /**
  120077. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  120078. */
  120079. autoClearDepthAndStencil: boolean;
  120080. /**
  120081. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  120082. */
  120083. clearColor: Color4;
  120084. /**
  120085. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  120086. */
  120087. ambientColor: Color3;
  120088. /**
  120089. * This is use to store the default BRDF lookup for PBR materials in your scene.
  120090. * It should only be one of the following (if not the default embedded one):
  120091. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  120092. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  120093. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  120094. * The material properties need to be setup according to the type of texture in use.
  120095. */
  120096. environmentBRDFTexture: BaseTexture;
  120097. /**
  120098. * Texture used in all pbr material as the reflection texture.
  120099. * As in the majority of the scene they are the same (exception for multi room and so on),
  120100. * this is easier to reference from here than from all the materials.
  120101. */
  120102. get environmentTexture(): Nullable<BaseTexture>;
  120103. /**
  120104. * Texture used in all pbr material as the reflection texture.
  120105. * As in the majority of the scene they are the same (exception for multi room and so on),
  120106. * this is easier to set here than in all the materials.
  120107. */
  120108. set environmentTexture(value: Nullable<BaseTexture>);
  120109. /** @hidden */
  120110. protected _environmentIntensity: number;
  120111. /**
  120112. * Intensity of the environment in all pbr material.
  120113. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120114. * As in the majority of the scene they are the same (exception for multi room and so on),
  120115. * this is easier to reference from here than from all the materials.
  120116. */
  120117. get environmentIntensity(): number;
  120118. /**
  120119. * Intensity of the environment in all pbr material.
  120120. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120121. * As in the majority of the scene they are the same (exception for multi room and so on),
  120122. * this is easier to set here than in all the materials.
  120123. */
  120124. set environmentIntensity(value: number);
  120125. /** @hidden */
  120126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120127. /**
  120128. * Default image processing configuration used either in the rendering
  120129. * Forward main pass or through the imageProcessingPostProcess if present.
  120130. * As in the majority of the scene they are the same (exception for multi camera),
  120131. * this is easier to reference from here than from all the materials and post process.
  120132. *
  120133. * No setter as we it is a shared configuration, you can set the values instead.
  120134. */
  120135. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  120136. private _forceWireframe;
  120137. /**
  120138. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  120139. */
  120140. set forceWireframe(value: boolean);
  120141. get forceWireframe(): boolean;
  120142. private _skipFrustumClipping;
  120143. /**
  120144. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  120145. */
  120146. set skipFrustumClipping(value: boolean);
  120147. get skipFrustumClipping(): boolean;
  120148. private _forcePointsCloud;
  120149. /**
  120150. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  120151. */
  120152. set forcePointsCloud(value: boolean);
  120153. get forcePointsCloud(): boolean;
  120154. /**
  120155. * Gets or sets the active clipplane 1
  120156. */
  120157. clipPlane: Nullable<Plane>;
  120158. /**
  120159. * Gets or sets the active clipplane 2
  120160. */
  120161. clipPlane2: Nullable<Plane>;
  120162. /**
  120163. * Gets or sets the active clipplane 3
  120164. */
  120165. clipPlane3: Nullable<Plane>;
  120166. /**
  120167. * Gets or sets the active clipplane 4
  120168. */
  120169. clipPlane4: Nullable<Plane>;
  120170. /**
  120171. * Gets or sets the active clipplane 5
  120172. */
  120173. clipPlane5: Nullable<Plane>;
  120174. /**
  120175. * Gets or sets the active clipplane 6
  120176. */
  120177. clipPlane6: Nullable<Plane>;
  120178. /**
  120179. * Gets or sets a boolean indicating if animations are enabled
  120180. */
  120181. animationsEnabled: boolean;
  120182. private _animationPropertiesOverride;
  120183. /**
  120184. * Gets or sets the animation properties override
  120185. */
  120186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  120187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  120188. /**
  120189. * Gets or sets a boolean indicating if a constant deltatime has to be used
  120190. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  120191. */
  120192. useConstantAnimationDeltaTime: boolean;
  120193. /**
  120194. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  120195. * Please note that it requires to run a ray cast through the scene on every frame
  120196. */
  120197. constantlyUpdateMeshUnderPointer: boolean;
  120198. /**
  120199. * Defines the HTML cursor to use when hovering over interactive elements
  120200. */
  120201. hoverCursor: string;
  120202. /**
  120203. * Defines the HTML default cursor to use (empty by default)
  120204. */
  120205. defaultCursor: string;
  120206. /**
  120207. * Defines whether cursors are handled by the scene.
  120208. */
  120209. doNotHandleCursors: boolean;
  120210. /**
  120211. * This is used to call preventDefault() on pointer down
  120212. * in order to block unwanted artifacts like system double clicks
  120213. */
  120214. preventDefaultOnPointerDown: boolean;
  120215. /**
  120216. * This is used to call preventDefault() on pointer up
  120217. * in order to block unwanted artifacts like system double clicks
  120218. */
  120219. preventDefaultOnPointerUp: boolean;
  120220. /**
  120221. * Gets or sets user defined metadata
  120222. */
  120223. metadata: any;
  120224. /**
  120225. * For internal use only. Please do not use.
  120226. */
  120227. reservedDataStore: any;
  120228. /**
  120229. * Gets the name of the plugin used to load this scene (null by default)
  120230. */
  120231. loadingPluginName: string;
  120232. /**
  120233. * Use this array to add regular expressions used to disable offline support for specific urls
  120234. */
  120235. disableOfflineSupportExceptionRules: RegExp[];
  120236. /**
  120237. * An event triggered when the scene is disposed.
  120238. */
  120239. onDisposeObservable: Observable<Scene>;
  120240. private _onDisposeObserver;
  120241. /** Sets a function to be executed when this scene is disposed. */
  120242. set onDispose(callback: () => void);
  120243. /**
  120244. * An event triggered before rendering the scene (right after animations and physics)
  120245. */
  120246. onBeforeRenderObservable: Observable<Scene>;
  120247. private _onBeforeRenderObserver;
  120248. /** Sets a function to be executed before rendering this scene */
  120249. set beforeRender(callback: Nullable<() => void>);
  120250. /**
  120251. * An event triggered after rendering the scene
  120252. */
  120253. onAfterRenderObservable: Observable<Scene>;
  120254. /**
  120255. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  120256. */
  120257. onAfterRenderCameraObservable: Observable<Camera>;
  120258. private _onAfterRenderObserver;
  120259. /** Sets a function to be executed after rendering this scene */
  120260. set afterRender(callback: Nullable<() => void>);
  120261. /**
  120262. * An event triggered before animating the scene
  120263. */
  120264. onBeforeAnimationsObservable: Observable<Scene>;
  120265. /**
  120266. * An event triggered after animations processing
  120267. */
  120268. onAfterAnimationsObservable: Observable<Scene>;
  120269. /**
  120270. * An event triggered before draw calls are ready to be sent
  120271. */
  120272. onBeforeDrawPhaseObservable: Observable<Scene>;
  120273. /**
  120274. * An event triggered after draw calls have been sent
  120275. */
  120276. onAfterDrawPhaseObservable: Observable<Scene>;
  120277. /**
  120278. * An event triggered when the scene is ready
  120279. */
  120280. onReadyObservable: Observable<Scene>;
  120281. /**
  120282. * An event triggered before rendering a camera
  120283. */
  120284. onBeforeCameraRenderObservable: Observable<Camera>;
  120285. private _onBeforeCameraRenderObserver;
  120286. /** Sets a function to be executed before rendering a camera*/
  120287. set beforeCameraRender(callback: () => void);
  120288. /**
  120289. * An event triggered after rendering a camera
  120290. */
  120291. onAfterCameraRenderObservable: Observable<Camera>;
  120292. private _onAfterCameraRenderObserver;
  120293. /** Sets a function to be executed after rendering a camera*/
  120294. set afterCameraRender(callback: () => void);
  120295. /**
  120296. * An event triggered when active meshes evaluation is about to start
  120297. */
  120298. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  120299. /**
  120300. * An event triggered when active meshes evaluation is done
  120301. */
  120302. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  120303. /**
  120304. * An event triggered when particles rendering is about to start
  120305. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120306. */
  120307. onBeforeParticlesRenderingObservable: Observable<Scene>;
  120308. /**
  120309. * An event triggered when particles rendering is done
  120310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120311. */
  120312. onAfterParticlesRenderingObservable: Observable<Scene>;
  120313. /**
  120314. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120315. */
  120316. onDataLoadedObservable: Observable<Scene>;
  120317. /**
  120318. * An event triggered when a camera is created
  120319. */
  120320. onNewCameraAddedObservable: Observable<Camera>;
  120321. /**
  120322. * An event triggered when a camera is removed
  120323. */
  120324. onCameraRemovedObservable: Observable<Camera>;
  120325. /**
  120326. * An event triggered when a light is created
  120327. */
  120328. onNewLightAddedObservable: Observable<Light>;
  120329. /**
  120330. * An event triggered when a light is removed
  120331. */
  120332. onLightRemovedObservable: Observable<Light>;
  120333. /**
  120334. * An event triggered when a geometry is created
  120335. */
  120336. onNewGeometryAddedObservable: Observable<Geometry>;
  120337. /**
  120338. * An event triggered when a geometry is removed
  120339. */
  120340. onGeometryRemovedObservable: Observable<Geometry>;
  120341. /**
  120342. * An event triggered when a transform node is created
  120343. */
  120344. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120345. /**
  120346. * An event triggered when a transform node is removed
  120347. */
  120348. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120349. /**
  120350. * An event triggered when a mesh is created
  120351. */
  120352. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120353. /**
  120354. * An event triggered when a mesh is removed
  120355. */
  120356. onMeshRemovedObservable: Observable<AbstractMesh>;
  120357. /**
  120358. * An event triggered when a skeleton is created
  120359. */
  120360. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120361. /**
  120362. * An event triggered when a skeleton is removed
  120363. */
  120364. onSkeletonRemovedObservable: Observable<Skeleton>;
  120365. /**
  120366. * An event triggered when a material is created
  120367. */
  120368. onNewMaterialAddedObservable: Observable<Material>;
  120369. /**
  120370. * An event triggered when a material is removed
  120371. */
  120372. onMaterialRemovedObservable: Observable<Material>;
  120373. /**
  120374. * An event triggered when a texture is created
  120375. */
  120376. onNewTextureAddedObservable: Observable<BaseTexture>;
  120377. /**
  120378. * An event triggered when a texture is removed
  120379. */
  120380. onTextureRemovedObservable: Observable<BaseTexture>;
  120381. /**
  120382. * An event triggered when render targets are about to be rendered
  120383. * Can happen multiple times per frame.
  120384. */
  120385. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120386. /**
  120387. * An event triggered when render targets were rendered.
  120388. * Can happen multiple times per frame.
  120389. */
  120390. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120391. /**
  120392. * An event triggered before calculating deterministic simulation step
  120393. */
  120394. onBeforeStepObservable: Observable<Scene>;
  120395. /**
  120396. * An event triggered after calculating deterministic simulation step
  120397. */
  120398. onAfterStepObservable: Observable<Scene>;
  120399. /**
  120400. * An event triggered when the activeCamera property is updated
  120401. */
  120402. onActiveCameraChanged: Observable<Scene>;
  120403. /**
  120404. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120405. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120406. * 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)
  120407. */
  120408. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120409. /**
  120410. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120411. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120412. * 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)
  120413. */
  120414. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120415. /**
  120416. * This Observable will when a mesh has been imported into the scene.
  120417. */
  120418. onMeshImportedObservable: Observable<AbstractMesh>;
  120419. /**
  120420. * This Observable will when an animation file has been imported into the scene.
  120421. */
  120422. onAnimationFileImportedObservable: Observable<Scene>;
  120423. /**
  120424. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120425. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120426. */
  120427. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120428. /** @hidden */
  120429. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120430. /**
  120431. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120432. */
  120433. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120434. /**
  120435. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120436. */
  120437. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120438. /**
  120439. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120440. */
  120441. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120442. /** Callback called when a pointer move is detected */
  120443. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120444. /** Callback called when a pointer down is detected */
  120445. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120446. /** Callback called when a pointer up is detected */
  120447. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120448. /** Callback called when a pointer pick is detected */
  120449. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120450. /**
  120451. * 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).
  120452. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120453. */
  120454. onPrePointerObservable: Observable<PointerInfoPre>;
  120455. /**
  120456. * Observable event triggered each time an input event is received from the rendering canvas
  120457. */
  120458. onPointerObservable: Observable<PointerInfo>;
  120459. /**
  120460. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120461. */
  120462. get unTranslatedPointer(): Vector2;
  120463. /**
  120464. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120465. */
  120466. static get DragMovementThreshold(): number;
  120467. static set DragMovementThreshold(value: number);
  120468. /**
  120469. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120470. */
  120471. static get LongPressDelay(): number;
  120472. static set LongPressDelay(value: number);
  120473. /**
  120474. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120475. */
  120476. static get DoubleClickDelay(): number;
  120477. static set DoubleClickDelay(value: number);
  120478. /** If you need to check double click without raising a single click at first click, enable this flag */
  120479. static get ExclusiveDoubleClickMode(): boolean;
  120480. static set ExclusiveDoubleClickMode(value: boolean);
  120481. /** @hidden */
  120482. _mirroredCameraPosition: Nullable<Vector3>;
  120483. /**
  120484. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120485. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120486. */
  120487. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120488. /**
  120489. * Observable event triggered each time an keyboard event is received from the hosting window
  120490. */
  120491. onKeyboardObservable: Observable<KeyboardInfo>;
  120492. private _useRightHandedSystem;
  120493. /**
  120494. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120495. */
  120496. set useRightHandedSystem(value: boolean);
  120497. get useRightHandedSystem(): boolean;
  120498. private _timeAccumulator;
  120499. private _currentStepId;
  120500. private _currentInternalStep;
  120501. /**
  120502. * Sets the step Id used by deterministic lock step
  120503. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120504. * @param newStepId defines the step Id
  120505. */
  120506. setStepId(newStepId: number): void;
  120507. /**
  120508. * Gets the step Id used by deterministic lock step
  120509. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120510. * @returns the step Id
  120511. */
  120512. getStepId(): number;
  120513. /**
  120514. * Gets the internal step used by deterministic lock step
  120515. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120516. * @returns the internal step
  120517. */
  120518. getInternalStep(): number;
  120519. private _fogEnabled;
  120520. /**
  120521. * Gets or sets a boolean indicating if fog is enabled on this scene
  120522. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120523. * (Default is true)
  120524. */
  120525. set fogEnabled(value: boolean);
  120526. get fogEnabled(): boolean;
  120527. private _fogMode;
  120528. /**
  120529. * Gets or sets the fog mode to use
  120530. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120531. * | mode | value |
  120532. * | --- | --- |
  120533. * | FOGMODE_NONE | 0 |
  120534. * | FOGMODE_EXP | 1 |
  120535. * | FOGMODE_EXP2 | 2 |
  120536. * | FOGMODE_LINEAR | 3 |
  120537. */
  120538. set fogMode(value: number);
  120539. get fogMode(): number;
  120540. /**
  120541. * Gets or sets the fog color to use
  120542. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120543. * (Default is Color3(0.2, 0.2, 0.3))
  120544. */
  120545. fogColor: Color3;
  120546. /**
  120547. * Gets or sets the fog density to use
  120548. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120549. * (Default is 0.1)
  120550. */
  120551. fogDensity: number;
  120552. /**
  120553. * Gets or sets the fog start distance to use
  120554. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120555. * (Default is 0)
  120556. */
  120557. fogStart: number;
  120558. /**
  120559. * Gets or sets the fog end distance to use
  120560. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120561. * (Default is 1000)
  120562. */
  120563. fogEnd: number;
  120564. /**
  120565. * Flag indicating that the frame buffer binding is handled by another component
  120566. */
  120567. prePass: boolean;
  120568. private _shadowsEnabled;
  120569. /**
  120570. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120571. */
  120572. set shadowsEnabled(value: boolean);
  120573. get shadowsEnabled(): boolean;
  120574. private _lightsEnabled;
  120575. /**
  120576. * Gets or sets a boolean indicating if lights are enabled on this scene
  120577. */
  120578. set lightsEnabled(value: boolean);
  120579. get lightsEnabled(): boolean;
  120580. /** All of the active cameras added to this scene. */
  120581. activeCameras: Camera[];
  120582. /** @hidden */
  120583. _activeCamera: Nullable<Camera>;
  120584. /** Gets or sets the current active camera */
  120585. get activeCamera(): Nullable<Camera>;
  120586. set activeCamera(value: Nullable<Camera>);
  120587. private _defaultMaterial;
  120588. /** The default material used on meshes when no material is affected */
  120589. get defaultMaterial(): Material;
  120590. /** The default material used on meshes when no material is affected */
  120591. set defaultMaterial(value: Material);
  120592. private _texturesEnabled;
  120593. /**
  120594. * Gets or sets a boolean indicating if textures are enabled on this scene
  120595. */
  120596. set texturesEnabled(value: boolean);
  120597. get texturesEnabled(): boolean;
  120598. /**
  120599. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120600. */
  120601. physicsEnabled: boolean;
  120602. /**
  120603. * Gets or sets a boolean indicating if particles are enabled on this scene
  120604. */
  120605. particlesEnabled: boolean;
  120606. /**
  120607. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120608. */
  120609. spritesEnabled: boolean;
  120610. private _skeletonsEnabled;
  120611. /**
  120612. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120613. */
  120614. set skeletonsEnabled(value: boolean);
  120615. get skeletonsEnabled(): boolean;
  120616. /**
  120617. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120618. */
  120619. lensFlaresEnabled: boolean;
  120620. /**
  120621. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120622. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120623. */
  120624. collisionsEnabled: boolean;
  120625. private _collisionCoordinator;
  120626. /** @hidden */
  120627. get collisionCoordinator(): ICollisionCoordinator;
  120628. /**
  120629. * Defines the gravity applied to this scene (used only for collisions)
  120630. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120631. */
  120632. gravity: Vector3;
  120633. /**
  120634. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120635. */
  120636. postProcessesEnabled: boolean;
  120637. /**
  120638. * Gets the current postprocess manager
  120639. */
  120640. postProcessManager: PostProcessManager;
  120641. /**
  120642. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120643. */
  120644. renderTargetsEnabled: boolean;
  120645. /**
  120646. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120647. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120648. */
  120649. dumpNextRenderTargets: boolean;
  120650. /**
  120651. * The list of user defined render targets added to the scene
  120652. */
  120653. customRenderTargets: RenderTargetTexture[];
  120654. /**
  120655. * Defines if texture loading must be delayed
  120656. * If true, textures will only be loaded when they need to be rendered
  120657. */
  120658. useDelayedTextureLoading: boolean;
  120659. /**
  120660. * Gets the list of meshes imported to the scene through SceneLoader
  120661. */
  120662. importedMeshesFiles: String[];
  120663. /**
  120664. * Gets or sets a boolean indicating if probes are enabled on this scene
  120665. */
  120666. probesEnabled: boolean;
  120667. /**
  120668. * Gets or sets the current offline provider to use to store scene data
  120669. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120670. */
  120671. offlineProvider: IOfflineProvider;
  120672. /**
  120673. * Gets or sets the action manager associated with the scene
  120674. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120675. */
  120676. actionManager: AbstractActionManager;
  120677. private _meshesForIntersections;
  120678. /**
  120679. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120680. */
  120681. proceduralTexturesEnabled: boolean;
  120682. private _engine;
  120683. private _totalVertices;
  120684. /** @hidden */
  120685. _activeIndices: PerfCounter;
  120686. /** @hidden */
  120687. _activeParticles: PerfCounter;
  120688. /** @hidden */
  120689. _activeBones: PerfCounter;
  120690. private _animationRatio;
  120691. /** @hidden */
  120692. _animationTimeLast: number;
  120693. /** @hidden */
  120694. _animationTime: number;
  120695. /**
  120696. * Gets or sets a general scale for animation speed
  120697. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120698. */
  120699. animationTimeScale: number;
  120700. /** @hidden */
  120701. _cachedMaterial: Nullable<Material>;
  120702. /** @hidden */
  120703. _cachedEffect: Nullable<Effect>;
  120704. /** @hidden */
  120705. _cachedVisibility: Nullable<number>;
  120706. private _renderId;
  120707. private _frameId;
  120708. private _executeWhenReadyTimeoutId;
  120709. private _intermediateRendering;
  120710. private _viewUpdateFlag;
  120711. private _projectionUpdateFlag;
  120712. /** @hidden */
  120713. _toBeDisposed: Nullable<IDisposable>[];
  120714. private _activeRequests;
  120715. /** @hidden */
  120716. _pendingData: any[];
  120717. private _isDisposed;
  120718. /**
  120719. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120720. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120721. */
  120722. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120723. private _activeMeshes;
  120724. private _processedMaterials;
  120725. private _renderTargets;
  120726. /** @hidden */
  120727. _activeParticleSystems: SmartArray<IParticleSystem>;
  120728. private _activeSkeletons;
  120729. private _softwareSkinnedMeshes;
  120730. private _renderingManager;
  120731. /** @hidden */
  120732. _activeAnimatables: Animatable[];
  120733. private _transformMatrix;
  120734. private _sceneUbo;
  120735. /** @hidden */
  120736. _viewMatrix: Matrix;
  120737. private _projectionMatrix;
  120738. /** @hidden */
  120739. _forcedViewPosition: Nullable<Vector3>;
  120740. /** @hidden */
  120741. _frustumPlanes: Plane[];
  120742. /**
  120743. * Gets the list of frustum planes (built from the active camera)
  120744. */
  120745. get frustumPlanes(): Plane[];
  120746. /**
  120747. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120748. * This is useful if there are more lights that the maximum simulteanous authorized
  120749. */
  120750. requireLightSorting: boolean;
  120751. /** @hidden */
  120752. readonly useMaterialMeshMap: boolean;
  120753. /** @hidden */
  120754. readonly useClonedMeshMap: boolean;
  120755. private _externalData;
  120756. private _uid;
  120757. /**
  120758. * @hidden
  120759. * Backing store of defined scene components.
  120760. */
  120761. _components: ISceneComponent[];
  120762. /**
  120763. * @hidden
  120764. * Backing store of defined scene components.
  120765. */
  120766. _serializableComponents: ISceneSerializableComponent[];
  120767. /**
  120768. * List of components to register on the next registration step.
  120769. */
  120770. private _transientComponents;
  120771. /**
  120772. * Registers the transient components if needed.
  120773. */
  120774. private _registerTransientComponents;
  120775. /**
  120776. * @hidden
  120777. * Add a component to the scene.
  120778. * Note that the ccomponent could be registered on th next frame if this is called after
  120779. * the register component stage.
  120780. * @param component Defines the component to add to the scene
  120781. */
  120782. _addComponent(component: ISceneComponent): void;
  120783. /**
  120784. * @hidden
  120785. * Gets a component from the scene.
  120786. * @param name defines the name of the component to retrieve
  120787. * @returns the component or null if not present
  120788. */
  120789. _getComponent(name: string): Nullable<ISceneComponent>;
  120790. /**
  120791. * @hidden
  120792. * Defines the actions happening before camera updates.
  120793. */
  120794. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120795. /**
  120796. * @hidden
  120797. * Defines the actions happening before clear the canvas.
  120798. */
  120799. _beforeClearStage: Stage<SimpleStageAction>;
  120800. /**
  120801. * @hidden
  120802. * Defines the actions when collecting render targets for the frame.
  120803. */
  120804. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120805. /**
  120806. * @hidden
  120807. * Defines the actions happening for one camera in the frame.
  120808. */
  120809. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120810. /**
  120811. * @hidden
  120812. * Defines the actions happening during the per mesh ready checks.
  120813. */
  120814. _isReadyForMeshStage: Stage<MeshStageAction>;
  120815. /**
  120816. * @hidden
  120817. * Defines the actions happening before evaluate active mesh checks.
  120818. */
  120819. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120820. /**
  120821. * @hidden
  120822. * Defines the actions happening during the evaluate sub mesh checks.
  120823. */
  120824. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120825. /**
  120826. * @hidden
  120827. * Defines the actions happening during the active mesh stage.
  120828. */
  120829. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120830. /**
  120831. * @hidden
  120832. * Defines the actions happening during the per camera render target step.
  120833. */
  120834. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120835. /**
  120836. * @hidden
  120837. * Defines the actions happening just before the active camera is drawing.
  120838. */
  120839. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120840. /**
  120841. * @hidden
  120842. * Defines the actions happening just before a render target is drawing.
  120843. */
  120844. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120845. /**
  120846. * @hidden
  120847. * Defines the actions happening just before a rendering group is drawing.
  120848. */
  120849. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120850. /**
  120851. * @hidden
  120852. * Defines the actions happening just before a mesh is drawing.
  120853. */
  120854. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120855. /**
  120856. * @hidden
  120857. * Defines the actions happening just after a mesh has been drawn.
  120858. */
  120859. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120860. /**
  120861. * @hidden
  120862. * Defines the actions happening just after a rendering group has been drawn.
  120863. */
  120864. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120865. /**
  120866. * @hidden
  120867. * Defines the actions happening just after the active camera has been drawn.
  120868. */
  120869. _afterCameraDrawStage: Stage<CameraStageAction>;
  120870. /**
  120871. * @hidden
  120872. * Defines the actions happening just after a render target has been drawn.
  120873. */
  120874. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120875. /**
  120876. * @hidden
  120877. * Defines the actions happening just after rendering all cameras and computing intersections.
  120878. */
  120879. _afterRenderStage: Stage<SimpleStageAction>;
  120880. /**
  120881. * @hidden
  120882. * Defines the actions happening when a pointer move event happens.
  120883. */
  120884. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120885. /**
  120886. * @hidden
  120887. * Defines the actions happening when a pointer down event happens.
  120888. */
  120889. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120890. /**
  120891. * @hidden
  120892. * Defines the actions happening when a pointer up event happens.
  120893. */
  120894. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120895. /**
  120896. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120897. */
  120898. private geometriesByUniqueId;
  120899. /**
  120900. * Creates a new Scene
  120901. * @param engine defines the engine to use to render this scene
  120902. * @param options defines the scene options
  120903. */
  120904. constructor(engine: Engine, options?: SceneOptions);
  120905. /**
  120906. * Gets a string identifying the name of the class
  120907. * @returns "Scene" string
  120908. */
  120909. getClassName(): string;
  120910. private _defaultMeshCandidates;
  120911. /**
  120912. * @hidden
  120913. */
  120914. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120915. private _defaultSubMeshCandidates;
  120916. /**
  120917. * @hidden
  120918. */
  120919. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120920. /**
  120921. * Sets the default candidate providers for the scene.
  120922. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120923. * and getCollidingSubMeshCandidates to their default function
  120924. */
  120925. setDefaultCandidateProviders(): void;
  120926. /**
  120927. * Gets the mesh that is currently under the pointer
  120928. */
  120929. get meshUnderPointer(): Nullable<AbstractMesh>;
  120930. /**
  120931. * Gets or sets the current on-screen X position of the pointer
  120932. */
  120933. get pointerX(): number;
  120934. set pointerX(value: number);
  120935. /**
  120936. * Gets or sets the current on-screen Y position of the pointer
  120937. */
  120938. get pointerY(): number;
  120939. set pointerY(value: number);
  120940. /**
  120941. * Gets the cached material (ie. the latest rendered one)
  120942. * @returns the cached material
  120943. */
  120944. getCachedMaterial(): Nullable<Material>;
  120945. /**
  120946. * Gets the cached effect (ie. the latest rendered one)
  120947. * @returns the cached effect
  120948. */
  120949. getCachedEffect(): Nullable<Effect>;
  120950. /**
  120951. * Gets the cached visibility state (ie. the latest rendered one)
  120952. * @returns the cached visibility state
  120953. */
  120954. getCachedVisibility(): Nullable<number>;
  120955. /**
  120956. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120957. * @param material defines the current material
  120958. * @param effect defines the current effect
  120959. * @param visibility defines the current visibility state
  120960. * @returns true if one parameter is not cached
  120961. */
  120962. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120963. /**
  120964. * Gets the engine associated with the scene
  120965. * @returns an Engine
  120966. */
  120967. getEngine(): Engine;
  120968. /**
  120969. * Gets the total number of vertices rendered per frame
  120970. * @returns the total number of vertices rendered per frame
  120971. */
  120972. getTotalVertices(): number;
  120973. /**
  120974. * Gets the performance counter for total vertices
  120975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120976. */
  120977. get totalVerticesPerfCounter(): PerfCounter;
  120978. /**
  120979. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120980. * @returns the total number of active indices rendered per frame
  120981. */
  120982. getActiveIndices(): number;
  120983. /**
  120984. * Gets the performance counter for active indices
  120985. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120986. */
  120987. get totalActiveIndicesPerfCounter(): PerfCounter;
  120988. /**
  120989. * Gets the total number of active particles rendered per frame
  120990. * @returns the total number of active particles rendered per frame
  120991. */
  120992. getActiveParticles(): number;
  120993. /**
  120994. * Gets the performance counter for active particles
  120995. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120996. */
  120997. get activeParticlesPerfCounter(): PerfCounter;
  120998. /**
  120999. * Gets the total number of active bones rendered per frame
  121000. * @returns the total number of active bones rendered per frame
  121001. */
  121002. getActiveBones(): number;
  121003. /**
  121004. * Gets the performance counter for active bones
  121005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121006. */
  121007. get activeBonesPerfCounter(): PerfCounter;
  121008. /**
  121009. * Gets the array of active meshes
  121010. * @returns an array of AbstractMesh
  121011. */
  121012. getActiveMeshes(): SmartArray<AbstractMesh>;
  121013. /**
  121014. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  121015. * @returns a number
  121016. */
  121017. getAnimationRatio(): number;
  121018. /**
  121019. * Gets an unique Id for the current render phase
  121020. * @returns a number
  121021. */
  121022. getRenderId(): number;
  121023. /**
  121024. * Gets an unique Id for the current frame
  121025. * @returns a number
  121026. */
  121027. getFrameId(): number;
  121028. /** Call this function if you want to manually increment the render Id*/
  121029. incrementRenderId(): void;
  121030. private _createUbo;
  121031. /**
  121032. * Use this method to simulate a pointer move on a mesh
  121033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121036. * @returns the current scene
  121037. */
  121038. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121039. /**
  121040. * Use this method to simulate a pointer down on a mesh
  121041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121044. * @returns the current scene
  121045. */
  121046. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121047. /**
  121048. * Use this method to simulate a pointer up on a mesh
  121049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121052. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  121053. * @returns the current scene
  121054. */
  121055. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  121056. /**
  121057. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  121058. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  121059. * @returns true if the pointer was captured
  121060. */
  121061. isPointerCaptured(pointerId?: number): boolean;
  121062. /**
  121063. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  121064. * @param attachUp defines if you want to attach events to pointerup
  121065. * @param attachDown defines if you want to attach events to pointerdown
  121066. * @param attachMove defines if you want to attach events to pointermove
  121067. */
  121068. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  121069. /** Detaches all event handlers*/
  121070. detachControl(): void;
  121071. /**
  121072. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  121073. * Delay loaded resources are not taking in account
  121074. * @return true if all required resources are ready
  121075. */
  121076. isReady(): boolean;
  121077. /** Resets all cached information relative to material (including effect and visibility) */
  121078. resetCachedMaterial(): void;
  121079. /**
  121080. * Registers a function to be called before every frame render
  121081. * @param func defines the function to register
  121082. */
  121083. registerBeforeRender(func: () => void): void;
  121084. /**
  121085. * Unregisters a function called before every frame render
  121086. * @param func defines the function to unregister
  121087. */
  121088. unregisterBeforeRender(func: () => void): void;
  121089. /**
  121090. * Registers a function to be called after every frame render
  121091. * @param func defines the function to register
  121092. */
  121093. registerAfterRender(func: () => void): void;
  121094. /**
  121095. * Unregisters a function called after every frame render
  121096. * @param func defines the function to unregister
  121097. */
  121098. unregisterAfterRender(func: () => void): void;
  121099. private _executeOnceBeforeRender;
  121100. /**
  121101. * The provided function will run before render once and will be disposed afterwards.
  121102. * A timeout delay can be provided so that the function will be executed in N ms.
  121103. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  121104. * @param func The function to be executed.
  121105. * @param timeout optional delay in ms
  121106. */
  121107. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  121108. /** @hidden */
  121109. _addPendingData(data: any): void;
  121110. /** @hidden */
  121111. _removePendingData(data: any): void;
  121112. /**
  121113. * Returns the number of items waiting to be loaded
  121114. * @returns the number of items waiting to be loaded
  121115. */
  121116. getWaitingItemsCount(): number;
  121117. /**
  121118. * Returns a boolean indicating if the scene is still loading data
  121119. */
  121120. get isLoading(): boolean;
  121121. /**
  121122. * Registers a function to be executed when the scene is ready
  121123. * @param {Function} func - the function to be executed
  121124. */
  121125. executeWhenReady(func: () => void): void;
  121126. /**
  121127. * Returns a promise that resolves when the scene is ready
  121128. * @returns A promise that resolves when the scene is ready
  121129. */
  121130. whenReadyAsync(): Promise<void>;
  121131. /** @hidden */
  121132. _checkIsReady(): void;
  121133. /**
  121134. * Gets all animatable attached to the scene
  121135. */
  121136. get animatables(): Animatable[];
  121137. /**
  121138. * Resets the last animation time frame.
  121139. * Useful to override when animations start running when loading a scene for the first time.
  121140. */
  121141. resetLastAnimationTimeFrame(): void;
  121142. /**
  121143. * Gets the current view matrix
  121144. * @returns a Matrix
  121145. */
  121146. getViewMatrix(): Matrix;
  121147. /**
  121148. * Gets the current projection matrix
  121149. * @returns a Matrix
  121150. */
  121151. getProjectionMatrix(): Matrix;
  121152. /**
  121153. * Gets the current transform matrix
  121154. * @returns a Matrix made of View * Projection
  121155. */
  121156. getTransformMatrix(): Matrix;
  121157. /**
  121158. * Sets the current transform matrix
  121159. * @param viewL defines the View matrix to use
  121160. * @param projectionL defines the Projection matrix to use
  121161. * @param viewR defines the right View matrix to use (if provided)
  121162. * @param projectionR defines the right Projection matrix to use (if provided)
  121163. */
  121164. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  121165. /**
  121166. * Gets the uniform buffer used to store scene data
  121167. * @returns a UniformBuffer
  121168. */
  121169. getSceneUniformBuffer(): UniformBuffer;
  121170. /**
  121171. * Gets an unique (relatively to the current scene) Id
  121172. * @returns an unique number for the scene
  121173. */
  121174. getUniqueId(): number;
  121175. /**
  121176. * Add a mesh to the list of scene's meshes
  121177. * @param newMesh defines the mesh to add
  121178. * @param recursive if all child meshes should also be added to the scene
  121179. */
  121180. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  121181. /**
  121182. * Remove a mesh for the list of scene's meshes
  121183. * @param toRemove defines the mesh to remove
  121184. * @param recursive if all child meshes should also be removed from the scene
  121185. * @returns the index where the mesh was in the mesh list
  121186. */
  121187. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  121188. /**
  121189. * Add a transform node to the list of scene's transform nodes
  121190. * @param newTransformNode defines the transform node to add
  121191. */
  121192. addTransformNode(newTransformNode: TransformNode): void;
  121193. /**
  121194. * Remove a transform node for the list of scene's transform nodes
  121195. * @param toRemove defines the transform node to remove
  121196. * @returns the index where the transform node was in the transform node list
  121197. */
  121198. removeTransformNode(toRemove: TransformNode): number;
  121199. /**
  121200. * Remove a skeleton for the list of scene's skeletons
  121201. * @param toRemove defines the skeleton to remove
  121202. * @returns the index where the skeleton was in the skeleton list
  121203. */
  121204. removeSkeleton(toRemove: Skeleton): number;
  121205. /**
  121206. * Remove a morph target for the list of scene's morph targets
  121207. * @param toRemove defines the morph target to remove
  121208. * @returns the index where the morph target was in the morph target list
  121209. */
  121210. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  121211. /**
  121212. * Remove a light for the list of scene's lights
  121213. * @param toRemove defines the light to remove
  121214. * @returns the index where the light was in the light list
  121215. */
  121216. removeLight(toRemove: Light): number;
  121217. /**
  121218. * Remove a camera for the list of scene's cameras
  121219. * @param toRemove defines the camera to remove
  121220. * @returns the index where the camera was in the camera list
  121221. */
  121222. removeCamera(toRemove: Camera): number;
  121223. /**
  121224. * Remove a particle system for the list of scene's particle systems
  121225. * @param toRemove defines the particle system to remove
  121226. * @returns the index where the particle system was in the particle system list
  121227. */
  121228. removeParticleSystem(toRemove: IParticleSystem): number;
  121229. /**
  121230. * Remove a animation for the list of scene's animations
  121231. * @param toRemove defines the animation to remove
  121232. * @returns the index where the animation was in the animation list
  121233. */
  121234. removeAnimation(toRemove: Animation): number;
  121235. /**
  121236. * Will stop the animation of the given target
  121237. * @param target - the target
  121238. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  121239. * @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)
  121240. */
  121241. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  121242. /**
  121243. * Removes the given animation group from this scene.
  121244. * @param toRemove The animation group to remove
  121245. * @returns The index of the removed animation group
  121246. */
  121247. removeAnimationGroup(toRemove: AnimationGroup): number;
  121248. /**
  121249. * Removes the given multi-material from this scene.
  121250. * @param toRemove The multi-material to remove
  121251. * @returns The index of the removed multi-material
  121252. */
  121253. removeMultiMaterial(toRemove: MultiMaterial): number;
  121254. /**
  121255. * Removes the given material from this scene.
  121256. * @param toRemove The material to remove
  121257. * @returns The index of the removed material
  121258. */
  121259. removeMaterial(toRemove: Material): number;
  121260. /**
  121261. * Removes the given action manager from this scene.
  121262. * @param toRemove The action manager to remove
  121263. * @returns The index of the removed action manager
  121264. */
  121265. removeActionManager(toRemove: AbstractActionManager): number;
  121266. /**
  121267. * Removes the given texture from this scene.
  121268. * @param toRemove The texture to remove
  121269. * @returns The index of the removed texture
  121270. */
  121271. removeTexture(toRemove: BaseTexture): number;
  121272. /**
  121273. * Adds the given light to this scene
  121274. * @param newLight The light to add
  121275. */
  121276. addLight(newLight: Light): void;
  121277. /**
  121278. * Sorts the list list based on light priorities
  121279. */
  121280. sortLightsByPriority(): void;
  121281. /**
  121282. * Adds the given camera to this scene
  121283. * @param newCamera The camera to add
  121284. */
  121285. addCamera(newCamera: Camera): void;
  121286. /**
  121287. * Adds the given skeleton to this scene
  121288. * @param newSkeleton The skeleton to add
  121289. */
  121290. addSkeleton(newSkeleton: Skeleton): void;
  121291. /**
  121292. * Adds the given particle system to this scene
  121293. * @param newParticleSystem The particle system to add
  121294. */
  121295. addParticleSystem(newParticleSystem: IParticleSystem): void;
  121296. /**
  121297. * Adds the given animation to this scene
  121298. * @param newAnimation The animation to add
  121299. */
  121300. addAnimation(newAnimation: Animation): void;
  121301. /**
  121302. * Adds the given animation group to this scene.
  121303. * @param newAnimationGroup The animation group to add
  121304. */
  121305. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  121306. /**
  121307. * Adds the given multi-material to this scene
  121308. * @param newMultiMaterial The multi-material to add
  121309. */
  121310. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  121311. /**
  121312. * Adds the given material to this scene
  121313. * @param newMaterial The material to add
  121314. */
  121315. addMaterial(newMaterial: Material): void;
  121316. /**
  121317. * Adds the given morph target to this scene
  121318. * @param newMorphTargetManager The morph target to add
  121319. */
  121320. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121321. /**
  121322. * Adds the given geometry to this scene
  121323. * @param newGeometry The geometry to add
  121324. */
  121325. addGeometry(newGeometry: Geometry): void;
  121326. /**
  121327. * Adds the given action manager to this scene
  121328. * @param newActionManager The action manager to add
  121329. */
  121330. addActionManager(newActionManager: AbstractActionManager): void;
  121331. /**
  121332. * Adds the given texture to this scene.
  121333. * @param newTexture The texture to add
  121334. */
  121335. addTexture(newTexture: BaseTexture): void;
  121336. /**
  121337. * Switch active camera
  121338. * @param newCamera defines the new active camera
  121339. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121340. */
  121341. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121342. /**
  121343. * sets the active camera of the scene using its ID
  121344. * @param id defines the camera's ID
  121345. * @return the new active camera or null if none found.
  121346. */
  121347. setActiveCameraByID(id: string): Nullable<Camera>;
  121348. /**
  121349. * sets the active camera of the scene using its name
  121350. * @param name defines the camera's name
  121351. * @returns the new active camera or null if none found.
  121352. */
  121353. setActiveCameraByName(name: string): Nullable<Camera>;
  121354. /**
  121355. * get an animation group using its name
  121356. * @param name defines the material's name
  121357. * @return the animation group or null if none found.
  121358. */
  121359. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121360. /**
  121361. * Get a material using its unique id
  121362. * @param uniqueId defines the material's unique id
  121363. * @return the material or null if none found.
  121364. */
  121365. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121366. /**
  121367. * get a material using its id
  121368. * @param id defines the material's ID
  121369. * @return the material or null if none found.
  121370. */
  121371. getMaterialByID(id: string): Nullable<Material>;
  121372. /**
  121373. * Gets a the last added material using a given id
  121374. * @param id defines the material's ID
  121375. * @return the last material with the given id or null if none found.
  121376. */
  121377. getLastMaterialByID(id: string): Nullable<Material>;
  121378. /**
  121379. * Gets a material using its name
  121380. * @param name defines the material's name
  121381. * @return the material or null if none found.
  121382. */
  121383. getMaterialByName(name: string): Nullable<Material>;
  121384. /**
  121385. * Get a texture using its unique id
  121386. * @param uniqueId defines the texture's unique id
  121387. * @return the texture or null if none found.
  121388. */
  121389. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121390. /**
  121391. * Gets a camera using its id
  121392. * @param id defines the id to look for
  121393. * @returns the camera or null if not found
  121394. */
  121395. getCameraByID(id: string): Nullable<Camera>;
  121396. /**
  121397. * Gets a camera using its unique id
  121398. * @param uniqueId defines the unique id to look for
  121399. * @returns the camera or null if not found
  121400. */
  121401. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121402. /**
  121403. * Gets a camera using its name
  121404. * @param name defines the camera's name
  121405. * @return the camera or null if none found.
  121406. */
  121407. getCameraByName(name: string): Nullable<Camera>;
  121408. /**
  121409. * Gets a bone using its id
  121410. * @param id defines the bone's id
  121411. * @return the bone or null if not found
  121412. */
  121413. getBoneByID(id: string): Nullable<Bone>;
  121414. /**
  121415. * Gets a bone using its id
  121416. * @param name defines the bone's name
  121417. * @return the bone or null if not found
  121418. */
  121419. getBoneByName(name: string): Nullable<Bone>;
  121420. /**
  121421. * Gets a light node using its name
  121422. * @param name defines the the light's name
  121423. * @return the light or null if none found.
  121424. */
  121425. getLightByName(name: string): Nullable<Light>;
  121426. /**
  121427. * Gets a light node using its id
  121428. * @param id defines the light's id
  121429. * @return the light or null if none found.
  121430. */
  121431. getLightByID(id: string): Nullable<Light>;
  121432. /**
  121433. * Gets a light node using its scene-generated unique ID
  121434. * @param uniqueId defines the light's unique id
  121435. * @return the light or null if none found.
  121436. */
  121437. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121438. /**
  121439. * Gets a particle system by id
  121440. * @param id defines the particle system id
  121441. * @return the corresponding system or null if none found
  121442. */
  121443. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121444. /**
  121445. * Gets a geometry using its ID
  121446. * @param id defines the geometry's id
  121447. * @return the geometry or null if none found.
  121448. */
  121449. getGeometryByID(id: string): Nullable<Geometry>;
  121450. private _getGeometryByUniqueID;
  121451. /**
  121452. * Add a new geometry to this scene
  121453. * @param geometry defines the geometry to be added to the scene.
  121454. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121455. * @return a boolean defining if the geometry was added or not
  121456. */
  121457. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121458. /**
  121459. * Removes an existing geometry
  121460. * @param geometry defines the geometry to be removed from the scene
  121461. * @return a boolean defining if the geometry was removed or not
  121462. */
  121463. removeGeometry(geometry: Geometry): boolean;
  121464. /**
  121465. * Gets the list of geometries attached to the scene
  121466. * @returns an array of Geometry
  121467. */
  121468. getGeometries(): Geometry[];
  121469. /**
  121470. * Gets the first added mesh found of a given ID
  121471. * @param id defines the id to search for
  121472. * @return the mesh found or null if not found at all
  121473. */
  121474. getMeshByID(id: string): Nullable<AbstractMesh>;
  121475. /**
  121476. * Gets a list of meshes using their id
  121477. * @param id defines the id to search for
  121478. * @returns a list of meshes
  121479. */
  121480. getMeshesByID(id: string): Array<AbstractMesh>;
  121481. /**
  121482. * Gets the first added transform node found of a given ID
  121483. * @param id defines the id to search for
  121484. * @return the found transform node or null if not found at all.
  121485. */
  121486. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121487. /**
  121488. * Gets a transform node with its auto-generated unique id
  121489. * @param uniqueId efines the unique id to search for
  121490. * @return the found transform node or null if not found at all.
  121491. */
  121492. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121493. /**
  121494. * Gets a list of transform nodes using their id
  121495. * @param id defines the id to search for
  121496. * @returns a list of transform nodes
  121497. */
  121498. getTransformNodesByID(id: string): Array<TransformNode>;
  121499. /**
  121500. * Gets a mesh with its auto-generated unique id
  121501. * @param uniqueId defines the unique id to search for
  121502. * @return the found mesh or null if not found at all.
  121503. */
  121504. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121505. /**
  121506. * Gets a the last added mesh using a given id
  121507. * @param id defines the id to search for
  121508. * @return the found mesh or null if not found at all.
  121509. */
  121510. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121511. /**
  121512. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121513. * @param id defines the id to search for
  121514. * @return the found node or null if not found at all
  121515. */
  121516. getLastEntryByID(id: string): Nullable<Node>;
  121517. /**
  121518. * Gets a node (Mesh, Camera, Light) using a given id
  121519. * @param id defines the id to search for
  121520. * @return the found node or null if not found at all
  121521. */
  121522. getNodeByID(id: string): Nullable<Node>;
  121523. /**
  121524. * Gets a node (Mesh, Camera, Light) using a given name
  121525. * @param name defines the name to search for
  121526. * @return the found node or null if not found at all.
  121527. */
  121528. getNodeByName(name: string): Nullable<Node>;
  121529. /**
  121530. * Gets a mesh using a given name
  121531. * @param name defines the name to search for
  121532. * @return the found mesh or null if not found at all.
  121533. */
  121534. getMeshByName(name: string): Nullable<AbstractMesh>;
  121535. /**
  121536. * Gets a transform node using a given name
  121537. * @param name defines the name to search for
  121538. * @return the found transform node or null if not found at all.
  121539. */
  121540. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121541. /**
  121542. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121543. * @param id defines the id to search for
  121544. * @return the found skeleton or null if not found at all.
  121545. */
  121546. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121547. /**
  121548. * Gets a skeleton using a given auto generated unique id
  121549. * @param uniqueId defines the unique id to search for
  121550. * @return the found skeleton or null if not found at all.
  121551. */
  121552. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121553. /**
  121554. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121555. * @param id defines the id to search for
  121556. * @return the found skeleton or null if not found at all.
  121557. */
  121558. getSkeletonById(id: string): Nullable<Skeleton>;
  121559. /**
  121560. * Gets a skeleton using a given name
  121561. * @param name defines the name to search for
  121562. * @return the found skeleton or null if not found at all.
  121563. */
  121564. getSkeletonByName(name: string): Nullable<Skeleton>;
  121565. /**
  121566. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121567. * @param id defines the id to search for
  121568. * @return the found morph target manager or null if not found at all.
  121569. */
  121570. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121571. /**
  121572. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121573. * @param id defines the id to search for
  121574. * @return the found morph target or null if not found at all.
  121575. */
  121576. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121577. /**
  121578. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121579. * @param name defines the name to search for
  121580. * @return the found morph target or null if not found at all.
  121581. */
  121582. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121583. /**
  121584. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121585. * @param name defines the name to search for
  121586. * @return the found post process or null if not found at all.
  121587. */
  121588. getPostProcessByName(name: string): Nullable<PostProcess>;
  121589. /**
  121590. * Gets a boolean indicating if the given mesh is active
  121591. * @param mesh defines the mesh to look for
  121592. * @returns true if the mesh is in the active list
  121593. */
  121594. isActiveMesh(mesh: AbstractMesh): boolean;
  121595. /**
  121596. * Return a unique id as a string which can serve as an identifier for the scene
  121597. */
  121598. get uid(): string;
  121599. /**
  121600. * Add an externaly attached data from its key.
  121601. * This method call will fail and return false, if such key already exists.
  121602. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121603. * @param key the unique key that identifies the data
  121604. * @param data the data object to associate to the key for this Engine instance
  121605. * @return true if no such key were already present and the data was added successfully, false otherwise
  121606. */
  121607. addExternalData<T>(key: string, data: T): boolean;
  121608. /**
  121609. * Get an externaly attached data from its key
  121610. * @param key the unique key that identifies the data
  121611. * @return the associated data, if present (can be null), or undefined if not present
  121612. */
  121613. getExternalData<T>(key: string): Nullable<T>;
  121614. /**
  121615. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121616. * @param key the unique key that identifies the data
  121617. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121618. * @return the associated data, can be null if the factory returned null.
  121619. */
  121620. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121621. /**
  121622. * Remove an externaly attached data from the Engine instance
  121623. * @param key the unique key that identifies the data
  121624. * @return true if the data was successfully removed, false if it doesn't exist
  121625. */
  121626. removeExternalData(key: string): boolean;
  121627. private _evaluateSubMesh;
  121628. /**
  121629. * Clear the processed materials smart array preventing retention point in material dispose.
  121630. */
  121631. freeProcessedMaterials(): void;
  121632. private _preventFreeActiveMeshesAndRenderingGroups;
  121633. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121634. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121635. * when disposing several meshes in a row or a hierarchy of meshes.
  121636. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121637. */
  121638. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121639. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121640. /**
  121641. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121642. */
  121643. freeActiveMeshes(): void;
  121644. /**
  121645. * Clear the info related to rendering groups preventing retention points during dispose.
  121646. */
  121647. freeRenderingGroups(): void;
  121648. /** @hidden */
  121649. _isInIntermediateRendering(): boolean;
  121650. /**
  121651. * Lambda returning the list of potentially active meshes.
  121652. */
  121653. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121654. /**
  121655. * Lambda returning the list of potentially active sub meshes.
  121656. */
  121657. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121658. /**
  121659. * Lambda returning the list of potentially intersecting sub meshes.
  121660. */
  121661. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121662. /**
  121663. * Lambda returning the list of potentially colliding sub meshes.
  121664. */
  121665. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121666. private _activeMeshesFrozen;
  121667. private _skipEvaluateActiveMeshesCompletely;
  121668. /**
  121669. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121670. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121671. * @returns the current scene
  121672. */
  121673. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121674. /**
  121675. * Use this function to restart evaluating active meshes on every frame
  121676. * @returns the current scene
  121677. */
  121678. unfreezeActiveMeshes(): Scene;
  121679. private _evaluateActiveMeshes;
  121680. private _activeMesh;
  121681. /**
  121682. * Update the transform matrix to update from the current active camera
  121683. * @param force defines a boolean used to force the update even if cache is up to date
  121684. */
  121685. updateTransformMatrix(force?: boolean): void;
  121686. private _bindFrameBuffer;
  121687. /** @hidden */
  121688. _allowPostProcessClearColor: boolean;
  121689. /** @hidden */
  121690. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121691. private _processSubCameras;
  121692. private _checkIntersections;
  121693. /** @hidden */
  121694. _advancePhysicsEngineStep(step: number): void;
  121695. /**
  121696. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121697. */
  121698. getDeterministicFrameTime: () => number;
  121699. /** @hidden */
  121700. _animate(): void;
  121701. /** Execute all animations (for a frame) */
  121702. animate(): void;
  121703. /**
  121704. * Render the scene
  121705. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121706. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121707. */
  121708. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121709. /**
  121710. * Freeze all materials
  121711. * A frozen material will not be updatable but should be faster to render
  121712. */
  121713. freezeMaterials(): void;
  121714. /**
  121715. * Unfreeze all materials
  121716. * A frozen material will not be updatable but should be faster to render
  121717. */
  121718. unfreezeMaterials(): void;
  121719. /**
  121720. * Releases all held ressources
  121721. */
  121722. dispose(): void;
  121723. /**
  121724. * Gets if the scene is already disposed
  121725. */
  121726. get isDisposed(): boolean;
  121727. /**
  121728. * Call this function to reduce memory footprint of the scene.
  121729. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121730. */
  121731. clearCachedVertexData(): void;
  121732. /**
  121733. * This function will remove the local cached buffer data from texture.
  121734. * It will save memory but will prevent the texture from being rebuilt
  121735. */
  121736. cleanCachedTextureBuffer(): void;
  121737. /**
  121738. * Get the world extend vectors with an optional filter
  121739. *
  121740. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121741. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121742. */
  121743. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121744. min: Vector3;
  121745. max: Vector3;
  121746. };
  121747. /**
  121748. * Creates a ray that can be used to pick in the scene
  121749. * @param x defines the x coordinate of the origin (on-screen)
  121750. * @param y defines the y coordinate of the origin (on-screen)
  121751. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121752. * @param camera defines the camera to use for the picking
  121753. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121754. * @returns a Ray
  121755. */
  121756. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121757. /**
  121758. * Creates a ray that can be used to pick in the scene
  121759. * @param x defines the x coordinate of the origin (on-screen)
  121760. * @param y defines the y coordinate of the origin (on-screen)
  121761. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121762. * @param result defines the ray where to store the picking ray
  121763. * @param camera defines the camera to use for the picking
  121764. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121765. * @returns the current scene
  121766. */
  121767. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121768. /**
  121769. * Creates a ray that can be used to pick in the scene
  121770. * @param x defines the x coordinate of the origin (on-screen)
  121771. * @param y defines the y coordinate of the origin (on-screen)
  121772. * @param camera defines the camera to use for the picking
  121773. * @returns a Ray
  121774. */
  121775. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121776. /**
  121777. * Creates a ray that can be used to pick in the scene
  121778. * @param x defines the x coordinate of the origin (on-screen)
  121779. * @param y defines the y coordinate of the origin (on-screen)
  121780. * @param result defines the ray where to store the picking ray
  121781. * @param camera defines the camera to use for the picking
  121782. * @returns the current scene
  121783. */
  121784. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121785. /** Launch a ray to try to pick a mesh in the scene
  121786. * @param x position on screen
  121787. * @param y position on screen
  121788. * @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
  121789. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121790. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121792. * @returns a PickingInfo
  121793. */
  121794. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121795. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121796. * @param x position on screen
  121797. * @param y position on screen
  121798. * @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
  121799. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121800. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121801. * @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)
  121802. */
  121803. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121804. /** Use the given ray to pick a mesh in the scene
  121805. * @param ray The ray to use to pick meshes
  121806. * @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
  121807. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121808. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121809. * @returns a PickingInfo
  121810. */
  121811. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121812. /**
  121813. * Launch a ray to try to pick a mesh in the scene
  121814. * @param x X position on screen
  121815. * @param y Y position on screen
  121816. * @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
  121817. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121818. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121819. * @returns an array of PickingInfo
  121820. */
  121821. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121822. /**
  121823. * Launch a ray to try to pick a mesh in the scene
  121824. * @param ray Ray to use
  121825. * @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
  121826. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121827. * @returns an array of PickingInfo
  121828. */
  121829. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121830. /**
  121831. * Force the value of meshUnderPointer
  121832. * @param mesh defines the mesh to use
  121833. * @param pointerId optional pointer id when using more than one pointer
  121834. */
  121835. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121836. /**
  121837. * Gets the mesh under the pointer
  121838. * @returns a Mesh or null if no mesh is under the pointer
  121839. */
  121840. getPointerOverMesh(): Nullable<AbstractMesh>;
  121841. /** @hidden */
  121842. _rebuildGeometries(): void;
  121843. /** @hidden */
  121844. _rebuildTextures(): void;
  121845. private _getByTags;
  121846. /**
  121847. * Get a list of meshes by tags
  121848. * @param tagsQuery defines the tags query to use
  121849. * @param forEach defines a predicate used to filter results
  121850. * @returns an array of Mesh
  121851. */
  121852. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121853. /**
  121854. * Get a list of cameras by tags
  121855. * @param tagsQuery defines the tags query to use
  121856. * @param forEach defines a predicate used to filter results
  121857. * @returns an array of Camera
  121858. */
  121859. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121860. /**
  121861. * Get a list of lights by tags
  121862. * @param tagsQuery defines the tags query to use
  121863. * @param forEach defines a predicate used to filter results
  121864. * @returns an array of Light
  121865. */
  121866. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121867. /**
  121868. * Get a list of materials by tags
  121869. * @param tagsQuery defines the tags query to use
  121870. * @param forEach defines a predicate used to filter results
  121871. * @returns an array of Material
  121872. */
  121873. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121874. /**
  121875. * Get a list of transform nodes by tags
  121876. * @param tagsQuery defines the tags query to use
  121877. * @param forEach defines a predicate used to filter results
  121878. * @returns an array of TransformNode
  121879. */
  121880. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121881. /**
  121882. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121883. * This allowed control for front to back rendering or reversly depending of the special needs.
  121884. *
  121885. * @param renderingGroupId The rendering group id corresponding to its index
  121886. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121887. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121888. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121889. */
  121890. 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;
  121891. /**
  121892. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121893. *
  121894. * @param renderingGroupId The rendering group id corresponding to its index
  121895. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121896. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121897. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121898. */
  121899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121900. /**
  121901. * Gets the current auto clear configuration for one rendering group of the rendering
  121902. * manager.
  121903. * @param index the rendering group index to get the information for
  121904. * @returns The auto clear setup for the requested rendering group
  121905. */
  121906. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121907. private _blockMaterialDirtyMechanism;
  121908. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121909. get blockMaterialDirtyMechanism(): boolean;
  121910. set blockMaterialDirtyMechanism(value: boolean);
  121911. /**
  121912. * Will flag all materials as dirty to trigger new shader compilation
  121913. * @param flag defines the flag used to specify which material part must be marked as dirty
  121914. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121915. */
  121916. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121917. /** @hidden */
  121918. _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;
  121919. /** @hidden */
  121920. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121921. /** @hidden */
  121922. _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;
  121923. /** @hidden */
  121924. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121925. /** @hidden */
  121926. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121927. /** @hidden */
  121928. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121929. }
  121930. }
  121931. declare module BABYLON {
  121932. /**
  121933. * Set of assets to keep when moving a scene into an asset container.
  121934. */
  121935. export class KeepAssets extends AbstractScene {
  121936. }
  121937. /**
  121938. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121939. */
  121940. export class InstantiatedEntries {
  121941. /**
  121942. * List of new root nodes (eg. nodes with no parent)
  121943. */
  121944. rootNodes: TransformNode[];
  121945. /**
  121946. * List of new skeletons
  121947. */
  121948. skeletons: Skeleton[];
  121949. /**
  121950. * List of new animation groups
  121951. */
  121952. animationGroups: AnimationGroup[];
  121953. }
  121954. /**
  121955. * Container with a set of assets that can be added or removed from a scene.
  121956. */
  121957. export class AssetContainer extends AbstractScene {
  121958. private _wasAddedToScene;
  121959. /**
  121960. * The scene the AssetContainer belongs to.
  121961. */
  121962. scene: Scene;
  121963. /**
  121964. * Instantiates an AssetContainer.
  121965. * @param scene The scene the AssetContainer belongs to.
  121966. */
  121967. constructor(scene: Scene);
  121968. /**
  121969. * Instantiate or clone all meshes and add the new ones to the scene.
  121970. * Skeletons and animation groups will all be cloned
  121971. * @param nameFunction defines an optional function used to get new names for clones
  121972. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121973. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121974. */
  121975. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121976. /**
  121977. * Adds all the assets from the container to the scene.
  121978. */
  121979. addAllToScene(): void;
  121980. /**
  121981. * Removes all the assets in the container from the scene
  121982. */
  121983. removeAllFromScene(): void;
  121984. /**
  121985. * Disposes all the assets in the container
  121986. */
  121987. dispose(): void;
  121988. private _moveAssets;
  121989. /**
  121990. * Removes all the assets contained in the scene and adds them to the container.
  121991. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121992. */
  121993. moveAllFromScene(keepAssets?: KeepAssets): void;
  121994. /**
  121995. * 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.
  121996. * @returns the root mesh
  121997. */
  121998. createRootMesh(): Mesh;
  121999. /**
  122000. * Merge animations (direct and animation groups) from this asset container into a scene
  122001. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  122002. * @param animatables set of animatables to retarget to a node from the scene
  122003. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  122004. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  122005. */
  122006. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  122007. }
  122008. }
  122009. declare module BABYLON {
  122010. /**
  122011. * Defines how the parser contract is defined.
  122012. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  122013. */
  122014. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  122015. /**
  122016. * Defines how the individual parser contract is defined.
  122017. * These parser can parse an individual asset
  122018. */
  122019. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  122020. /**
  122021. * Base class of the scene acting as a container for the different elements composing a scene.
  122022. * This class is dynamically extended by the different components of the scene increasing
  122023. * flexibility and reducing coupling
  122024. */
  122025. export abstract class AbstractScene {
  122026. /**
  122027. * Stores the list of available parsers in the application.
  122028. */
  122029. private static _BabylonFileParsers;
  122030. /**
  122031. * Stores the list of available individual parsers in the application.
  122032. */
  122033. private static _IndividualBabylonFileParsers;
  122034. /**
  122035. * Adds a parser in the list of available ones
  122036. * @param name Defines the name of the parser
  122037. * @param parser Defines the parser to add
  122038. */
  122039. static AddParser(name: string, parser: BabylonFileParser): void;
  122040. /**
  122041. * Gets a general parser from the list of avaialble ones
  122042. * @param name Defines the name of the parser
  122043. * @returns the requested parser or null
  122044. */
  122045. static GetParser(name: string): Nullable<BabylonFileParser>;
  122046. /**
  122047. * Adds n individual parser in the list of available ones
  122048. * @param name Defines the name of the parser
  122049. * @param parser Defines the parser to add
  122050. */
  122051. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  122052. /**
  122053. * Gets an individual parser from the list of avaialble ones
  122054. * @param name Defines the name of the parser
  122055. * @returns the requested parser or null
  122056. */
  122057. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  122058. /**
  122059. * Parser json data and populate both a scene and its associated container object
  122060. * @param jsonData Defines the data to parse
  122061. * @param scene Defines the scene to parse the data for
  122062. * @param container Defines the container attached to the parsing sequence
  122063. * @param rootUrl Defines the root url of the data
  122064. */
  122065. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  122066. /**
  122067. * Gets the list of root nodes (ie. nodes with no parent)
  122068. */
  122069. rootNodes: Node[];
  122070. /** All of the cameras added to this scene
  122071. * @see https://doc.babylonjs.com/babylon101/cameras
  122072. */
  122073. cameras: Camera[];
  122074. /**
  122075. * All of the lights added to this scene
  122076. * @see https://doc.babylonjs.com/babylon101/lights
  122077. */
  122078. lights: Light[];
  122079. /**
  122080. * All of the (abstract) meshes added to this scene
  122081. */
  122082. meshes: AbstractMesh[];
  122083. /**
  122084. * The list of skeletons added to the scene
  122085. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  122086. */
  122087. skeletons: Skeleton[];
  122088. /**
  122089. * All of the particle systems added to this scene
  122090. * @see https://doc.babylonjs.com/babylon101/particles
  122091. */
  122092. particleSystems: IParticleSystem[];
  122093. /**
  122094. * Gets a list of Animations associated with the scene
  122095. */
  122096. animations: Animation[];
  122097. /**
  122098. * All of the animation groups added to this scene
  122099. * @see https://doc.babylonjs.com/how_to/group
  122100. */
  122101. animationGroups: AnimationGroup[];
  122102. /**
  122103. * All of the multi-materials added to this scene
  122104. * @see https://doc.babylonjs.com/how_to/multi_materials
  122105. */
  122106. multiMaterials: MultiMaterial[];
  122107. /**
  122108. * All of the materials added to this scene
  122109. * In the context of a Scene, it is not supposed to be modified manually.
  122110. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  122111. * Note also that the order of the Material within the array is not significant and might change.
  122112. * @see https://doc.babylonjs.com/babylon101/materials
  122113. */
  122114. materials: Material[];
  122115. /**
  122116. * The list of morph target managers added to the scene
  122117. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  122118. */
  122119. morphTargetManagers: MorphTargetManager[];
  122120. /**
  122121. * The list of geometries used in the scene.
  122122. */
  122123. geometries: Geometry[];
  122124. /**
  122125. * All of the tranform nodes added to this scene
  122126. * In the context of a Scene, it is not supposed to be modified manually.
  122127. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  122128. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  122129. * @see https://doc.babylonjs.com/how_to/transformnode
  122130. */
  122131. transformNodes: TransformNode[];
  122132. /**
  122133. * ActionManagers available on the scene.
  122134. */
  122135. actionManagers: AbstractActionManager[];
  122136. /**
  122137. * Textures to keep.
  122138. */
  122139. textures: BaseTexture[];
  122140. /** @hidden */
  122141. protected _environmentTexture: Nullable<BaseTexture>;
  122142. /**
  122143. * Texture used in all pbr material as the reflection texture.
  122144. * As in the majority of the scene they are the same (exception for multi room and so on),
  122145. * this is easier to reference from here than from all the materials.
  122146. */
  122147. get environmentTexture(): Nullable<BaseTexture>;
  122148. set environmentTexture(value: Nullable<BaseTexture>);
  122149. /**
  122150. * The list of postprocesses added to the scene
  122151. */
  122152. postProcesses: PostProcess[];
  122153. /**
  122154. * @returns all meshes, lights, cameras, transformNodes and bones
  122155. */
  122156. getNodes(): Array<Node>;
  122157. }
  122158. }
  122159. declare module BABYLON {
  122160. /**
  122161. * Interface used to define options for Sound class
  122162. */
  122163. export interface ISoundOptions {
  122164. /**
  122165. * Does the sound autoplay once loaded.
  122166. */
  122167. autoplay?: boolean;
  122168. /**
  122169. * Does the sound loop after it finishes playing once.
  122170. */
  122171. loop?: boolean;
  122172. /**
  122173. * Sound's volume
  122174. */
  122175. volume?: number;
  122176. /**
  122177. * Is it a spatial sound?
  122178. */
  122179. spatialSound?: boolean;
  122180. /**
  122181. * Maximum distance to hear that sound
  122182. */
  122183. maxDistance?: number;
  122184. /**
  122185. * Uses user defined attenuation function
  122186. */
  122187. useCustomAttenuation?: boolean;
  122188. /**
  122189. * Define the roll off factor of spatial sounds.
  122190. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122191. */
  122192. rolloffFactor?: number;
  122193. /**
  122194. * Define the reference distance the sound should be heard perfectly.
  122195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122196. */
  122197. refDistance?: number;
  122198. /**
  122199. * Define the distance attenuation model the sound will follow.
  122200. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122201. */
  122202. distanceModel?: string;
  122203. /**
  122204. * Defines the playback speed (1 by default)
  122205. */
  122206. playbackRate?: number;
  122207. /**
  122208. * Defines if the sound is from a streaming source
  122209. */
  122210. streaming?: boolean;
  122211. /**
  122212. * Defines an optional length (in seconds) inside the sound file
  122213. */
  122214. length?: number;
  122215. /**
  122216. * Defines an optional offset (in seconds) inside the sound file
  122217. */
  122218. offset?: number;
  122219. /**
  122220. * If true, URLs will not be required to state the audio file codec to use.
  122221. */
  122222. skipCodecCheck?: boolean;
  122223. }
  122224. /**
  122225. * Defines a sound that can be played in the application.
  122226. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  122227. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122228. */
  122229. export class Sound {
  122230. /**
  122231. * The name of the sound in the scene.
  122232. */
  122233. name: string;
  122234. /**
  122235. * Does the sound autoplay once loaded.
  122236. */
  122237. autoplay: boolean;
  122238. /**
  122239. * Does the sound loop after it finishes playing once.
  122240. */
  122241. loop: boolean;
  122242. /**
  122243. * Does the sound use a custom attenuation curve to simulate the falloff
  122244. * happening when the source gets further away from the camera.
  122245. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122246. */
  122247. useCustomAttenuation: boolean;
  122248. /**
  122249. * The sound track id this sound belongs to.
  122250. */
  122251. soundTrackId: number;
  122252. /**
  122253. * Is this sound currently played.
  122254. */
  122255. isPlaying: boolean;
  122256. /**
  122257. * Is this sound currently paused.
  122258. */
  122259. isPaused: boolean;
  122260. /**
  122261. * Does this sound enables spatial sound.
  122262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122263. */
  122264. spatialSound: boolean;
  122265. /**
  122266. * Define the reference distance the sound should be heard perfectly.
  122267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122268. */
  122269. refDistance: number;
  122270. /**
  122271. * Define the roll off factor of spatial sounds.
  122272. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122273. */
  122274. rolloffFactor: number;
  122275. /**
  122276. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  122277. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122278. */
  122279. maxDistance: number;
  122280. /**
  122281. * Define the distance attenuation model the sound will follow.
  122282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122283. */
  122284. distanceModel: string;
  122285. /**
  122286. * @hidden
  122287. * Back Compat
  122288. **/
  122289. onended: () => any;
  122290. /**
  122291. * Gets or sets an object used to store user defined information for the sound.
  122292. */
  122293. metadata: any;
  122294. /**
  122295. * Observable event when the current playing sound finishes.
  122296. */
  122297. onEndedObservable: Observable<Sound>;
  122298. private _panningModel;
  122299. private _playbackRate;
  122300. private _streaming;
  122301. private _startTime;
  122302. private _startOffset;
  122303. private _position;
  122304. /** @hidden */
  122305. _positionInEmitterSpace: boolean;
  122306. private _localDirection;
  122307. private _volume;
  122308. private _isReadyToPlay;
  122309. private _isDirectional;
  122310. private _readyToPlayCallback;
  122311. private _audioBuffer;
  122312. private _soundSource;
  122313. private _streamingSource;
  122314. private _soundPanner;
  122315. private _soundGain;
  122316. private _inputAudioNode;
  122317. private _outputAudioNode;
  122318. private _coneInnerAngle;
  122319. private _coneOuterAngle;
  122320. private _coneOuterGain;
  122321. private _scene;
  122322. private _connectedTransformNode;
  122323. private _customAttenuationFunction;
  122324. private _registerFunc;
  122325. private _isOutputConnected;
  122326. private _htmlAudioElement;
  122327. private _urlType;
  122328. private _length?;
  122329. private _offset?;
  122330. /** @hidden */
  122331. static _SceneComponentInitialization: (scene: Scene) => void;
  122332. /**
  122333. * Create a sound and attach it to a scene
  122334. * @param name Name of your sound
  122335. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122336. * @param scene defines the scene the sound belongs to
  122337. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122338. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122339. */
  122340. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122341. /**
  122342. * Release the sound and its associated resources
  122343. */
  122344. dispose(): void;
  122345. /**
  122346. * Gets if the sounds is ready to be played or not.
  122347. * @returns true if ready, otherwise false
  122348. */
  122349. isReady(): boolean;
  122350. private _soundLoaded;
  122351. /**
  122352. * Sets the data of the sound from an audiobuffer
  122353. * @param audioBuffer The audioBuffer containing the data
  122354. */
  122355. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122356. /**
  122357. * Updates the current sounds options such as maxdistance, loop...
  122358. * @param options A JSON object containing values named as the object properties
  122359. */
  122360. updateOptions(options: ISoundOptions): void;
  122361. private _createSpatialParameters;
  122362. private _updateSpatialParameters;
  122363. /**
  122364. * Switch the panning model to HRTF:
  122365. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122366. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122367. */
  122368. switchPanningModelToHRTF(): void;
  122369. /**
  122370. * Switch the panning model to Equal Power:
  122371. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122373. */
  122374. switchPanningModelToEqualPower(): void;
  122375. private _switchPanningModel;
  122376. /**
  122377. * Connect this sound to a sound track audio node like gain...
  122378. * @param soundTrackAudioNode the sound track audio node to connect to
  122379. */
  122380. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122381. /**
  122382. * Transform this sound into a directional source
  122383. * @param coneInnerAngle Size of the inner cone in degree
  122384. * @param coneOuterAngle Size of the outer cone in degree
  122385. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122386. */
  122387. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122388. /**
  122389. * Gets or sets the inner angle for the directional cone.
  122390. */
  122391. get directionalConeInnerAngle(): number;
  122392. /**
  122393. * Gets or sets the inner angle for the directional cone.
  122394. */
  122395. set directionalConeInnerAngle(value: number);
  122396. /**
  122397. * Gets or sets the outer angle for the directional cone.
  122398. */
  122399. get directionalConeOuterAngle(): number;
  122400. /**
  122401. * Gets or sets the outer angle for the directional cone.
  122402. */
  122403. set directionalConeOuterAngle(value: number);
  122404. /**
  122405. * Sets the position of the emitter if spatial sound is enabled
  122406. * @param newPosition Defines the new posisiton
  122407. */
  122408. setPosition(newPosition: Vector3): void;
  122409. /**
  122410. * Sets the local direction of the emitter if spatial sound is enabled
  122411. * @param newLocalDirection Defines the new local direction
  122412. */
  122413. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122414. private _updateDirection;
  122415. /** @hidden */
  122416. updateDistanceFromListener(): void;
  122417. /**
  122418. * Sets a new custom attenuation function for the sound.
  122419. * @param callback Defines the function used for the attenuation
  122420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122421. */
  122422. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122423. /**
  122424. * Play the sound
  122425. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122426. * @param offset (optional) Start the sound at a specific time in seconds
  122427. * @param length (optional) Sound duration (in seconds)
  122428. */
  122429. play(time?: number, offset?: number, length?: number): void;
  122430. private _onended;
  122431. /**
  122432. * Stop the sound
  122433. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122434. */
  122435. stop(time?: number): void;
  122436. /**
  122437. * Put the sound in pause
  122438. */
  122439. pause(): void;
  122440. /**
  122441. * Sets a dedicated volume for this sounds
  122442. * @param newVolume Define the new volume of the sound
  122443. * @param time Define time for gradual change to new volume
  122444. */
  122445. setVolume(newVolume: number, time?: number): void;
  122446. /**
  122447. * Set the sound play back rate
  122448. * @param newPlaybackRate Define the playback rate the sound should be played at
  122449. */
  122450. setPlaybackRate(newPlaybackRate: number): void;
  122451. /**
  122452. * Gets the volume of the sound.
  122453. * @returns the volume of the sound
  122454. */
  122455. getVolume(): number;
  122456. /**
  122457. * Attach the sound to a dedicated mesh
  122458. * @param transformNode The transform node to connect the sound with
  122459. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122460. */
  122461. attachToMesh(transformNode: TransformNode): void;
  122462. /**
  122463. * Detach the sound from the previously attached mesh
  122464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122465. */
  122466. detachFromMesh(): void;
  122467. private _onRegisterAfterWorldMatrixUpdate;
  122468. /**
  122469. * Clone the current sound in the scene.
  122470. * @returns the new sound clone
  122471. */
  122472. clone(): Nullable<Sound>;
  122473. /**
  122474. * Gets the current underlying audio buffer containing the data
  122475. * @returns the audio buffer
  122476. */
  122477. getAudioBuffer(): Nullable<AudioBuffer>;
  122478. /**
  122479. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122480. * @returns the source node
  122481. */
  122482. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122483. /**
  122484. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122485. * @returns the gain node
  122486. */
  122487. getSoundGain(): Nullable<GainNode>;
  122488. /**
  122489. * Serializes the Sound in a JSON representation
  122490. * @returns the JSON representation of the sound
  122491. */
  122492. serialize(): any;
  122493. /**
  122494. * Parse a JSON representation of a sound to innstantiate in a given scene
  122495. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122496. * @param scene Define the scene the new parsed sound should be created in
  122497. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122498. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122499. * @returns the newly parsed sound
  122500. */
  122501. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122502. }
  122503. }
  122504. declare module BABYLON {
  122505. /**
  122506. * This defines an action helpful to play a defined sound on a triggered action.
  122507. */
  122508. export class PlaySoundAction extends Action {
  122509. private _sound;
  122510. /**
  122511. * Instantiate the action
  122512. * @param triggerOptions defines the trigger options
  122513. * @param sound defines the sound to play
  122514. * @param condition defines the trigger related conditions
  122515. */
  122516. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122517. /** @hidden */
  122518. _prepare(): void;
  122519. /**
  122520. * Execute the action and play the sound.
  122521. */
  122522. execute(): void;
  122523. /**
  122524. * Serializes the actions and its related information.
  122525. * @param parent defines the object to serialize in
  122526. * @returns the serialized object
  122527. */
  122528. serialize(parent: any): any;
  122529. }
  122530. /**
  122531. * This defines an action helpful to stop a defined sound on a triggered action.
  122532. */
  122533. export class StopSoundAction extends Action {
  122534. private _sound;
  122535. /**
  122536. * Instantiate the action
  122537. * @param triggerOptions defines the trigger options
  122538. * @param sound defines the sound to stop
  122539. * @param condition defines the trigger related conditions
  122540. */
  122541. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122542. /** @hidden */
  122543. _prepare(): void;
  122544. /**
  122545. * Execute the action and stop the sound.
  122546. */
  122547. execute(): void;
  122548. /**
  122549. * Serializes the actions and its related information.
  122550. * @param parent defines the object to serialize in
  122551. * @returns the serialized object
  122552. */
  122553. serialize(parent: any): any;
  122554. }
  122555. }
  122556. declare module BABYLON {
  122557. /**
  122558. * This defines an action responsible to change the value of a property
  122559. * by interpolating between its current value and the newly set one once triggered.
  122560. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122561. */
  122562. export class InterpolateValueAction extends Action {
  122563. /**
  122564. * Defines the path of the property where the value should be interpolated
  122565. */
  122566. propertyPath: string;
  122567. /**
  122568. * Defines the target value at the end of the interpolation.
  122569. */
  122570. value: any;
  122571. /**
  122572. * Defines the time it will take for the property to interpolate to the value.
  122573. */
  122574. duration: number;
  122575. /**
  122576. * Defines if the other scene animations should be stopped when the action has been triggered
  122577. */
  122578. stopOtherAnimations?: boolean;
  122579. /**
  122580. * Defines a callback raised once the interpolation animation has been done.
  122581. */
  122582. onInterpolationDone?: () => void;
  122583. /**
  122584. * Observable triggered once the interpolation animation has been done.
  122585. */
  122586. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122587. private _target;
  122588. private _effectiveTarget;
  122589. private _property;
  122590. /**
  122591. * Instantiate the action
  122592. * @param triggerOptions defines the trigger options
  122593. * @param target defines the object containing the value to interpolate
  122594. * @param propertyPath defines the path to the property in the target object
  122595. * @param value defines the target value at the end of the interpolation
  122596. * @param duration deines the time it will take for the property to interpolate to the value.
  122597. * @param condition defines the trigger related conditions
  122598. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122599. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122600. */
  122601. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122602. /** @hidden */
  122603. _prepare(): void;
  122604. /**
  122605. * Execute the action starts the value interpolation.
  122606. */
  122607. execute(): void;
  122608. /**
  122609. * Serializes the actions and its related information.
  122610. * @param parent defines the object to serialize in
  122611. * @returns the serialized object
  122612. */
  122613. serialize(parent: any): any;
  122614. }
  122615. }
  122616. declare module BABYLON {
  122617. /**
  122618. * Options allowed during the creation of a sound track.
  122619. */
  122620. export interface ISoundTrackOptions {
  122621. /**
  122622. * The volume the sound track should take during creation
  122623. */
  122624. volume?: number;
  122625. /**
  122626. * Define if the sound track is the main sound track of the scene
  122627. */
  122628. mainTrack?: boolean;
  122629. }
  122630. /**
  122631. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122632. * It will be also used in a future release to apply effects on a specific track.
  122633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122634. */
  122635. export class SoundTrack {
  122636. /**
  122637. * The unique identifier of the sound track in the scene.
  122638. */
  122639. id: number;
  122640. /**
  122641. * The list of sounds included in the sound track.
  122642. */
  122643. soundCollection: Array<Sound>;
  122644. private _outputAudioNode;
  122645. private _scene;
  122646. private _connectedAnalyser;
  122647. private _options;
  122648. private _isInitialized;
  122649. /**
  122650. * Creates a new sound track.
  122651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122652. * @param scene Define the scene the sound track belongs to
  122653. * @param options
  122654. */
  122655. constructor(scene: Scene, options?: ISoundTrackOptions);
  122656. private _initializeSoundTrackAudioGraph;
  122657. /**
  122658. * Release the sound track and its associated resources
  122659. */
  122660. dispose(): void;
  122661. /**
  122662. * Adds a sound to this sound track
  122663. * @param sound define the cound to add
  122664. * @ignoreNaming
  122665. */
  122666. AddSound(sound: Sound): void;
  122667. /**
  122668. * Removes a sound to this sound track
  122669. * @param sound define the cound to remove
  122670. * @ignoreNaming
  122671. */
  122672. RemoveSound(sound: Sound): void;
  122673. /**
  122674. * Set a global volume for the full sound track.
  122675. * @param newVolume Define the new volume of the sound track
  122676. */
  122677. setVolume(newVolume: number): void;
  122678. /**
  122679. * Switch the panning model to HRTF:
  122680. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122682. */
  122683. switchPanningModelToHRTF(): void;
  122684. /**
  122685. * Switch the panning model to Equal Power:
  122686. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122688. */
  122689. switchPanningModelToEqualPower(): void;
  122690. /**
  122691. * Connect the sound track to an audio analyser allowing some amazing
  122692. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122694. * @param analyser The analyser to connect to the engine
  122695. */
  122696. connectToAnalyser(analyser: Analyser): void;
  122697. }
  122698. }
  122699. declare module BABYLON {
  122700. interface AbstractScene {
  122701. /**
  122702. * The list of sounds used in the scene.
  122703. */
  122704. sounds: Nullable<Array<Sound>>;
  122705. }
  122706. interface Scene {
  122707. /**
  122708. * @hidden
  122709. * Backing field
  122710. */
  122711. _mainSoundTrack: SoundTrack;
  122712. /**
  122713. * The main sound track played by the scene.
  122714. * It cotains your primary collection of sounds.
  122715. */
  122716. mainSoundTrack: SoundTrack;
  122717. /**
  122718. * The list of sound tracks added to the scene
  122719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122720. */
  122721. soundTracks: Nullable<Array<SoundTrack>>;
  122722. /**
  122723. * Gets a sound using a given name
  122724. * @param name defines the name to search for
  122725. * @return the found sound or null if not found at all.
  122726. */
  122727. getSoundByName(name: string): Nullable<Sound>;
  122728. /**
  122729. * Gets or sets if audio support is enabled
  122730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122731. */
  122732. audioEnabled: boolean;
  122733. /**
  122734. * Gets or sets if audio will be output to headphones
  122735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122736. */
  122737. headphone: boolean;
  122738. /**
  122739. * Gets or sets custom audio listener position provider
  122740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122741. */
  122742. audioListenerPositionProvider: Nullable<() => Vector3>;
  122743. /**
  122744. * Gets or sets a refresh rate when using 3D audio positioning
  122745. */
  122746. audioPositioningRefreshRate: number;
  122747. }
  122748. /**
  122749. * Defines the sound scene component responsible to manage any sounds
  122750. * in a given scene.
  122751. */
  122752. export class AudioSceneComponent implements ISceneSerializableComponent {
  122753. private static _CameraDirectionLH;
  122754. private static _CameraDirectionRH;
  122755. /**
  122756. * The component name helpfull to identify the component in the list of scene components.
  122757. */
  122758. readonly name: string;
  122759. /**
  122760. * The scene the component belongs to.
  122761. */
  122762. scene: Scene;
  122763. private _audioEnabled;
  122764. /**
  122765. * Gets whether audio is enabled or not.
  122766. * Please use related enable/disable method to switch state.
  122767. */
  122768. get audioEnabled(): boolean;
  122769. private _headphone;
  122770. /**
  122771. * Gets whether audio is outputing to headphone or not.
  122772. * Please use the according Switch methods to change output.
  122773. */
  122774. get headphone(): boolean;
  122775. /**
  122776. * Gets or sets a refresh rate when using 3D audio positioning
  122777. */
  122778. audioPositioningRefreshRate: number;
  122779. private _audioListenerPositionProvider;
  122780. /**
  122781. * Gets the current audio listener position provider
  122782. */
  122783. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122784. /**
  122785. * Sets a custom listener position for all sounds in the scene
  122786. * By default, this is the position of the first active camera
  122787. */
  122788. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122789. /**
  122790. * Creates a new instance of the component for the given scene
  122791. * @param scene Defines the scene to register the component in
  122792. */
  122793. constructor(scene: Scene);
  122794. /**
  122795. * Registers the component in a given scene
  122796. */
  122797. register(): void;
  122798. /**
  122799. * Rebuilds the elements related to this component in case of
  122800. * context lost for instance.
  122801. */
  122802. rebuild(): void;
  122803. /**
  122804. * Serializes the component data to the specified json object
  122805. * @param serializationObject The object to serialize to
  122806. */
  122807. serialize(serializationObject: any): void;
  122808. /**
  122809. * Adds all the elements from the container to the scene
  122810. * @param container the container holding the elements
  122811. */
  122812. addFromContainer(container: AbstractScene): void;
  122813. /**
  122814. * Removes all the elements in the container from the scene
  122815. * @param container contains the elements to remove
  122816. * @param dispose if the removed element should be disposed (default: false)
  122817. */
  122818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122819. /**
  122820. * Disposes the component and the associated ressources.
  122821. */
  122822. dispose(): void;
  122823. /**
  122824. * Disables audio in the associated scene.
  122825. */
  122826. disableAudio(): void;
  122827. /**
  122828. * Enables audio in the associated scene.
  122829. */
  122830. enableAudio(): void;
  122831. /**
  122832. * Switch audio to headphone output.
  122833. */
  122834. switchAudioModeForHeadphones(): void;
  122835. /**
  122836. * Switch audio to normal speakers.
  122837. */
  122838. switchAudioModeForNormalSpeakers(): void;
  122839. private _cachedCameraDirection;
  122840. private _cachedCameraPosition;
  122841. private _lastCheck;
  122842. private _afterRender;
  122843. }
  122844. }
  122845. declare module BABYLON {
  122846. /**
  122847. * Wraps one or more Sound objects and selects one with random weight for playback.
  122848. */
  122849. export class WeightedSound {
  122850. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122851. loop: boolean;
  122852. private _coneInnerAngle;
  122853. private _coneOuterAngle;
  122854. private _volume;
  122855. /** A Sound is currently playing. */
  122856. isPlaying: boolean;
  122857. /** A Sound is currently paused. */
  122858. isPaused: boolean;
  122859. private _sounds;
  122860. private _weights;
  122861. private _currentIndex?;
  122862. /**
  122863. * Creates a new WeightedSound from the list of sounds given.
  122864. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122865. * @param sounds Array of Sounds that will be selected from.
  122866. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122867. */
  122868. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122869. /**
  122870. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122871. */
  122872. get directionalConeInnerAngle(): number;
  122873. /**
  122874. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122875. */
  122876. set directionalConeInnerAngle(value: number);
  122877. /**
  122878. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122879. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122880. */
  122881. get directionalConeOuterAngle(): number;
  122882. /**
  122883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122885. */
  122886. set directionalConeOuterAngle(value: number);
  122887. /**
  122888. * Playback volume.
  122889. */
  122890. get volume(): number;
  122891. /**
  122892. * Playback volume.
  122893. */
  122894. set volume(value: number);
  122895. private _onended;
  122896. /**
  122897. * Suspend playback
  122898. */
  122899. pause(): void;
  122900. /**
  122901. * Stop playback
  122902. */
  122903. stop(): void;
  122904. /**
  122905. * Start playback.
  122906. * @param startOffset Position the clip head at a specific time in seconds.
  122907. */
  122908. play(startOffset?: number): void;
  122909. }
  122910. }
  122911. declare module BABYLON {
  122912. /**
  122913. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122914. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122915. */
  122916. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122917. /**
  122918. * Gets the name of the behavior.
  122919. */
  122920. get name(): string;
  122921. /**
  122922. * The easing function used by animations
  122923. */
  122924. static EasingFunction: BackEase;
  122925. /**
  122926. * The easing mode used by animations
  122927. */
  122928. static EasingMode: number;
  122929. /**
  122930. * The duration of the animation, in milliseconds
  122931. */
  122932. transitionDuration: number;
  122933. /**
  122934. * Length of the distance animated by the transition when lower radius is reached
  122935. */
  122936. lowerRadiusTransitionRange: number;
  122937. /**
  122938. * Length of the distance animated by the transition when upper radius is reached
  122939. */
  122940. upperRadiusTransitionRange: number;
  122941. private _autoTransitionRange;
  122942. /**
  122943. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122944. */
  122945. get autoTransitionRange(): boolean;
  122946. /**
  122947. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122948. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122949. */
  122950. set autoTransitionRange(value: boolean);
  122951. private _attachedCamera;
  122952. private _onAfterCheckInputsObserver;
  122953. private _onMeshTargetChangedObserver;
  122954. /**
  122955. * Initializes the behavior.
  122956. */
  122957. init(): void;
  122958. /**
  122959. * Attaches the behavior to its arc rotate camera.
  122960. * @param camera Defines the camera to attach the behavior to
  122961. */
  122962. attach(camera: ArcRotateCamera): void;
  122963. /**
  122964. * Detaches the behavior from its current arc rotate camera.
  122965. */
  122966. detach(): void;
  122967. private _radiusIsAnimating;
  122968. private _radiusBounceTransition;
  122969. private _animatables;
  122970. private _cachedWheelPrecision;
  122971. /**
  122972. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122973. * @param radiusLimit The limit to check against.
  122974. * @return Bool to indicate if at limit.
  122975. */
  122976. private _isRadiusAtLimit;
  122977. /**
  122978. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122979. * @param radiusDelta The delta by which to animate to. Can be negative.
  122980. */
  122981. private _applyBoundRadiusAnimation;
  122982. /**
  122983. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122984. */
  122985. protected _clearAnimationLocks(): void;
  122986. /**
  122987. * Stops and removes all animations that have been applied to the camera
  122988. */
  122989. stopAllAnimations(): void;
  122990. }
  122991. }
  122992. declare module BABYLON {
  122993. /**
  122994. * 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.
  122995. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122996. */
  122997. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122998. /**
  122999. * Gets the name of the behavior.
  123000. */
  123001. get name(): string;
  123002. private _mode;
  123003. private _radiusScale;
  123004. private _positionScale;
  123005. private _defaultElevation;
  123006. private _elevationReturnTime;
  123007. private _elevationReturnWaitTime;
  123008. private _zoomStopsAnimation;
  123009. private _framingTime;
  123010. /**
  123011. * The easing function used by animations
  123012. */
  123013. static EasingFunction: ExponentialEase;
  123014. /**
  123015. * The easing mode used by animations
  123016. */
  123017. static EasingMode: number;
  123018. /**
  123019. * Sets the current mode used by the behavior
  123020. */
  123021. set mode(mode: number);
  123022. /**
  123023. * Gets current mode used by the behavior.
  123024. */
  123025. get mode(): number;
  123026. /**
  123027. * Sets the scale applied to the radius (1 by default)
  123028. */
  123029. set radiusScale(radius: number);
  123030. /**
  123031. * Gets the scale applied to the radius
  123032. */
  123033. get radiusScale(): number;
  123034. /**
  123035. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123036. */
  123037. set positionScale(scale: number);
  123038. /**
  123039. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123040. */
  123041. get positionScale(): number;
  123042. /**
  123043. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123044. * behaviour is triggered, in radians.
  123045. */
  123046. set defaultElevation(elevation: number);
  123047. /**
  123048. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123049. * behaviour is triggered, in radians.
  123050. */
  123051. get defaultElevation(): number;
  123052. /**
  123053. * Sets the time (in milliseconds) taken to return to the default beta position.
  123054. * Negative value indicates camera should not return to default.
  123055. */
  123056. set elevationReturnTime(speed: number);
  123057. /**
  123058. * Gets the time (in milliseconds) taken to return to the default beta position.
  123059. * Negative value indicates camera should not return to default.
  123060. */
  123061. get elevationReturnTime(): number;
  123062. /**
  123063. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123064. */
  123065. set elevationReturnWaitTime(time: number);
  123066. /**
  123067. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123068. */
  123069. get elevationReturnWaitTime(): number;
  123070. /**
  123071. * Sets the flag that indicates if user zooming should stop animation.
  123072. */
  123073. set zoomStopsAnimation(flag: boolean);
  123074. /**
  123075. * Gets the flag that indicates if user zooming should stop animation.
  123076. */
  123077. get zoomStopsAnimation(): boolean;
  123078. /**
  123079. * Sets the transition time when framing the mesh, in milliseconds
  123080. */
  123081. set framingTime(time: number);
  123082. /**
  123083. * Gets the transition time when framing the mesh, in milliseconds
  123084. */
  123085. get framingTime(): number;
  123086. /**
  123087. * Define if the behavior should automatically change the configured
  123088. * camera limits and sensibilities.
  123089. */
  123090. autoCorrectCameraLimitsAndSensibility: boolean;
  123091. private _onPrePointerObservableObserver;
  123092. private _onAfterCheckInputsObserver;
  123093. private _onMeshTargetChangedObserver;
  123094. private _attachedCamera;
  123095. private _isPointerDown;
  123096. private _lastInteractionTime;
  123097. /**
  123098. * Initializes the behavior.
  123099. */
  123100. init(): void;
  123101. /**
  123102. * Attaches the behavior to its arc rotate camera.
  123103. * @param camera Defines the camera to attach the behavior to
  123104. */
  123105. attach(camera: ArcRotateCamera): void;
  123106. /**
  123107. * Detaches the behavior from its current arc rotate camera.
  123108. */
  123109. detach(): void;
  123110. private _animatables;
  123111. private _betaIsAnimating;
  123112. private _betaTransition;
  123113. private _radiusTransition;
  123114. private _vectorTransition;
  123115. /**
  123116. * Targets the given mesh and updates zoom level accordingly.
  123117. * @param mesh The mesh to target.
  123118. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123119. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123120. */
  123121. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123122. /**
  123123. * Targets the given mesh with its children and updates zoom level accordingly.
  123124. * @param mesh The mesh to target.
  123125. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123126. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123127. */
  123128. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123129. /**
  123130. * Targets the given meshes with their children and updates zoom level accordingly.
  123131. * @param meshes The mesh to target.
  123132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123134. */
  123135. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123136. /**
  123137. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  123138. * @param minimumWorld Determines the smaller position of the bounding box extend
  123139. * @param maximumWorld Determines the bigger position of the bounding box extend
  123140. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123141. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123142. */
  123143. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123144. /**
  123145. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  123146. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  123147. * frustum width.
  123148. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  123149. * to fully enclose the mesh in the viewing frustum.
  123150. */
  123151. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  123152. /**
  123153. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  123154. * is automatically returned to its default position (expected to be above ground plane).
  123155. */
  123156. private _maintainCameraAboveGround;
  123157. /**
  123158. * Returns the frustum slope based on the canvas ratio and camera FOV
  123159. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  123160. */
  123161. private _getFrustumSlope;
  123162. /**
  123163. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  123164. */
  123165. private _clearAnimationLocks;
  123166. /**
  123167. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123168. */
  123169. private _applyUserInteraction;
  123170. /**
  123171. * Stops and removes all animations that have been applied to the camera
  123172. */
  123173. stopAllAnimations(): void;
  123174. /**
  123175. * Gets a value indicating if the user is moving the camera
  123176. */
  123177. get isUserIsMoving(): boolean;
  123178. /**
  123179. * The camera can move all the way towards the mesh.
  123180. */
  123181. static IgnoreBoundsSizeMode: number;
  123182. /**
  123183. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  123184. */
  123185. static FitFrustumSidesMode: number;
  123186. }
  123187. }
  123188. declare module BABYLON {
  123189. /**
  123190. * Base class for Camera Pointer Inputs.
  123191. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  123192. * for example usage.
  123193. */
  123194. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  123195. /**
  123196. * Defines the camera the input is attached to.
  123197. */
  123198. abstract camera: Camera;
  123199. /**
  123200. * Whether keyboard modifier keys are pressed at time of last mouse event.
  123201. */
  123202. protected _altKey: boolean;
  123203. protected _ctrlKey: boolean;
  123204. protected _metaKey: boolean;
  123205. protected _shiftKey: boolean;
  123206. /**
  123207. * Which mouse buttons were pressed at time of last mouse event.
  123208. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  123209. */
  123210. protected _buttonsPressed: number;
  123211. /**
  123212. * Defines the buttons associated with the input to handle camera move.
  123213. */
  123214. buttons: number[];
  123215. /**
  123216. * Attach the input controls to a specific dom element to get the input from.
  123217. * @param element Defines the element the controls should be listened from
  123218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123219. */
  123220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123221. /**
  123222. * Detach the current controls from the specified dom element.
  123223. * @param element Defines the element to stop listening the inputs from
  123224. */
  123225. detachControl(element: Nullable<HTMLElement>): void;
  123226. /**
  123227. * Gets the class name of the current input.
  123228. * @returns the class name
  123229. */
  123230. getClassName(): string;
  123231. /**
  123232. * Get the friendly name associated with the input class.
  123233. * @returns the input friendly name
  123234. */
  123235. getSimpleName(): string;
  123236. /**
  123237. * Called on pointer POINTERDOUBLETAP event.
  123238. * Override this method to provide functionality on POINTERDOUBLETAP event.
  123239. */
  123240. protected onDoubleTap(type: string): void;
  123241. /**
  123242. * Called on pointer POINTERMOVE event if only a single touch is active.
  123243. * Override this method to provide functionality.
  123244. */
  123245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123246. /**
  123247. * Called on pointer POINTERMOVE event if multiple touches are active.
  123248. * Override this method to provide functionality.
  123249. */
  123250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123251. /**
  123252. * Called on JS contextmenu event.
  123253. * Override this method to provide functionality.
  123254. */
  123255. protected onContextMenu(evt: PointerEvent): void;
  123256. /**
  123257. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123258. * press.
  123259. * Override this method to provide functionality.
  123260. */
  123261. protected onButtonDown(evt: PointerEvent): void;
  123262. /**
  123263. * Called each time a new POINTERUP event occurs. Ie, for each button
  123264. * release.
  123265. * Override this method to provide functionality.
  123266. */
  123267. protected onButtonUp(evt: PointerEvent): void;
  123268. /**
  123269. * Called when window becomes inactive.
  123270. * Override this method to provide functionality.
  123271. */
  123272. protected onLostFocus(): void;
  123273. private _pointerInput;
  123274. private _observer;
  123275. private _onLostFocus;
  123276. private pointA;
  123277. private pointB;
  123278. }
  123279. }
  123280. declare module BABYLON {
  123281. /**
  123282. * Manage the pointers inputs to control an arc rotate camera.
  123283. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123284. */
  123285. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  123286. /**
  123287. * Defines the camera the input is attached to.
  123288. */
  123289. camera: ArcRotateCamera;
  123290. /**
  123291. * Gets the class name of the current input.
  123292. * @returns the class name
  123293. */
  123294. getClassName(): string;
  123295. /**
  123296. * Defines the buttons associated with the input to handle camera move.
  123297. */
  123298. buttons: number[];
  123299. /**
  123300. * Defines the pointer angular sensibility along the X axis or how fast is
  123301. * the camera rotating.
  123302. */
  123303. angularSensibilityX: number;
  123304. /**
  123305. * Defines the pointer angular sensibility along the Y axis or how fast is
  123306. * the camera rotating.
  123307. */
  123308. angularSensibilityY: number;
  123309. /**
  123310. * Defines the pointer pinch precision or how fast is the camera zooming.
  123311. */
  123312. pinchPrecision: number;
  123313. /**
  123314. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123315. * from 0.
  123316. * It defines the percentage of current camera.radius to use as delta when
  123317. * pinch zoom is used.
  123318. */
  123319. pinchDeltaPercentage: number;
  123320. /**
  123321. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123322. * that any object in the plane at the camera's target point will scale
  123323. * perfectly with finger motion.
  123324. * Overrides pinchDeltaPercentage and pinchPrecision.
  123325. */
  123326. useNaturalPinchZoom: boolean;
  123327. /**
  123328. * Defines the pointer panning sensibility or how fast is the camera moving.
  123329. */
  123330. panningSensibility: number;
  123331. /**
  123332. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123333. */
  123334. multiTouchPanning: boolean;
  123335. /**
  123336. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123337. * zoom (pinch) through multitouch.
  123338. */
  123339. multiTouchPanAndZoom: boolean;
  123340. /**
  123341. * Revers pinch action direction.
  123342. */
  123343. pinchInwards: boolean;
  123344. private _isPanClick;
  123345. private _twoFingerActivityCount;
  123346. private _isPinching;
  123347. /**
  123348. * Called on pointer POINTERMOVE event if only a single touch is active.
  123349. */
  123350. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123351. /**
  123352. * Called on pointer POINTERDOUBLETAP event.
  123353. */
  123354. protected onDoubleTap(type: string): void;
  123355. /**
  123356. * Called on pointer POINTERMOVE event if multiple touches are active.
  123357. */
  123358. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123359. /**
  123360. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123361. * press.
  123362. */
  123363. protected onButtonDown(evt: PointerEvent): void;
  123364. /**
  123365. * Called each time a new POINTERUP event occurs. Ie, for each button
  123366. * release.
  123367. */
  123368. protected onButtonUp(evt: PointerEvent): void;
  123369. /**
  123370. * Called when window becomes inactive.
  123371. */
  123372. protected onLostFocus(): void;
  123373. }
  123374. }
  123375. declare module BABYLON {
  123376. /**
  123377. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123379. */
  123380. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123381. /**
  123382. * Defines the camera the input is attached to.
  123383. */
  123384. camera: ArcRotateCamera;
  123385. /**
  123386. * Defines the list of key codes associated with the up action (increase alpha)
  123387. */
  123388. keysUp: number[];
  123389. /**
  123390. * Defines the list of key codes associated with the down action (decrease alpha)
  123391. */
  123392. keysDown: number[];
  123393. /**
  123394. * Defines the list of key codes associated with the left action (increase beta)
  123395. */
  123396. keysLeft: number[];
  123397. /**
  123398. * Defines the list of key codes associated with the right action (decrease beta)
  123399. */
  123400. keysRight: number[];
  123401. /**
  123402. * Defines the list of key codes associated with the reset action.
  123403. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123404. */
  123405. keysReset: number[];
  123406. /**
  123407. * Defines the panning sensibility of the inputs.
  123408. * (How fast is the camera panning)
  123409. */
  123410. panningSensibility: number;
  123411. /**
  123412. * Defines the zooming sensibility of the inputs.
  123413. * (How fast is the camera zooming)
  123414. */
  123415. zoomingSensibility: number;
  123416. /**
  123417. * Defines whether maintaining the alt key down switch the movement mode from
  123418. * orientation to zoom.
  123419. */
  123420. useAltToZoom: boolean;
  123421. /**
  123422. * Rotation speed of the camera
  123423. */
  123424. angularSpeed: number;
  123425. private _keys;
  123426. private _ctrlPressed;
  123427. private _altPressed;
  123428. private _onCanvasBlurObserver;
  123429. private _onKeyboardObserver;
  123430. private _engine;
  123431. private _scene;
  123432. /**
  123433. * Attach the input controls to a specific dom element to get the input from.
  123434. * @param element Defines the element the controls should be listened from
  123435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123436. */
  123437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123438. /**
  123439. * Detach the current controls from the specified dom element.
  123440. * @param element Defines the element to stop listening the inputs from
  123441. */
  123442. detachControl(element: Nullable<HTMLElement>): void;
  123443. /**
  123444. * Update the current camera state depending on the inputs that have been used this frame.
  123445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123446. */
  123447. checkInputs(): void;
  123448. /**
  123449. * Gets the class name of the current intput.
  123450. * @returns the class name
  123451. */
  123452. getClassName(): string;
  123453. /**
  123454. * Get the friendly name associated with the input class.
  123455. * @returns the input friendly name
  123456. */
  123457. getSimpleName(): string;
  123458. }
  123459. }
  123460. declare module BABYLON {
  123461. /**
  123462. * Manage the mouse wheel inputs to control an arc rotate camera.
  123463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123464. */
  123465. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123466. /**
  123467. * Defines the camera the input is attached to.
  123468. */
  123469. camera: ArcRotateCamera;
  123470. /**
  123471. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123472. */
  123473. wheelPrecision: number;
  123474. /**
  123475. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123476. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123477. */
  123478. wheelDeltaPercentage: number;
  123479. private _wheel;
  123480. private _observer;
  123481. private computeDeltaFromMouseWheelLegacyEvent;
  123482. /**
  123483. * Attach the input controls to a specific dom element to get the input from.
  123484. * @param element Defines the element the controls should be listened from
  123485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123486. */
  123487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123488. /**
  123489. * Detach the current controls from the specified dom element.
  123490. * @param element Defines the element to stop listening the inputs from
  123491. */
  123492. detachControl(element: Nullable<HTMLElement>): void;
  123493. /**
  123494. * Gets the class name of the current intput.
  123495. * @returns the class name
  123496. */
  123497. getClassName(): string;
  123498. /**
  123499. * Get the friendly name associated with the input class.
  123500. * @returns the input friendly name
  123501. */
  123502. getSimpleName(): string;
  123503. }
  123504. }
  123505. declare module BABYLON {
  123506. /**
  123507. * Default Inputs manager for the ArcRotateCamera.
  123508. * It groups all the default supported inputs for ease of use.
  123509. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123510. */
  123511. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123512. /**
  123513. * Instantiates a new ArcRotateCameraInputsManager.
  123514. * @param camera Defines the camera the inputs belong to
  123515. */
  123516. constructor(camera: ArcRotateCamera);
  123517. /**
  123518. * Add mouse wheel input support to the input manager.
  123519. * @returns the current input manager
  123520. */
  123521. addMouseWheel(): ArcRotateCameraInputsManager;
  123522. /**
  123523. * Add pointers input support to the input manager.
  123524. * @returns the current input manager
  123525. */
  123526. addPointers(): ArcRotateCameraInputsManager;
  123527. /**
  123528. * Add keyboard input support to the input manager.
  123529. * @returns the current input manager
  123530. */
  123531. addKeyboard(): ArcRotateCameraInputsManager;
  123532. }
  123533. }
  123534. declare module BABYLON {
  123535. /**
  123536. * This represents an orbital type of camera.
  123537. *
  123538. * 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.
  123539. * 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.
  123540. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123541. */
  123542. export class ArcRotateCamera extends TargetCamera {
  123543. /**
  123544. * Defines the rotation angle of the camera along the longitudinal axis.
  123545. */
  123546. alpha: number;
  123547. /**
  123548. * Defines the rotation angle of the camera along the latitudinal axis.
  123549. */
  123550. beta: number;
  123551. /**
  123552. * Defines the radius of the camera from it s target point.
  123553. */
  123554. radius: number;
  123555. protected _target: Vector3;
  123556. protected _targetHost: Nullable<AbstractMesh>;
  123557. /**
  123558. * Defines the target point of the camera.
  123559. * The camera looks towards it form the radius distance.
  123560. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123561. */
  123562. get target(): Vector3;
  123563. set target(value: Vector3);
  123564. /**
  123565. * Define the current local position of the camera in the scene
  123566. */
  123567. get position(): Vector3;
  123568. set position(newPosition: Vector3);
  123569. protected _upToYMatrix: Matrix;
  123570. protected _YToUpMatrix: Matrix;
  123571. /**
  123572. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123573. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123574. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123575. */
  123576. set upVector(vec: Vector3);
  123577. get upVector(): Vector3;
  123578. /**
  123579. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123580. */
  123581. setMatUp(): void;
  123582. /**
  123583. * Current inertia value on the longitudinal axis.
  123584. * The bigger this number the longer it will take for the camera to stop.
  123585. */
  123586. inertialAlphaOffset: number;
  123587. /**
  123588. * Current inertia value on the latitudinal axis.
  123589. * The bigger this number the longer it will take for the camera to stop.
  123590. */
  123591. inertialBetaOffset: number;
  123592. /**
  123593. * Current inertia value on the radius axis.
  123594. * The bigger this number the longer it will take for the camera to stop.
  123595. */
  123596. inertialRadiusOffset: number;
  123597. /**
  123598. * Minimum allowed angle on the longitudinal axis.
  123599. * This can help limiting how the Camera is able to move in the scene.
  123600. */
  123601. lowerAlphaLimit: Nullable<number>;
  123602. /**
  123603. * Maximum allowed angle on the longitudinal axis.
  123604. * This can help limiting how the Camera is able to move in the scene.
  123605. */
  123606. upperAlphaLimit: Nullable<number>;
  123607. /**
  123608. * Minimum allowed angle on the latitudinal axis.
  123609. * This can help limiting how the Camera is able to move in the scene.
  123610. */
  123611. lowerBetaLimit: number;
  123612. /**
  123613. * Maximum allowed angle on the latitudinal axis.
  123614. * This can help limiting how the Camera is able to move in the scene.
  123615. */
  123616. upperBetaLimit: number;
  123617. /**
  123618. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123619. * This can help limiting how the Camera is able to move in the scene.
  123620. */
  123621. lowerRadiusLimit: Nullable<number>;
  123622. /**
  123623. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123624. * This can help limiting how the Camera is able to move in the scene.
  123625. */
  123626. upperRadiusLimit: Nullable<number>;
  123627. /**
  123628. * Defines the current inertia value used during panning of the camera along the X axis.
  123629. */
  123630. inertialPanningX: number;
  123631. /**
  123632. * Defines the current inertia value used during panning of the camera along the Y axis.
  123633. */
  123634. inertialPanningY: number;
  123635. /**
  123636. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123637. * Basically if your fingers moves away from more than this distance you will be considered
  123638. * in pinch mode.
  123639. */
  123640. pinchToPanMaxDistance: number;
  123641. /**
  123642. * Defines the maximum distance the camera can pan.
  123643. * This could help keeping the cammera always in your scene.
  123644. */
  123645. panningDistanceLimit: Nullable<number>;
  123646. /**
  123647. * Defines the target of the camera before paning.
  123648. */
  123649. panningOriginTarget: Vector3;
  123650. /**
  123651. * Defines the value of the inertia used during panning.
  123652. * 0 would mean stop inertia and one would mean no decelleration at all.
  123653. */
  123654. panningInertia: number;
  123655. /**
  123656. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123657. */
  123658. get angularSensibilityX(): number;
  123659. set angularSensibilityX(value: number);
  123660. /**
  123661. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123662. */
  123663. get angularSensibilityY(): number;
  123664. set angularSensibilityY(value: number);
  123665. /**
  123666. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123667. */
  123668. get pinchPrecision(): number;
  123669. set pinchPrecision(value: number);
  123670. /**
  123671. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123672. * It will be used instead of pinchDeltaPrecision if different from 0.
  123673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123674. */
  123675. get pinchDeltaPercentage(): number;
  123676. set pinchDeltaPercentage(value: number);
  123677. /**
  123678. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123679. * and pinch delta percentage.
  123680. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123681. * that any object in the plane at the camera's target point will scale
  123682. * perfectly with finger motion.
  123683. */
  123684. get useNaturalPinchZoom(): boolean;
  123685. set useNaturalPinchZoom(value: boolean);
  123686. /**
  123687. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123688. */
  123689. get panningSensibility(): number;
  123690. set panningSensibility(value: number);
  123691. /**
  123692. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123693. */
  123694. get keysUp(): number[];
  123695. set keysUp(value: number[]);
  123696. /**
  123697. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123698. */
  123699. get keysDown(): number[];
  123700. set keysDown(value: number[]);
  123701. /**
  123702. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123703. */
  123704. get keysLeft(): number[];
  123705. set keysLeft(value: number[]);
  123706. /**
  123707. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123708. */
  123709. get keysRight(): number[];
  123710. set keysRight(value: number[]);
  123711. /**
  123712. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123713. */
  123714. get wheelPrecision(): number;
  123715. set wheelPrecision(value: number);
  123716. /**
  123717. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123718. * It will be used instead of pinchDeltaPrecision if different from 0.
  123719. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123720. */
  123721. get wheelDeltaPercentage(): number;
  123722. set wheelDeltaPercentage(value: number);
  123723. /**
  123724. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123725. */
  123726. zoomOnFactor: number;
  123727. /**
  123728. * Defines a screen offset for the camera position.
  123729. */
  123730. targetScreenOffset: Vector2;
  123731. /**
  123732. * Allows the camera to be completely reversed.
  123733. * If false the camera can not arrive upside down.
  123734. */
  123735. allowUpsideDown: boolean;
  123736. /**
  123737. * Define if double tap/click is used to restore the previously saved state of the camera.
  123738. */
  123739. useInputToRestoreState: boolean;
  123740. /** @hidden */
  123741. _viewMatrix: Matrix;
  123742. /** @hidden */
  123743. _useCtrlForPanning: boolean;
  123744. /** @hidden */
  123745. _panningMouseButton: number;
  123746. /**
  123747. * Defines the input associated to the camera.
  123748. */
  123749. inputs: ArcRotateCameraInputsManager;
  123750. /** @hidden */
  123751. _reset: () => void;
  123752. /**
  123753. * Defines the allowed panning axis.
  123754. */
  123755. panningAxis: Vector3;
  123756. protected _localDirection: Vector3;
  123757. protected _transformedDirection: Vector3;
  123758. private _bouncingBehavior;
  123759. /**
  123760. * Gets the bouncing behavior of the camera if it has been enabled.
  123761. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123762. */
  123763. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123764. /**
  123765. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123766. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123767. */
  123768. get useBouncingBehavior(): boolean;
  123769. set useBouncingBehavior(value: boolean);
  123770. private _framingBehavior;
  123771. /**
  123772. * Gets the framing behavior of the camera if it has been enabled.
  123773. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123774. */
  123775. get framingBehavior(): Nullable<FramingBehavior>;
  123776. /**
  123777. * Defines if the framing behavior of the camera is enabled on the camera.
  123778. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123779. */
  123780. get useFramingBehavior(): boolean;
  123781. set useFramingBehavior(value: boolean);
  123782. private _autoRotationBehavior;
  123783. /**
  123784. * Gets the auto rotation behavior of the camera if it has been enabled.
  123785. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123786. */
  123787. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123788. /**
  123789. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123790. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123791. */
  123792. get useAutoRotationBehavior(): boolean;
  123793. set useAutoRotationBehavior(value: boolean);
  123794. /**
  123795. * Observable triggered when the mesh target has been changed on the camera.
  123796. */
  123797. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123798. /**
  123799. * Event raised when the camera is colliding with a mesh.
  123800. */
  123801. onCollide: (collidedMesh: AbstractMesh) => void;
  123802. /**
  123803. * Defines whether the camera should check collision with the objects oh the scene.
  123804. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123805. */
  123806. checkCollisions: boolean;
  123807. /**
  123808. * Defines the collision radius of the camera.
  123809. * This simulates a sphere around the camera.
  123810. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123811. */
  123812. collisionRadius: Vector3;
  123813. protected _collider: Collider;
  123814. protected _previousPosition: Vector3;
  123815. protected _collisionVelocity: Vector3;
  123816. protected _newPosition: Vector3;
  123817. protected _previousAlpha: number;
  123818. protected _previousBeta: number;
  123819. protected _previousRadius: number;
  123820. protected _collisionTriggered: boolean;
  123821. protected _targetBoundingCenter: Nullable<Vector3>;
  123822. private _computationVector;
  123823. /**
  123824. * Instantiates a new ArcRotateCamera in a given scene
  123825. * @param name Defines the name of the camera
  123826. * @param alpha Defines the camera rotation along the logitudinal axis
  123827. * @param beta Defines the camera rotation along the latitudinal axis
  123828. * @param radius Defines the camera distance from its target
  123829. * @param target Defines the camera target
  123830. * @param scene Defines the scene the camera belongs to
  123831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123832. */
  123833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123834. /** @hidden */
  123835. _initCache(): void;
  123836. /** @hidden */
  123837. _updateCache(ignoreParentClass?: boolean): void;
  123838. protected _getTargetPosition(): Vector3;
  123839. private _storedAlpha;
  123840. private _storedBeta;
  123841. private _storedRadius;
  123842. private _storedTarget;
  123843. private _storedTargetScreenOffset;
  123844. /**
  123845. * Stores the current state of the camera (alpha, beta, radius and target)
  123846. * @returns the camera itself
  123847. */
  123848. storeState(): Camera;
  123849. /**
  123850. * @hidden
  123851. * Restored camera state. You must call storeState() first
  123852. */
  123853. _restoreStateValues(): boolean;
  123854. /** @hidden */
  123855. _isSynchronizedViewMatrix(): boolean;
  123856. /**
  123857. * Attached controls to the current camera.
  123858. * @param element Defines the element the controls should be listened from
  123859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123860. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123861. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123862. */
  123863. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123864. /**
  123865. * Detach the current controls from the camera.
  123866. * The camera will stop reacting to inputs.
  123867. * @param element Defines the element to stop listening the inputs from
  123868. */
  123869. detachControl(element: HTMLElement): void;
  123870. /** @hidden */
  123871. _checkInputs(): void;
  123872. protected _checkLimits(): void;
  123873. /**
  123874. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123875. */
  123876. rebuildAnglesAndRadius(): void;
  123877. /**
  123878. * Use a position to define the current camera related information like alpha, beta and radius
  123879. * @param position Defines the position to set the camera at
  123880. */
  123881. setPosition(position: Vector3): void;
  123882. /**
  123883. * Defines the target the camera should look at.
  123884. * This will automatically adapt alpha beta and radius to fit within the new target.
  123885. * @param target Defines the new target as a Vector or a mesh
  123886. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123887. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123888. */
  123889. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123890. /** @hidden */
  123891. _getViewMatrix(): Matrix;
  123892. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123893. /**
  123894. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123895. * @param meshes Defines the mesh to zoom on
  123896. * @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)
  123897. */
  123898. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123899. /**
  123900. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123901. * The target will be changed but the radius
  123902. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123903. * @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)
  123904. */
  123905. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123906. min: Vector3;
  123907. max: Vector3;
  123908. distance: number;
  123909. }, doNotUpdateMaxZ?: boolean): void;
  123910. /**
  123911. * @override
  123912. * Override Camera.createRigCamera
  123913. */
  123914. createRigCamera(name: string, cameraIndex: number): Camera;
  123915. /**
  123916. * @hidden
  123917. * @override
  123918. * Override Camera._updateRigCameras
  123919. */
  123920. _updateRigCameras(): void;
  123921. /**
  123922. * Destroy the camera and release the current resources hold by it.
  123923. */
  123924. dispose(): void;
  123925. /**
  123926. * Gets the current object class name.
  123927. * @return the class name
  123928. */
  123929. getClassName(): string;
  123930. }
  123931. }
  123932. declare module BABYLON {
  123933. /**
  123934. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123935. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123936. */
  123937. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123938. /**
  123939. * Gets the name of the behavior.
  123940. */
  123941. get name(): string;
  123942. private _zoomStopsAnimation;
  123943. private _idleRotationSpeed;
  123944. private _idleRotationWaitTime;
  123945. private _idleRotationSpinupTime;
  123946. /**
  123947. * Sets the flag that indicates if user zooming should stop animation.
  123948. */
  123949. set zoomStopsAnimation(flag: boolean);
  123950. /**
  123951. * Gets the flag that indicates if user zooming should stop animation.
  123952. */
  123953. get zoomStopsAnimation(): boolean;
  123954. /**
  123955. * Sets the default speed at which the camera rotates around the model.
  123956. */
  123957. set idleRotationSpeed(speed: number);
  123958. /**
  123959. * Gets the default speed at which the camera rotates around the model.
  123960. */
  123961. get idleRotationSpeed(): number;
  123962. /**
  123963. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123964. */
  123965. set idleRotationWaitTime(time: number);
  123966. /**
  123967. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123968. */
  123969. get idleRotationWaitTime(): number;
  123970. /**
  123971. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123972. */
  123973. set idleRotationSpinupTime(time: number);
  123974. /**
  123975. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123976. */
  123977. get idleRotationSpinupTime(): number;
  123978. /**
  123979. * Gets a value indicating if the camera is currently rotating because of this behavior
  123980. */
  123981. get rotationInProgress(): boolean;
  123982. private _onPrePointerObservableObserver;
  123983. private _onAfterCheckInputsObserver;
  123984. private _attachedCamera;
  123985. private _isPointerDown;
  123986. private _lastFrameTime;
  123987. private _lastInteractionTime;
  123988. private _cameraRotationSpeed;
  123989. /**
  123990. * Initializes the behavior.
  123991. */
  123992. init(): void;
  123993. /**
  123994. * Attaches the behavior to its arc rotate camera.
  123995. * @param camera Defines the camera to attach the behavior to
  123996. */
  123997. attach(camera: ArcRotateCamera): void;
  123998. /**
  123999. * Detaches the behavior from its current arc rotate camera.
  124000. */
  124001. detach(): void;
  124002. /**
  124003. * Returns true if user is scrolling.
  124004. * @return true if user is scrolling.
  124005. */
  124006. private _userIsZooming;
  124007. private _lastFrameRadius;
  124008. private _shouldAnimationStopForInteraction;
  124009. /**
  124010. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  124011. */
  124012. private _applyUserInteraction;
  124013. private _userIsMoving;
  124014. }
  124015. }
  124016. declare module BABYLON {
  124017. /**
  124018. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  124019. */
  124020. export class AttachToBoxBehavior implements Behavior<Mesh> {
  124021. private ui;
  124022. /**
  124023. * The name of the behavior
  124024. */
  124025. name: string;
  124026. /**
  124027. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  124028. */
  124029. distanceAwayFromFace: number;
  124030. /**
  124031. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  124032. */
  124033. distanceAwayFromBottomOfFace: number;
  124034. private _faceVectors;
  124035. private _target;
  124036. private _scene;
  124037. private _onRenderObserver;
  124038. private _tmpMatrix;
  124039. private _tmpVector;
  124040. /**
  124041. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  124042. * @param ui The transform node that should be attched to the mesh
  124043. */
  124044. constructor(ui: TransformNode);
  124045. /**
  124046. * Initializes the behavior
  124047. */
  124048. init(): void;
  124049. private _closestFace;
  124050. private _zeroVector;
  124051. private _lookAtTmpMatrix;
  124052. private _lookAtToRef;
  124053. /**
  124054. * Attaches the AttachToBoxBehavior to the passed in mesh
  124055. * @param target The mesh that the specified node will be attached to
  124056. */
  124057. attach(target: Mesh): void;
  124058. /**
  124059. * Detaches the behavior from the mesh
  124060. */
  124061. detach(): void;
  124062. }
  124063. }
  124064. declare module BABYLON {
  124065. /**
  124066. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  124067. */
  124068. export class FadeInOutBehavior implements Behavior<Mesh> {
  124069. /**
  124070. * Time in milliseconds to delay before fading in (Default: 0)
  124071. */
  124072. delay: number;
  124073. /**
  124074. * Time in milliseconds for the mesh to fade in (Default: 300)
  124075. */
  124076. fadeInTime: number;
  124077. private _millisecondsPerFrame;
  124078. private _hovered;
  124079. private _hoverValue;
  124080. private _ownerNode;
  124081. /**
  124082. * Instatiates the FadeInOutBehavior
  124083. */
  124084. constructor();
  124085. /**
  124086. * The name of the behavior
  124087. */
  124088. get name(): string;
  124089. /**
  124090. * Initializes the behavior
  124091. */
  124092. init(): void;
  124093. /**
  124094. * Attaches the fade behavior on the passed in mesh
  124095. * @param ownerNode The mesh that will be faded in/out once attached
  124096. */
  124097. attach(ownerNode: Mesh): void;
  124098. /**
  124099. * Detaches the behavior from the mesh
  124100. */
  124101. detach(): void;
  124102. /**
  124103. * Triggers the mesh to begin fading in or out
  124104. * @param value if the object should fade in or out (true to fade in)
  124105. */
  124106. fadeIn(value: boolean): void;
  124107. private _update;
  124108. private _setAllVisibility;
  124109. }
  124110. }
  124111. declare module BABYLON {
  124112. /**
  124113. * Class containing a set of static utilities functions for managing Pivots
  124114. * @hidden
  124115. */
  124116. export class PivotTools {
  124117. private static _PivotCached;
  124118. private static _OldPivotPoint;
  124119. private static _PivotTranslation;
  124120. private static _PivotTmpVector;
  124121. private static _PivotPostMultiplyPivotMatrix;
  124122. /** @hidden */
  124123. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  124124. /** @hidden */
  124125. static _RestorePivotPoint(mesh: AbstractMesh): void;
  124126. }
  124127. }
  124128. declare module BABYLON {
  124129. /**
  124130. * Class containing static functions to help procedurally build meshes
  124131. */
  124132. export class PlaneBuilder {
  124133. /**
  124134. * Creates a plane mesh
  124135. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124136. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124137. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124141. * @param name defines the name of the mesh
  124142. * @param options defines the options used to create the mesh
  124143. * @param scene defines the hosting scene
  124144. * @returns the plane mesh
  124145. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124146. */
  124147. static CreatePlane(name: string, options: {
  124148. size?: number;
  124149. width?: number;
  124150. height?: number;
  124151. sideOrientation?: number;
  124152. frontUVs?: Vector4;
  124153. backUVs?: Vector4;
  124154. updatable?: boolean;
  124155. sourcePlane?: Plane;
  124156. }, scene?: Nullable<Scene>): Mesh;
  124157. }
  124158. }
  124159. declare module BABYLON {
  124160. /**
  124161. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  124162. */
  124163. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  124164. private static _AnyMouseID;
  124165. /**
  124166. * Abstract mesh the behavior is set on
  124167. */
  124168. attachedNode: AbstractMesh;
  124169. private _dragPlane;
  124170. private _scene;
  124171. private _pointerObserver;
  124172. private _beforeRenderObserver;
  124173. private static _planeScene;
  124174. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  124175. /**
  124176. * 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)
  124177. */
  124178. maxDragAngle: number;
  124179. /**
  124180. * @hidden
  124181. */
  124182. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  124183. /**
  124184. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124185. */
  124186. currentDraggingPointerID: number;
  124187. /**
  124188. * The last position where the pointer hit the drag plane in world space
  124189. */
  124190. lastDragPosition: Vector3;
  124191. /**
  124192. * If the behavior is currently in a dragging state
  124193. */
  124194. dragging: boolean;
  124195. /**
  124196. * 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)
  124197. */
  124198. dragDeltaRatio: number;
  124199. /**
  124200. * If the drag plane orientation should be updated during the dragging (Default: true)
  124201. */
  124202. updateDragPlane: boolean;
  124203. private _debugMode;
  124204. private _moving;
  124205. /**
  124206. * Fires each time the attached mesh is dragged with the pointer
  124207. * * delta between last drag position and current drag position in world space
  124208. * * dragDistance along the drag axis
  124209. * * dragPlaneNormal normal of the current drag plane used during the drag
  124210. * * dragPlanePoint in world space where the drag intersects the drag plane
  124211. */
  124212. onDragObservable: Observable<{
  124213. delta: Vector3;
  124214. dragPlanePoint: Vector3;
  124215. dragPlaneNormal: Vector3;
  124216. dragDistance: number;
  124217. pointerId: number;
  124218. }>;
  124219. /**
  124220. * Fires each time a drag begins (eg. mouse down on mesh)
  124221. */
  124222. onDragStartObservable: Observable<{
  124223. dragPlanePoint: Vector3;
  124224. pointerId: number;
  124225. }>;
  124226. /**
  124227. * Fires each time a drag ends (eg. mouse release after drag)
  124228. */
  124229. onDragEndObservable: Observable<{
  124230. dragPlanePoint: Vector3;
  124231. pointerId: number;
  124232. }>;
  124233. /**
  124234. * If the attached mesh should be moved when dragged
  124235. */
  124236. moveAttached: boolean;
  124237. /**
  124238. * If the drag behavior will react to drag events (Default: true)
  124239. */
  124240. enabled: boolean;
  124241. /**
  124242. * If pointer events should start and release the drag (Default: true)
  124243. */
  124244. startAndReleaseDragOnPointerEvents: boolean;
  124245. /**
  124246. * If camera controls should be detached during the drag
  124247. */
  124248. detachCameraControls: boolean;
  124249. /**
  124250. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  124251. */
  124252. useObjectOrientationForDragging: boolean;
  124253. private _options;
  124254. /**
  124255. * Gets the options used by the behavior
  124256. */
  124257. get options(): {
  124258. dragAxis?: Vector3;
  124259. dragPlaneNormal?: Vector3;
  124260. };
  124261. /**
  124262. * Sets the options used by the behavior
  124263. */
  124264. set options(options: {
  124265. dragAxis?: Vector3;
  124266. dragPlaneNormal?: Vector3;
  124267. });
  124268. /**
  124269. * Creates a pointer drag behavior that can be attached to a mesh
  124270. * @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)
  124271. */
  124272. constructor(options?: {
  124273. dragAxis?: Vector3;
  124274. dragPlaneNormal?: Vector3;
  124275. });
  124276. /**
  124277. * Predicate to determine if it is valid to move the object to a new position when it is moved
  124278. */
  124279. validateDrag: (targetPosition: Vector3) => boolean;
  124280. /**
  124281. * The name of the behavior
  124282. */
  124283. get name(): string;
  124284. /**
  124285. * Initializes the behavior
  124286. */
  124287. init(): void;
  124288. private _tmpVector;
  124289. private _alternatePickedPoint;
  124290. private _worldDragAxis;
  124291. private _targetPosition;
  124292. private _attachedElement;
  124293. /**
  124294. * Attaches the drag behavior the passed in mesh
  124295. * @param ownerNode The mesh that will be dragged around once attached
  124296. * @param predicate Predicate to use for pick filtering
  124297. */
  124298. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  124299. /**
  124300. * Force relase the drag action by code.
  124301. */
  124302. releaseDrag(): void;
  124303. private _startDragRay;
  124304. private _lastPointerRay;
  124305. /**
  124306. * Simulates the start of a pointer drag event on the behavior
  124307. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  124308. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  124309. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  124310. */
  124311. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124312. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124313. private _dragDelta;
  124314. protected _moveDrag(ray: Ray): void;
  124315. private _pickWithRayOnDragPlane;
  124316. private _pointA;
  124317. private _pointC;
  124318. private _localAxis;
  124319. private _lookAt;
  124320. private _updateDragPlanePosition;
  124321. /**
  124322. * Detaches the behavior from the mesh
  124323. */
  124324. detach(): void;
  124325. }
  124326. }
  124327. declare module BABYLON {
  124328. /**
  124329. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124330. */
  124331. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124332. private _dragBehaviorA;
  124333. private _dragBehaviorB;
  124334. private _startDistance;
  124335. private _initialScale;
  124336. private _targetScale;
  124337. private _ownerNode;
  124338. private _sceneRenderObserver;
  124339. /**
  124340. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124341. */
  124342. constructor();
  124343. /**
  124344. * The name of the behavior
  124345. */
  124346. get name(): string;
  124347. /**
  124348. * Initializes the behavior
  124349. */
  124350. init(): void;
  124351. private _getCurrentDistance;
  124352. /**
  124353. * Attaches the scale behavior the passed in mesh
  124354. * @param ownerNode The mesh that will be scaled around once attached
  124355. */
  124356. attach(ownerNode: Mesh): void;
  124357. /**
  124358. * Detaches the behavior from the mesh
  124359. */
  124360. detach(): void;
  124361. }
  124362. }
  124363. declare module BABYLON {
  124364. /**
  124365. * 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
  124366. */
  124367. export class SixDofDragBehavior implements Behavior<Mesh> {
  124368. private static _virtualScene;
  124369. private _ownerNode;
  124370. private _sceneRenderObserver;
  124371. private _scene;
  124372. private _targetPosition;
  124373. private _virtualOriginMesh;
  124374. private _virtualDragMesh;
  124375. private _pointerObserver;
  124376. private _moving;
  124377. private _startingOrientation;
  124378. private _attachedElement;
  124379. /**
  124380. * 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)
  124381. */
  124382. private zDragFactor;
  124383. /**
  124384. * If the object should rotate to face the drag origin
  124385. */
  124386. rotateDraggedObject: boolean;
  124387. /**
  124388. * If the behavior is currently in a dragging state
  124389. */
  124390. dragging: boolean;
  124391. /**
  124392. * 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)
  124393. */
  124394. dragDeltaRatio: number;
  124395. /**
  124396. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124397. */
  124398. currentDraggingPointerID: number;
  124399. /**
  124400. * If camera controls should be detached during the drag
  124401. */
  124402. detachCameraControls: boolean;
  124403. /**
  124404. * Fires each time a drag starts
  124405. */
  124406. onDragStartObservable: Observable<{}>;
  124407. /**
  124408. * Fires each time a drag ends (eg. mouse release after drag)
  124409. */
  124410. onDragEndObservable: Observable<{}>;
  124411. /**
  124412. * 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
  124413. */
  124414. constructor();
  124415. /**
  124416. * The name of the behavior
  124417. */
  124418. get name(): string;
  124419. /**
  124420. * Initializes the behavior
  124421. */
  124422. init(): void;
  124423. /**
  124424. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124425. */
  124426. private get _pointerCamera();
  124427. /**
  124428. * Attaches the scale behavior the passed in mesh
  124429. * @param ownerNode The mesh that will be scaled around once attached
  124430. */
  124431. attach(ownerNode: Mesh): void;
  124432. /**
  124433. * Detaches the behavior from the mesh
  124434. */
  124435. detach(): void;
  124436. }
  124437. }
  124438. declare module BABYLON {
  124439. /**
  124440. * Class used to apply inverse kinematics to bones
  124441. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124442. */
  124443. export class BoneIKController {
  124444. private static _tmpVecs;
  124445. private static _tmpQuat;
  124446. private static _tmpMats;
  124447. /**
  124448. * Gets or sets the target mesh
  124449. */
  124450. targetMesh: AbstractMesh;
  124451. /** Gets or sets the mesh used as pole */
  124452. poleTargetMesh: AbstractMesh;
  124453. /**
  124454. * Gets or sets the bone used as pole
  124455. */
  124456. poleTargetBone: Nullable<Bone>;
  124457. /**
  124458. * Gets or sets the target position
  124459. */
  124460. targetPosition: Vector3;
  124461. /**
  124462. * Gets or sets the pole target position
  124463. */
  124464. poleTargetPosition: Vector3;
  124465. /**
  124466. * Gets or sets the pole target local offset
  124467. */
  124468. poleTargetLocalOffset: Vector3;
  124469. /**
  124470. * Gets or sets the pole angle
  124471. */
  124472. poleAngle: number;
  124473. /**
  124474. * Gets or sets the mesh associated with the controller
  124475. */
  124476. mesh: AbstractMesh;
  124477. /**
  124478. * 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)
  124479. */
  124480. slerpAmount: number;
  124481. private _bone1Quat;
  124482. private _bone1Mat;
  124483. private _bone2Ang;
  124484. private _bone1;
  124485. private _bone2;
  124486. private _bone1Length;
  124487. private _bone2Length;
  124488. private _maxAngle;
  124489. private _maxReach;
  124490. private _rightHandedSystem;
  124491. private _bendAxis;
  124492. private _slerping;
  124493. private _adjustRoll;
  124494. /**
  124495. * Gets or sets maximum allowed angle
  124496. */
  124497. get maxAngle(): number;
  124498. set maxAngle(value: number);
  124499. /**
  124500. * Creates a new BoneIKController
  124501. * @param mesh defines the mesh to control
  124502. * @param bone defines the bone to control
  124503. * @param options defines options to set up the controller
  124504. */
  124505. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124506. targetMesh?: AbstractMesh;
  124507. poleTargetMesh?: AbstractMesh;
  124508. poleTargetBone?: Bone;
  124509. poleTargetLocalOffset?: Vector3;
  124510. poleAngle?: number;
  124511. bendAxis?: Vector3;
  124512. maxAngle?: number;
  124513. slerpAmount?: number;
  124514. });
  124515. private _setMaxAngle;
  124516. /**
  124517. * Force the controller to update the bones
  124518. */
  124519. update(): void;
  124520. }
  124521. }
  124522. declare module BABYLON {
  124523. /**
  124524. * Class used to make a bone look toward a point in space
  124525. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124526. */
  124527. export class BoneLookController {
  124528. private static _tmpVecs;
  124529. private static _tmpQuat;
  124530. private static _tmpMats;
  124531. /**
  124532. * The target Vector3 that the bone will look at
  124533. */
  124534. target: Vector3;
  124535. /**
  124536. * The mesh that the bone is attached to
  124537. */
  124538. mesh: AbstractMesh;
  124539. /**
  124540. * The bone that will be looking to the target
  124541. */
  124542. bone: Bone;
  124543. /**
  124544. * The up axis of the coordinate system that is used when the bone is rotated
  124545. */
  124546. upAxis: Vector3;
  124547. /**
  124548. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124549. */
  124550. upAxisSpace: Space;
  124551. /**
  124552. * Used to make an adjustment to the yaw of the bone
  124553. */
  124554. adjustYaw: number;
  124555. /**
  124556. * Used to make an adjustment to the pitch of the bone
  124557. */
  124558. adjustPitch: number;
  124559. /**
  124560. * Used to make an adjustment to the roll of the bone
  124561. */
  124562. adjustRoll: number;
  124563. /**
  124564. * 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)
  124565. */
  124566. slerpAmount: number;
  124567. private _minYaw;
  124568. private _maxYaw;
  124569. private _minPitch;
  124570. private _maxPitch;
  124571. private _minYawSin;
  124572. private _minYawCos;
  124573. private _maxYawSin;
  124574. private _maxYawCos;
  124575. private _midYawConstraint;
  124576. private _minPitchTan;
  124577. private _maxPitchTan;
  124578. private _boneQuat;
  124579. private _slerping;
  124580. private _transformYawPitch;
  124581. private _transformYawPitchInv;
  124582. private _firstFrameSkipped;
  124583. private _yawRange;
  124584. private _fowardAxis;
  124585. /**
  124586. * Gets or sets the minimum yaw angle that the bone can look to
  124587. */
  124588. get minYaw(): number;
  124589. set minYaw(value: number);
  124590. /**
  124591. * Gets or sets the maximum yaw angle that the bone can look to
  124592. */
  124593. get maxYaw(): number;
  124594. set maxYaw(value: number);
  124595. /**
  124596. * Gets or sets the minimum pitch angle that the bone can look to
  124597. */
  124598. get minPitch(): number;
  124599. set minPitch(value: number);
  124600. /**
  124601. * Gets or sets the maximum pitch angle that the bone can look to
  124602. */
  124603. get maxPitch(): number;
  124604. set maxPitch(value: number);
  124605. /**
  124606. * Create a BoneLookController
  124607. * @param mesh the mesh that the bone belongs to
  124608. * @param bone the bone that will be looking to the target
  124609. * @param target the target Vector3 to look at
  124610. * @param options optional settings:
  124611. * * maxYaw: the maximum angle the bone will yaw to
  124612. * * minYaw: the minimum angle the bone will yaw to
  124613. * * maxPitch: the maximum angle the bone will pitch to
  124614. * * minPitch: the minimum angle the bone will yaw to
  124615. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124616. * * upAxis: the up axis of the coordinate system
  124617. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124618. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124619. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124620. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124621. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124622. * * adjustRoll: used to make an adjustment to the roll of the bone
  124623. **/
  124624. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124625. maxYaw?: number;
  124626. minYaw?: number;
  124627. maxPitch?: number;
  124628. minPitch?: number;
  124629. slerpAmount?: number;
  124630. upAxis?: Vector3;
  124631. upAxisSpace?: Space;
  124632. yawAxis?: Vector3;
  124633. pitchAxis?: Vector3;
  124634. adjustYaw?: number;
  124635. adjustPitch?: number;
  124636. adjustRoll?: number;
  124637. });
  124638. /**
  124639. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124640. */
  124641. update(): void;
  124642. private _getAngleDiff;
  124643. private _getAngleBetween;
  124644. private _isAngleBetween;
  124645. }
  124646. }
  124647. declare module BABYLON {
  124648. /**
  124649. * Manage the gamepad inputs to control an arc rotate camera.
  124650. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124651. */
  124652. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124653. /**
  124654. * Defines the camera the input is attached to.
  124655. */
  124656. camera: ArcRotateCamera;
  124657. /**
  124658. * Defines the gamepad the input is gathering event from.
  124659. */
  124660. gamepad: Nullable<Gamepad>;
  124661. /**
  124662. * Defines the gamepad rotation sensiblity.
  124663. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124664. */
  124665. gamepadRotationSensibility: number;
  124666. /**
  124667. * Defines the gamepad move sensiblity.
  124668. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124669. */
  124670. gamepadMoveSensibility: number;
  124671. private _yAxisScale;
  124672. /**
  124673. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124674. */
  124675. get invertYAxis(): boolean;
  124676. set invertYAxis(value: boolean);
  124677. private _onGamepadConnectedObserver;
  124678. private _onGamepadDisconnectedObserver;
  124679. /**
  124680. * Attach the input controls to a specific dom element to get the input from.
  124681. * @param element Defines the element the controls should be listened from
  124682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124683. */
  124684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124685. /**
  124686. * Detach the current controls from the specified dom element.
  124687. * @param element Defines the element to stop listening the inputs from
  124688. */
  124689. detachControl(element: Nullable<HTMLElement>): void;
  124690. /**
  124691. * Update the current camera state depending on the inputs that have been used this frame.
  124692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124693. */
  124694. checkInputs(): void;
  124695. /**
  124696. * Gets the class name of the current intput.
  124697. * @returns the class name
  124698. */
  124699. getClassName(): string;
  124700. /**
  124701. * Get the friendly name associated with the input class.
  124702. * @returns the input friendly name
  124703. */
  124704. getSimpleName(): string;
  124705. }
  124706. }
  124707. declare module BABYLON {
  124708. interface ArcRotateCameraInputsManager {
  124709. /**
  124710. * Add orientation input support to the input manager.
  124711. * @returns the current input manager
  124712. */
  124713. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124714. }
  124715. /**
  124716. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124717. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124718. */
  124719. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124720. /**
  124721. * Defines the camera the input is attached to.
  124722. */
  124723. camera: ArcRotateCamera;
  124724. /**
  124725. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124726. */
  124727. alphaCorrection: number;
  124728. /**
  124729. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124730. */
  124731. gammaCorrection: number;
  124732. private _alpha;
  124733. private _gamma;
  124734. private _dirty;
  124735. private _deviceOrientationHandler;
  124736. /**
  124737. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124738. */
  124739. constructor();
  124740. /**
  124741. * Attach the input controls to a specific dom element to get the input from.
  124742. * @param element Defines the element the controls should be listened from
  124743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124744. */
  124745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124746. /** @hidden */
  124747. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124748. /**
  124749. * Update the current camera state depending on the inputs that have been used this frame.
  124750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124751. */
  124752. checkInputs(): void;
  124753. /**
  124754. * Detach the current controls from the specified dom element.
  124755. * @param element Defines the element to stop listening the inputs from
  124756. */
  124757. detachControl(element: Nullable<HTMLElement>): void;
  124758. /**
  124759. * Gets the class name of the current intput.
  124760. * @returns the class name
  124761. */
  124762. getClassName(): string;
  124763. /**
  124764. * Get the friendly name associated with the input class.
  124765. * @returns the input friendly name
  124766. */
  124767. getSimpleName(): string;
  124768. }
  124769. }
  124770. declare module BABYLON {
  124771. /**
  124772. * Listen to mouse events to control the camera.
  124773. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124774. */
  124775. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124776. /**
  124777. * Defines the camera the input is attached to.
  124778. */
  124779. camera: FlyCamera;
  124780. /**
  124781. * Defines if touch is enabled. (Default is true.)
  124782. */
  124783. touchEnabled: boolean;
  124784. /**
  124785. * Defines the buttons associated with the input to handle camera rotation.
  124786. */
  124787. buttons: number[];
  124788. /**
  124789. * Assign buttons for Yaw control.
  124790. */
  124791. buttonsYaw: number[];
  124792. /**
  124793. * Assign buttons for Pitch control.
  124794. */
  124795. buttonsPitch: number[];
  124796. /**
  124797. * Assign buttons for Roll control.
  124798. */
  124799. buttonsRoll: number[];
  124800. /**
  124801. * Detect if any button is being pressed while mouse is moved.
  124802. * -1 = Mouse locked.
  124803. * 0 = Left button.
  124804. * 1 = Middle Button.
  124805. * 2 = Right Button.
  124806. */
  124807. activeButton: number;
  124808. /**
  124809. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124810. * Higher values reduce its sensitivity.
  124811. */
  124812. angularSensibility: number;
  124813. private _mousemoveCallback;
  124814. private _observer;
  124815. private _rollObserver;
  124816. private previousPosition;
  124817. private noPreventDefault;
  124818. private element;
  124819. /**
  124820. * Listen to mouse events to control the camera.
  124821. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124823. */
  124824. constructor(touchEnabled?: boolean);
  124825. /**
  124826. * Attach the mouse control to the HTML DOM element.
  124827. * @param element Defines the element that listens to the input events.
  124828. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124829. */
  124830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124831. /**
  124832. * Detach the current controls from the specified dom element.
  124833. * @param element Defines the element to stop listening the inputs from
  124834. */
  124835. detachControl(element: Nullable<HTMLElement>): void;
  124836. /**
  124837. * Gets the class name of the current input.
  124838. * @returns the class name.
  124839. */
  124840. getClassName(): string;
  124841. /**
  124842. * Get the friendly name associated with the input class.
  124843. * @returns the input's friendly name.
  124844. */
  124845. getSimpleName(): string;
  124846. private _pointerInput;
  124847. private _onMouseMove;
  124848. /**
  124849. * Rotate camera by mouse offset.
  124850. */
  124851. private rotateCamera;
  124852. }
  124853. }
  124854. declare module BABYLON {
  124855. /**
  124856. * Default Inputs manager for the FlyCamera.
  124857. * It groups all the default supported inputs for ease of use.
  124858. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124859. */
  124860. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124861. /**
  124862. * Instantiates a new FlyCameraInputsManager.
  124863. * @param camera Defines the camera the inputs belong to.
  124864. */
  124865. constructor(camera: FlyCamera);
  124866. /**
  124867. * Add keyboard input support to the input manager.
  124868. * @returns the new FlyCameraKeyboardMoveInput().
  124869. */
  124870. addKeyboard(): FlyCameraInputsManager;
  124871. /**
  124872. * Add mouse input support to the input manager.
  124873. * @param touchEnabled Enable touch screen support.
  124874. * @returns the new FlyCameraMouseInput().
  124875. */
  124876. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124877. }
  124878. }
  124879. declare module BABYLON {
  124880. /**
  124881. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124882. * such as in a 3D Space Shooter or a Flight Simulator.
  124883. */
  124884. export class FlyCamera extends TargetCamera {
  124885. /**
  124886. * Define the collision ellipsoid of the camera.
  124887. * This is helpful for simulating a camera body, like a player's body.
  124888. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124889. */
  124890. ellipsoid: Vector3;
  124891. /**
  124892. * Define an offset for the position of the ellipsoid around the camera.
  124893. * This can be helpful if the camera is attached away from the player's body center,
  124894. * such as at its head.
  124895. */
  124896. ellipsoidOffset: Vector3;
  124897. /**
  124898. * Enable or disable collisions of the camera with the rest of the scene objects.
  124899. */
  124900. checkCollisions: boolean;
  124901. /**
  124902. * Enable or disable gravity on the camera.
  124903. */
  124904. applyGravity: boolean;
  124905. /**
  124906. * Define the current direction the camera is moving to.
  124907. */
  124908. cameraDirection: Vector3;
  124909. /**
  124910. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124911. * This overrides and empties cameraRotation.
  124912. */
  124913. rotationQuaternion: Quaternion;
  124914. /**
  124915. * Track Roll to maintain the wanted Rolling when looking around.
  124916. */
  124917. _trackRoll: number;
  124918. /**
  124919. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124920. */
  124921. rollCorrect: number;
  124922. /**
  124923. * Mimic a banked turn, Rolling the camera when Yawing.
  124924. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124925. */
  124926. bankedTurn: boolean;
  124927. /**
  124928. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124929. */
  124930. bankedTurnLimit: number;
  124931. /**
  124932. * Value of 0 disables the banked Roll.
  124933. * Value of 1 is equal to the Yaw angle in radians.
  124934. */
  124935. bankedTurnMultiplier: number;
  124936. /**
  124937. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124938. */
  124939. inputs: FlyCameraInputsManager;
  124940. /**
  124941. * Gets the input sensibility for mouse input.
  124942. * Higher values reduce sensitivity.
  124943. */
  124944. get angularSensibility(): number;
  124945. /**
  124946. * Sets the input sensibility for a mouse input.
  124947. * Higher values reduce sensitivity.
  124948. */
  124949. set angularSensibility(value: number);
  124950. /**
  124951. * Get the keys for camera movement forward.
  124952. */
  124953. get keysForward(): number[];
  124954. /**
  124955. * Set the keys for camera movement forward.
  124956. */
  124957. set keysForward(value: number[]);
  124958. /**
  124959. * Get the keys for camera movement backward.
  124960. */
  124961. get keysBackward(): number[];
  124962. set keysBackward(value: number[]);
  124963. /**
  124964. * Get the keys for camera movement up.
  124965. */
  124966. get keysUp(): number[];
  124967. /**
  124968. * Set the keys for camera movement up.
  124969. */
  124970. set keysUp(value: number[]);
  124971. /**
  124972. * Get the keys for camera movement down.
  124973. */
  124974. get keysDown(): number[];
  124975. /**
  124976. * Set the keys for camera movement down.
  124977. */
  124978. set keysDown(value: number[]);
  124979. /**
  124980. * Get the keys for camera movement left.
  124981. */
  124982. get keysLeft(): number[];
  124983. /**
  124984. * Set the keys for camera movement left.
  124985. */
  124986. set keysLeft(value: number[]);
  124987. /**
  124988. * Set the keys for camera movement right.
  124989. */
  124990. get keysRight(): number[];
  124991. /**
  124992. * Set the keys for camera movement right.
  124993. */
  124994. set keysRight(value: number[]);
  124995. /**
  124996. * Event raised when the camera collides with a mesh in the scene.
  124997. */
  124998. onCollide: (collidedMesh: AbstractMesh) => void;
  124999. private _collider;
  125000. private _needMoveForGravity;
  125001. private _oldPosition;
  125002. private _diffPosition;
  125003. private _newPosition;
  125004. /** @hidden */
  125005. _localDirection: Vector3;
  125006. /** @hidden */
  125007. _transformedDirection: Vector3;
  125008. /**
  125009. * Instantiates a FlyCamera.
  125010. * This is a flying camera, designed for 3D movement and rotation in all directions,
  125011. * such as in a 3D Space Shooter or a Flight Simulator.
  125012. * @param name Define the name of the camera in the scene.
  125013. * @param position Define the starting position of the camera in the scene.
  125014. * @param scene Define the scene the camera belongs to.
  125015. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  125016. */
  125017. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  125018. /**
  125019. * Attach a control to the HTML DOM element.
  125020. * @param element Defines the element that listens to the input events.
  125021. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  125022. */
  125023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125024. /**
  125025. * Detach a control from the HTML DOM element.
  125026. * The camera will stop reacting to that input.
  125027. * @param element Defines the element that listens to the input events.
  125028. */
  125029. detachControl(element: HTMLElement): void;
  125030. private _collisionMask;
  125031. /**
  125032. * Get the mask that the camera ignores in collision events.
  125033. */
  125034. get collisionMask(): number;
  125035. /**
  125036. * Set the mask that the camera ignores in collision events.
  125037. */
  125038. set collisionMask(mask: number);
  125039. /** @hidden */
  125040. _collideWithWorld(displacement: Vector3): void;
  125041. /** @hidden */
  125042. private _onCollisionPositionChange;
  125043. /** @hidden */
  125044. _checkInputs(): void;
  125045. /** @hidden */
  125046. _decideIfNeedsToMove(): boolean;
  125047. /** @hidden */
  125048. _updatePosition(): void;
  125049. /**
  125050. * Restore the Roll to its target value at the rate specified.
  125051. * @param rate - Higher means slower restoring.
  125052. * @hidden
  125053. */
  125054. restoreRoll(rate: number): void;
  125055. /**
  125056. * Destroy the camera and release the current resources held by it.
  125057. */
  125058. dispose(): void;
  125059. /**
  125060. * Get the current object class name.
  125061. * @returns the class name.
  125062. */
  125063. getClassName(): string;
  125064. }
  125065. }
  125066. declare module BABYLON {
  125067. /**
  125068. * Listen to keyboard events to control the camera.
  125069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125070. */
  125071. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  125072. /**
  125073. * Defines the camera the input is attached to.
  125074. */
  125075. camera: FlyCamera;
  125076. /**
  125077. * The list of keyboard keys used to control the forward move of the camera.
  125078. */
  125079. keysForward: number[];
  125080. /**
  125081. * The list of keyboard keys used to control the backward move of the camera.
  125082. */
  125083. keysBackward: number[];
  125084. /**
  125085. * The list of keyboard keys used to control the forward move of the camera.
  125086. */
  125087. keysUp: number[];
  125088. /**
  125089. * The list of keyboard keys used to control the backward move of the camera.
  125090. */
  125091. keysDown: number[];
  125092. /**
  125093. * The list of keyboard keys used to control the right strafe move of the camera.
  125094. */
  125095. keysRight: number[];
  125096. /**
  125097. * The list of keyboard keys used to control the left strafe move of the camera.
  125098. */
  125099. keysLeft: number[];
  125100. private _keys;
  125101. private _onCanvasBlurObserver;
  125102. private _onKeyboardObserver;
  125103. private _engine;
  125104. private _scene;
  125105. /**
  125106. * Attach the input controls to a specific dom element to get the input from.
  125107. * @param element Defines the element the controls should be listened from
  125108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125109. */
  125110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125111. /**
  125112. * Detach the current controls from the specified dom element.
  125113. * @param element Defines the element to stop listening the inputs from
  125114. */
  125115. detachControl(element: Nullable<HTMLElement>): void;
  125116. /**
  125117. * Gets the class name of the current intput.
  125118. * @returns the class name
  125119. */
  125120. getClassName(): string;
  125121. /** @hidden */
  125122. _onLostFocus(e: FocusEvent): void;
  125123. /**
  125124. * Get the friendly name associated with the input class.
  125125. * @returns the input friendly name
  125126. */
  125127. getSimpleName(): string;
  125128. /**
  125129. * Update the current camera state depending on the inputs that have been used this frame.
  125130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125131. */
  125132. checkInputs(): void;
  125133. }
  125134. }
  125135. declare module BABYLON {
  125136. /**
  125137. * Manage the mouse wheel inputs to control a follow camera.
  125138. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125139. */
  125140. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  125141. /**
  125142. * Defines the camera the input is attached to.
  125143. */
  125144. camera: FollowCamera;
  125145. /**
  125146. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  125147. */
  125148. axisControlRadius: boolean;
  125149. /**
  125150. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  125151. */
  125152. axisControlHeight: boolean;
  125153. /**
  125154. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  125155. */
  125156. axisControlRotation: boolean;
  125157. /**
  125158. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  125159. * relation to mouseWheel events.
  125160. */
  125161. wheelPrecision: number;
  125162. /**
  125163. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  125164. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  125165. */
  125166. wheelDeltaPercentage: number;
  125167. private _wheel;
  125168. private _observer;
  125169. /**
  125170. * Attach the input controls to a specific dom element to get the input from.
  125171. * @param element Defines the element the controls should be listened from
  125172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125173. */
  125174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125175. /**
  125176. * Detach the current controls from the specified dom element.
  125177. * @param element Defines the element to stop listening the inputs from
  125178. */
  125179. detachControl(element: Nullable<HTMLElement>): void;
  125180. /**
  125181. * Gets the class name of the current intput.
  125182. * @returns the class name
  125183. */
  125184. getClassName(): string;
  125185. /**
  125186. * Get the friendly name associated with the input class.
  125187. * @returns the input friendly name
  125188. */
  125189. getSimpleName(): string;
  125190. }
  125191. }
  125192. declare module BABYLON {
  125193. /**
  125194. * Manage the pointers inputs to control an follow camera.
  125195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125196. */
  125197. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  125198. /**
  125199. * Defines the camera the input is attached to.
  125200. */
  125201. camera: FollowCamera;
  125202. /**
  125203. * Gets the class name of the current input.
  125204. * @returns the class name
  125205. */
  125206. getClassName(): string;
  125207. /**
  125208. * Defines the pointer angular sensibility along the X axis or how fast is
  125209. * the camera rotating.
  125210. * A negative number will reverse the axis direction.
  125211. */
  125212. angularSensibilityX: number;
  125213. /**
  125214. * Defines the pointer angular sensibility along the Y axis or how fast is
  125215. * the camera rotating.
  125216. * A negative number will reverse the axis direction.
  125217. */
  125218. angularSensibilityY: number;
  125219. /**
  125220. * Defines the pointer pinch precision or how fast is the camera zooming.
  125221. * A negative number will reverse the axis direction.
  125222. */
  125223. pinchPrecision: number;
  125224. /**
  125225. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  125226. * from 0.
  125227. * It defines the percentage of current camera.radius to use as delta when
  125228. * pinch zoom is used.
  125229. */
  125230. pinchDeltaPercentage: number;
  125231. /**
  125232. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  125233. */
  125234. axisXControlRadius: boolean;
  125235. /**
  125236. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  125237. */
  125238. axisXControlHeight: boolean;
  125239. /**
  125240. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  125241. */
  125242. axisXControlRotation: boolean;
  125243. /**
  125244. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  125245. */
  125246. axisYControlRadius: boolean;
  125247. /**
  125248. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  125249. */
  125250. axisYControlHeight: boolean;
  125251. /**
  125252. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  125253. */
  125254. axisYControlRotation: boolean;
  125255. /**
  125256. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  125257. */
  125258. axisPinchControlRadius: boolean;
  125259. /**
  125260. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  125261. */
  125262. axisPinchControlHeight: boolean;
  125263. /**
  125264. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  125265. */
  125266. axisPinchControlRotation: boolean;
  125267. /**
  125268. * Log error messages if basic misconfiguration has occurred.
  125269. */
  125270. warningEnable: boolean;
  125271. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  125272. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  125273. private _warningCounter;
  125274. private _warning;
  125275. }
  125276. }
  125277. declare module BABYLON {
  125278. /**
  125279. * Default Inputs manager for the FollowCamera.
  125280. * It groups all the default supported inputs for ease of use.
  125281. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125282. */
  125283. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  125284. /**
  125285. * Instantiates a new FollowCameraInputsManager.
  125286. * @param camera Defines the camera the inputs belong to
  125287. */
  125288. constructor(camera: FollowCamera);
  125289. /**
  125290. * Add keyboard input support to the input manager.
  125291. * @returns the current input manager
  125292. */
  125293. addKeyboard(): FollowCameraInputsManager;
  125294. /**
  125295. * Add mouse wheel input support to the input manager.
  125296. * @returns the current input manager
  125297. */
  125298. addMouseWheel(): FollowCameraInputsManager;
  125299. /**
  125300. * Add pointers input support to the input manager.
  125301. * @returns the current input manager
  125302. */
  125303. addPointers(): FollowCameraInputsManager;
  125304. /**
  125305. * Add orientation input support to the input manager.
  125306. * @returns the current input manager
  125307. */
  125308. addVRDeviceOrientation(): FollowCameraInputsManager;
  125309. }
  125310. }
  125311. declare module BABYLON {
  125312. /**
  125313. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125314. * an arc rotate version arcFollowCamera are available.
  125315. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125316. */
  125317. export class FollowCamera extends TargetCamera {
  125318. /**
  125319. * Distance the follow camera should follow an object at
  125320. */
  125321. radius: number;
  125322. /**
  125323. * Minimum allowed distance of the camera to the axis of rotation
  125324. * (The camera can not get closer).
  125325. * This can help limiting how the Camera is able to move in the scene.
  125326. */
  125327. lowerRadiusLimit: Nullable<number>;
  125328. /**
  125329. * Maximum allowed distance of the camera to the axis of rotation
  125330. * (The camera can not get further).
  125331. * This can help limiting how the Camera is able to move in the scene.
  125332. */
  125333. upperRadiusLimit: Nullable<number>;
  125334. /**
  125335. * Define a rotation offset between the camera and the object it follows
  125336. */
  125337. rotationOffset: number;
  125338. /**
  125339. * Minimum allowed angle to camera position relative to target object.
  125340. * This can help limiting how the Camera is able to move in the scene.
  125341. */
  125342. lowerRotationOffsetLimit: Nullable<number>;
  125343. /**
  125344. * Maximum allowed angle to camera position relative to target object.
  125345. * This can help limiting how the Camera is able to move in the scene.
  125346. */
  125347. upperRotationOffsetLimit: Nullable<number>;
  125348. /**
  125349. * Define a height offset between the camera and the object it follows.
  125350. * It can help following an object from the top (like a car chaing a plane)
  125351. */
  125352. heightOffset: number;
  125353. /**
  125354. * Minimum allowed height of camera position relative to target object.
  125355. * This can help limiting how the Camera is able to move in the scene.
  125356. */
  125357. lowerHeightOffsetLimit: Nullable<number>;
  125358. /**
  125359. * Maximum allowed height of camera position relative to target object.
  125360. * This can help limiting how the Camera is able to move in the scene.
  125361. */
  125362. upperHeightOffsetLimit: Nullable<number>;
  125363. /**
  125364. * Define how fast the camera can accelerate to follow it s target.
  125365. */
  125366. cameraAcceleration: number;
  125367. /**
  125368. * Define the speed limit of the camera following an object.
  125369. */
  125370. maxCameraSpeed: number;
  125371. /**
  125372. * Define the target of the camera.
  125373. */
  125374. lockedTarget: Nullable<AbstractMesh>;
  125375. /**
  125376. * Defines the input associated with the camera.
  125377. */
  125378. inputs: FollowCameraInputsManager;
  125379. /**
  125380. * Instantiates the follow camera.
  125381. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125382. * @param name Define the name of the camera in the scene
  125383. * @param position Define the position of the camera
  125384. * @param scene Define the scene the camera belong to
  125385. * @param lockedTarget Define the target of the camera
  125386. */
  125387. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125388. private _follow;
  125389. /**
  125390. * Attached controls to the current camera.
  125391. * @param element Defines the element the controls should be listened from
  125392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125393. */
  125394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125395. /**
  125396. * Detach the current controls from the camera.
  125397. * The camera will stop reacting to inputs.
  125398. * @param element Defines the element to stop listening the inputs from
  125399. */
  125400. detachControl(element: HTMLElement): void;
  125401. /** @hidden */
  125402. _checkInputs(): void;
  125403. private _checkLimits;
  125404. /**
  125405. * Gets the camera class name.
  125406. * @returns the class name
  125407. */
  125408. getClassName(): string;
  125409. }
  125410. /**
  125411. * Arc Rotate version of the follow camera.
  125412. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125413. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125414. */
  125415. export class ArcFollowCamera extends TargetCamera {
  125416. /** The longitudinal angle of the camera */
  125417. alpha: number;
  125418. /** The latitudinal angle of the camera */
  125419. beta: number;
  125420. /** The radius of the camera from its target */
  125421. radius: number;
  125422. private _cartesianCoordinates;
  125423. /** Define the camera target (the mesh it should follow) */
  125424. private _meshTarget;
  125425. /**
  125426. * Instantiates a new ArcFollowCamera
  125427. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125428. * @param name Define the name of the camera
  125429. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125430. * @param beta Define the rotation angle of the camera around the elevation axis
  125431. * @param radius Define the radius of the camera from its target point
  125432. * @param target Define the target of the camera
  125433. * @param scene Define the scene the camera belongs to
  125434. */
  125435. constructor(name: string,
  125436. /** The longitudinal angle of the camera */
  125437. alpha: number,
  125438. /** The latitudinal angle of the camera */
  125439. beta: number,
  125440. /** The radius of the camera from its target */
  125441. radius: number,
  125442. /** Define the camera target (the mesh it should follow) */
  125443. target: Nullable<AbstractMesh>, scene: Scene);
  125444. private _follow;
  125445. /** @hidden */
  125446. _checkInputs(): void;
  125447. /**
  125448. * Returns the class name of the object.
  125449. * It is mostly used internally for serialization purposes.
  125450. */
  125451. getClassName(): string;
  125452. }
  125453. }
  125454. declare module BABYLON {
  125455. /**
  125456. * Manage the keyboard inputs to control the movement of a follow camera.
  125457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125458. */
  125459. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125460. /**
  125461. * Defines the camera the input is attached to.
  125462. */
  125463. camera: FollowCamera;
  125464. /**
  125465. * Defines the list of key codes associated with the up action (increase heightOffset)
  125466. */
  125467. keysHeightOffsetIncr: number[];
  125468. /**
  125469. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125470. */
  125471. keysHeightOffsetDecr: number[];
  125472. /**
  125473. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125474. */
  125475. keysHeightOffsetModifierAlt: boolean;
  125476. /**
  125477. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125478. */
  125479. keysHeightOffsetModifierCtrl: boolean;
  125480. /**
  125481. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125482. */
  125483. keysHeightOffsetModifierShift: boolean;
  125484. /**
  125485. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125486. */
  125487. keysRotationOffsetIncr: number[];
  125488. /**
  125489. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125490. */
  125491. keysRotationOffsetDecr: number[];
  125492. /**
  125493. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125494. */
  125495. keysRotationOffsetModifierAlt: boolean;
  125496. /**
  125497. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125498. */
  125499. keysRotationOffsetModifierCtrl: boolean;
  125500. /**
  125501. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125502. */
  125503. keysRotationOffsetModifierShift: boolean;
  125504. /**
  125505. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125506. */
  125507. keysRadiusIncr: number[];
  125508. /**
  125509. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125510. */
  125511. keysRadiusDecr: number[];
  125512. /**
  125513. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125514. */
  125515. keysRadiusModifierAlt: boolean;
  125516. /**
  125517. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125518. */
  125519. keysRadiusModifierCtrl: boolean;
  125520. /**
  125521. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125522. */
  125523. keysRadiusModifierShift: boolean;
  125524. /**
  125525. * Defines the rate of change of heightOffset.
  125526. */
  125527. heightSensibility: number;
  125528. /**
  125529. * Defines the rate of change of rotationOffset.
  125530. */
  125531. rotationSensibility: number;
  125532. /**
  125533. * Defines the rate of change of radius.
  125534. */
  125535. radiusSensibility: number;
  125536. private _keys;
  125537. private _ctrlPressed;
  125538. private _altPressed;
  125539. private _shiftPressed;
  125540. private _onCanvasBlurObserver;
  125541. private _onKeyboardObserver;
  125542. private _engine;
  125543. private _scene;
  125544. /**
  125545. * Attach the input controls to a specific dom element to get the input from.
  125546. * @param element Defines the element the controls should be listened from
  125547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125548. */
  125549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125550. /**
  125551. * Detach the current controls from the specified dom element.
  125552. * @param element Defines the element to stop listening the inputs from
  125553. */
  125554. detachControl(element: Nullable<HTMLElement>): void;
  125555. /**
  125556. * Update the current camera state depending on the inputs that have been used this frame.
  125557. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125558. */
  125559. checkInputs(): void;
  125560. /**
  125561. * Gets the class name of the current input.
  125562. * @returns the class name
  125563. */
  125564. getClassName(): string;
  125565. /**
  125566. * Get the friendly name associated with the input class.
  125567. * @returns the input friendly name
  125568. */
  125569. getSimpleName(): string;
  125570. /**
  125571. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125572. * allow modification of the heightOffset value.
  125573. */
  125574. private _modifierHeightOffset;
  125575. /**
  125576. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125577. * allow modification of the rotationOffset value.
  125578. */
  125579. private _modifierRotationOffset;
  125580. /**
  125581. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125582. * allow modification of the radius value.
  125583. */
  125584. private _modifierRadius;
  125585. }
  125586. }
  125587. declare module BABYLON {
  125588. interface FreeCameraInputsManager {
  125589. /**
  125590. * @hidden
  125591. */
  125592. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125593. /**
  125594. * Add orientation input support to the input manager.
  125595. * @returns the current input manager
  125596. */
  125597. addDeviceOrientation(): FreeCameraInputsManager;
  125598. }
  125599. /**
  125600. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125601. * Screen rotation is taken into account.
  125602. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125603. */
  125604. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125605. private _camera;
  125606. private _screenOrientationAngle;
  125607. private _constantTranform;
  125608. private _screenQuaternion;
  125609. private _alpha;
  125610. private _beta;
  125611. private _gamma;
  125612. /**
  125613. * Can be used to detect if a device orientation sensor is available on a device
  125614. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125615. * @returns a promise that will resolve on orientation change
  125616. */
  125617. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125618. /**
  125619. * @hidden
  125620. */
  125621. _onDeviceOrientationChangedObservable: Observable<void>;
  125622. /**
  125623. * Instantiates a new input
  125624. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125625. */
  125626. constructor();
  125627. /**
  125628. * Define the camera controlled by the input.
  125629. */
  125630. get camera(): FreeCamera;
  125631. set camera(camera: FreeCamera);
  125632. /**
  125633. * Attach the input controls to a specific dom element to get the input from.
  125634. * @param element Defines the element the controls should be listened from
  125635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125636. */
  125637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125638. private _orientationChanged;
  125639. private _deviceOrientation;
  125640. /**
  125641. * Detach the current controls from the specified dom element.
  125642. * @param element Defines the element to stop listening the inputs from
  125643. */
  125644. detachControl(element: Nullable<HTMLElement>): void;
  125645. /**
  125646. * Update the current camera state depending on the inputs that have been used this frame.
  125647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125648. */
  125649. checkInputs(): void;
  125650. /**
  125651. * Gets the class name of the current intput.
  125652. * @returns the class name
  125653. */
  125654. getClassName(): string;
  125655. /**
  125656. * Get the friendly name associated with the input class.
  125657. * @returns the input friendly name
  125658. */
  125659. getSimpleName(): string;
  125660. }
  125661. }
  125662. declare module BABYLON {
  125663. /**
  125664. * Manage the gamepad inputs to control a free camera.
  125665. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125666. */
  125667. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125668. /**
  125669. * Define the camera the input is attached to.
  125670. */
  125671. camera: FreeCamera;
  125672. /**
  125673. * Define the Gamepad controlling the input
  125674. */
  125675. gamepad: Nullable<Gamepad>;
  125676. /**
  125677. * Defines the gamepad rotation sensiblity.
  125678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125679. */
  125680. gamepadAngularSensibility: number;
  125681. /**
  125682. * Defines the gamepad move sensiblity.
  125683. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125684. */
  125685. gamepadMoveSensibility: number;
  125686. private _yAxisScale;
  125687. /**
  125688. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125689. */
  125690. get invertYAxis(): boolean;
  125691. set invertYAxis(value: boolean);
  125692. private _onGamepadConnectedObserver;
  125693. private _onGamepadDisconnectedObserver;
  125694. private _cameraTransform;
  125695. private _deltaTransform;
  125696. private _vector3;
  125697. private _vector2;
  125698. /**
  125699. * Attach the input controls to a specific dom element to get the input from.
  125700. * @param element Defines the element the controls should be listened from
  125701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125702. */
  125703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125704. /**
  125705. * Detach the current controls from the specified dom element.
  125706. * @param element Defines the element to stop listening the inputs from
  125707. */
  125708. detachControl(element: Nullable<HTMLElement>): void;
  125709. /**
  125710. * Update the current camera state depending on the inputs that have been used this frame.
  125711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125712. */
  125713. checkInputs(): void;
  125714. /**
  125715. * Gets the class name of the current intput.
  125716. * @returns the class name
  125717. */
  125718. getClassName(): string;
  125719. /**
  125720. * Get the friendly name associated with the input class.
  125721. * @returns the input friendly name
  125722. */
  125723. getSimpleName(): string;
  125724. }
  125725. }
  125726. declare module BABYLON {
  125727. /**
  125728. * Defines the potential axis of a Joystick
  125729. */
  125730. export enum JoystickAxis {
  125731. /** X axis */
  125732. X = 0,
  125733. /** Y axis */
  125734. Y = 1,
  125735. /** Z axis */
  125736. Z = 2
  125737. }
  125738. /**
  125739. * Represents the different customization options available
  125740. * for VirtualJoystick
  125741. */
  125742. interface VirtualJoystickCustomizations {
  125743. /**
  125744. * Size of the joystick's puck
  125745. */
  125746. puckSize: number;
  125747. /**
  125748. * Size of the joystick's container
  125749. */
  125750. containerSize: number;
  125751. /**
  125752. * Color of the joystick && puck
  125753. */
  125754. color: string;
  125755. /**
  125756. * Image URL for the joystick's puck
  125757. */
  125758. puckImage?: string;
  125759. /**
  125760. * Image URL for the joystick's container
  125761. */
  125762. containerImage?: string;
  125763. /**
  125764. * Defines the unmoving position of the joystick container
  125765. */
  125766. position?: {
  125767. x: number;
  125768. y: number;
  125769. };
  125770. /**
  125771. * Defines whether or not the joystick container is always visible
  125772. */
  125773. alwaysVisible: boolean;
  125774. /**
  125775. * Defines whether or not to limit the movement of the puck to the joystick's container
  125776. */
  125777. limitToContainer: boolean;
  125778. }
  125779. /**
  125780. * Class used to define virtual joystick (used in touch mode)
  125781. */
  125782. export class VirtualJoystick {
  125783. /**
  125784. * Gets or sets a boolean indicating that left and right values must be inverted
  125785. */
  125786. reverseLeftRight: boolean;
  125787. /**
  125788. * Gets or sets a boolean indicating that up and down values must be inverted
  125789. */
  125790. reverseUpDown: boolean;
  125791. /**
  125792. * Gets the offset value for the position (ie. the change of the position value)
  125793. */
  125794. deltaPosition: Vector3;
  125795. /**
  125796. * Gets a boolean indicating if the virtual joystick was pressed
  125797. */
  125798. pressed: boolean;
  125799. /**
  125800. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125801. */
  125802. static Canvas: Nullable<HTMLCanvasElement>;
  125803. /**
  125804. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125805. */
  125806. limitToContainer: boolean;
  125807. private static _globalJoystickIndex;
  125808. private static _alwaysVisibleSticks;
  125809. private static vjCanvasContext;
  125810. private static vjCanvasWidth;
  125811. private static vjCanvasHeight;
  125812. private static halfWidth;
  125813. private static _GetDefaultOptions;
  125814. private _action;
  125815. private _axisTargetedByLeftAndRight;
  125816. private _axisTargetedByUpAndDown;
  125817. private _joystickSensibility;
  125818. private _inversedSensibility;
  125819. private _joystickPointerID;
  125820. private _joystickColor;
  125821. private _joystickPointerPos;
  125822. private _joystickPreviousPointerPos;
  125823. private _joystickPointerStartPos;
  125824. private _deltaJoystickVector;
  125825. private _leftJoystick;
  125826. private _touches;
  125827. private _joystickPosition;
  125828. private _alwaysVisible;
  125829. private _puckImage;
  125830. private _containerImage;
  125831. private _joystickPuckSize;
  125832. private _joystickContainerSize;
  125833. private _clearPuckSize;
  125834. private _clearContainerSize;
  125835. private _clearPuckSizeOffset;
  125836. private _clearContainerSizeOffset;
  125837. private _onPointerDownHandlerRef;
  125838. private _onPointerMoveHandlerRef;
  125839. private _onPointerUpHandlerRef;
  125840. private _onResize;
  125841. /**
  125842. * Creates a new virtual joystick
  125843. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125844. * @param customizations Defines the options we want to customize the VirtualJoystick
  125845. */
  125846. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125847. /**
  125848. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125849. * @param newJoystickSensibility defines the new sensibility
  125850. */
  125851. setJoystickSensibility(newJoystickSensibility: number): void;
  125852. private _onPointerDown;
  125853. private _onPointerMove;
  125854. private _onPointerUp;
  125855. /**
  125856. * Change the color of the virtual joystick
  125857. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125858. */
  125859. setJoystickColor(newColor: string): void;
  125860. /**
  125861. * Size of the joystick's container
  125862. */
  125863. set containerSize(newSize: number);
  125864. get containerSize(): number;
  125865. /**
  125866. * Size of the joystick's puck
  125867. */
  125868. set puckSize(newSize: number);
  125869. get puckSize(): number;
  125870. /**
  125871. * Clears the set position of the joystick
  125872. */
  125873. clearPosition(): void;
  125874. /**
  125875. * Defines whether or not the joystick container is always visible
  125876. */
  125877. set alwaysVisible(value: boolean);
  125878. get alwaysVisible(): boolean;
  125879. /**
  125880. * Sets the constant position of the Joystick container
  125881. * @param x X axis coordinate
  125882. * @param y Y axis coordinate
  125883. */
  125884. setPosition(x: number, y: number): void;
  125885. /**
  125886. * Defines a callback to call when the joystick is touched
  125887. * @param action defines the callback
  125888. */
  125889. setActionOnTouch(action: () => any): void;
  125890. /**
  125891. * Defines which axis you'd like to control for left & right
  125892. * @param axis defines the axis to use
  125893. */
  125894. setAxisForLeftRight(axis: JoystickAxis): void;
  125895. /**
  125896. * Defines which axis you'd like to control for up & down
  125897. * @param axis defines the axis to use
  125898. */
  125899. setAxisForUpDown(axis: JoystickAxis): void;
  125900. /**
  125901. * Clears the canvas from the previous puck / container draw
  125902. */
  125903. private _clearPreviousDraw;
  125904. /**
  125905. * Loads `urlPath` to be used for the container's image
  125906. * @param urlPath defines the urlPath of an image to use
  125907. */
  125908. setContainerImage(urlPath: string): void;
  125909. /**
  125910. * Loads `urlPath` to be used for the puck's image
  125911. * @param urlPath defines the urlPath of an image to use
  125912. */
  125913. setPuckImage(urlPath: string): void;
  125914. /**
  125915. * Draws the Virtual Joystick's container
  125916. */
  125917. private _drawContainer;
  125918. /**
  125919. * Draws the Virtual Joystick's puck
  125920. */
  125921. private _drawPuck;
  125922. private _drawVirtualJoystick;
  125923. /**
  125924. * Release internal HTML canvas
  125925. */
  125926. releaseCanvas(): void;
  125927. }
  125928. }
  125929. declare module BABYLON {
  125930. interface FreeCameraInputsManager {
  125931. /**
  125932. * Add virtual joystick input support to the input manager.
  125933. * @returns the current input manager
  125934. */
  125935. addVirtualJoystick(): FreeCameraInputsManager;
  125936. }
  125937. /**
  125938. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125939. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125940. */
  125941. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125942. /**
  125943. * Defines the camera the input is attached to.
  125944. */
  125945. camera: FreeCamera;
  125946. private _leftjoystick;
  125947. private _rightjoystick;
  125948. /**
  125949. * Gets the left stick of the virtual joystick.
  125950. * @returns The virtual Joystick
  125951. */
  125952. getLeftJoystick(): VirtualJoystick;
  125953. /**
  125954. * Gets the right stick of the virtual joystick.
  125955. * @returns The virtual Joystick
  125956. */
  125957. getRightJoystick(): VirtualJoystick;
  125958. /**
  125959. * Update the current camera state depending on the inputs that have been used this frame.
  125960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125961. */
  125962. checkInputs(): void;
  125963. /**
  125964. * Attach the input controls to a specific dom element to get the input from.
  125965. * @param element Defines the element the controls should be listened from
  125966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125967. */
  125968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125969. /**
  125970. * Detach the current controls from the specified dom element.
  125971. * @param element Defines the element to stop listening the inputs from
  125972. */
  125973. detachControl(element: Nullable<HTMLElement>): void;
  125974. /**
  125975. * Gets the class name of the current intput.
  125976. * @returns the class name
  125977. */
  125978. getClassName(): string;
  125979. /**
  125980. * Get the friendly name associated with the input class.
  125981. * @returns the input friendly name
  125982. */
  125983. getSimpleName(): string;
  125984. }
  125985. }
  125986. declare module BABYLON {
  125987. /**
  125988. * This represents a FPS type of camera controlled by touch.
  125989. * This is like a universal camera minus the Gamepad controls.
  125990. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125991. */
  125992. export class TouchCamera extends FreeCamera {
  125993. /**
  125994. * Defines the touch sensibility for rotation.
  125995. * The higher the faster.
  125996. */
  125997. get touchAngularSensibility(): number;
  125998. set touchAngularSensibility(value: number);
  125999. /**
  126000. * Defines the touch sensibility for move.
  126001. * The higher the faster.
  126002. */
  126003. get touchMoveSensibility(): number;
  126004. set touchMoveSensibility(value: number);
  126005. /**
  126006. * Instantiates a new touch camera.
  126007. * This represents a FPS type of camera controlled by touch.
  126008. * This is like a universal camera minus the Gamepad controls.
  126009. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126010. * @param name Define the name of the camera in the scene
  126011. * @param position Define the start position of the camera in the scene
  126012. * @param scene Define the scene the camera belongs to
  126013. */
  126014. constructor(name: string, position: Vector3, scene: Scene);
  126015. /**
  126016. * Gets the current object class name.
  126017. * @return the class name
  126018. */
  126019. getClassName(): string;
  126020. /** @hidden */
  126021. _setupInputs(): void;
  126022. }
  126023. }
  126024. declare module BABYLON {
  126025. /**
  126026. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  126027. * being tilted forward or back and left or right.
  126028. */
  126029. export class DeviceOrientationCamera extends FreeCamera {
  126030. private _initialQuaternion;
  126031. private _quaternionCache;
  126032. private _tmpDragQuaternion;
  126033. private _disablePointerInputWhenUsingDeviceOrientation;
  126034. /**
  126035. * Creates a new device orientation camera
  126036. * @param name The name of the camera
  126037. * @param position The start position camera
  126038. * @param scene The scene the camera belongs to
  126039. */
  126040. constructor(name: string, position: Vector3, scene: Scene);
  126041. /**
  126042. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  126043. */
  126044. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  126045. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  126046. private _dragFactor;
  126047. /**
  126048. * Enabled turning on the y axis when the orientation sensor is active
  126049. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  126050. */
  126051. enableHorizontalDragging(dragFactor?: number): void;
  126052. /**
  126053. * Gets the current instance class name ("DeviceOrientationCamera").
  126054. * This helps avoiding instanceof at run time.
  126055. * @returns the class name
  126056. */
  126057. getClassName(): string;
  126058. /**
  126059. * @hidden
  126060. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  126061. */
  126062. _checkInputs(): void;
  126063. /**
  126064. * Reset the camera to its default orientation on the specified axis only.
  126065. * @param axis The axis to reset
  126066. */
  126067. resetToCurrentRotation(axis?: Axis): void;
  126068. }
  126069. }
  126070. declare module BABYLON {
  126071. /**
  126072. * Defines supported buttons for XBox360 compatible gamepads
  126073. */
  126074. export enum Xbox360Button {
  126075. /** A */
  126076. A = 0,
  126077. /** B */
  126078. B = 1,
  126079. /** X */
  126080. X = 2,
  126081. /** Y */
  126082. Y = 3,
  126083. /** Left button */
  126084. LB = 4,
  126085. /** Right button */
  126086. RB = 5,
  126087. /** Back */
  126088. Back = 8,
  126089. /** Start */
  126090. Start = 9,
  126091. /** Left stick */
  126092. LeftStick = 10,
  126093. /** Right stick */
  126094. RightStick = 11
  126095. }
  126096. /** Defines values for XBox360 DPad */
  126097. export enum Xbox360Dpad {
  126098. /** Up */
  126099. Up = 12,
  126100. /** Down */
  126101. Down = 13,
  126102. /** Left */
  126103. Left = 14,
  126104. /** Right */
  126105. Right = 15
  126106. }
  126107. /**
  126108. * Defines a XBox360 gamepad
  126109. */
  126110. export class Xbox360Pad extends Gamepad {
  126111. private _leftTrigger;
  126112. private _rightTrigger;
  126113. private _onlefttriggerchanged;
  126114. private _onrighttriggerchanged;
  126115. private _onbuttondown;
  126116. private _onbuttonup;
  126117. private _ondpaddown;
  126118. private _ondpadup;
  126119. /** Observable raised when a button is pressed */
  126120. onButtonDownObservable: Observable<Xbox360Button>;
  126121. /** Observable raised when a button is released */
  126122. onButtonUpObservable: Observable<Xbox360Button>;
  126123. /** Observable raised when a pad is pressed */
  126124. onPadDownObservable: Observable<Xbox360Dpad>;
  126125. /** Observable raised when a pad is released */
  126126. onPadUpObservable: Observable<Xbox360Dpad>;
  126127. private _buttonA;
  126128. private _buttonB;
  126129. private _buttonX;
  126130. private _buttonY;
  126131. private _buttonBack;
  126132. private _buttonStart;
  126133. private _buttonLB;
  126134. private _buttonRB;
  126135. private _buttonLeftStick;
  126136. private _buttonRightStick;
  126137. private _dPadUp;
  126138. private _dPadDown;
  126139. private _dPadLeft;
  126140. private _dPadRight;
  126141. private _isXboxOnePad;
  126142. /**
  126143. * Creates a new XBox360 gamepad object
  126144. * @param id defines the id of this gamepad
  126145. * @param index defines its index
  126146. * @param gamepad defines the internal HTML gamepad object
  126147. * @param xboxOne defines if it is a XBox One gamepad
  126148. */
  126149. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  126150. /**
  126151. * Defines the callback to call when left trigger is pressed
  126152. * @param callback defines the callback to use
  126153. */
  126154. onlefttriggerchanged(callback: (value: number) => void): void;
  126155. /**
  126156. * Defines the callback to call when right trigger is pressed
  126157. * @param callback defines the callback to use
  126158. */
  126159. onrighttriggerchanged(callback: (value: number) => void): void;
  126160. /**
  126161. * Gets the left trigger value
  126162. */
  126163. get leftTrigger(): number;
  126164. /**
  126165. * Sets the left trigger value
  126166. */
  126167. set leftTrigger(newValue: number);
  126168. /**
  126169. * Gets the right trigger value
  126170. */
  126171. get rightTrigger(): number;
  126172. /**
  126173. * Sets the right trigger value
  126174. */
  126175. set rightTrigger(newValue: number);
  126176. /**
  126177. * Defines the callback to call when a button is pressed
  126178. * @param callback defines the callback to use
  126179. */
  126180. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  126181. /**
  126182. * Defines the callback to call when a button is released
  126183. * @param callback defines the callback to use
  126184. */
  126185. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  126186. /**
  126187. * Defines the callback to call when a pad is pressed
  126188. * @param callback defines the callback to use
  126189. */
  126190. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  126191. /**
  126192. * Defines the callback to call when a pad is released
  126193. * @param callback defines the callback to use
  126194. */
  126195. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  126196. private _setButtonValue;
  126197. private _setDPadValue;
  126198. /**
  126199. * Gets the value of the `A` button
  126200. */
  126201. get buttonA(): number;
  126202. /**
  126203. * Sets the value of the `A` button
  126204. */
  126205. set buttonA(value: number);
  126206. /**
  126207. * Gets the value of the `B` button
  126208. */
  126209. get buttonB(): number;
  126210. /**
  126211. * Sets the value of the `B` button
  126212. */
  126213. set buttonB(value: number);
  126214. /**
  126215. * Gets the value of the `X` button
  126216. */
  126217. get buttonX(): number;
  126218. /**
  126219. * Sets the value of the `X` button
  126220. */
  126221. set buttonX(value: number);
  126222. /**
  126223. * Gets the value of the `Y` button
  126224. */
  126225. get buttonY(): number;
  126226. /**
  126227. * Sets the value of the `Y` button
  126228. */
  126229. set buttonY(value: number);
  126230. /**
  126231. * Gets the value of the `Start` button
  126232. */
  126233. get buttonStart(): number;
  126234. /**
  126235. * Sets the value of the `Start` button
  126236. */
  126237. set buttonStart(value: number);
  126238. /**
  126239. * Gets the value of the `Back` button
  126240. */
  126241. get buttonBack(): number;
  126242. /**
  126243. * Sets the value of the `Back` button
  126244. */
  126245. set buttonBack(value: number);
  126246. /**
  126247. * Gets the value of the `Left` button
  126248. */
  126249. get buttonLB(): number;
  126250. /**
  126251. * Sets the value of the `Left` button
  126252. */
  126253. set buttonLB(value: number);
  126254. /**
  126255. * Gets the value of the `Right` button
  126256. */
  126257. get buttonRB(): number;
  126258. /**
  126259. * Sets the value of the `Right` button
  126260. */
  126261. set buttonRB(value: number);
  126262. /**
  126263. * Gets the value of the Left joystick
  126264. */
  126265. get buttonLeftStick(): number;
  126266. /**
  126267. * Sets the value of the Left joystick
  126268. */
  126269. set buttonLeftStick(value: number);
  126270. /**
  126271. * Gets the value of the Right joystick
  126272. */
  126273. get buttonRightStick(): number;
  126274. /**
  126275. * Sets the value of the Right joystick
  126276. */
  126277. set buttonRightStick(value: number);
  126278. /**
  126279. * Gets the value of D-pad up
  126280. */
  126281. get dPadUp(): number;
  126282. /**
  126283. * Sets the value of D-pad up
  126284. */
  126285. set dPadUp(value: number);
  126286. /**
  126287. * Gets the value of D-pad down
  126288. */
  126289. get dPadDown(): number;
  126290. /**
  126291. * Sets the value of D-pad down
  126292. */
  126293. set dPadDown(value: number);
  126294. /**
  126295. * Gets the value of D-pad left
  126296. */
  126297. get dPadLeft(): number;
  126298. /**
  126299. * Sets the value of D-pad left
  126300. */
  126301. set dPadLeft(value: number);
  126302. /**
  126303. * Gets the value of D-pad right
  126304. */
  126305. get dPadRight(): number;
  126306. /**
  126307. * Sets the value of D-pad right
  126308. */
  126309. set dPadRight(value: number);
  126310. /**
  126311. * Force the gamepad to synchronize with device values
  126312. */
  126313. update(): void;
  126314. /**
  126315. * Disposes the gamepad
  126316. */
  126317. dispose(): void;
  126318. }
  126319. }
  126320. declare module BABYLON {
  126321. /**
  126322. * Defines supported buttons for DualShock compatible gamepads
  126323. */
  126324. export enum DualShockButton {
  126325. /** Cross */
  126326. Cross = 0,
  126327. /** Circle */
  126328. Circle = 1,
  126329. /** Square */
  126330. Square = 2,
  126331. /** Triangle */
  126332. Triangle = 3,
  126333. /** L1 */
  126334. L1 = 4,
  126335. /** R1 */
  126336. R1 = 5,
  126337. /** Share */
  126338. Share = 8,
  126339. /** Options */
  126340. Options = 9,
  126341. /** Left stick */
  126342. LeftStick = 10,
  126343. /** Right stick */
  126344. RightStick = 11
  126345. }
  126346. /** Defines values for DualShock DPad */
  126347. export enum DualShockDpad {
  126348. /** Up */
  126349. Up = 12,
  126350. /** Down */
  126351. Down = 13,
  126352. /** Left */
  126353. Left = 14,
  126354. /** Right */
  126355. Right = 15
  126356. }
  126357. /**
  126358. * Defines a DualShock gamepad
  126359. */
  126360. export class DualShockPad extends Gamepad {
  126361. private _leftTrigger;
  126362. private _rightTrigger;
  126363. private _onlefttriggerchanged;
  126364. private _onrighttriggerchanged;
  126365. private _onbuttondown;
  126366. private _onbuttonup;
  126367. private _ondpaddown;
  126368. private _ondpadup;
  126369. /** Observable raised when a button is pressed */
  126370. onButtonDownObservable: Observable<DualShockButton>;
  126371. /** Observable raised when a button is released */
  126372. onButtonUpObservable: Observable<DualShockButton>;
  126373. /** Observable raised when a pad is pressed */
  126374. onPadDownObservable: Observable<DualShockDpad>;
  126375. /** Observable raised when a pad is released */
  126376. onPadUpObservable: Observable<DualShockDpad>;
  126377. private _buttonCross;
  126378. private _buttonCircle;
  126379. private _buttonSquare;
  126380. private _buttonTriangle;
  126381. private _buttonShare;
  126382. private _buttonOptions;
  126383. private _buttonL1;
  126384. private _buttonR1;
  126385. private _buttonLeftStick;
  126386. private _buttonRightStick;
  126387. private _dPadUp;
  126388. private _dPadDown;
  126389. private _dPadLeft;
  126390. private _dPadRight;
  126391. /**
  126392. * Creates a new DualShock gamepad object
  126393. * @param id defines the id of this gamepad
  126394. * @param index defines its index
  126395. * @param gamepad defines the internal HTML gamepad object
  126396. */
  126397. constructor(id: string, index: number, gamepad: any);
  126398. /**
  126399. * Defines the callback to call when left trigger is pressed
  126400. * @param callback defines the callback to use
  126401. */
  126402. onlefttriggerchanged(callback: (value: number) => void): void;
  126403. /**
  126404. * Defines the callback to call when right trigger is pressed
  126405. * @param callback defines the callback to use
  126406. */
  126407. onrighttriggerchanged(callback: (value: number) => void): void;
  126408. /**
  126409. * Gets the left trigger value
  126410. */
  126411. get leftTrigger(): number;
  126412. /**
  126413. * Sets the left trigger value
  126414. */
  126415. set leftTrigger(newValue: number);
  126416. /**
  126417. * Gets the right trigger value
  126418. */
  126419. get rightTrigger(): number;
  126420. /**
  126421. * Sets the right trigger value
  126422. */
  126423. set rightTrigger(newValue: number);
  126424. /**
  126425. * Defines the callback to call when a button is pressed
  126426. * @param callback defines the callback to use
  126427. */
  126428. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126429. /**
  126430. * Defines the callback to call when a button is released
  126431. * @param callback defines the callback to use
  126432. */
  126433. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126434. /**
  126435. * Defines the callback to call when a pad is pressed
  126436. * @param callback defines the callback to use
  126437. */
  126438. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126439. /**
  126440. * Defines the callback to call when a pad is released
  126441. * @param callback defines the callback to use
  126442. */
  126443. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126444. private _setButtonValue;
  126445. private _setDPadValue;
  126446. /**
  126447. * Gets the value of the `Cross` button
  126448. */
  126449. get buttonCross(): number;
  126450. /**
  126451. * Sets the value of the `Cross` button
  126452. */
  126453. set buttonCross(value: number);
  126454. /**
  126455. * Gets the value of the `Circle` button
  126456. */
  126457. get buttonCircle(): number;
  126458. /**
  126459. * Sets the value of the `Circle` button
  126460. */
  126461. set buttonCircle(value: number);
  126462. /**
  126463. * Gets the value of the `Square` button
  126464. */
  126465. get buttonSquare(): number;
  126466. /**
  126467. * Sets the value of the `Square` button
  126468. */
  126469. set buttonSquare(value: number);
  126470. /**
  126471. * Gets the value of the `Triangle` button
  126472. */
  126473. get buttonTriangle(): number;
  126474. /**
  126475. * Sets the value of the `Triangle` button
  126476. */
  126477. set buttonTriangle(value: number);
  126478. /**
  126479. * Gets the value of the `Options` button
  126480. */
  126481. get buttonOptions(): number;
  126482. /**
  126483. * Sets the value of the `Options` button
  126484. */
  126485. set buttonOptions(value: number);
  126486. /**
  126487. * Gets the value of the `Share` button
  126488. */
  126489. get buttonShare(): number;
  126490. /**
  126491. * Sets the value of the `Share` button
  126492. */
  126493. set buttonShare(value: number);
  126494. /**
  126495. * Gets the value of the `L1` button
  126496. */
  126497. get buttonL1(): number;
  126498. /**
  126499. * Sets the value of the `L1` button
  126500. */
  126501. set buttonL1(value: number);
  126502. /**
  126503. * Gets the value of the `R1` button
  126504. */
  126505. get buttonR1(): number;
  126506. /**
  126507. * Sets the value of the `R1` button
  126508. */
  126509. set buttonR1(value: number);
  126510. /**
  126511. * Gets the value of the Left joystick
  126512. */
  126513. get buttonLeftStick(): number;
  126514. /**
  126515. * Sets the value of the Left joystick
  126516. */
  126517. set buttonLeftStick(value: number);
  126518. /**
  126519. * Gets the value of the Right joystick
  126520. */
  126521. get buttonRightStick(): number;
  126522. /**
  126523. * Sets the value of the Right joystick
  126524. */
  126525. set buttonRightStick(value: number);
  126526. /**
  126527. * Gets the value of D-pad up
  126528. */
  126529. get dPadUp(): number;
  126530. /**
  126531. * Sets the value of D-pad up
  126532. */
  126533. set dPadUp(value: number);
  126534. /**
  126535. * Gets the value of D-pad down
  126536. */
  126537. get dPadDown(): number;
  126538. /**
  126539. * Sets the value of D-pad down
  126540. */
  126541. set dPadDown(value: number);
  126542. /**
  126543. * Gets the value of D-pad left
  126544. */
  126545. get dPadLeft(): number;
  126546. /**
  126547. * Sets the value of D-pad left
  126548. */
  126549. set dPadLeft(value: number);
  126550. /**
  126551. * Gets the value of D-pad right
  126552. */
  126553. get dPadRight(): number;
  126554. /**
  126555. * Sets the value of D-pad right
  126556. */
  126557. set dPadRight(value: number);
  126558. /**
  126559. * Force the gamepad to synchronize with device values
  126560. */
  126561. update(): void;
  126562. /**
  126563. * Disposes the gamepad
  126564. */
  126565. dispose(): void;
  126566. }
  126567. }
  126568. declare module BABYLON {
  126569. /**
  126570. * Manager for handling gamepads
  126571. */
  126572. export class GamepadManager {
  126573. private _scene?;
  126574. private _babylonGamepads;
  126575. private _oneGamepadConnected;
  126576. /** @hidden */
  126577. _isMonitoring: boolean;
  126578. private _gamepadEventSupported;
  126579. private _gamepadSupport?;
  126580. /**
  126581. * observable to be triggered when the gamepad controller has been connected
  126582. */
  126583. onGamepadConnectedObservable: Observable<Gamepad>;
  126584. /**
  126585. * observable to be triggered when the gamepad controller has been disconnected
  126586. */
  126587. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126588. private _onGamepadConnectedEvent;
  126589. private _onGamepadDisconnectedEvent;
  126590. /**
  126591. * Initializes the gamepad manager
  126592. * @param _scene BabylonJS scene
  126593. */
  126594. constructor(_scene?: Scene | undefined);
  126595. /**
  126596. * The gamepads in the game pad manager
  126597. */
  126598. get gamepads(): Gamepad[];
  126599. /**
  126600. * Get the gamepad controllers based on type
  126601. * @param type The type of gamepad controller
  126602. * @returns Nullable gamepad
  126603. */
  126604. getGamepadByType(type?: number): Nullable<Gamepad>;
  126605. /**
  126606. * Disposes the gamepad manager
  126607. */
  126608. dispose(): void;
  126609. private _addNewGamepad;
  126610. private _startMonitoringGamepads;
  126611. private _stopMonitoringGamepads;
  126612. /** @hidden */
  126613. _checkGamepadsStatus(): void;
  126614. private _updateGamepadObjects;
  126615. }
  126616. }
  126617. declare module BABYLON {
  126618. interface Scene {
  126619. /** @hidden */
  126620. _gamepadManager: Nullable<GamepadManager>;
  126621. /**
  126622. * Gets the gamepad manager associated with the scene
  126623. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126624. */
  126625. gamepadManager: GamepadManager;
  126626. }
  126627. /**
  126628. * Interface representing a free camera inputs manager
  126629. */
  126630. interface FreeCameraInputsManager {
  126631. /**
  126632. * Adds gamepad input support to the FreeCameraInputsManager.
  126633. * @returns the FreeCameraInputsManager
  126634. */
  126635. addGamepad(): FreeCameraInputsManager;
  126636. }
  126637. /**
  126638. * Interface representing an arc rotate camera inputs manager
  126639. */
  126640. interface ArcRotateCameraInputsManager {
  126641. /**
  126642. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126643. * @returns the camera inputs manager
  126644. */
  126645. addGamepad(): ArcRotateCameraInputsManager;
  126646. }
  126647. /**
  126648. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126649. */
  126650. export class GamepadSystemSceneComponent implements ISceneComponent {
  126651. /**
  126652. * The component name helpfull to identify the component in the list of scene components.
  126653. */
  126654. readonly name: string;
  126655. /**
  126656. * The scene the component belongs to.
  126657. */
  126658. scene: Scene;
  126659. /**
  126660. * Creates a new instance of the component for the given scene
  126661. * @param scene Defines the scene to register the component in
  126662. */
  126663. constructor(scene: Scene);
  126664. /**
  126665. * Registers the component in a given scene
  126666. */
  126667. register(): void;
  126668. /**
  126669. * Rebuilds the elements related to this component in case of
  126670. * context lost for instance.
  126671. */
  126672. rebuild(): void;
  126673. /**
  126674. * Disposes the component and the associated ressources
  126675. */
  126676. dispose(): void;
  126677. private _beforeCameraUpdate;
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * 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,
  126683. * which still works and will still be found in many Playgrounds.
  126684. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126685. */
  126686. export class UniversalCamera extends TouchCamera {
  126687. /**
  126688. * Defines the gamepad rotation sensiblity.
  126689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126690. */
  126691. get gamepadAngularSensibility(): number;
  126692. set gamepadAngularSensibility(value: number);
  126693. /**
  126694. * Defines the gamepad move sensiblity.
  126695. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126696. */
  126697. get gamepadMoveSensibility(): number;
  126698. set gamepadMoveSensibility(value: number);
  126699. /**
  126700. * 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,
  126701. * which still works and will still be found in many Playgrounds.
  126702. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126703. * @param name Define the name of the camera in the scene
  126704. * @param position Define the start position of the camera in the scene
  126705. * @param scene Define the scene the camera belongs to
  126706. */
  126707. constructor(name: string, position: Vector3, scene: Scene);
  126708. /**
  126709. * Gets the current object class name.
  126710. * @return the class name
  126711. */
  126712. getClassName(): string;
  126713. }
  126714. }
  126715. declare module BABYLON {
  126716. /**
  126717. * This represents a FPS type of camera. This is only here for back compat purpose.
  126718. * Please use the UniversalCamera instead as both are identical.
  126719. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126720. */
  126721. export class GamepadCamera extends UniversalCamera {
  126722. /**
  126723. * Instantiates a new Gamepad Camera
  126724. * This represents a FPS type of camera. This is only here for back compat purpose.
  126725. * Please use the UniversalCamera instead as both are identical.
  126726. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126727. * @param name Define the name of the camera in the scene
  126728. * @param position Define the start position of the camera in the scene
  126729. * @param scene Define the scene the camera belongs to
  126730. */
  126731. constructor(name: string, position: Vector3, scene: Scene);
  126732. /**
  126733. * Gets the current object class name.
  126734. * @return the class name
  126735. */
  126736. getClassName(): string;
  126737. }
  126738. }
  126739. declare module BABYLON {
  126740. /** @hidden */
  126741. export var passPixelShader: {
  126742. name: string;
  126743. shader: string;
  126744. };
  126745. }
  126746. declare module BABYLON {
  126747. /** @hidden */
  126748. export var passCubePixelShader: {
  126749. name: string;
  126750. shader: string;
  126751. };
  126752. }
  126753. declare module BABYLON {
  126754. /**
  126755. * PassPostProcess which produces an output the same as it's input
  126756. */
  126757. export class PassPostProcess extends PostProcess {
  126758. /**
  126759. * Gets a string identifying the name of the class
  126760. * @returns "PassPostProcess" string
  126761. */
  126762. getClassName(): string;
  126763. /**
  126764. * Creates the PassPostProcess
  126765. * @param name The name of the effect.
  126766. * @param options The required width/height ratio to downsize to before computing the render pass.
  126767. * @param camera The camera to apply the render pass to.
  126768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126769. * @param engine The engine which the post process will be applied. (default: current engine)
  126770. * @param reusable If the post process can be reused on the same frame. (default: false)
  126771. * @param textureType The type of texture to be used when performing the post processing.
  126772. * @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)
  126773. */
  126774. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126775. /** @hidden */
  126776. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126777. }
  126778. /**
  126779. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126780. */
  126781. export class PassCubePostProcess extends PostProcess {
  126782. private _face;
  126783. /**
  126784. * Gets or sets the cube face to display.
  126785. * * 0 is +X
  126786. * * 1 is -X
  126787. * * 2 is +Y
  126788. * * 3 is -Y
  126789. * * 4 is +Z
  126790. * * 5 is -Z
  126791. */
  126792. get face(): number;
  126793. set face(value: number);
  126794. /**
  126795. * Gets a string identifying the name of the class
  126796. * @returns "PassCubePostProcess" string
  126797. */
  126798. getClassName(): string;
  126799. /**
  126800. * Creates the PassCubePostProcess
  126801. * @param name The name of the effect.
  126802. * @param options The required width/height ratio to downsize to before computing the render pass.
  126803. * @param camera The camera to apply the render pass to.
  126804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126805. * @param engine The engine which the post process will be applied. (default: current engine)
  126806. * @param reusable If the post process can be reused on the same frame. (default: false)
  126807. * @param textureType The type of texture to be used when performing the post processing.
  126808. * @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)
  126809. */
  126810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126811. /** @hidden */
  126812. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126813. }
  126814. }
  126815. declare module BABYLON {
  126816. /** @hidden */
  126817. export var anaglyphPixelShader: {
  126818. name: string;
  126819. shader: string;
  126820. };
  126821. }
  126822. declare module BABYLON {
  126823. /**
  126824. * Postprocess used to generate anaglyphic rendering
  126825. */
  126826. export class AnaglyphPostProcess extends PostProcess {
  126827. private _passedProcess;
  126828. /**
  126829. * Gets a string identifying the name of the class
  126830. * @returns "AnaglyphPostProcess" string
  126831. */
  126832. getClassName(): string;
  126833. /**
  126834. * Creates a new AnaglyphPostProcess
  126835. * @param name defines postprocess name
  126836. * @param options defines creation options or target ratio scale
  126837. * @param rigCameras defines cameras using this postprocess
  126838. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126839. * @param engine defines hosting engine
  126840. * @param reusable defines if the postprocess will be reused multiple times per frame
  126841. */
  126842. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126843. }
  126844. }
  126845. declare module BABYLON {
  126846. /**
  126847. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126848. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126849. */
  126850. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126851. /**
  126852. * Creates a new AnaglyphArcRotateCamera
  126853. * @param name defines camera name
  126854. * @param alpha defines alpha angle (in radians)
  126855. * @param beta defines beta angle (in radians)
  126856. * @param radius defines radius
  126857. * @param target defines camera target
  126858. * @param interaxialDistance defines distance between each color axis
  126859. * @param scene defines the hosting scene
  126860. */
  126861. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126862. /**
  126863. * Gets camera class name
  126864. * @returns AnaglyphArcRotateCamera
  126865. */
  126866. getClassName(): string;
  126867. }
  126868. }
  126869. declare module BABYLON {
  126870. /**
  126871. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126872. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126873. */
  126874. export class AnaglyphFreeCamera extends FreeCamera {
  126875. /**
  126876. * Creates a new AnaglyphFreeCamera
  126877. * @param name defines camera name
  126878. * @param position defines initial position
  126879. * @param interaxialDistance defines distance between each color axis
  126880. * @param scene defines the hosting scene
  126881. */
  126882. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126883. /**
  126884. * Gets camera class name
  126885. * @returns AnaglyphFreeCamera
  126886. */
  126887. getClassName(): string;
  126888. }
  126889. }
  126890. declare module BABYLON {
  126891. /**
  126892. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126893. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126894. */
  126895. export class AnaglyphGamepadCamera extends GamepadCamera {
  126896. /**
  126897. * Creates a new AnaglyphGamepadCamera
  126898. * @param name defines camera name
  126899. * @param position defines initial position
  126900. * @param interaxialDistance defines distance between each color axis
  126901. * @param scene defines the hosting scene
  126902. */
  126903. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126904. /**
  126905. * Gets camera class name
  126906. * @returns AnaglyphGamepadCamera
  126907. */
  126908. getClassName(): string;
  126909. }
  126910. }
  126911. declare module BABYLON {
  126912. /**
  126913. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126914. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126915. */
  126916. export class AnaglyphUniversalCamera extends UniversalCamera {
  126917. /**
  126918. * Creates a new AnaglyphUniversalCamera
  126919. * @param name defines camera name
  126920. * @param position defines initial position
  126921. * @param interaxialDistance defines distance between each color axis
  126922. * @param scene defines the hosting scene
  126923. */
  126924. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126925. /**
  126926. * Gets camera class name
  126927. * @returns AnaglyphUniversalCamera
  126928. */
  126929. getClassName(): string;
  126930. }
  126931. }
  126932. declare module BABYLON {
  126933. /**
  126934. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126935. * @see https://doc.babylonjs.com/features/cameras
  126936. */
  126937. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126938. /**
  126939. * Creates a new StereoscopicArcRotateCamera
  126940. * @param name defines camera name
  126941. * @param alpha defines alpha angle (in radians)
  126942. * @param beta defines beta angle (in radians)
  126943. * @param radius defines radius
  126944. * @param target defines camera target
  126945. * @param interaxialDistance defines distance between each color axis
  126946. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126947. * @param scene defines the hosting scene
  126948. */
  126949. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126950. /**
  126951. * Gets camera class name
  126952. * @returns StereoscopicArcRotateCamera
  126953. */
  126954. getClassName(): string;
  126955. }
  126956. }
  126957. declare module BABYLON {
  126958. /**
  126959. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126960. * @see https://doc.babylonjs.com/features/cameras
  126961. */
  126962. export class StereoscopicFreeCamera extends FreeCamera {
  126963. /**
  126964. * Creates a new StereoscopicFreeCamera
  126965. * @param name defines camera name
  126966. * @param position defines initial position
  126967. * @param interaxialDistance defines distance between each color axis
  126968. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126969. * @param scene defines the hosting scene
  126970. */
  126971. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126972. /**
  126973. * Gets camera class name
  126974. * @returns StereoscopicFreeCamera
  126975. */
  126976. getClassName(): string;
  126977. }
  126978. }
  126979. declare module BABYLON {
  126980. /**
  126981. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126982. * @see https://doc.babylonjs.com/features/cameras
  126983. */
  126984. export class StereoscopicGamepadCamera extends GamepadCamera {
  126985. /**
  126986. * Creates a new StereoscopicGamepadCamera
  126987. * @param name defines camera name
  126988. * @param position defines initial position
  126989. * @param interaxialDistance defines distance between each color axis
  126990. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126991. * @param scene defines the hosting scene
  126992. */
  126993. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126994. /**
  126995. * Gets camera class name
  126996. * @returns StereoscopicGamepadCamera
  126997. */
  126998. getClassName(): string;
  126999. }
  127000. }
  127001. declare module BABYLON {
  127002. /**
  127003. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  127004. * @see https://doc.babylonjs.com/features/cameras
  127005. */
  127006. export class StereoscopicUniversalCamera extends UniversalCamera {
  127007. /**
  127008. * Creates a new StereoscopicUniversalCamera
  127009. * @param name defines camera name
  127010. * @param position defines initial position
  127011. * @param interaxialDistance defines distance between each color axis
  127012. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  127013. * @param scene defines the hosting scene
  127014. */
  127015. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  127016. /**
  127017. * Gets camera class name
  127018. * @returns StereoscopicUniversalCamera
  127019. */
  127020. getClassName(): string;
  127021. }
  127022. }
  127023. declare module BABYLON {
  127024. /**
  127025. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  127026. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127027. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127028. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127029. */
  127030. export class VirtualJoysticksCamera extends FreeCamera {
  127031. /**
  127032. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  127033. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127034. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127035. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127036. * @param name Define the name of the camera in the scene
  127037. * @param position Define the start position of the camera in the scene
  127038. * @param scene Define the scene the camera belongs to
  127039. */
  127040. constructor(name: string, position: Vector3, scene: Scene);
  127041. /**
  127042. * Gets the current object class name.
  127043. * @return the class name
  127044. */
  127045. getClassName(): string;
  127046. }
  127047. }
  127048. declare module BABYLON {
  127049. /**
  127050. * This represents all the required metrics to create a VR camera.
  127051. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  127052. */
  127053. export class VRCameraMetrics {
  127054. /**
  127055. * Define the horizontal resolution off the screen.
  127056. */
  127057. hResolution: number;
  127058. /**
  127059. * Define the vertical resolution off the screen.
  127060. */
  127061. vResolution: number;
  127062. /**
  127063. * Define the horizontal screen size.
  127064. */
  127065. hScreenSize: number;
  127066. /**
  127067. * Define the vertical screen size.
  127068. */
  127069. vScreenSize: number;
  127070. /**
  127071. * Define the vertical screen center position.
  127072. */
  127073. vScreenCenter: number;
  127074. /**
  127075. * Define the distance of the eyes to the screen.
  127076. */
  127077. eyeToScreenDistance: number;
  127078. /**
  127079. * Define the distance between both lenses
  127080. */
  127081. lensSeparationDistance: number;
  127082. /**
  127083. * Define the distance between both viewer's eyes.
  127084. */
  127085. interpupillaryDistance: number;
  127086. /**
  127087. * Define the distortion factor of the VR postprocess.
  127088. * Please, touch with care.
  127089. */
  127090. distortionK: number[];
  127091. /**
  127092. * Define the chromatic aberration correction factors for the VR post process.
  127093. */
  127094. chromaAbCorrection: number[];
  127095. /**
  127096. * Define the scale factor of the post process.
  127097. * The smaller the better but the slower.
  127098. */
  127099. postProcessScaleFactor: number;
  127100. /**
  127101. * Define an offset for the lens center.
  127102. */
  127103. lensCenterOffset: number;
  127104. /**
  127105. * Define if the current vr camera should compensate the distortion of the lense or not.
  127106. */
  127107. compensateDistortion: boolean;
  127108. /**
  127109. * Defines if multiview should be enabled when rendering (Default: false)
  127110. */
  127111. multiviewEnabled: boolean;
  127112. /**
  127113. * Gets the rendering aspect ratio based on the provided resolutions.
  127114. */
  127115. get aspectRatio(): number;
  127116. /**
  127117. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  127118. */
  127119. get aspectRatioFov(): number;
  127120. /**
  127121. * @hidden
  127122. */
  127123. get leftHMatrix(): Matrix;
  127124. /**
  127125. * @hidden
  127126. */
  127127. get rightHMatrix(): Matrix;
  127128. /**
  127129. * @hidden
  127130. */
  127131. get leftPreViewMatrix(): Matrix;
  127132. /**
  127133. * @hidden
  127134. */
  127135. get rightPreViewMatrix(): Matrix;
  127136. /**
  127137. * Get the default VRMetrics based on the most generic setup.
  127138. * @returns the default vr metrics
  127139. */
  127140. static GetDefault(): VRCameraMetrics;
  127141. }
  127142. }
  127143. declare module BABYLON {
  127144. /** @hidden */
  127145. export var vrDistortionCorrectionPixelShader: {
  127146. name: string;
  127147. shader: string;
  127148. };
  127149. }
  127150. declare module BABYLON {
  127151. /**
  127152. * VRDistortionCorrectionPostProcess used for mobile VR
  127153. */
  127154. export class VRDistortionCorrectionPostProcess extends PostProcess {
  127155. private _isRightEye;
  127156. private _distortionFactors;
  127157. private _postProcessScaleFactor;
  127158. private _lensCenterOffset;
  127159. private _scaleIn;
  127160. private _scaleFactor;
  127161. private _lensCenter;
  127162. /**
  127163. * Gets a string identifying the name of the class
  127164. * @returns "VRDistortionCorrectionPostProcess" string
  127165. */
  127166. getClassName(): string;
  127167. /**
  127168. * Initializes the VRDistortionCorrectionPostProcess
  127169. * @param name The name of the effect.
  127170. * @param camera The camera to apply the render pass to.
  127171. * @param isRightEye If this is for the right eye distortion
  127172. * @param vrMetrics All the required metrics for the VR camera
  127173. */
  127174. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  127175. }
  127176. }
  127177. declare module BABYLON {
  127178. /**
  127179. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  127180. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127181. */
  127182. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  127183. /**
  127184. * Creates a new VRDeviceOrientationArcRotateCamera
  127185. * @param name defines camera name
  127186. * @param alpha defines the camera rotation along the logitudinal axis
  127187. * @param beta defines the camera rotation along the latitudinal axis
  127188. * @param radius defines the camera distance from its target
  127189. * @param target defines the camera target
  127190. * @param scene defines the scene the camera belongs to
  127191. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127192. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127193. */
  127194. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127195. /**
  127196. * Gets camera class name
  127197. * @returns VRDeviceOrientationArcRotateCamera
  127198. */
  127199. getClassName(): string;
  127200. }
  127201. }
  127202. declare module BABYLON {
  127203. /**
  127204. * Camera used to simulate VR rendering (based on FreeCamera)
  127205. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127206. */
  127207. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  127208. /**
  127209. * Creates a new VRDeviceOrientationFreeCamera
  127210. * @param name defines camera name
  127211. * @param position defines the start position of the camera
  127212. * @param scene defines the scene the camera belongs to
  127213. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127214. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127215. */
  127216. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127217. /**
  127218. * Gets camera class name
  127219. * @returns VRDeviceOrientationFreeCamera
  127220. */
  127221. getClassName(): string;
  127222. }
  127223. }
  127224. declare module BABYLON {
  127225. /**
  127226. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  127227. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127228. */
  127229. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  127230. /**
  127231. * Creates a new VRDeviceOrientationGamepadCamera
  127232. * @param name defines camera name
  127233. * @param position defines the start position of the camera
  127234. * @param scene defines the scene the camera belongs to
  127235. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127236. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127237. */
  127238. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127239. /**
  127240. * Gets camera class name
  127241. * @returns VRDeviceOrientationGamepadCamera
  127242. */
  127243. getClassName(): string;
  127244. }
  127245. }
  127246. declare module BABYLON {
  127247. /**
  127248. * A class extending Texture allowing drawing on a texture
  127249. * @see https://doc.babylonjs.com/how_to/dynamictexture
  127250. */
  127251. export class DynamicTexture extends Texture {
  127252. private _generateMipMaps;
  127253. private _canvas;
  127254. private _context;
  127255. /**
  127256. * Creates a DynamicTexture
  127257. * @param name defines the name of the texture
  127258. * @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
  127259. * @param scene defines the scene where you want the texture
  127260. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  127261. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127262. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  127263. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  127264. */
  127265. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  127266. /**
  127267. * Get the current class name of the texture useful for serialization or dynamic coding.
  127268. * @returns "DynamicTexture"
  127269. */
  127270. getClassName(): string;
  127271. /**
  127272. * Gets the current state of canRescale
  127273. */
  127274. get canRescale(): boolean;
  127275. private _recreate;
  127276. /**
  127277. * Scales the texture
  127278. * @param ratio the scale factor to apply to both width and height
  127279. */
  127280. scale(ratio: number): void;
  127281. /**
  127282. * Resizes the texture
  127283. * @param width the new width
  127284. * @param height the new height
  127285. */
  127286. scaleTo(width: number, height: number): void;
  127287. /**
  127288. * Gets the context of the canvas used by the texture
  127289. * @returns the canvas context of the dynamic texture
  127290. */
  127291. getContext(): CanvasRenderingContext2D;
  127292. /**
  127293. * Clears the texture
  127294. */
  127295. clear(): void;
  127296. /**
  127297. * Updates the texture
  127298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127299. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  127300. */
  127301. update(invertY?: boolean, premulAlpha?: boolean): void;
  127302. /**
  127303. * Draws text onto the texture
  127304. * @param text defines the text to be drawn
  127305. * @param x defines the placement of the text from the left
  127306. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  127307. * @param font defines the font to be used with font-style, font-size, font-name
  127308. * @param color defines the color used for the text
  127309. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  127310. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127311. * @param update defines whether texture is immediately update (default is true)
  127312. */
  127313. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127314. /**
  127315. * Clones the texture
  127316. * @returns the clone of the texture.
  127317. */
  127318. clone(): DynamicTexture;
  127319. /**
  127320. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127321. * @returns a serialized dynamic texture object
  127322. */
  127323. serialize(): any;
  127324. private _IsCanvasElement;
  127325. /** @hidden */
  127326. _rebuild(): void;
  127327. }
  127328. }
  127329. declare module BABYLON {
  127330. /**
  127331. * Class containing static functions to help procedurally build meshes
  127332. */
  127333. export class GroundBuilder {
  127334. /**
  127335. * Creates a ground mesh
  127336. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127337. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127339. * @param name defines the name of the mesh
  127340. * @param options defines the options used to create the mesh
  127341. * @param scene defines the hosting scene
  127342. * @returns the ground mesh
  127343. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127344. */
  127345. static CreateGround(name: string, options: {
  127346. width?: number;
  127347. height?: number;
  127348. subdivisions?: number;
  127349. subdivisionsX?: number;
  127350. subdivisionsY?: number;
  127351. updatable?: boolean;
  127352. }, scene: any): Mesh;
  127353. /**
  127354. * Creates a tiled ground mesh
  127355. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127356. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127357. * * 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
  127358. * * 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
  127359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127360. * @param name defines the name of the mesh
  127361. * @param options defines the options used to create the mesh
  127362. * @param scene defines the hosting scene
  127363. * @returns the tiled ground mesh
  127364. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127365. */
  127366. static CreateTiledGround(name: string, options: {
  127367. xmin: number;
  127368. zmin: number;
  127369. xmax: number;
  127370. zmax: number;
  127371. subdivisions?: {
  127372. w: number;
  127373. h: number;
  127374. };
  127375. precision?: {
  127376. w: number;
  127377. h: number;
  127378. };
  127379. updatable?: boolean;
  127380. }, scene?: Nullable<Scene>): Mesh;
  127381. /**
  127382. * Creates a ground mesh from a height map
  127383. * * The parameter `url` sets the URL of the height map image resource.
  127384. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127385. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127386. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127387. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127388. * * 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.
  127389. * * 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).
  127390. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127392. * @param name defines the name of the mesh
  127393. * @param url defines the url to the height map
  127394. * @param options defines the options used to create the mesh
  127395. * @param scene defines the hosting scene
  127396. * @returns the ground mesh
  127397. * @see https://doc.babylonjs.com/babylon101/height_map
  127398. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127399. */
  127400. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127401. width?: number;
  127402. height?: number;
  127403. subdivisions?: number;
  127404. minHeight?: number;
  127405. maxHeight?: number;
  127406. colorFilter?: Color3;
  127407. alphaFilter?: number;
  127408. updatable?: boolean;
  127409. onReady?: (mesh: GroundMesh) => void;
  127410. }, scene?: Nullable<Scene>): GroundMesh;
  127411. }
  127412. }
  127413. declare module BABYLON {
  127414. /**
  127415. * Class containing static functions to help procedurally build meshes
  127416. */
  127417. export class TorusBuilder {
  127418. /**
  127419. * Creates a torus mesh
  127420. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127421. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127422. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127426. * @param name defines the name of the mesh
  127427. * @param options defines the options used to create the mesh
  127428. * @param scene defines the hosting scene
  127429. * @returns the torus mesh
  127430. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127431. */
  127432. static CreateTorus(name: string, options: {
  127433. diameter?: number;
  127434. thickness?: number;
  127435. tessellation?: number;
  127436. updatable?: boolean;
  127437. sideOrientation?: number;
  127438. frontUVs?: Vector4;
  127439. backUVs?: Vector4;
  127440. }, scene: any): Mesh;
  127441. }
  127442. }
  127443. declare module BABYLON {
  127444. /**
  127445. * Class containing static functions to help procedurally build meshes
  127446. */
  127447. export class CylinderBuilder {
  127448. /**
  127449. * Creates a cylinder or a cone mesh
  127450. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127451. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127452. * * 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.
  127453. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127454. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127455. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127456. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127457. * * 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).
  127458. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127459. * * 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).
  127460. * * 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
  127461. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127462. * * 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
  127463. * * 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.
  127464. * * If `enclose` is false, a ring surface is one element.
  127465. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127466. * * 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
  127467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127470. * @param name defines the name of the mesh
  127471. * @param options defines the options used to create the mesh
  127472. * @param scene defines the hosting scene
  127473. * @returns the cylinder mesh
  127474. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127475. */
  127476. static CreateCylinder(name: string, options: {
  127477. height?: number;
  127478. diameterTop?: number;
  127479. diameterBottom?: number;
  127480. diameter?: number;
  127481. tessellation?: number;
  127482. subdivisions?: number;
  127483. arc?: number;
  127484. faceColors?: Color4[];
  127485. faceUV?: Vector4[];
  127486. updatable?: boolean;
  127487. hasRings?: boolean;
  127488. enclose?: boolean;
  127489. cap?: number;
  127490. sideOrientation?: number;
  127491. frontUVs?: Vector4;
  127492. backUVs?: Vector4;
  127493. }, scene: any): Mesh;
  127494. }
  127495. }
  127496. declare module BABYLON {
  127497. /**
  127498. * States of the webXR experience
  127499. */
  127500. export enum WebXRState {
  127501. /**
  127502. * Transitioning to being in XR mode
  127503. */
  127504. ENTERING_XR = 0,
  127505. /**
  127506. * Transitioning to non XR mode
  127507. */
  127508. EXITING_XR = 1,
  127509. /**
  127510. * In XR mode and presenting
  127511. */
  127512. IN_XR = 2,
  127513. /**
  127514. * Not entered XR mode
  127515. */
  127516. NOT_IN_XR = 3
  127517. }
  127518. /**
  127519. * Abstraction of the XR render target
  127520. */
  127521. export interface WebXRRenderTarget extends IDisposable {
  127522. /**
  127523. * xrpresent context of the canvas which can be used to display/mirror xr content
  127524. */
  127525. canvasContext: WebGLRenderingContext;
  127526. /**
  127527. * xr layer for the canvas
  127528. */
  127529. xrLayer: Nullable<XRWebGLLayer>;
  127530. /**
  127531. * Initializes the xr layer for the session
  127532. * @param xrSession xr session
  127533. * @returns a promise that will resolve once the XR Layer has been created
  127534. */
  127535. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127536. }
  127537. }
  127538. declare module BABYLON {
  127539. /**
  127540. * COnfiguration object for WebXR output canvas
  127541. */
  127542. export class WebXRManagedOutputCanvasOptions {
  127543. /**
  127544. * An optional canvas in case you wish to create it yourself and provide it here.
  127545. * If not provided, a new canvas will be created
  127546. */
  127547. canvasElement?: HTMLCanvasElement;
  127548. /**
  127549. * Options for this XR Layer output
  127550. */
  127551. canvasOptions?: XRWebGLLayerOptions;
  127552. /**
  127553. * CSS styling for a newly created canvas (if not provided)
  127554. */
  127555. newCanvasCssStyle?: string;
  127556. /**
  127557. * Get the default values of the configuration object
  127558. * @param engine defines the engine to use (can be null)
  127559. * @returns default values of this configuration object
  127560. */
  127561. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127562. }
  127563. /**
  127564. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127565. */
  127566. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127567. private _options;
  127568. private _canvas;
  127569. private _engine;
  127570. private _originalCanvasSize;
  127571. /**
  127572. * Rendering context of the canvas which can be used to display/mirror xr content
  127573. */
  127574. canvasContext: WebGLRenderingContext;
  127575. /**
  127576. * xr layer for the canvas
  127577. */
  127578. xrLayer: Nullable<XRWebGLLayer>;
  127579. /**
  127580. * Obseervers registered here will be triggered when the xr layer was initialized
  127581. */
  127582. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127583. /**
  127584. * Initializes the canvas to be added/removed upon entering/exiting xr
  127585. * @param _xrSessionManager The XR Session manager
  127586. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127587. */
  127588. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127589. /**
  127590. * Disposes of the object
  127591. */
  127592. dispose(): void;
  127593. /**
  127594. * Initializes the xr layer for the session
  127595. * @param xrSession xr session
  127596. * @returns a promise that will resolve once the XR Layer has been created
  127597. */
  127598. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127599. private _addCanvas;
  127600. private _removeCanvas;
  127601. private _setCanvasSize;
  127602. private _setManagedOutputCanvas;
  127603. }
  127604. }
  127605. declare module BABYLON {
  127606. /**
  127607. * Manages an XRSession to work with Babylon's engine
  127608. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127609. */
  127610. export class WebXRSessionManager implements IDisposable {
  127611. /** The scene which the session should be created for */
  127612. scene: Scene;
  127613. private _referenceSpace;
  127614. private _rttProvider;
  127615. private _sessionEnded;
  127616. private _xrNavigator;
  127617. private baseLayer;
  127618. /**
  127619. * The base reference space from which the session started. good if you want to reset your
  127620. * reference space
  127621. */
  127622. baseReferenceSpace: XRReferenceSpace;
  127623. /**
  127624. * Current XR frame
  127625. */
  127626. currentFrame: Nullable<XRFrame>;
  127627. /** WebXR timestamp updated every frame */
  127628. currentTimestamp: number;
  127629. /**
  127630. * Used just in case of a failure to initialize an immersive session.
  127631. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127632. */
  127633. defaultHeightCompensation: number;
  127634. /**
  127635. * Fires every time a new xrFrame arrives which can be used to update the camera
  127636. */
  127637. onXRFrameObservable: Observable<XRFrame>;
  127638. /**
  127639. * Fires when the reference space changed
  127640. */
  127641. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127642. /**
  127643. * Fires when the xr session is ended either by the device or manually done
  127644. */
  127645. onXRSessionEnded: Observable<any>;
  127646. /**
  127647. * Fires when the xr session is ended either by the device or manually done
  127648. */
  127649. onXRSessionInit: Observable<XRSession>;
  127650. /**
  127651. * Underlying xr session
  127652. */
  127653. session: XRSession;
  127654. /**
  127655. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127656. * or get the offset the player is currently at.
  127657. */
  127658. viewerReferenceSpace: XRReferenceSpace;
  127659. /**
  127660. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127661. * @param scene The scene which the session should be created for
  127662. */
  127663. constructor(
  127664. /** The scene which the session should be created for */
  127665. scene: Scene);
  127666. /**
  127667. * The current reference space used in this session. This reference space can constantly change!
  127668. * It is mainly used to offset the camera's position.
  127669. */
  127670. get referenceSpace(): XRReferenceSpace;
  127671. /**
  127672. * Set a new reference space and triggers the observable
  127673. */
  127674. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127675. /**
  127676. * Disposes of the session manager
  127677. */
  127678. dispose(): void;
  127679. /**
  127680. * Stops the xrSession and restores the render loop
  127681. * @returns Promise which resolves after it exits XR
  127682. */
  127683. exitXRAsync(): Promise<void>;
  127684. /**
  127685. * Gets the correct render target texture to be rendered this frame for this eye
  127686. * @param eye the eye for which to get the render target
  127687. * @returns the render target for the specified eye
  127688. */
  127689. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127690. /**
  127691. * Creates a WebXRRenderTarget object for the XR session
  127692. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127693. * @param options optional options to provide when creating a new render target
  127694. * @returns a WebXR render target to which the session can render
  127695. */
  127696. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127697. /**
  127698. * Initializes the manager
  127699. * After initialization enterXR can be called to start an XR session
  127700. * @returns Promise which resolves after it is initialized
  127701. */
  127702. initializeAsync(): Promise<void>;
  127703. /**
  127704. * Initializes an xr session
  127705. * @param xrSessionMode mode to initialize
  127706. * @param xrSessionInit defines optional and required values to pass to the session builder
  127707. * @returns a promise which will resolve once the session has been initialized
  127708. */
  127709. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127710. /**
  127711. * Checks if a session would be supported for the creation options specified
  127712. * @param sessionMode session mode to check if supported eg. immersive-vr
  127713. * @returns A Promise that resolves to true if supported and false if not
  127714. */
  127715. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127716. /**
  127717. * Resets the reference space to the one started the session
  127718. */
  127719. resetReferenceSpace(): void;
  127720. /**
  127721. * Starts rendering to the xr layer
  127722. */
  127723. runXRRenderLoop(): void;
  127724. /**
  127725. * Sets the reference space on the xr session
  127726. * @param referenceSpaceType space to set
  127727. * @returns a promise that will resolve once the reference space has been set
  127728. */
  127729. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127730. /**
  127731. * Updates the render state of the session
  127732. * @param state state to set
  127733. * @returns a promise that resolves once the render state has been updated
  127734. */
  127735. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127736. /**
  127737. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127738. * @param sessionMode defines the session to test
  127739. * @returns a promise with boolean as final value
  127740. */
  127741. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127742. private _createRenderTargetTexture;
  127743. }
  127744. }
  127745. declare module BABYLON {
  127746. /**
  127747. * WebXR Camera which holds the views for the xrSession
  127748. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127749. */
  127750. export class WebXRCamera extends FreeCamera {
  127751. private _xrSessionManager;
  127752. private _firstFrame;
  127753. private _referenceQuaternion;
  127754. private _referencedPosition;
  127755. private _xrInvPositionCache;
  127756. private _xrInvQuaternionCache;
  127757. /**
  127758. * Observable raised before camera teleportation
  127759. */
  127760. onBeforeCameraTeleport: Observable<Vector3>;
  127761. /**
  127762. * Observable raised after camera teleportation
  127763. */
  127764. onAfterCameraTeleport: Observable<Vector3>;
  127765. /**
  127766. * Should position compensation execute on first frame.
  127767. * This is used when copying the position from a native (non XR) camera
  127768. */
  127769. compensateOnFirstFrame: boolean;
  127770. /**
  127771. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127772. * @param name the name of the camera
  127773. * @param scene the scene to add the camera to
  127774. * @param _xrSessionManager a constructed xr session manager
  127775. */
  127776. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127777. /**
  127778. * Return the user's height, unrelated to the current ground.
  127779. * This will be the y position of this camera, when ground level is 0.
  127780. */
  127781. get realWorldHeight(): number;
  127782. /** @hidden */
  127783. _updateForDualEyeDebugging(): void;
  127784. /**
  127785. * Sets this camera's transformation based on a non-vr camera
  127786. * @param otherCamera the non-vr camera to copy the transformation from
  127787. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127788. */
  127789. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127790. /**
  127791. * Gets the current instance class name ("WebXRCamera").
  127792. * @returns the class name
  127793. */
  127794. getClassName(): string;
  127795. private _rotate180;
  127796. private _updateFromXRSession;
  127797. private _updateNumberOfRigCameras;
  127798. private _updateReferenceSpace;
  127799. private _updateReferenceSpaceOffset;
  127800. }
  127801. }
  127802. declare module BABYLON {
  127803. /**
  127804. * Defining the interface required for a (webxr) feature
  127805. */
  127806. export interface IWebXRFeature extends IDisposable {
  127807. /**
  127808. * Is this feature attached
  127809. */
  127810. attached: boolean;
  127811. /**
  127812. * Should auto-attach be disabled?
  127813. */
  127814. disableAutoAttach: boolean;
  127815. /**
  127816. * Attach the feature to the session
  127817. * Will usually be called by the features manager
  127818. *
  127819. * @param force should attachment be forced (even when already attached)
  127820. * @returns true if successful.
  127821. */
  127822. attach(force?: boolean): boolean;
  127823. /**
  127824. * Detach the feature from the session
  127825. * Will usually be called by the features manager
  127826. *
  127827. * @returns true if successful.
  127828. */
  127829. detach(): boolean;
  127830. /**
  127831. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127832. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127833. *
  127834. * @returns whether or not the feature is compatible in this environment
  127835. */
  127836. isCompatible(): boolean;
  127837. /**
  127838. * Was this feature disposed;
  127839. */
  127840. isDisposed: boolean;
  127841. /**
  127842. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127843. */
  127844. xrNativeFeatureName?: string;
  127845. /**
  127846. * A list of (Babylon WebXR) features this feature depends on
  127847. */
  127848. dependsOn?: string[];
  127849. }
  127850. /**
  127851. * A list of the currently available features without referencing them
  127852. */
  127853. export class WebXRFeatureName {
  127854. /**
  127855. * The name of the anchor system feature
  127856. */
  127857. static readonly ANCHOR_SYSTEM: string;
  127858. /**
  127859. * The name of the background remover feature
  127860. */
  127861. static readonly BACKGROUND_REMOVER: string;
  127862. /**
  127863. * The name of the hit test feature
  127864. */
  127865. static readonly HIT_TEST: string;
  127866. /**
  127867. * physics impostors for xr controllers feature
  127868. */
  127869. static readonly PHYSICS_CONTROLLERS: string;
  127870. /**
  127871. * The name of the plane detection feature
  127872. */
  127873. static readonly PLANE_DETECTION: string;
  127874. /**
  127875. * The name of the pointer selection feature
  127876. */
  127877. static readonly POINTER_SELECTION: string;
  127878. /**
  127879. * The name of the teleportation feature
  127880. */
  127881. static readonly TELEPORTATION: string;
  127882. /**
  127883. * The name of the feature points feature.
  127884. */
  127885. static readonly FEATURE_POINTS: string;
  127886. /**
  127887. * The name of the hand tracking feature.
  127888. */
  127889. static readonly HAND_TRACKING: string;
  127890. }
  127891. /**
  127892. * Defining the constructor of a feature. Used to register the modules.
  127893. */
  127894. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127895. /**
  127896. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127897. * It is mainly used in AR sessions.
  127898. *
  127899. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127900. */
  127901. export class WebXRFeaturesManager implements IDisposable {
  127902. private _xrSessionManager;
  127903. private static readonly _AvailableFeatures;
  127904. private _features;
  127905. /**
  127906. * constructs a new features manages.
  127907. *
  127908. * @param _xrSessionManager an instance of WebXRSessionManager
  127909. */
  127910. constructor(_xrSessionManager: WebXRSessionManager);
  127911. /**
  127912. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127913. * Mainly used internally.
  127914. *
  127915. * @param featureName the name of the feature to register
  127916. * @param constructorFunction the function used to construct the module
  127917. * @param version the (babylon) version of the module
  127918. * @param stable is that a stable version of this module
  127919. */
  127920. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127921. /**
  127922. * Returns a constructor of a specific feature.
  127923. *
  127924. * @param featureName the name of the feature to construct
  127925. * @param version the version of the feature to load
  127926. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127927. * @param options optional options provided to the module.
  127928. * @returns a function that, when called, will return a new instance of this feature
  127929. */
  127930. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127931. /**
  127932. * Can be used to return the list of features currently registered
  127933. *
  127934. * @returns an Array of available features
  127935. */
  127936. static GetAvailableFeatures(): string[];
  127937. /**
  127938. * Gets the versions available for a specific feature
  127939. * @param featureName the name of the feature
  127940. * @returns an array with the available versions
  127941. */
  127942. static GetAvailableVersions(featureName: string): string[];
  127943. /**
  127944. * Return the latest unstable version of this feature
  127945. * @param featureName the name of the feature to search
  127946. * @returns the version number. if not found will return -1
  127947. */
  127948. static GetLatestVersionOfFeature(featureName: string): number;
  127949. /**
  127950. * Return the latest stable version of this feature
  127951. * @param featureName the name of the feature to search
  127952. * @returns the version number. if not found will return -1
  127953. */
  127954. static GetStableVersionOfFeature(featureName: string): number;
  127955. /**
  127956. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127957. * Can be used during a session to start a feature
  127958. * @param featureName the name of feature to attach
  127959. */
  127960. attachFeature(featureName: string): void;
  127961. /**
  127962. * Can be used inside a session or when the session ends to detach a specific feature
  127963. * @param featureName the name of the feature to detach
  127964. */
  127965. detachFeature(featureName: string): void;
  127966. /**
  127967. * Used to disable an already-enabled feature
  127968. * The feature will be disposed and will be recreated once enabled.
  127969. * @param featureName the feature to disable
  127970. * @returns true if disable was successful
  127971. */
  127972. disableFeature(featureName: string | {
  127973. Name: string;
  127974. }): boolean;
  127975. /**
  127976. * dispose this features manager
  127977. */
  127978. dispose(): void;
  127979. /**
  127980. * 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.
  127981. * 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.
  127982. *
  127983. * @param featureName the name of the feature to load or the class of the feature
  127984. * @param version optional version to load. if not provided the latest version will be enabled
  127985. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127986. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127987. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127988. * @returns a new constructed feature or throws an error if feature not found.
  127989. */
  127990. enableFeature(featureName: string | {
  127991. Name: string;
  127992. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127993. /**
  127994. * get the implementation of an enabled feature.
  127995. * @param featureName the name of the feature to load
  127996. * @returns the feature class, if found
  127997. */
  127998. getEnabledFeature(featureName: string): IWebXRFeature;
  127999. /**
  128000. * Get the list of enabled features
  128001. * @returns an array of enabled features
  128002. */
  128003. getEnabledFeatures(): string[];
  128004. /**
  128005. * This function will exten the session creation configuration object with enabled features.
  128006. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  128007. * according to the defined "required" variable, provided during enableFeature call
  128008. * @param xrSessionInit the xr Session init object to extend
  128009. *
  128010. * @returns an extended XRSessionInit object
  128011. */
  128012. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  128013. }
  128014. }
  128015. declare module BABYLON {
  128016. /**
  128017. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  128018. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  128019. */
  128020. export class WebXRExperienceHelper implements IDisposable {
  128021. private scene;
  128022. private _nonVRCamera;
  128023. private _originalSceneAutoClear;
  128024. private _supported;
  128025. /**
  128026. * Camera used to render xr content
  128027. */
  128028. camera: WebXRCamera;
  128029. /** A features manager for this xr session */
  128030. featuresManager: WebXRFeaturesManager;
  128031. /**
  128032. * Observers registered here will be triggered after the camera's initial transformation is set
  128033. * This can be used to set a different ground level or an extra rotation.
  128034. *
  128035. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  128036. * to the position set after this observable is done executing.
  128037. */
  128038. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  128039. /**
  128040. * Fires when the state of the experience helper has changed
  128041. */
  128042. onStateChangedObservable: Observable<WebXRState>;
  128043. /** Session manager used to keep track of xr session */
  128044. sessionManager: WebXRSessionManager;
  128045. /**
  128046. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  128047. */
  128048. state: WebXRState;
  128049. /**
  128050. * Creates a WebXRExperienceHelper
  128051. * @param scene The scene the helper should be created in
  128052. */
  128053. private constructor();
  128054. /**
  128055. * Creates the experience helper
  128056. * @param scene the scene to attach the experience helper to
  128057. * @returns a promise for the experience helper
  128058. */
  128059. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  128060. /**
  128061. * Disposes of the experience helper
  128062. */
  128063. dispose(): void;
  128064. /**
  128065. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  128066. * @param sessionMode options for the XR session
  128067. * @param referenceSpaceType frame of reference of the XR session
  128068. * @param renderTarget the output canvas that will be used to enter XR mode
  128069. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  128070. * @returns promise that resolves after xr mode has entered
  128071. */
  128072. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  128073. /**
  128074. * Exits XR mode and returns the scene to its original state
  128075. * @returns promise that resolves after xr mode has exited
  128076. */
  128077. exitXRAsync(): Promise<void>;
  128078. private _nonXRToXRCamera;
  128079. private _setState;
  128080. }
  128081. }
  128082. declare module BABYLON {
  128083. /**
  128084. * X-Y values for axes in WebXR
  128085. */
  128086. export interface IWebXRMotionControllerAxesValue {
  128087. /**
  128088. * The value of the x axis
  128089. */
  128090. x: number;
  128091. /**
  128092. * The value of the y-axis
  128093. */
  128094. y: number;
  128095. }
  128096. /**
  128097. * changed / previous values for the values of this component
  128098. */
  128099. export interface IWebXRMotionControllerComponentChangesValues<T> {
  128100. /**
  128101. * current (this frame) value
  128102. */
  128103. current: T;
  128104. /**
  128105. * previous (last change) value
  128106. */
  128107. previous: T;
  128108. }
  128109. /**
  128110. * Represents changes in the component between current frame and last values recorded
  128111. */
  128112. export interface IWebXRMotionControllerComponentChanges {
  128113. /**
  128114. * will be populated with previous and current values if axes changed
  128115. */
  128116. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  128117. /**
  128118. * will be populated with previous and current values if pressed changed
  128119. */
  128120. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128121. /**
  128122. * will be populated with previous and current values if touched changed
  128123. */
  128124. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128125. /**
  128126. * will be populated with previous and current values if value changed
  128127. */
  128128. value?: IWebXRMotionControllerComponentChangesValues<number>;
  128129. }
  128130. /**
  128131. * This class represents a single component (for example button or thumbstick) of a motion controller
  128132. */
  128133. export class WebXRControllerComponent implements IDisposable {
  128134. /**
  128135. * the id of this component
  128136. */
  128137. id: string;
  128138. /**
  128139. * the type of the component
  128140. */
  128141. type: MotionControllerComponentType;
  128142. private _buttonIndex;
  128143. private _axesIndices;
  128144. private _axes;
  128145. private _changes;
  128146. private _currentValue;
  128147. private _hasChanges;
  128148. private _pressed;
  128149. private _touched;
  128150. /**
  128151. * button component type
  128152. */
  128153. static BUTTON_TYPE: MotionControllerComponentType;
  128154. /**
  128155. * squeeze component type
  128156. */
  128157. static SQUEEZE_TYPE: MotionControllerComponentType;
  128158. /**
  128159. * Thumbstick component type
  128160. */
  128161. static THUMBSTICK_TYPE: MotionControllerComponentType;
  128162. /**
  128163. * Touchpad component type
  128164. */
  128165. static TOUCHPAD_TYPE: MotionControllerComponentType;
  128166. /**
  128167. * trigger component type
  128168. */
  128169. static TRIGGER_TYPE: MotionControllerComponentType;
  128170. /**
  128171. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  128172. * the axes data changes
  128173. */
  128174. onAxisValueChangedObservable: Observable<{
  128175. x: number;
  128176. y: number;
  128177. }>;
  128178. /**
  128179. * Observers registered here will be triggered when the state of a button changes
  128180. * State change is either pressed / touched / value
  128181. */
  128182. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  128183. /**
  128184. * Creates a new component for a motion controller.
  128185. * It is created by the motion controller itself
  128186. *
  128187. * @param id the id of this component
  128188. * @param type the type of the component
  128189. * @param _buttonIndex index in the buttons array of the gamepad
  128190. * @param _axesIndices indices of the values in the axes array of the gamepad
  128191. */
  128192. constructor(
  128193. /**
  128194. * the id of this component
  128195. */
  128196. id: string,
  128197. /**
  128198. * the type of the component
  128199. */
  128200. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  128201. /**
  128202. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  128203. */
  128204. get axes(): IWebXRMotionControllerAxesValue;
  128205. /**
  128206. * Get the changes. Elements will be populated only if they changed with their previous and current value
  128207. */
  128208. get changes(): IWebXRMotionControllerComponentChanges;
  128209. /**
  128210. * Return whether or not the component changed the last frame
  128211. */
  128212. get hasChanges(): boolean;
  128213. /**
  128214. * is the button currently pressed
  128215. */
  128216. get pressed(): boolean;
  128217. /**
  128218. * is the button currently touched
  128219. */
  128220. get touched(): boolean;
  128221. /**
  128222. * Get the current value of this component
  128223. */
  128224. get value(): number;
  128225. /**
  128226. * Dispose this component
  128227. */
  128228. dispose(): void;
  128229. /**
  128230. * Are there axes correlating to this component
  128231. * @return true is axes data is available
  128232. */
  128233. isAxes(): boolean;
  128234. /**
  128235. * Is this component a button (hence - pressable)
  128236. * @returns true if can be pressed
  128237. */
  128238. isButton(): boolean;
  128239. /**
  128240. * update this component using the gamepad object it is in. Called on every frame
  128241. * @param nativeController the native gamepad controller object
  128242. */
  128243. update(nativeController: IMinimalMotionControllerObject): void;
  128244. }
  128245. }
  128246. declare module BABYLON {
  128247. /**
  128248. * Interface used to represent data loading progression
  128249. */
  128250. export interface ISceneLoaderProgressEvent {
  128251. /**
  128252. * Defines if data length to load can be evaluated
  128253. */
  128254. readonly lengthComputable: boolean;
  128255. /**
  128256. * Defines the loaded data length
  128257. */
  128258. readonly loaded: number;
  128259. /**
  128260. * Defines the data length to load
  128261. */
  128262. readonly total: number;
  128263. }
  128264. /**
  128265. * Interface used by SceneLoader plugins to define supported file extensions
  128266. */
  128267. export interface ISceneLoaderPluginExtensions {
  128268. /**
  128269. * Defines the list of supported extensions
  128270. */
  128271. [extension: string]: {
  128272. isBinary: boolean;
  128273. };
  128274. }
  128275. /**
  128276. * Interface used by SceneLoader plugin factory
  128277. */
  128278. export interface ISceneLoaderPluginFactory {
  128279. /**
  128280. * Defines the name of the factory
  128281. */
  128282. name: string;
  128283. /**
  128284. * Function called to create a new plugin
  128285. * @return the new plugin
  128286. */
  128287. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  128288. /**
  128289. * The callback that returns true if the data can be directly loaded.
  128290. * @param data string containing the file data
  128291. * @returns if the data can be loaded directly
  128292. */
  128293. canDirectLoad?(data: string): boolean;
  128294. }
  128295. /**
  128296. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  128297. */
  128298. export interface ISceneLoaderPluginBase {
  128299. /**
  128300. * The friendly name of this plugin.
  128301. */
  128302. name: string;
  128303. /**
  128304. * The file extensions supported by this plugin.
  128305. */
  128306. extensions: string | ISceneLoaderPluginExtensions;
  128307. /**
  128308. * The callback called when loading from a url.
  128309. * @param scene scene loading this url
  128310. * @param url url to load
  128311. * @param onSuccess callback called when the file successfully loads
  128312. * @param onProgress callback called while file is loading (if the server supports this mode)
  128313. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128314. * @param onError callback called when the file fails to load
  128315. * @returns a file request object
  128316. */
  128317. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128318. /**
  128319. * The callback called when loading from a file object.
  128320. * @param scene scene loading this file
  128321. * @param file defines the file to load
  128322. * @param onSuccess defines the callback to call when data is loaded
  128323. * @param onProgress defines the callback to call during loading process
  128324. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128325. * @param onError defines the callback to call when an error occurs
  128326. * @returns a file request object
  128327. */
  128328. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128329. /**
  128330. * The callback that returns true if the data can be directly loaded.
  128331. * @param data string containing the file data
  128332. * @returns if the data can be loaded directly
  128333. */
  128334. canDirectLoad?(data: string): boolean;
  128335. /**
  128336. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128337. * @param scene scene loading this data
  128338. * @param data string containing the data
  128339. * @returns data to pass to the plugin
  128340. */
  128341. directLoad?(scene: Scene, data: string): any;
  128342. /**
  128343. * The callback that allows custom handling of the root url based on the response url.
  128344. * @param rootUrl the original root url
  128345. * @param responseURL the response url if available
  128346. * @returns the new root url
  128347. */
  128348. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128349. }
  128350. /**
  128351. * Interface used to define a SceneLoader plugin
  128352. */
  128353. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128354. /**
  128355. * Import meshes into a scene.
  128356. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128357. * @param scene The scene to import into
  128358. * @param data The data to import
  128359. * @param rootUrl The root url for scene and resources
  128360. * @param meshes The meshes array to import into
  128361. * @param particleSystems The particle systems array to import into
  128362. * @param skeletons The skeletons array to import into
  128363. * @param onError The callback when import fails
  128364. * @returns True if successful or false otherwise
  128365. */
  128366. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128367. /**
  128368. * Load into a scene.
  128369. * @param scene The scene to load into
  128370. * @param data The data to import
  128371. * @param rootUrl The root url for scene and resources
  128372. * @param onError The callback when import fails
  128373. * @returns True if successful or false otherwise
  128374. */
  128375. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128376. /**
  128377. * Load into an asset container.
  128378. * @param scene The scene to load into
  128379. * @param data The data to import
  128380. * @param rootUrl The root url for scene and resources
  128381. * @param onError The callback when import fails
  128382. * @returns The loaded asset container
  128383. */
  128384. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128385. }
  128386. /**
  128387. * Interface used to define an async SceneLoader plugin
  128388. */
  128389. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128390. /**
  128391. * Import meshes into a scene.
  128392. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128393. * @param scene The scene to import into
  128394. * @param data The data to import
  128395. * @param rootUrl The root url for scene and resources
  128396. * @param onProgress The callback when the load progresses
  128397. * @param fileName Defines the name of the file to load
  128398. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128399. */
  128400. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128401. meshes: AbstractMesh[];
  128402. particleSystems: IParticleSystem[];
  128403. skeletons: Skeleton[];
  128404. animationGroups: AnimationGroup[];
  128405. }>;
  128406. /**
  128407. * Load into a scene.
  128408. * @param scene The scene to load into
  128409. * @param data The data to import
  128410. * @param rootUrl The root url for scene and resources
  128411. * @param onProgress The callback when the load progresses
  128412. * @param fileName Defines the name of the file to load
  128413. * @returns Nothing
  128414. */
  128415. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128416. /**
  128417. * Load into an asset container.
  128418. * @param scene The scene to load into
  128419. * @param data The data to import
  128420. * @param rootUrl The root url for scene and resources
  128421. * @param onProgress The callback when the load progresses
  128422. * @param fileName Defines the name of the file to load
  128423. * @returns The loaded asset container
  128424. */
  128425. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128426. }
  128427. /**
  128428. * Mode that determines how to handle old animation groups before loading new ones.
  128429. */
  128430. export enum SceneLoaderAnimationGroupLoadingMode {
  128431. /**
  128432. * Reset all old animations to initial state then dispose them.
  128433. */
  128434. Clean = 0,
  128435. /**
  128436. * Stop all old animations.
  128437. */
  128438. Stop = 1,
  128439. /**
  128440. * Restart old animations from first frame.
  128441. */
  128442. Sync = 2,
  128443. /**
  128444. * Old animations remains untouched.
  128445. */
  128446. NoSync = 3
  128447. }
  128448. /**
  128449. * Defines a plugin registered by the SceneLoader
  128450. */
  128451. interface IRegisteredPlugin {
  128452. /**
  128453. * Defines the plugin to use
  128454. */
  128455. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128456. /**
  128457. * Defines if the plugin supports binary data
  128458. */
  128459. isBinary: boolean;
  128460. }
  128461. /**
  128462. * Class used to load scene from various file formats using registered plugins
  128463. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128464. */
  128465. export class SceneLoader {
  128466. /**
  128467. * No logging while loading
  128468. */
  128469. static readonly NO_LOGGING: number;
  128470. /**
  128471. * Minimal logging while loading
  128472. */
  128473. static readonly MINIMAL_LOGGING: number;
  128474. /**
  128475. * Summary logging while loading
  128476. */
  128477. static readonly SUMMARY_LOGGING: number;
  128478. /**
  128479. * Detailled logging while loading
  128480. */
  128481. static readonly DETAILED_LOGGING: number;
  128482. /**
  128483. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128484. */
  128485. static get ForceFullSceneLoadingForIncremental(): boolean;
  128486. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128487. /**
  128488. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128489. */
  128490. static get ShowLoadingScreen(): boolean;
  128491. static set ShowLoadingScreen(value: boolean);
  128492. /**
  128493. * Defines the current logging level (while loading the scene)
  128494. * @ignorenaming
  128495. */
  128496. static get loggingLevel(): number;
  128497. static set loggingLevel(value: number);
  128498. /**
  128499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128500. */
  128501. static get CleanBoneMatrixWeights(): boolean;
  128502. static set CleanBoneMatrixWeights(value: boolean);
  128503. /**
  128504. * Event raised when a plugin is used to load a scene
  128505. */
  128506. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128507. private static _registeredPlugins;
  128508. private static _showingLoadingScreen;
  128509. /**
  128510. * Gets the default plugin (used to load Babylon files)
  128511. * @returns the .babylon plugin
  128512. */
  128513. static GetDefaultPlugin(): IRegisteredPlugin;
  128514. private static _GetPluginForExtension;
  128515. private static _GetPluginForDirectLoad;
  128516. private static _GetPluginForFilename;
  128517. private static _GetDirectLoad;
  128518. private static _LoadData;
  128519. private static _GetFileInfo;
  128520. /**
  128521. * Gets a plugin that can load the given extension
  128522. * @param extension defines the extension to load
  128523. * @returns a plugin or null if none works
  128524. */
  128525. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128526. /**
  128527. * Gets a boolean indicating that the given extension can be loaded
  128528. * @param extension defines the extension to load
  128529. * @returns true if the extension is supported
  128530. */
  128531. static IsPluginForExtensionAvailable(extension: string): boolean;
  128532. /**
  128533. * Adds a new plugin to the list of registered plugins
  128534. * @param plugin defines the plugin to add
  128535. */
  128536. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128537. /**
  128538. * Import meshes into a scene
  128539. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128540. * @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)
  128541. * @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)
  128542. * @param scene the instance of BABYLON.Scene to append to
  128543. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128544. * @param onProgress a callback with a progress event for each file being loaded
  128545. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128546. * @param pluginExtension the extension used to determine the plugin
  128547. * @returns The loaded plugin
  128548. */
  128549. 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>;
  128550. /**
  128551. * Import meshes into a scene
  128552. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128553. * @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)
  128554. * @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)
  128555. * @param scene the instance of BABYLON.Scene to append to
  128556. * @param onProgress a callback with a progress event for each file being loaded
  128557. * @param pluginExtension the extension used to determine the plugin
  128558. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128559. */
  128560. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128561. meshes: AbstractMesh[];
  128562. particleSystems: IParticleSystem[];
  128563. skeletons: Skeleton[];
  128564. animationGroups: AnimationGroup[];
  128565. }>;
  128566. /**
  128567. * Load a scene
  128568. * @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)
  128569. * @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)
  128570. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128571. * @param onSuccess a callback with the scene when import succeeds
  128572. * @param onProgress a callback with a progress event for each file being loaded
  128573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128574. * @param pluginExtension the extension used to determine the plugin
  128575. * @returns The loaded plugin
  128576. */
  128577. 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>;
  128578. /**
  128579. * Load a scene
  128580. * @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)
  128581. * @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)
  128582. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128583. * @param onProgress a callback with a progress event for each file being loaded
  128584. * @param pluginExtension the extension used to determine the plugin
  128585. * @returns The loaded scene
  128586. */
  128587. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128588. /**
  128589. * Append a scene
  128590. * @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)
  128591. * @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)
  128592. * @param scene is the instance of BABYLON.Scene to append to
  128593. * @param onSuccess a callback with the scene when import succeeds
  128594. * @param onProgress a callback with a progress event for each file being loaded
  128595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128596. * @param pluginExtension the extension used to determine the plugin
  128597. * @returns The loaded plugin
  128598. */
  128599. 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>;
  128600. /**
  128601. * Append a scene
  128602. * @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)
  128603. * @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)
  128604. * @param scene is the instance of BABYLON.Scene to append to
  128605. * @param onProgress a callback with a progress event for each file being loaded
  128606. * @param pluginExtension the extension used to determine the plugin
  128607. * @returns The given scene
  128608. */
  128609. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128610. /**
  128611. * Load a scene into an asset container
  128612. * @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)
  128613. * @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)
  128614. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128615. * @param onSuccess a callback with the scene when import succeeds
  128616. * @param onProgress a callback with a progress event for each file being loaded
  128617. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128618. * @param pluginExtension the extension used to determine the plugin
  128619. * @returns The loaded plugin
  128620. */
  128621. 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>;
  128622. /**
  128623. * Load a scene into an asset container
  128624. * @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)
  128625. * @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)
  128626. * @param scene is the instance of Scene to append to
  128627. * @param onProgress a callback with a progress event for each file being loaded
  128628. * @param pluginExtension the extension used to determine the plugin
  128629. * @returns The loaded asset container
  128630. */
  128631. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128632. /**
  128633. * Import animations from a file into a scene
  128634. * @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)
  128635. * @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)
  128636. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128637. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128638. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128639. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128640. * @param onSuccess a callback with the scene when import succeeds
  128641. * @param onProgress a callback with a progress event for each file being loaded
  128642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128643. * @param pluginExtension the extension used to determine the plugin
  128644. */
  128645. 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;
  128646. /**
  128647. * Import animations from a file into a scene
  128648. * @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)
  128649. * @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)
  128650. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128651. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128652. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128653. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128654. * @param onSuccess a callback with the scene when import succeeds
  128655. * @param onProgress a callback with a progress event for each file being loaded
  128656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128657. * @param pluginExtension the extension used to determine the plugin
  128658. * @returns the updated scene with imported animations
  128659. */
  128660. 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>;
  128661. }
  128662. }
  128663. declare module BABYLON {
  128664. /**
  128665. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128666. */
  128667. export type MotionControllerHandedness = "none" | "left" | "right";
  128668. /**
  128669. * The type of components available in motion controllers.
  128670. * This is not the name of the component.
  128671. */
  128672. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128673. /**
  128674. * The state of a controller component
  128675. */
  128676. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128677. /**
  128678. * The schema of motion controller layout.
  128679. * No object will be initialized using this interface
  128680. * This is used just to define the profile.
  128681. */
  128682. export interface IMotionControllerLayout {
  128683. /**
  128684. * Path to load the assets. Usually relative to the base path
  128685. */
  128686. assetPath: string;
  128687. /**
  128688. * Available components (unsorted)
  128689. */
  128690. components: {
  128691. /**
  128692. * A map of component Ids
  128693. */
  128694. [componentId: string]: {
  128695. /**
  128696. * The type of input the component outputs
  128697. */
  128698. type: MotionControllerComponentType;
  128699. /**
  128700. * The indices of this component in the gamepad object
  128701. */
  128702. gamepadIndices: {
  128703. /**
  128704. * Index of button
  128705. */
  128706. button?: number;
  128707. /**
  128708. * If available, index of x-axis
  128709. */
  128710. xAxis?: number;
  128711. /**
  128712. * If available, index of y-axis
  128713. */
  128714. yAxis?: number;
  128715. };
  128716. /**
  128717. * The mesh's root node name
  128718. */
  128719. rootNodeName: string;
  128720. /**
  128721. * Animation definitions for this model
  128722. */
  128723. visualResponses: {
  128724. [stateKey: string]: {
  128725. /**
  128726. * What property will be animated
  128727. */
  128728. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128729. /**
  128730. * What states influence this visual response
  128731. */
  128732. states: MotionControllerComponentStateType[];
  128733. /**
  128734. * Type of animation - movement or visibility
  128735. */
  128736. valueNodeProperty: "transform" | "visibility";
  128737. /**
  128738. * Base node name to move. Its position will be calculated according to the min and max nodes
  128739. */
  128740. valueNodeName?: string;
  128741. /**
  128742. * Minimum movement node
  128743. */
  128744. minNodeName?: string;
  128745. /**
  128746. * Max movement node
  128747. */
  128748. maxNodeName?: string;
  128749. };
  128750. };
  128751. /**
  128752. * If touch enabled, what is the name of node to display user feedback
  128753. */
  128754. touchPointNodeName?: string;
  128755. };
  128756. };
  128757. /**
  128758. * Is it xr standard mapping or not
  128759. */
  128760. gamepadMapping: "" | "xr-standard";
  128761. /**
  128762. * Base root node of this entire model
  128763. */
  128764. rootNodeName: string;
  128765. /**
  128766. * Defines the main button component id
  128767. */
  128768. selectComponentId: string;
  128769. }
  128770. /**
  128771. * A definition for the layout map in the input profile
  128772. */
  128773. export interface IMotionControllerLayoutMap {
  128774. /**
  128775. * Layouts with handedness type as a key
  128776. */
  128777. [handedness: string]: IMotionControllerLayout;
  128778. }
  128779. /**
  128780. * The XR Input profile schema
  128781. * Profiles can be found here:
  128782. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128783. */
  128784. export interface IMotionControllerProfile {
  128785. /**
  128786. * fallback profiles for this profileId
  128787. */
  128788. fallbackProfileIds: string[];
  128789. /**
  128790. * The layout map, with handedness as key
  128791. */
  128792. layouts: IMotionControllerLayoutMap;
  128793. /**
  128794. * The id of this profile
  128795. * correlates to the profile(s) in the xrInput.profiles array
  128796. */
  128797. profileId: string;
  128798. }
  128799. /**
  128800. * A helper-interface for the 3 meshes needed for controller button animation
  128801. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128802. */
  128803. export interface IMotionControllerButtonMeshMap {
  128804. /**
  128805. * the mesh that defines the pressed value mesh position.
  128806. * This is used to find the max-position of this button
  128807. */
  128808. pressedMesh: AbstractMesh;
  128809. /**
  128810. * the mesh that defines the unpressed value mesh position.
  128811. * This is used to find the min (or initial) position of this button
  128812. */
  128813. unpressedMesh: AbstractMesh;
  128814. /**
  128815. * The mesh that will be changed when value changes
  128816. */
  128817. valueMesh: AbstractMesh;
  128818. }
  128819. /**
  128820. * A helper-interface for the 3 meshes needed for controller axis animation.
  128821. * This will be expanded when touchpad animations are fully supported
  128822. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128823. */
  128824. export interface IMotionControllerMeshMap {
  128825. /**
  128826. * the mesh that defines the maximum value mesh position.
  128827. */
  128828. maxMesh?: AbstractMesh;
  128829. /**
  128830. * the mesh that defines the minimum value mesh position.
  128831. */
  128832. minMesh?: AbstractMesh;
  128833. /**
  128834. * The mesh that will be changed when axis value changes
  128835. */
  128836. valueMesh?: AbstractMesh;
  128837. }
  128838. /**
  128839. * The elements needed for change-detection of the gamepad objects in motion controllers
  128840. */
  128841. export interface IMinimalMotionControllerObject {
  128842. /**
  128843. * Available axes of this controller
  128844. */
  128845. axes: number[];
  128846. /**
  128847. * An array of available buttons
  128848. */
  128849. buttons: Array<{
  128850. /**
  128851. * Value of the button/trigger
  128852. */
  128853. value: number;
  128854. /**
  128855. * If the button/trigger is currently touched
  128856. */
  128857. touched: boolean;
  128858. /**
  128859. * If the button/trigger is currently pressed
  128860. */
  128861. pressed: boolean;
  128862. }>;
  128863. /**
  128864. * EXPERIMENTAL haptic support.
  128865. */
  128866. hapticActuators?: Array<{
  128867. pulse: (value: number, duration: number) => Promise<boolean>;
  128868. }>;
  128869. }
  128870. /**
  128871. * An Abstract Motion controller
  128872. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128873. * Each component has an observable to check for changes in value and state
  128874. */
  128875. export abstract class WebXRAbstractMotionController implements IDisposable {
  128876. protected scene: Scene;
  128877. protected layout: IMotionControllerLayout;
  128878. /**
  128879. * The gamepad object correlating to this controller
  128880. */
  128881. gamepadObject: IMinimalMotionControllerObject;
  128882. /**
  128883. * handedness (left/right/none) of this controller
  128884. */
  128885. handedness: MotionControllerHandedness;
  128886. private _initComponent;
  128887. private _modelReady;
  128888. /**
  128889. * A map of components (WebXRControllerComponent) in this motion controller
  128890. * Components have a ComponentType and can also have both button and axis definitions
  128891. */
  128892. readonly components: {
  128893. [id: string]: WebXRControllerComponent;
  128894. };
  128895. /**
  128896. * Disable the model's animation. Can be set at any time.
  128897. */
  128898. disableAnimation: boolean;
  128899. /**
  128900. * Observers registered here will be triggered when the model of this controller is done loading
  128901. */
  128902. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128903. /**
  128904. * The profile id of this motion controller
  128905. */
  128906. abstract profileId: string;
  128907. /**
  128908. * The root mesh of the model. It is null if the model was not yet initialized
  128909. */
  128910. rootMesh: Nullable<AbstractMesh>;
  128911. /**
  128912. * constructs a new abstract motion controller
  128913. * @param scene the scene to which the model of the controller will be added
  128914. * @param layout The profile layout to load
  128915. * @param gamepadObject The gamepad object correlating to this controller
  128916. * @param handedness handedness (left/right/none) of this controller
  128917. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128918. */
  128919. constructor(scene: Scene, layout: IMotionControllerLayout,
  128920. /**
  128921. * The gamepad object correlating to this controller
  128922. */
  128923. gamepadObject: IMinimalMotionControllerObject,
  128924. /**
  128925. * handedness (left/right/none) of this controller
  128926. */
  128927. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128928. /**
  128929. * Dispose this controller, the model mesh and all its components
  128930. */
  128931. dispose(): void;
  128932. /**
  128933. * Returns all components of specific type
  128934. * @param type the type to search for
  128935. * @return an array of components with this type
  128936. */
  128937. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128938. /**
  128939. * get a component based an its component id as defined in layout.components
  128940. * @param id the id of the component
  128941. * @returns the component correlates to the id or undefined if not found
  128942. */
  128943. getComponent(id: string): WebXRControllerComponent;
  128944. /**
  128945. * Get the list of components available in this motion controller
  128946. * @returns an array of strings correlating to available components
  128947. */
  128948. getComponentIds(): string[];
  128949. /**
  128950. * Get the first component of specific type
  128951. * @param type type of component to find
  128952. * @return a controller component or null if not found
  128953. */
  128954. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128955. /**
  128956. * Get the main (Select) component of this controller as defined in the layout
  128957. * @returns the main component of this controller
  128958. */
  128959. getMainComponent(): WebXRControllerComponent;
  128960. /**
  128961. * Loads the model correlating to this controller
  128962. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128963. * @returns A promise fulfilled with the result of the model loading
  128964. */
  128965. loadModel(): Promise<boolean>;
  128966. /**
  128967. * Update this model using the current XRFrame
  128968. * @param xrFrame the current xr frame to use and update the model
  128969. */
  128970. updateFromXRFrame(xrFrame: XRFrame): void;
  128971. /**
  128972. * Backwards compatibility due to a deeply-integrated typo
  128973. */
  128974. get handness(): XREye;
  128975. /**
  128976. * Pulse (vibrate) this controller
  128977. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128978. * Consecutive calls to this function will cancel the last pulse call
  128979. *
  128980. * @param value the strength of the pulse in 0.0...1.0 range
  128981. * @param duration Duration of the pulse in milliseconds
  128982. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128983. * @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
  128984. */
  128985. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128986. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128987. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128988. /**
  128989. * Moves the axis on the controller mesh based on its current state
  128990. * @param axis the index of the axis
  128991. * @param axisValue the value of the axis which determines the meshes new position
  128992. * @hidden
  128993. */
  128994. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128995. /**
  128996. * Update the model itself with the current frame data
  128997. * @param xrFrame the frame to use for updating the model mesh
  128998. */
  128999. protected updateModel(xrFrame: XRFrame): void;
  129000. /**
  129001. * Get the filename and path for this controller's model
  129002. * @returns a map of filename and path
  129003. */
  129004. protected abstract _getFilenameAndPath(): {
  129005. filename: string;
  129006. path: string;
  129007. };
  129008. /**
  129009. * This function is called before the mesh is loaded. It checks for loading constraints.
  129010. * For example, this function can check if the GLB loader is available
  129011. * If this function returns false, the generic controller will be loaded instead
  129012. * @returns Is the client ready to load the mesh
  129013. */
  129014. protected abstract _getModelLoadingConstraints(): boolean;
  129015. /**
  129016. * This function will be called after the model was successfully loaded and can be used
  129017. * for mesh transformations before it is available for the user
  129018. * @param meshes the loaded meshes
  129019. */
  129020. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  129021. /**
  129022. * Set the root mesh for this controller. Important for the WebXR controller class
  129023. * @param meshes the loaded meshes
  129024. */
  129025. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  129026. /**
  129027. * A function executed each frame that updates the mesh (if needed)
  129028. * @param xrFrame the current xrFrame
  129029. */
  129030. protected abstract _updateModel(xrFrame: XRFrame): void;
  129031. private _getGenericFilenameAndPath;
  129032. private _getGenericParentMesh;
  129033. }
  129034. }
  129035. declare module BABYLON {
  129036. /**
  129037. * A generic trigger-only motion controller for WebXR
  129038. */
  129039. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  129040. /**
  129041. * Static version of the profile id of this controller
  129042. */
  129043. static ProfileId: string;
  129044. profileId: string;
  129045. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  129046. protected _getFilenameAndPath(): {
  129047. filename: string;
  129048. path: string;
  129049. };
  129050. protected _getModelLoadingConstraints(): boolean;
  129051. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  129052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129053. protected _updateModel(): void;
  129054. }
  129055. }
  129056. declare module BABYLON {
  129057. /**
  129058. * Class containing static functions to help procedurally build meshes
  129059. */
  129060. export class SphereBuilder {
  129061. /**
  129062. * Creates a sphere mesh
  129063. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129064. * * 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`)
  129065. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129066. * * 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
  129067. * * 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)
  129068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129071. * @param name defines the name of the mesh
  129072. * @param options defines the options used to create the mesh
  129073. * @param scene defines the hosting scene
  129074. * @returns the sphere mesh
  129075. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129076. */
  129077. static CreateSphere(name: string, options: {
  129078. segments?: number;
  129079. diameter?: number;
  129080. diameterX?: number;
  129081. diameterY?: number;
  129082. diameterZ?: number;
  129083. arc?: number;
  129084. slice?: number;
  129085. sideOrientation?: number;
  129086. frontUVs?: Vector4;
  129087. backUVs?: Vector4;
  129088. updatable?: boolean;
  129089. }, scene?: Nullable<Scene>): Mesh;
  129090. }
  129091. }
  129092. declare module BABYLON {
  129093. /**
  129094. * A profiled motion controller has its profile loaded from an online repository.
  129095. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  129096. */
  129097. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  129098. private _repositoryUrl;
  129099. private _buttonMeshMapping;
  129100. private _touchDots;
  129101. /**
  129102. * The profile ID of this controller. Will be populated when the controller initializes.
  129103. */
  129104. profileId: string;
  129105. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  129106. dispose(): void;
  129107. protected _getFilenameAndPath(): {
  129108. filename: string;
  129109. path: string;
  129110. };
  129111. protected _getModelLoadingConstraints(): boolean;
  129112. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  129113. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129114. protected _updateModel(_xrFrame: XRFrame): void;
  129115. }
  129116. }
  129117. declare module BABYLON {
  129118. /**
  129119. * A construction function type to create a new controller based on an xrInput object
  129120. */
  129121. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  129122. /**
  129123. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  129124. *
  129125. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  129126. * it should be replaced with auto-loaded controllers.
  129127. *
  129128. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  129129. */
  129130. export class WebXRMotionControllerManager {
  129131. private static _AvailableControllers;
  129132. private static _Fallbacks;
  129133. private static _ProfileLoadingPromises;
  129134. private static _ProfilesList;
  129135. /**
  129136. * The base URL of the online controller repository. Can be changed at any time.
  129137. */
  129138. static BaseRepositoryUrl: string;
  129139. /**
  129140. * Which repository gets priority - local or online
  129141. */
  129142. static PrioritizeOnlineRepository: boolean;
  129143. /**
  129144. * Use the online repository, or use only locally-defined controllers
  129145. */
  129146. static UseOnlineRepository: boolean;
  129147. /**
  129148. * Clear the cache used for profile loading and reload when requested again
  129149. */
  129150. static ClearProfilesCache(): void;
  129151. /**
  129152. * Register the default fallbacks.
  129153. * This function is called automatically when this file is imported.
  129154. */
  129155. static DefaultFallbacks(): void;
  129156. /**
  129157. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  129158. * @param profileId the profile to which a fallback needs to be found
  129159. * @return an array with corresponding fallback profiles
  129160. */
  129161. static FindFallbackWithProfileId(profileId: string): string[];
  129162. /**
  129163. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  129164. * The order of search:
  129165. *
  129166. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  129167. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  129168. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  129169. * 4) return the generic trigger controller if none were found
  129170. *
  129171. * @param xrInput the xrInput to which a new controller is initialized
  129172. * @param scene the scene to which the model will be added
  129173. * @param forceProfile force a certain profile for this controller
  129174. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  129175. */
  129176. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  129177. /**
  129178. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  129179. *
  129180. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  129181. *
  129182. * @param type the profile type to register
  129183. * @param constructFunction the function to be called when loading this profile
  129184. */
  129185. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  129186. /**
  129187. * Register a fallback to a specific profile.
  129188. * @param profileId the profileId that will receive the fallbacks
  129189. * @param fallbacks A list of fallback profiles
  129190. */
  129191. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  129192. /**
  129193. * Will update the list of profiles available in the repository
  129194. * @return a promise that resolves to a map of profiles available online
  129195. */
  129196. static UpdateProfilesList(): Promise<{
  129197. [profile: string]: string;
  129198. }>;
  129199. private static _LoadProfileFromRepository;
  129200. private static _LoadProfilesFromAvailableControllers;
  129201. }
  129202. }
  129203. declare module BABYLON {
  129204. /**
  129205. * Configuration options for the WebXR controller creation
  129206. */
  129207. export interface IWebXRControllerOptions {
  129208. /**
  129209. * Should the controller mesh be animated when a user interacts with it
  129210. * The pressed buttons / thumbstick and touchpad animations will be disabled
  129211. */
  129212. disableMotionControllerAnimation?: boolean;
  129213. /**
  129214. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  129215. */
  129216. doNotLoadControllerMesh?: boolean;
  129217. /**
  129218. * Force a specific controller type for this controller.
  129219. * This can be used when creating your own profile or when testing different controllers
  129220. */
  129221. forceControllerProfile?: string;
  129222. /**
  129223. * Defines a rendering group ID for meshes that will be loaded.
  129224. * This is for the default controllers only.
  129225. */
  129226. renderingGroupId?: number;
  129227. }
  129228. /**
  129229. * Represents an XR controller
  129230. */
  129231. export class WebXRInputSource {
  129232. private _scene;
  129233. /** The underlying input source for the controller */
  129234. inputSource: XRInputSource;
  129235. private _options;
  129236. private _tmpVector;
  129237. private _uniqueId;
  129238. private _disposed;
  129239. /**
  129240. * 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
  129241. */
  129242. grip?: AbstractMesh;
  129243. /**
  129244. * If available, this is the gamepad object related to this controller.
  129245. * Using this object it is possible to get click events and trackpad changes of the
  129246. * webxr controller that is currently being used.
  129247. */
  129248. motionController?: WebXRAbstractMotionController;
  129249. /**
  129250. * Event that fires when the controller is removed/disposed.
  129251. * The object provided as event data is this controller, after associated assets were disposed.
  129252. * uniqueId is still available.
  129253. */
  129254. onDisposeObservable: Observable<WebXRInputSource>;
  129255. /**
  129256. * Will be triggered when the mesh associated with the motion controller is done loading.
  129257. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  129258. * A shortened version of controller -> motion controller -> on mesh loaded.
  129259. */
  129260. onMeshLoadedObservable: Observable<AbstractMesh>;
  129261. /**
  129262. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  129263. */
  129264. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  129265. /**
  129266. * Pointer which can be used to select objects or attach a visible laser to
  129267. */
  129268. pointer: AbstractMesh;
  129269. /**
  129270. * Creates the input source object
  129271. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  129272. * @param _scene the scene which the controller should be associated to
  129273. * @param inputSource the underlying input source for the controller
  129274. * @param _options options for this controller creation
  129275. */
  129276. constructor(_scene: Scene,
  129277. /** The underlying input source for the controller */
  129278. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  129279. /**
  129280. * Get this controllers unique id
  129281. */
  129282. get uniqueId(): string;
  129283. /**
  129284. * Disposes of the object
  129285. */
  129286. dispose(): void;
  129287. /**
  129288. * Gets a world space ray coming from the pointer or grip
  129289. * @param result the resulting ray
  129290. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  129291. */
  129292. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  129293. /**
  129294. * Updates the controller pose based on the given XRFrame
  129295. * @param xrFrame xr frame to update the pose with
  129296. * @param referenceSpace reference space to use
  129297. */
  129298. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  129299. }
  129300. }
  129301. declare module BABYLON {
  129302. /**
  129303. * The schema for initialization options of the XR Input class
  129304. */
  129305. export interface IWebXRInputOptions {
  129306. /**
  129307. * If set to true no model will be automatically loaded
  129308. */
  129309. doNotLoadControllerMeshes?: boolean;
  129310. /**
  129311. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  129312. * If not found, the xr input profile data will be used.
  129313. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129314. */
  129315. forceInputProfile?: string;
  129316. /**
  129317. * Do not send a request to the controller repository to load the profile.
  129318. *
  129319. * Instead, use the controllers available in babylon itself.
  129320. */
  129321. disableOnlineControllerRepository?: boolean;
  129322. /**
  129323. * A custom URL for the controllers repository
  129324. */
  129325. customControllersRepositoryURL?: string;
  129326. /**
  129327. * Should the controller model's components not move according to the user input
  129328. */
  129329. disableControllerAnimation?: boolean;
  129330. /**
  129331. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129332. */
  129333. controllerOptions?: IWebXRControllerOptions;
  129334. }
  129335. /**
  129336. * XR input used to track XR inputs such as controllers/rays
  129337. */
  129338. export class WebXRInput implements IDisposable {
  129339. /**
  129340. * the xr session manager for this session
  129341. */
  129342. xrSessionManager: WebXRSessionManager;
  129343. /**
  129344. * the WebXR camera for this session. Mainly used for teleportation
  129345. */
  129346. xrCamera: WebXRCamera;
  129347. private readonly options;
  129348. /**
  129349. * XR controllers being tracked
  129350. */
  129351. controllers: Array<WebXRInputSource>;
  129352. private _frameObserver;
  129353. private _sessionEndedObserver;
  129354. private _sessionInitObserver;
  129355. /**
  129356. * Event when a controller has been connected/added
  129357. */
  129358. onControllerAddedObservable: Observable<WebXRInputSource>;
  129359. /**
  129360. * Event when a controller has been removed/disconnected
  129361. */
  129362. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129363. /**
  129364. * Initializes the WebXRInput
  129365. * @param xrSessionManager the xr session manager for this session
  129366. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129367. * @param options = initialization options for this xr input
  129368. */
  129369. constructor(
  129370. /**
  129371. * the xr session manager for this session
  129372. */
  129373. xrSessionManager: WebXRSessionManager,
  129374. /**
  129375. * the WebXR camera for this session. Mainly used for teleportation
  129376. */
  129377. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129378. private _onInputSourcesChange;
  129379. private _addAndRemoveControllers;
  129380. /**
  129381. * Disposes of the object
  129382. */
  129383. dispose(): void;
  129384. }
  129385. }
  129386. declare module BABYLON {
  129387. /**
  129388. * This is the base class for all WebXR features.
  129389. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129390. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129391. */
  129392. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129393. protected _xrSessionManager: WebXRSessionManager;
  129394. private _attached;
  129395. private _removeOnDetach;
  129396. /**
  129397. * Is this feature disposed?
  129398. */
  129399. isDisposed: boolean;
  129400. /**
  129401. * Should auto-attach be disabled?
  129402. */
  129403. disableAutoAttach: boolean;
  129404. /**
  129405. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129406. */
  129407. xrNativeFeatureName: string;
  129408. /**
  129409. * Construct a new (abstract) WebXR feature
  129410. * @param _xrSessionManager the xr session manager for this feature
  129411. */
  129412. constructor(_xrSessionManager: WebXRSessionManager);
  129413. /**
  129414. * Is this feature attached
  129415. */
  129416. get attached(): boolean;
  129417. /**
  129418. * attach this feature
  129419. *
  129420. * @param force should attachment be forced (even when already attached)
  129421. * @returns true if successful, false is failed or already attached
  129422. */
  129423. attach(force?: boolean): boolean;
  129424. /**
  129425. * detach this feature.
  129426. *
  129427. * @returns true if successful, false if failed or already detached
  129428. */
  129429. detach(): boolean;
  129430. /**
  129431. * Dispose this feature and all of the resources attached
  129432. */
  129433. dispose(): void;
  129434. /**
  129435. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129436. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129437. *
  129438. * @returns whether or not the feature is compatible in this environment
  129439. */
  129440. isCompatible(): boolean;
  129441. /**
  129442. * This is used to register callbacks that will automatically be removed when detach is called.
  129443. * @param observable the observable to which the observer will be attached
  129444. * @param callback the callback to register
  129445. */
  129446. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129447. /**
  129448. * Code in this function will be executed on each xrFrame received from the browser.
  129449. * This function will not execute after the feature is detached.
  129450. * @param _xrFrame the current frame
  129451. */
  129452. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129453. }
  129454. }
  129455. declare module BABYLON {
  129456. /**
  129457. * Renders a layer on top of an existing scene
  129458. */
  129459. export class UtilityLayerRenderer implements IDisposable {
  129460. /** the original scene that will be rendered on top of */
  129461. originalScene: Scene;
  129462. private _pointerCaptures;
  129463. private _lastPointerEvents;
  129464. private static _DefaultUtilityLayer;
  129465. private static _DefaultKeepDepthUtilityLayer;
  129466. private _sharedGizmoLight;
  129467. private _renderCamera;
  129468. /**
  129469. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129470. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129471. * @returns the camera that is used when rendering the utility layer
  129472. */
  129473. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129474. /**
  129475. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129476. * @param cam the camera that should be used when rendering the utility layer
  129477. */
  129478. setRenderCamera(cam: Nullable<Camera>): void;
  129479. /**
  129480. * @hidden
  129481. * Light which used by gizmos to get light shading
  129482. */
  129483. _getSharedGizmoLight(): HemisphericLight;
  129484. /**
  129485. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129486. */
  129487. pickUtilitySceneFirst: boolean;
  129488. /**
  129489. * 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)
  129490. */
  129491. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129492. /**
  129493. * 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)
  129494. */
  129495. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129496. /**
  129497. * The scene that is rendered on top of the original scene
  129498. */
  129499. utilityLayerScene: Scene;
  129500. /**
  129501. * If the utility layer should automatically be rendered on top of existing scene
  129502. */
  129503. shouldRender: boolean;
  129504. /**
  129505. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129506. */
  129507. onlyCheckPointerDownEvents: boolean;
  129508. /**
  129509. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129510. */
  129511. processAllEvents: boolean;
  129512. /**
  129513. * Observable raised when the pointer move from the utility layer scene to the main scene
  129514. */
  129515. onPointerOutObservable: Observable<number>;
  129516. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129517. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129518. private _afterRenderObserver;
  129519. private _sceneDisposeObserver;
  129520. private _originalPointerObserver;
  129521. /**
  129522. * Instantiates a UtilityLayerRenderer
  129523. * @param originalScene the original scene that will be rendered on top of
  129524. * @param handleEvents boolean indicating if the utility layer should handle events
  129525. */
  129526. constructor(
  129527. /** the original scene that will be rendered on top of */
  129528. originalScene: Scene, handleEvents?: boolean);
  129529. private _notifyObservers;
  129530. /**
  129531. * Renders the utility layers scene on top of the original scene
  129532. */
  129533. render(): void;
  129534. /**
  129535. * Disposes of the renderer
  129536. */
  129537. dispose(): void;
  129538. private _updateCamera;
  129539. }
  129540. }
  129541. declare module BABYLON {
  129542. /**
  129543. * Options interface for the pointer selection module
  129544. */
  129545. export interface IWebXRControllerPointerSelectionOptions {
  129546. /**
  129547. * if provided, this scene will be used to render meshes.
  129548. */
  129549. customUtilityLayerScene?: Scene;
  129550. /**
  129551. * 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)
  129552. * If not disabled, the last picked point will be used to execute a pointer up event
  129553. * If disabled, pointer up event will be triggered right after the pointer down event.
  129554. * Used in screen and gaze target ray mode only
  129555. */
  129556. disablePointerUpOnTouchOut: boolean;
  129557. /**
  129558. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129559. */
  129560. forceGazeMode: boolean;
  129561. /**
  129562. * 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
  129563. * to start a new countdown to the pointer down event.
  129564. * Defaults to 1.
  129565. */
  129566. gazeModePointerMovedFactor?: number;
  129567. /**
  129568. * Different button type to use instead of the main component
  129569. */
  129570. overrideButtonId?: string;
  129571. /**
  129572. * use this rendering group id for the meshes (optional)
  129573. */
  129574. renderingGroupId?: number;
  129575. /**
  129576. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129577. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129578. * 3000 means 3 seconds between pointing at something and selecting it
  129579. */
  129580. timeToSelect?: number;
  129581. /**
  129582. * Should meshes created here be added to a utility layer or the main scene
  129583. */
  129584. useUtilityLayer?: boolean;
  129585. /**
  129586. * Optional WebXR camera to be used for gaze selection
  129587. */
  129588. gazeCamera?: WebXRCamera;
  129589. /**
  129590. * the xr input to use with this pointer selection
  129591. */
  129592. xrInput: WebXRInput;
  129593. }
  129594. /**
  129595. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129596. */
  129597. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129598. private readonly _options;
  129599. private static _idCounter;
  129600. private _attachController;
  129601. private _controllers;
  129602. private _scene;
  129603. private _tmpVectorForPickCompare;
  129604. /**
  129605. * The module's name
  129606. */
  129607. static readonly Name: string;
  129608. /**
  129609. * The (Babylon) version of this module.
  129610. * This is an integer representing the implementation version.
  129611. * This number does not correspond to the WebXR specs version
  129612. */
  129613. static readonly Version: number;
  129614. /**
  129615. * Disable lighting on the laser pointer (so it will always be visible)
  129616. */
  129617. disablePointerLighting: boolean;
  129618. /**
  129619. * Disable lighting on the selection mesh (so it will always be visible)
  129620. */
  129621. disableSelectionMeshLighting: boolean;
  129622. /**
  129623. * Should the laser pointer be displayed
  129624. */
  129625. displayLaserPointer: boolean;
  129626. /**
  129627. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129628. */
  129629. displaySelectionMesh: boolean;
  129630. /**
  129631. * This color will be set to the laser pointer when selection is triggered
  129632. */
  129633. laserPointerPickedColor: Color3;
  129634. /**
  129635. * Default color of the laser pointer
  129636. */
  129637. laserPointerDefaultColor: Color3;
  129638. /**
  129639. * default color of the selection ring
  129640. */
  129641. selectionMeshDefaultColor: Color3;
  129642. /**
  129643. * This color will be applied to the selection ring when selection is triggered
  129644. */
  129645. selectionMeshPickedColor: Color3;
  129646. /**
  129647. * Optional filter to be used for ray selection. This predicate shares behavior with
  129648. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129649. */
  129650. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129651. /**
  129652. * constructs a new background remover module
  129653. * @param _xrSessionManager the session manager for this module
  129654. * @param _options read-only options to be used in this module
  129655. */
  129656. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129657. /**
  129658. * attach this feature
  129659. * Will usually be called by the features manager
  129660. *
  129661. * @returns true if successful.
  129662. */
  129663. attach(): boolean;
  129664. /**
  129665. * detach this feature.
  129666. * Will usually be called by the features manager
  129667. *
  129668. * @returns true if successful.
  129669. */
  129670. detach(): boolean;
  129671. /**
  129672. * Will get the mesh under a specific pointer.
  129673. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129674. * @param controllerId the controllerId to check
  129675. * @returns The mesh under pointer or null if no mesh is under the pointer
  129676. */
  129677. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129678. /**
  129679. * Get the xr controller that correlates to the pointer id in the pointer event
  129680. *
  129681. * @param id the pointer id to search for
  129682. * @returns the controller that correlates to this id or null if not found
  129683. */
  129684. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129685. protected _onXRFrame(_xrFrame: XRFrame): void;
  129686. private _attachGazeMode;
  129687. private _attachScreenRayMode;
  129688. private _attachTrackedPointerRayMode;
  129689. private _convertNormalToDirectionOfRay;
  129690. private _detachController;
  129691. private _generateNewMeshPair;
  129692. private _pickingMoved;
  129693. private _updatePointerDistance;
  129694. /** @hidden */
  129695. get lasterPointerDefaultColor(): Color3;
  129696. }
  129697. }
  129698. declare module BABYLON {
  129699. /**
  129700. * Button which can be used to enter a different mode of XR
  129701. */
  129702. export class WebXREnterExitUIButton {
  129703. /** button element */
  129704. element: HTMLElement;
  129705. /** XR initialization options for the button */
  129706. sessionMode: XRSessionMode;
  129707. /** Reference space type */
  129708. referenceSpaceType: XRReferenceSpaceType;
  129709. /**
  129710. * Creates a WebXREnterExitUIButton
  129711. * @param element button element
  129712. * @param sessionMode XR initialization session mode
  129713. * @param referenceSpaceType the type of reference space to be used
  129714. */
  129715. constructor(
  129716. /** button element */
  129717. element: HTMLElement,
  129718. /** XR initialization options for the button */
  129719. sessionMode: XRSessionMode,
  129720. /** Reference space type */
  129721. referenceSpaceType: XRReferenceSpaceType);
  129722. /**
  129723. * Extendable function which can be used to update the button's visuals when the state changes
  129724. * @param activeButton the current active button in the UI
  129725. */
  129726. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129727. }
  129728. /**
  129729. * Options to create the webXR UI
  129730. */
  129731. export class WebXREnterExitUIOptions {
  129732. /**
  129733. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129734. */
  129735. customButtons?: Array<WebXREnterExitUIButton>;
  129736. /**
  129737. * A reference space type to use when creating the default button.
  129738. * Default is local-floor
  129739. */
  129740. referenceSpaceType?: XRReferenceSpaceType;
  129741. /**
  129742. * Context to enter xr with
  129743. */
  129744. renderTarget?: Nullable<WebXRRenderTarget>;
  129745. /**
  129746. * A session mode to use when creating the default button.
  129747. * Default is immersive-vr
  129748. */
  129749. sessionMode?: XRSessionMode;
  129750. /**
  129751. * A list of optional features to init the session with
  129752. */
  129753. optionalFeatures?: string[];
  129754. /**
  129755. * A list of optional features to init the session with
  129756. */
  129757. requiredFeatures?: string[];
  129758. }
  129759. /**
  129760. * UI to allow the user to enter/exit XR mode
  129761. */
  129762. export class WebXREnterExitUI implements IDisposable {
  129763. private scene;
  129764. /** version of the options passed to this UI */
  129765. options: WebXREnterExitUIOptions;
  129766. private _activeButton;
  129767. private _buttons;
  129768. /**
  129769. * The HTML Div Element to which buttons are added.
  129770. */
  129771. readonly overlay: HTMLDivElement;
  129772. /**
  129773. * Fired every time the active button is changed.
  129774. *
  129775. * When xr is entered via a button that launches xr that button will be the callback parameter
  129776. *
  129777. * When exiting xr the callback parameter will be null)
  129778. */
  129779. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129780. /**
  129781. *
  129782. * @param scene babylon scene object to use
  129783. * @param options (read-only) version of the options passed to this UI
  129784. */
  129785. private constructor();
  129786. /**
  129787. * Creates UI to allow the user to enter/exit XR mode
  129788. * @param scene the scene to add the ui to
  129789. * @param helper the xr experience helper to enter/exit xr with
  129790. * @param options options to configure the UI
  129791. * @returns the created ui
  129792. */
  129793. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129794. /**
  129795. * Disposes of the XR UI component
  129796. */
  129797. dispose(): void;
  129798. private _updateButtons;
  129799. }
  129800. }
  129801. declare module BABYLON {
  129802. /**
  129803. * Class containing static functions to help procedurally build meshes
  129804. */
  129805. export class LinesBuilder {
  129806. /**
  129807. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129808. * * 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
  129809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129810. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129811. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129812. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129813. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129814. * * 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
  129815. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129818. * @param name defines the name of the new line system
  129819. * @param options defines the options used to create the line system
  129820. * @param scene defines the hosting scene
  129821. * @returns a new line system mesh
  129822. */
  129823. static CreateLineSystem(name: string, options: {
  129824. lines: Vector3[][];
  129825. updatable?: boolean;
  129826. instance?: Nullable<LinesMesh>;
  129827. colors?: Nullable<Color4[][]>;
  129828. useVertexAlpha?: boolean;
  129829. }, scene: Nullable<Scene>): LinesMesh;
  129830. /**
  129831. * Creates a line mesh
  129832. * 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
  129833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129834. * * The parameter `points` is an array successive Vector3
  129835. * * 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
  129836. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129837. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129838. * * When updating an instance, remember that only point positions can change, not the number of points
  129839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129841. * @param name defines the name of the new line system
  129842. * @param options defines the options used to create the line system
  129843. * @param scene defines the hosting scene
  129844. * @returns a new line mesh
  129845. */
  129846. static CreateLines(name: string, options: {
  129847. points: Vector3[];
  129848. updatable?: boolean;
  129849. instance?: Nullable<LinesMesh>;
  129850. colors?: Color4[];
  129851. useVertexAlpha?: boolean;
  129852. }, scene?: Nullable<Scene>): LinesMesh;
  129853. /**
  129854. * Creates a dashed line mesh
  129855. * * 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
  129856. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129857. * * The parameter `points` is an array successive Vector3
  129858. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129859. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129860. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129861. * * 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
  129862. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129863. * * When updating an instance, remember that only point positions can change, not the number of points
  129864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129865. * @param name defines the name of the mesh
  129866. * @param options defines the options used to create the mesh
  129867. * @param scene defines the hosting scene
  129868. * @returns the dashed line mesh
  129869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129870. */
  129871. static CreateDashedLines(name: string, options: {
  129872. points: Vector3[];
  129873. dashSize?: number;
  129874. gapSize?: number;
  129875. dashNb?: number;
  129876. updatable?: boolean;
  129877. instance?: LinesMesh;
  129878. useVertexAlpha?: boolean;
  129879. }, scene?: Nullable<Scene>): LinesMesh;
  129880. }
  129881. }
  129882. declare module BABYLON {
  129883. /**
  129884. * Construction options for a timer
  129885. */
  129886. export interface ITimerOptions<T> {
  129887. /**
  129888. * Time-to-end
  129889. */
  129890. timeout: number;
  129891. /**
  129892. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129893. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129894. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129895. */
  129896. contextObservable: Observable<T>;
  129897. /**
  129898. * Optional parameters when adding an observer to the observable
  129899. */
  129900. observableParameters?: {
  129901. mask?: number;
  129902. insertFirst?: boolean;
  129903. scope?: any;
  129904. };
  129905. /**
  129906. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129907. */
  129908. breakCondition?: (data?: ITimerData<T>) => boolean;
  129909. /**
  129910. * Will be triggered when the time condition has met
  129911. */
  129912. onEnded?: (data: ITimerData<any>) => void;
  129913. /**
  129914. * Will be triggered when the break condition has met (prematurely ended)
  129915. */
  129916. onAborted?: (data: ITimerData<any>) => void;
  129917. /**
  129918. * Optional function to execute on each tick (or count)
  129919. */
  129920. onTick?: (data: ITimerData<any>) => void;
  129921. }
  129922. /**
  129923. * An interface defining the data sent by the timer
  129924. */
  129925. export interface ITimerData<T> {
  129926. /**
  129927. * When did it start
  129928. */
  129929. startTime: number;
  129930. /**
  129931. * Time now
  129932. */
  129933. currentTime: number;
  129934. /**
  129935. * Time passed since started
  129936. */
  129937. deltaTime: number;
  129938. /**
  129939. * How much is completed, in [0.0...1.0].
  129940. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129941. */
  129942. completeRate: number;
  129943. /**
  129944. * What the registered observable sent in the last count
  129945. */
  129946. payload: T;
  129947. }
  129948. /**
  129949. * The current state of the timer
  129950. */
  129951. export enum TimerState {
  129952. /**
  129953. * Timer initialized, not yet started
  129954. */
  129955. INIT = 0,
  129956. /**
  129957. * Timer started and counting
  129958. */
  129959. STARTED = 1,
  129960. /**
  129961. * Timer ended (whether aborted or time reached)
  129962. */
  129963. ENDED = 2
  129964. }
  129965. /**
  129966. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129967. *
  129968. * @param options options with which to initialize this timer
  129969. */
  129970. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129971. /**
  129972. * An advanced implementation of a timer class
  129973. */
  129974. export class AdvancedTimer<T = any> implements IDisposable {
  129975. /**
  129976. * Will notify each time the timer calculates the remaining time
  129977. */
  129978. onEachCountObservable: Observable<ITimerData<T>>;
  129979. /**
  129980. * Will trigger when the timer was aborted due to the break condition
  129981. */
  129982. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129983. /**
  129984. * Will trigger when the timer ended successfully
  129985. */
  129986. onTimerEndedObservable: Observable<ITimerData<T>>;
  129987. /**
  129988. * Will trigger when the timer state has changed
  129989. */
  129990. onStateChangedObservable: Observable<TimerState>;
  129991. private _observer;
  129992. private _contextObservable;
  129993. private _observableParameters;
  129994. private _startTime;
  129995. private _timer;
  129996. private _state;
  129997. private _breakCondition;
  129998. private _timeToEnd;
  129999. private _breakOnNextTick;
  130000. /**
  130001. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  130002. * @param options construction options for this advanced timer
  130003. */
  130004. constructor(options: ITimerOptions<T>);
  130005. /**
  130006. * set a breaking condition for this timer. Default is to never break during count
  130007. * @param predicate the new break condition. Returns true to break, false otherwise
  130008. */
  130009. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  130010. /**
  130011. * Reset ALL associated observables in this advanced timer
  130012. */
  130013. clearObservables(): void;
  130014. /**
  130015. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  130016. *
  130017. * @param timeToEnd how much time to measure until timer ended
  130018. */
  130019. start(timeToEnd?: number): void;
  130020. /**
  130021. * Will force a stop on the next tick.
  130022. */
  130023. stop(): void;
  130024. /**
  130025. * Dispose this timer, clearing all resources
  130026. */
  130027. dispose(): void;
  130028. private _setState;
  130029. private _tick;
  130030. private _stop;
  130031. }
  130032. }
  130033. declare module BABYLON {
  130034. /**
  130035. * The options container for the teleportation module
  130036. */
  130037. export interface IWebXRTeleportationOptions {
  130038. /**
  130039. * if provided, this scene will be used to render meshes.
  130040. */
  130041. customUtilityLayerScene?: Scene;
  130042. /**
  130043. * Values to configure the default target mesh
  130044. */
  130045. defaultTargetMeshOptions?: {
  130046. /**
  130047. * Fill color of the teleportation area
  130048. */
  130049. teleportationFillColor?: string;
  130050. /**
  130051. * Border color for the teleportation area
  130052. */
  130053. teleportationBorderColor?: string;
  130054. /**
  130055. * Disable the mesh's animation sequence
  130056. */
  130057. disableAnimation?: boolean;
  130058. /**
  130059. * Disable lighting on the material or the ring and arrow
  130060. */
  130061. disableLighting?: boolean;
  130062. /**
  130063. * Override the default material of the torus and arrow
  130064. */
  130065. torusArrowMaterial?: Material;
  130066. };
  130067. /**
  130068. * A list of meshes to use as floor meshes.
  130069. * Meshes can be added and removed after initializing the feature using the
  130070. * addFloorMesh and removeFloorMesh functions
  130071. * If empty, rotation will still work
  130072. */
  130073. floorMeshes?: AbstractMesh[];
  130074. /**
  130075. * use this rendering group id for the meshes (optional)
  130076. */
  130077. renderingGroupId?: number;
  130078. /**
  130079. * Should teleportation move only to snap points
  130080. */
  130081. snapPointsOnly?: boolean;
  130082. /**
  130083. * An array of points to which the teleportation will snap to.
  130084. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  130085. */
  130086. snapPositions?: Vector3[];
  130087. /**
  130088. * How close should the teleportation ray be in order to snap to position.
  130089. * Default to 0.8 units (meters)
  130090. */
  130091. snapToPositionRadius?: number;
  130092. /**
  130093. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  130094. * If you want to support rotation, make sure your mesh has a direction indicator.
  130095. *
  130096. * When left untouched, the default mesh will be initialized.
  130097. */
  130098. teleportationTargetMesh?: AbstractMesh;
  130099. /**
  130100. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  130101. */
  130102. timeToTeleport?: number;
  130103. /**
  130104. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  130105. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  130106. */
  130107. useMainComponentOnly?: boolean;
  130108. /**
  130109. * Should meshes created here be added to a utility layer or the main scene
  130110. */
  130111. useUtilityLayer?: boolean;
  130112. /**
  130113. * Babylon XR Input class for controller
  130114. */
  130115. xrInput: WebXRInput;
  130116. /**
  130117. * Meshes that the teleportation ray cannot go through
  130118. */
  130119. pickBlockerMeshes?: AbstractMesh[];
  130120. }
  130121. /**
  130122. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  130123. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  130124. * the input of the attached controllers.
  130125. */
  130126. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  130127. private _options;
  130128. private _controllers;
  130129. private _currentTeleportationControllerId;
  130130. private _floorMeshes;
  130131. private _quadraticBezierCurve;
  130132. private _selectionFeature;
  130133. private _snapToPositions;
  130134. private _snappedToPoint;
  130135. private _teleportationRingMaterial?;
  130136. private _tmpRay;
  130137. private _tmpVector;
  130138. private _tmpQuaternion;
  130139. /**
  130140. * The module's name
  130141. */
  130142. static readonly Name: string;
  130143. /**
  130144. * The (Babylon) version of this module.
  130145. * This is an integer representing the implementation version.
  130146. * This number does not correspond to the webxr specs version
  130147. */
  130148. static readonly Version: number;
  130149. /**
  130150. * Is movement backwards enabled
  130151. */
  130152. backwardsMovementEnabled: boolean;
  130153. /**
  130154. * Distance to travel when moving backwards
  130155. */
  130156. backwardsTeleportationDistance: number;
  130157. /**
  130158. * The distance from the user to the inspection point in the direction of the controller
  130159. * A higher number will allow the user to move further
  130160. * defaults to 5 (meters, in xr units)
  130161. */
  130162. parabolicCheckRadius: number;
  130163. /**
  130164. * Should the module support parabolic ray on top of direct ray
  130165. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  130166. * Very helpful when moving between floors / different heights
  130167. */
  130168. parabolicRayEnabled: boolean;
  130169. /**
  130170. * How much rotation should be applied when rotating right and left
  130171. */
  130172. rotationAngle: number;
  130173. /**
  130174. * Is rotation enabled when moving forward?
  130175. * Disabling this feature will prevent the user from deciding the direction when teleporting
  130176. */
  130177. rotationEnabled: boolean;
  130178. /**
  130179. * constructs a new anchor system
  130180. * @param _xrSessionManager an instance of WebXRSessionManager
  130181. * @param _options configuration object for this feature
  130182. */
  130183. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  130184. /**
  130185. * Get the snapPointsOnly flag
  130186. */
  130187. get snapPointsOnly(): boolean;
  130188. /**
  130189. * Sets the snapPointsOnly flag
  130190. * @param snapToPoints should teleportation be exclusively to snap points
  130191. */
  130192. set snapPointsOnly(snapToPoints: boolean);
  130193. /**
  130194. * Add a new mesh to the floor meshes array
  130195. * @param mesh the mesh to use as floor mesh
  130196. */
  130197. addFloorMesh(mesh: AbstractMesh): void;
  130198. /**
  130199. * Add a new snap-to point to fix teleportation to this position
  130200. * @param newSnapPoint The new Snap-To point
  130201. */
  130202. addSnapPoint(newSnapPoint: Vector3): void;
  130203. attach(): boolean;
  130204. detach(): boolean;
  130205. dispose(): void;
  130206. /**
  130207. * Remove a mesh from the floor meshes array
  130208. * @param mesh the mesh to remove
  130209. */
  130210. removeFloorMesh(mesh: AbstractMesh): void;
  130211. /**
  130212. * Remove a mesh from the floor meshes array using its name
  130213. * @param name the mesh name to remove
  130214. */
  130215. removeFloorMeshByName(name: string): void;
  130216. /**
  130217. * 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
  130218. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  130219. * @returns was the point found and removed or not
  130220. */
  130221. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  130222. /**
  130223. * This function sets a selection feature that will be disabled when
  130224. * the forward ray is shown and will be reattached when hidden.
  130225. * This is used to remove the selection rays when moving.
  130226. * @param selectionFeature the feature to disable when forward movement is enabled
  130227. */
  130228. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  130229. protected _onXRFrame(_xrFrame: XRFrame): void;
  130230. private _attachController;
  130231. private _createDefaultTargetMesh;
  130232. private _detachController;
  130233. private _findClosestSnapPointWithRadius;
  130234. private _setTargetMeshPosition;
  130235. private _setTargetMeshVisibility;
  130236. private _showParabolicPath;
  130237. private _teleportForward;
  130238. }
  130239. }
  130240. declare module BABYLON {
  130241. /**
  130242. * Options for the default xr helper
  130243. */
  130244. export class WebXRDefaultExperienceOptions {
  130245. /**
  130246. * Enable or disable default UI to enter XR
  130247. */
  130248. disableDefaultUI?: boolean;
  130249. /**
  130250. * Should teleportation not initialize. defaults to false.
  130251. */
  130252. disableTeleportation?: boolean;
  130253. /**
  130254. * Floor meshes that will be used for teleport
  130255. */
  130256. floorMeshes?: Array<AbstractMesh>;
  130257. /**
  130258. * If set to true, the first frame will not be used to reset position
  130259. * The first frame is mainly used when copying transformation from the old camera
  130260. * Mainly used in AR
  130261. */
  130262. ignoreNativeCameraTransformation?: boolean;
  130263. /**
  130264. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  130265. */
  130266. inputOptions?: IWebXRInputOptions;
  130267. /**
  130268. * optional configuration for the output canvas
  130269. */
  130270. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  130271. /**
  130272. * optional UI options. This can be used among other to change session mode and reference space type
  130273. */
  130274. uiOptions?: WebXREnterExitUIOptions;
  130275. /**
  130276. * When loading teleportation and pointer select, use stable versions instead of latest.
  130277. */
  130278. useStablePlugins?: boolean;
  130279. /**
  130280. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  130281. */
  130282. renderingGroupId?: number;
  130283. /**
  130284. * A list of optional features to init the session with
  130285. * If set to true, all features we support will be added
  130286. */
  130287. optionalFeatures?: boolean | string[];
  130288. }
  130289. /**
  130290. * Default experience which provides a similar setup to the previous webVRExperience
  130291. */
  130292. export class WebXRDefaultExperience {
  130293. /**
  130294. * Base experience
  130295. */
  130296. baseExperience: WebXRExperienceHelper;
  130297. /**
  130298. * Enables ui for entering/exiting xr
  130299. */
  130300. enterExitUI: WebXREnterExitUI;
  130301. /**
  130302. * Input experience extension
  130303. */
  130304. input: WebXRInput;
  130305. /**
  130306. * Enables laser pointer and selection
  130307. */
  130308. pointerSelection: WebXRControllerPointerSelection;
  130309. /**
  130310. * Default target xr should render to
  130311. */
  130312. renderTarget: WebXRRenderTarget;
  130313. /**
  130314. * Enables teleportation
  130315. */
  130316. teleportation: WebXRMotionControllerTeleportation;
  130317. private constructor();
  130318. /**
  130319. * Creates the default xr experience
  130320. * @param scene scene
  130321. * @param options options for basic configuration
  130322. * @returns resulting WebXRDefaultExperience
  130323. */
  130324. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130325. /**
  130326. * DIsposes of the experience helper
  130327. */
  130328. dispose(): void;
  130329. }
  130330. }
  130331. declare module BABYLON {
  130332. /**
  130333. * Options to modify the vr teleportation behavior.
  130334. */
  130335. export interface VRTeleportationOptions {
  130336. /**
  130337. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130338. */
  130339. floorMeshName?: string;
  130340. /**
  130341. * A list of meshes to be used as the teleportation floor. (default: empty)
  130342. */
  130343. floorMeshes?: Mesh[];
  130344. /**
  130345. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130346. */
  130347. teleportationMode?: number;
  130348. /**
  130349. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130350. */
  130351. teleportationTime?: number;
  130352. /**
  130353. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130354. */
  130355. teleportationSpeed?: number;
  130356. /**
  130357. * The easing function used in the animation or null for Linear. (default CircleEase)
  130358. */
  130359. easingFunction?: EasingFunction;
  130360. }
  130361. /**
  130362. * Options to modify the vr experience helper's behavior.
  130363. */
  130364. export interface VRExperienceHelperOptions extends WebVROptions {
  130365. /**
  130366. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130367. */
  130368. createDeviceOrientationCamera?: boolean;
  130369. /**
  130370. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130371. */
  130372. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130373. /**
  130374. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130375. */
  130376. laserToggle?: boolean;
  130377. /**
  130378. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130379. */
  130380. floorMeshes?: Mesh[];
  130381. /**
  130382. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130383. */
  130384. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130385. /**
  130386. * Defines if WebXR should be used instead of WebVR (if available)
  130387. */
  130388. useXR?: boolean;
  130389. }
  130390. /**
  130391. * Event containing information after VR has been entered
  130392. */
  130393. export class OnAfterEnteringVRObservableEvent {
  130394. /**
  130395. * If entering vr was successful
  130396. */
  130397. success: boolean;
  130398. }
  130399. /**
  130400. * Helps to quickly add VR support to an existing scene.
  130401. * See https://doc.babylonjs.com/how_to/webvr_helper
  130402. */
  130403. export class VRExperienceHelper {
  130404. /** Options to modify the vr experience helper's behavior. */
  130405. webVROptions: VRExperienceHelperOptions;
  130406. private _scene;
  130407. private _position;
  130408. private _btnVR;
  130409. private _btnVRDisplayed;
  130410. private _webVRsupported;
  130411. private _webVRready;
  130412. private _webVRrequesting;
  130413. private _webVRpresenting;
  130414. private _hasEnteredVR;
  130415. private _fullscreenVRpresenting;
  130416. private _inputElement;
  130417. private _webVRCamera;
  130418. private _vrDeviceOrientationCamera;
  130419. private _deviceOrientationCamera;
  130420. private _existingCamera;
  130421. private _onKeyDown;
  130422. private _onVrDisplayPresentChange;
  130423. private _onVRDisplayChanged;
  130424. private _onVRRequestPresentStart;
  130425. private _onVRRequestPresentComplete;
  130426. /**
  130427. * 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)
  130428. */
  130429. enableGazeEvenWhenNoPointerLock: boolean;
  130430. /**
  130431. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130432. */
  130433. exitVROnDoubleTap: boolean;
  130434. /**
  130435. * Observable raised right before entering VR.
  130436. */
  130437. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130438. /**
  130439. * Observable raised when entering VR has completed.
  130440. */
  130441. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130442. /**
  130443. * Observable raised when exiting VR.
  130444. */
  130445. onExitingVRObservable: Observable<VRExperienceHelper>;
  130446. /**
  130447. * Observable raised when controller mesh is loaded.
  130448. */
  130449. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130450. /** Return this.onEnteringVRObservable
  130451. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130452. */
  130453. get onEnteringVR(): Observable<VRExperienceHelper>;
  130454. /** Return this.onExitingVRObservable
  130455. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130456. */
  130457. get onExitingVR(): Observable<VRExperienceHelper>;
  130458. /** Return this.onControllerMeshLoadedObservable
  130459. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130460. */
  130461. get onControllerMeshLoaded(): Observable<WebVRController>;
  130462. private _rayLength;
  130463. private _useCustomVRButton;
  130464. private _teleportationRequested;
  130465. private _teleportActive;
  130466. private _floorMeshName;
  130467. private _floorMeshesCollection;
  130468. private _teleportationMode;
  130469. private _teleportationTime;
  130470. private _teleportationSpeed;
  130471. private _teleportationEasing;
  130472. private _rotationAllowed;
  130473. private _teleportBackwardsVector;
  130474. private _teleportationTarget;
  130475. private _isDefaultTeleportationTarget;
  130476. private _postProcessMove;
  130477. private _teleportationFillColor;
  130478. private _teleportationBorderColor;
  130479. private _rotationAngle;
  130480. private _haloCenter;
  130481. private _cameraGazer;
  130482. private _padSensibilityUp;
  130483. private _padSensibilityDown;
  130484. private _leftController;
  130485. private _rightController;
  130486. private _gazeColor;
  130487. private _laserColor;
  130488. private _pickedLaserColor;
  130489. private _pickedGazeColor;
  130490. /**
  130491. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130492. */
  130493. onNewMeshSelected: Observable<AbstractMesh>;
  130494. /**
  130495. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130496. * This observable will provide the mesh and the controller used to select the mesh
  130497. */
  130498. onMeshSelectedWithController: Observable<{
  130499. mesh: AbstractMesh;
  130500. controller: WebVRController;
  130501. }>;
  130502. /**
  130503. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130504. */
  130505. onNewMeshPicked: Observable<PickingInfo>;
  130506. private _circleEase;
  130507. /**
  130508. * Observable raised before camera teleportation
  130509. */
  130510. onBeforeCameraTeleport: Observable<Vector3>;
  130511. /**
  130512. * Observable raised after camera teleportation
  130513. */
  130514. onAfterCameraTeleport: Observable<Vector3>;
  130515. /**
  130516. * Observable raised when current selected mesh gets unselected
  130517. */
  130518. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130519. private _raySelectionPredicate;
  130520. /**
  130521. * To be optionaly changed by user to define custom ray selection
  130522. */
  130523. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130524. /**
  130525. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130526. */
  130527. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130528. /**
  130529. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130530. */
  130531. teleportationEnabled: boolean;
  130532. private _defaultHeight;
  130533. private _teleportationInitialized;
  130534. private _interactionsEnabled;
  130535. private _interactionsRequested;
  130536. private _displayGaze;
  130537. private _displayLaserPointer;
  130538. /**
  130539. * The mesh used to display where the user is going to teleport.
  130540. */
  130541. get teleportationTarget(): Mesh;
  130542. /**
  130543. * Sets the mesh to be used to display where the user is going to teleport.
  130544. */
  130545. set teleportationTarget(value: Mesh);
  130546. /**
  130547. * 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
  130548. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130549. * See https://doc.babylonjs.com/resources/baking_transformations
  130550. */
  130551. get gazeTrackerMesh(): Mesh;
  130552. set gazeTrackerMesh(value: Mesh);
  130553. /**
  130554. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130555. */
  130556. updateGazeTrackerScale: boolean;
  130557. /**
  130558. * If the gaze trackers color should be updated when selecting meshes
  130559. */
  130560. updateGazeTrackerColor: boolean;
  130561. /**
  130562. * If the controller laser color should be updated when selecting meshes
  130563. */
  130564. updateControllerLaserColor: boolean;
  130565. /**
  130566. * The gaze tracking mesh corresponding to the left controller
  130567. */
  130568. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130569. /**
  130570. * The gaze tracking mesh corresponding to the right controller
  130571. */
  130572. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130573. /**
  130574. * If the ray of the gaze should be displayed.
  130575. */
  130576. get displayGaze(): boolean;
  130577. /**
  130578. * Sets if the ray of the gaze should be displayed.
  130579. */
  130580. set displayGaze(value: boolean);
  130581. /**
  130582. * If the ray of the LaserPointer should be displayed.
  130583. */
  130584. get displayLaserPointer(): boolean;
  130585. /**
  130586. * Sets if the ray of the LaserPointer should be displayed.
  130587. */
  130588. set displayLaserPointer(value: boolean);
  130589. /**
  130590. * The deviceOrientationCamera used as the camera when not in VR.
  130591. */
  130592. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130593. /**
  130594. * Based on the current WebVR support, returns the current VR camera used.
  130595. */
  130596. get currentVRCamera(): Nullable<Camera>;
  130597. /**
  130598. * The webVRCamera which is used when in VR.
  130599. */
  130600. get webVRCamera(): WebVRFreeCamera;
  130601. /**
  130602. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130603. */
  130604. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130605. /**
  130606. * The html button that is used to trigger entering into VR.
  130607. */
  130608. get vrButton(): Nullable<HTMLButtonElement>;
  130609. private get _teleportationRequestInitiated();
  130610. /**
  130611. * Defines whether or not Pointer lock should be requested when switching to
  130612. * full screen.
  130613. */
  130614. requestPointerLockOnFullScreen: boolean;
  130615. /**
  130616. * If asking to force XR, this will be populated with the default xr experience
  130617. */
  130618. xr: WebXRDefaultExperience;
  130619. /**
  130620. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130621. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130622. */
  130623. xrTestDone: boolean;
  130624. /**
  130625. * Instantiates a VRExperienceHelper.
  130626. * Helps to quickly add VR support to an existing scene.
  130627. * @param scene The scene the VRExperienceHelper belongs to.
  130628. * @param webVROptions Options to modify the vr experience helper's behavior.
  130629. */
  130630. constructor(scene: Scene,
  130631. /** Options to modify the vr experience helper's behavior. */
  130632. webVROptions?: VRExperienceHelperOptions);
  130633. private completeVRInit;
  130634. private _onDefaultMeshLoaded;
  130635. private _onResize;
  130636. private _onFullscreenChange;
  130637. /**
  130638. * Gets a value indicating if we are currently in VR mode.
  130639. */
  130640. get isInVRMode(): boolean;
  130641. private onVrDisplayPresentChange;
  130642. private onVRDisplayChanged;
  130643. private moveButtonToBottomRight;
  130644. private displayVRButton;
  130645. private updateButtonVisibility;
  130646. private _cachedAngularSensibility;
  130647. /**
  130648. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130649. * Otherwise, will use the fullscreen API.
  130650. */
  130651. enterVR(): void;
  130652. /**
  130653. * Attempt to exit VR, or fullscreen.
  130654. */
  130655. exitVR(): void;
  130656. /**
  130657. * The position of the vr experience helper.
  130658. */
  130659. get position(): Vector3;
  130660. /**
  130661. * Sets the position of the vr experience helper.
  130662. */
  130663. set position(value: Vector3);
  130664. /**
  130665. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130666. */
  130667. enableInteractions(): void;
  130668. private get _noControllerIsActive();
  130669. private beforeRender;
  130670. private _isTeleportationFloor;
  130671. /**
  130672. * Adds a floor mesh to be used for teleportation.
  130673. * @param floorMesh the mesh to be used for teleportation.
  130674. */
  130675. addFloorMesh(floorMesh: Mesh): void;
  130676. /**
  130677. * Removes a floor mesh from being used for teleportation.
  130678. * @param floorMesh the mesh to be removed.
  130679. */
  130680. removeFloorMesh(floorMesh: Mesh): void;
  130681. /**
  130682. * Enables interactions and teleportation using the VR controllers and gaze.
  130683. * @param vrTeleportationOptions options to modify teleportation behavior.
  130684. */
  130685. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130686. private _onNewGamepadConnected;
  130687. private _tryEnableInteractionOnController;
  130688. private _onNewGamepadDisconnected;
  130689. private _enableInteractionOnController;
  130690. private _checkTeleportWithRay;
  130691. private _checkRotate;
  130692. private _checkTeleportBackwards;
  130693. private _enableTeleportationOnController;
  130694. private _createTeleportationCircles;
  130695. private _displayTeleportationTarget;
  130696. private _hideTeleportationTarget;
  130697. private _rotateCamera;
  130698. private _moveTeleportationSelectorTo;
  130699. private _workingVector;
  130700. private _workingQuaternion;
  130701. private _workingMatrix;
  130702. /**
  130703. * Time Constant Teleportation Mode
  130704. */
  130705. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130706. /**
  130707. * Speed Constant Teleportation Mode
  130708. */
  130709. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130710. /**
  130711. * Teleports the users feet to the desired location
  130712. * @param location The location where the user's feet should be placed
  130713. */
  130714. teleportCamera(location: Vector3): void;
  130715. private _convertNormalToDirectionOfRay;
  130716. private _castRayAndSelectObject;
  130717. private _notifySelectedMeshUnselected;
  130718. /**
  130719. * Permanently set new colors for the laser pointer
  130720. * @param color the new laser color
  130721. * @param pickedColor the new laser color when picked mesh detected
  130722. */
  130723. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130724. /**
  130725. * Set lighting enabled / disabled on the laser pointer of both controllers
  130726. * @param enabled should the lighting be enabled on the laser pointer
  130727. */
  130728. setLaserLightingState(enabled?: boolean): void;
  130729. /**
  130730. * Permanently set new colors for the gaze pointer
  130731. * @param color the new gaze color
  130732. * @param pickedColor the new gaze color when picked mesh detected
  130733. */
  130734. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130735. /**
  130736. * Sets the color of the laser ray from the vr controllers.
  130737. * @param color new color for the ray.
  130738. */
  130739. changeLaserColor(color: Color3): void;
  130740. /**
  130741. * Sets the color of the ray from the vr headsets gaze.
  130742. * @param color new color for the ray.
  130743. */
  130744. changeGazeColor(color: Color3): void;
  130745. /**
  130746. * Exits VR and disposes of the vr experience helper
  130747. */
  130748. dispose(): void;
  130749. /**
  130750. * Gets the name of the VRExperienceHelper class
  130751. * @returns "VRExperienceHelper"
  130752. */
  130753. getClassName(): string;
  130754. }
  130755. }
  130756. declare module BABYLON {
  130757. /**
  130758. * Contains an array of blocks representing the octree
  130759. */
  130760. export interface IOctreeContainer<T> {
  130761. /**
  130762. * Blocks within the octree
  130763. */
  130764. blocks: Array<OctreeBlock<T>>;
  130765. }
  130766. /**
  130767. * Class used to store a cell in an octree
  130768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130769. */
  130770. export class OctreeBlock<T> {
  130771. /**
  130772. * Gets the content of the current block
  130773. */
  130774. entries: T[];
  130775. /**
  130776. * Gets the list of block children
  130777. */
  130778. blocks: Array<OctreeBlock<T>>;
  130779. private _depth;
  130780. private _maxDepth;
  130781. private _capacity;
  130782. private _minPoint;
  130783. private _maxPoint;
  130784. private _boundingVectors;
  130785. private _creationFunc;
  130786. /**
  130787. * Creates a new block
  130788. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130789. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130790. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130791. * @param depth defines the current depth of this block in the octree
  130792. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130793. * @param creationFunc defines a callback to call when an element is added to the block
  130794. */
  130795. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130796. /**
  130797. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130798. */
  130799. get capacity(): number;
  130800. /**
  130801. * Gets the minimum vector (in world space) of the block's bounding box
  130802. */
  130803. get minPoint(): Vector3;
  130804. /**
  130805. * Gets the maximum vector (in world space) of the block's bounding box
  130806. */
  130807. get maxPoint(): Vector3;
  130808. /**
  130809. * Add a new element to this block
  130810. * @param entry defines the element to add
  130811. */
  130812. addEntry(entry: T): void;
  130813. /**
  130814. * Remove an element from this block
  130815. * @param entry defines the element to remove
  130816. */
  130817. removeEntry(entry: T): void;
  130818. /**
  130819. * Add an array of elements to this block
  130820. * @param entries defines the array of elements to add
  130821. */
  130822. addEntries(entries: T[]): void;
  130823. /**
  130824. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130825. * @param frustumPlanes defines the frustum planes to test
  130826. * @param selection defines the array to store current content if selection is positive
  130827. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130828. */
  130829. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130830. /**
  130831. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130832. * @param sphereCenter defines the bounding sphere center
  130833. * @param sphereRadius defines the bounding sphere radius
  130834. * @param selection defines the array to store current content if selection is positive
  130835. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130836. */
  130837. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130838. /**
  130839. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130840. * @param ray defines the ray to test with
  130841. * @param selection defines the array to store current content if selection is positive
  130842. */
  130843. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130844. /**
  130845. * Subdivide the content into child blocks (this block will then be empty)
  130846. */
  130847. createInnerBlocks(): void;
  130848. /**
  130849. * @hidden
  130850. */
  130851. 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;
  130852. }
  130853. }
  130854. declare module BABYLON {
  130855. /**
  130856. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130857. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130858. */
  130859. export class Octree<T> {
  130860. /** 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.) */
  130861. maxDepth: number;
  130862. /**
  130863. * Blocks within the octree containing objects
  130864. */
  130865. blocks: Array<OctreeBlock<T>>;
  130866. /**
  130867. * Content stored in the octree
  130868. */
  130869. dynamicContent: T[];
  130870. private _maxBlockCapacity;
  130871. private _selectionContent;
  130872. private _creationFunc;
  130873. /**
  130874. * Creates a octree
  130875. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130876. * @param creationFunc function to be used to instatiate the octree
  130877. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130878. * @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.)
  130879. */
  130880. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130881. /** 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.) */
  130882. maxDepth?: number);
  130883. /**
  130884. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130885. * @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);
  130886. * @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);
  130887. * @param entries meshes to be added to the octree blocks
  130888. */
  130889. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130890. /**
  130891. * Adds a mesh to the octree
  130892. * @param entry Mesh to add to the octree
  130893. */
  130894. addMesh(entry: T): void;
  130895. /**
  130896. * Remove an element from the octree
  130897. * @param entry defines the element to remove
  130898. */
  130899. removeMesh(entry: T): void;
  130900. /**
  130901. * Selects an array of meshes within the frustum
  130902. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130903. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130904. * @returns array of meshes within the frustum
  130905. */
  130906. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130907. /**
  130908. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130909. * @param sphereCenter defines the bounding sphere center
  130910. * @param sphereRadius defines the bounding sphere radius
  130911. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130912. * @returns an array of objects that intersect the sphere
  130913. */
  130914. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130915. /**
  130916. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130917. * @param ray defines the ray to test with
  130918. * @returns array of intersected objects
  130919. */
  130920. intersectsRay(ray: Ray): SmartArray<T>;
  130921. /**
  130922. * Adds a mesh into the octree block if it intersects the block
  130923. */
  130924. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130925. /**
  130926. * Adds a submesh into the octree block if it intersects the block
  130927. */
  130928. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130929. }
  130930. }
  130931. declare module BABYLON {
  130932. interface Scene {
  130933. /**
  130934. * @hidden
  130935. * Backing Filed
  130936. */
  130937. _selectionOctree: Octree<AbstractMesh>;
  130938. /**
  130939. * Gets the octree used to boost mesh selection (picking)
  130940. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130941. */
  130942. selectionOctree: Octree<AbstractMesh>;
  130943. /**
  130944. * Creates or updates the octree used to boost selection (picking)
  130945. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130946. * @param maxCapacity defines the maximum capacity per leaf
  130947. * @param maxDepth defines the maximum depth of the octree
  130948. * @returns an octree of AbstractMesh
  130949. */
  130950. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130951. }
  130952. interface AbstractMesh {
  130953. /**
  130954. * @hidden
  130955. * Backing Field
  130956. */
  130957. _submeshesOctree: Octree<SubMesh>;
  130958. /**
  130959. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130960. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130961. * @param maxCapacity defines the maximum size of each block (64 by default)
  130962. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130963. * @returns the new octree
  130964. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130965. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130966. */
  130967. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130968. }
  130969. /**
  130970. * Defines the octree scene component responsible to manage any octrees
  130971. * in a given scene.
  130972. */
  130973. export class OctreeSceneComponent {
  130974. /**
  130975. * The component name help to identify the component in the list of scene components.
  130976. */
  130977. readonly name: string;
  130978. /**
  130979. * The scene the component belongs to.
  130980. */
  130981. scene: Scene;
  130982. /**
  130983. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130984. */
  130985. readonly checksIsEnabled: boolean;
  130986. /**
  130987. * Creates a new instance of the component for the given scene
  130988. * @param scene Defines the scene to register the component in
  130989. */
  130990. constructor(scene: Scene);
  130991. /**
  130992. * Registers the component in a given scene
  130993. */
  130994. register(): void;
  130995. /**
  130996. * Return the list of active meshes
  130997. * @returns the list of active meshes
  130998. */
  130999. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131000. /**
  131001. * Return the list of active sub meshes
  131002. * @param mesh The mesh to get the candidates sub meshes from
  131003. * @returns the list of active sub meshes
  131004. */
  131005. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131006. private _tempRay;
  131007. /**
  131008. * Return the list of sub meshes intersecting with a given local ray
  131009. * @param mesh defines the mesh to find the submesh for
  131010. * @param localRay defines the ray in local space
  131011. * @returns the list of intersecting sub meshes
  131012. */
  131013. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  131014. /**
  131015. * Return the list of sub meshes colliding with a collider
  131016. * @param mesh defines the mesh to find the submesh for
  131017. * @param collider defines the collider to evaluate the collision against
  131018. * @returns the list of colliding sub meshes
  131019. */
  131020. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  131021. /**
  131022. * Rebuilds the elements related to this component in case of
  131023. * context lost for instance.
  131024. */
  131025. rebuild(): void;
  131026. /**
  131027. * Disposes the component and the associated ressources.
  131028. */
  131029. dispose(): void;
  131030. }
  131031. }
  131032. declare module BABYLON {
  131033. /**
  131034. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  131035. */
  131036. export class Gizmo implements IDisposable {
  131037. /** The utility layer the gizmo will be added to */
  131038. gizmoLayer: UtilityLayerRenderer;
  131039. /**
  131040. * The root mesh of the gizmo
  131041. */
  131042. _rootMesh: Mesh;
  131043. private _attachedMesh;
  131044. private _attachedNode;
  131045. /**
  131046. * Ratio for the scale of the gizmo (Default: 1)
  131047. */
  131048. protected _scaleRatio: number;
  131049. /**
  131050. * boolean updated by pointermove when a gizmo mesh is hovered
  131051. */
  131052. protected _isHovered: boolean;
  131053. /**
  131054. * Ratio for the scale of the gizmo (Default: 1)
  131055. */
  131056. set scaleRatio(value: number);
  131057. get scaleRatio(): number;
  131058. /**
  131059. * True when the mouse pointer is hovered a gizmo mesh
  131060. */
  131061. get isHovered(): boolean;
  131062. /**
  131063. * If a custom mesh has been set (Default: false)
  131064. */
  131065. protected _customMeshSet: boolean;
  131066. /**
  131067. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  131068. * * When set, interactions will be enabled
  131069. */
  131070. get attachedMesh(): Nullable<AbstractMesh>;
  131071. set attachedMesh(value: Nullable<AbstractMesh>);
  131072. /**
  131073. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  131074. * * When set, interactions will be enabled
  131075. */
  131076. get attachedNode(): Nullable<Node>;
  131077. set attachedNode(value: Nullable<Node>);
  131078. /**
  131079. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131080. * @param mesh The mesh to replace the default mesh of the gizmo
  131081. */
  131082. setCustomMesh(mesh: Mesh): void;
  131083. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  131084. /**
  131085. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  131086. */
  131087. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131088. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131089. /**
  131090. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  131091. */
  131092. updateGizmoPositionToMatchAttachedMesh: boolean;
  131093. /**
  131094. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  131095. */
  131096. updateScale: boolean;
  131097. protected _interactionsEnabled: boolean;
  131098. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131099. private _beforeRenderObserver;
  131100. private _tempQuaternion;
  131101. private _tempVector;
  131102. private _tempVector2;
  131103. private _tempMatrix1;
  131104. private _tempMatrix2;
  131105. private _rightHandtoLeftHandMatrix;
  131106. /**
  131107. * Creates a gizmo
  131108. * @param gizmoLayer The utility layer the gizmo will be added to
  131109. */
  131110. constructor(
  131111. /** The utility layer the gizmo will be added to */
  131112. gizmoLayer?: UtilityLayerRenderer);
  131113. /**
  131114. * Updates the gizmo to match the attached mesh's position/rotation
  131115. */
  131116. protected _update(): void;
  131117. /**
  131118. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  131119. * @param value Node, TransformNode or mesh
  131120. */
  131121. protected _matrixChanged(): void;
  131122. /**
  131123. * Disposes of the gizmo
  131124. */
  131125. dispose(): void;
  131126. }
  131127. }
  131128. declare module BABYLON {
  131129. /**
  131130. * Single plane drag gizmo
  131131. */
  131132. export class PlaneDragGizmo extends Gizmo {
  131133. /**
  131134. * Drag behavior responsible for the gizmos dragging interactions
  131135. */
  131136. dragBehavior: PointerDragBehavior;
  131137. private _pointerObserver;
  131138. /**
  131139. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131140. */
  131141. snapDistance: number;
  131142. /**
  131143. * Event that fires each time the gizmo snaps to a new location.
  131144. * * snapDistance is the the change in distance
  131145. */
  131146. onSnapObservable: Observable<{
  131147. snapDistance: number;
  131148. }>;
  131149. private _plane;
  131150. private _coloredMaterial;
  131151. private _hoverMaterial;
  131152. private _isEnabled;
  131153. private _parent;
  131154. /** @hidden */
  131155. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  131156. /** @hidden */
  131157. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131158. /**
  131159. * Creates a PlaneDragGizmo
  131160. * @param gizmoLayer The utility layer the gizmo will be added to
  131161. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  131162. * @param color The color of the gizmo
  131163. */
  131164. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  131165. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131166. /**
  131167. * If the gizmo is enabled
  131168. */
  131169. set isEnabled(value: boolean);
  131170. get isEnabled(): boolean;
  131171. /**
  131172. * Disposes of the gizmo
  131173. */
  131174. dispose(): void;
  131175. }
  131176. }
  131177. declare module BABYLON {
  131178. /**
  131179. * Gizmo that enables dragging a mesh along 3 axis
  131180. */
  131181. export class PositionGizmo extends Gizmo {
  131182. /**
  131183. * Internal gizmo used for interactions on the x axis
  131184. */
  131185. xGizmo: AxisDragGizmo;
  131186. /**
  131187. * Internal gizmo used for interactions on the y axis
  131188. */
  131189. yGizmo: AxisDragGizmo;
  131190. /**
  131191. * Internal gizmo used for interactions on the z axis
  131192. */
  131193. zGizmo: AxisDragGizmo;
  131194. /**
  131195. * Internal gizmo used for interactions on the yz plane
  131196. */
  131197. xPlaneGizmo: PlaneDragGizmo;
  131198. /**
  131199. * Internal gizmo used for interactions on the xz plane
  131200. */
  131201. yPlaneGizmo: PlaneDragGizmo;
  131202. /**
  131203. * Internal gizmo used for interactions on the xy plane
  131204. */
  131205. zPlaneGizmo: PlaneDragGizmo;
  131206. /**
  131207. * private variables
  131208. */
  131209. private _meshAttached;
  131210. private _nodeAttached;
  131211. private _snapDistance;
  131212. /** Fires an event when any of it's sub gizmos are dragged */
  131213. onDragStartObservable: Observable<unknown>;
  131214. /** Fires an event when any of it's sub gizmos are released from dragging */
  131215. onDragEndObservable: Observable<unknown>;
  131216. /**
  131217. * If set to true, planar drag is enabled
  131218. */
  131219. private _planarGizmoEnabled;
  131220. get attachedMesh(): Nullable<AbstractMesh>;
  131221. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131222. get attachedNode(): Nullable<Node>;
  131223. set attachedNode(node: Nullable<Node>);
  131224. /**
  131225. * True when the mouse pointer is hovering a gizmo mesh
  131226. */
  131227. get isHovered(): boolean;
  131228. /**
  131229. * Creates a PositionGizmo
  131230. * @param gizmoLayer The utility layer the gizmo will be added to
  131231. @param thickness display gizmo axis thickness
  131232. */
  131233. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  131234. /**
  131235. * If the planar drag gizmo is enabled
  131236. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  131237. */
  131238. set planarGizmoEnabled(value: boolean);
  131239. get planarGizmoEnabled(): boolean;
  131240. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131241. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131242. /**
  131243. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131244. */
  131245. set snapDistance(value: number);
  131246. get snapDistance(): number;
  131247. /**
  131248. * Ratio for the scale of the gizmo (Default: 1)
  131249. */
  131250. set scaleRatio(value: number);
  131251. get scaleRatio(): number;
  131252. /**
  131253. * Disposes of the gizmo
  131254. */
  131255. dispose(): void;
  131256. /**
  131257. * CustomMeshes are not supported by this gizmo
  131258. * @param mesh The mesh to replace the default mesh of the gizmo
  131259. */
  131260. setCustomMesh(mesh: Mesh): void;
  131261. }
  131262. }
  131263. declare module BABYLON {
  131264. /**
  131265. * Single axis drag gizmo
  131266. */
  131267. export class AxisDragGizmo extends Gizmo {
  131268. /**
  131269. * Drag behavior responsible for the gizmos dragging interactions
  131270. */
  131271. dragBehavior: PointerDragBehavior;
  131272. private _pointerObserver;
  131273. /**
  131274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131275. */
  131276. snapDistance: number;
  131277. /**
  131278. * Event that fires each time the gizmo snaps to a new location.
  131279. * * snapDistance is the the change in distance
  131280. */
  131281. onSnapObservable: Observable<{
  131282. snapDistance: number;
  131283. }>;
  131284. private _isEnabled;
  131285. private _parent;
  131286. private _arrow;
  131287. private _coloredMaterial;
  131288. private _hoverMaterial;
  131289. /** @hidden */
  131290. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  131291. /** @hidden */
  131292. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131293. /**
  131294. * Creates an AxisDragGizmo
  131295. * @param gizmoLayer The utility layer the gizmo will be added to
  131296. * @param dragAxis The axis which the gizmo will be able to drag on
  131297. * @param color The color of the gizmo
  131298. * @param thickness display gizmo axis thickness
  131299. */
  131300. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  131301. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131302. /**
  131303. * If the gizmo is enabled
  131304. */
  131305. set isEnabled(value: boolean);
  131306. get isEnabled(): boolean;
  131307. /**
  131308. * Disposes of the gizmo
  131309. */
  131310. dispose(): void;
  131311. }
  131312. }
  131313. declare module BABYLON.Debug {
  131314. /**
  131315. * The Axes viewer will show 3 axes in a specific point in space
  131316. */
  131317. export class AxesViewer {
  131318. private _xAxis;
  131319. private _yAxis;
  131320. private _zAxis;
  131321. private _scaleLinesFactor;
  131322. private _instanced;
  131323. /**
  131324. * Gets the hosting scene
  131325. */
  131326. scene: Nullable<Scene>;
  131327. /**
  131328. * Gets or sets a number used to scale line length
  131329. */
  131330. scaleLines: number;
  131331. /** Gets the node hierarchy used to render x-axis */
  131332. get xAxis(): TransformNode;
  131333. /** Gets the node hierarchy used to render y-axis */
  131334. get yAxis(): TransformNode;
  131335. /** Gets the node hierarchy used to render z-axis */
  131336. get zAxis(): TransformNode;
  131337. /**
  131338. * Creates a new AxesViewer
  131339. * @param scene defines the hosting scene
  131340. * @param scaleLines defines a number used to scale line length (1 by default)
  131341. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131342. * @param xAxis defines the node hierarchy used to render the x-axis
  131343. * @param yAxis defines the node hierarchy used to render the y-axis
  131344. * @param zAxis defines the node hierarchy used to render the z-axis
  131345. */
  131346. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131347. /**
  131348. * Force the viewer to update
  131349. * @param position defines the position of the viewer
  131350. * @param xaxis defines the x axis of the viewer
  131351. * @param yaxis defines the y axis of the viewer
  131352. * @param zaxis defines the z axis of the viewer
  131353. */
  131354. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131355. /**
  131356. * Creates an instance of this axes viewer.
  131357. * @returns a new axes viewer with instanced meshes
  131358. */
  131359. createInstance(): AxesViewer;
  131360. /** Releases resources */
  131361. dispose(): void;
  131362. private static _SetRenderingGroupId;
  131363. }
  131364. }
  131365. declare module BABYLON.Debug {
  131366. /**
  131367. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131368. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131369. */
  131370. export class BoneAxesViewer extends AxesViewer {
  131371. /**
  131372. * Gets or sets the target mesh where to display the axes viewer
  131373. */
  131374. mesh: Nullable<Mesh>;
  131375. /**
  131376. * Gets or sets the target bone where to display the axes viewer
  131377. */
  131378. bone: Nullable<Bone>;
  131379. /** Gets current position */
  131380. pos: Vector3;
  131381. /** Gets direction of X axis */
  131382. xaxis: Vector3;
  131383. /** Gets direction of Y axis */
  131384. yaxis: Vector3;
  131385. /** Gets direction of Z axis */
  131386. zaxis: Vector3;
  131387. /**
  131388. * Creates a new BoneAxesViewer
  131389. * @param scene defines the hosting scene
  131390. * @param bone defines the target bone
  131391. * @param mesh defines the target mesh
  131392. * @param scaleLines defines a scaling factor for line length (1 by default)
  131393. */
  131394. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131395. /**
  131396. * Force the viewer to update
  131397. */
  131398. update(): void;
  131399. /** Releases resources */
  131400. dispose(): void;
  131401. }
  131402. }
  131403. declare module BABYLON {
  131404. /**
  131405. * Interface used to define scene explorer extensibility option
  131406. */
  131407. export interface IExplorerExtensibilityOption {
  131408. /**
  131409. * Define the option label
  131410. */
  131411. label: string;
  131412. /**
  131413. * Defines the action to execute on click
  131414. */
  131415. action: (entity: any) => void;
  131416. }
  131417. /**
  131418. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131419. */
  131420. export interface IExplorerExtensibilityGroup {
  131421. /**
  131422. * Defines a predicate to test if a given type mut be extended
  131423. */
  131424. predicate: (entity: any) => boolean;
  131425. /**
  131426. * Gets the list of options added to a type
  131427. */
  131428. entries: IExplorerExtensibilityOption[];
  131429. }
  131430. /**
  131431. * Interface used to define the options to use to create the Inspector
  131432. */
  131433. export interface IInspectorOptions {
  131434. /**
  131435. * Display in overlay mode (default: false)
  131436. */
  131437. overlay?: boolean;
  131438. /**
  131439. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131440. */
  131441. globalRoot?: HTMLElement;
  131442. /**
  131443. * Display the Scene explorer
  131444. */
  131445. showExplorer?: boolean;
  131446. /**
  131447. * Display the property inspector
  131448. */
  131449. showInspector?: boolean;
  131450. /**
  131451. * Display in embed mode (both panes on the right)
  131452. */
  131453. embedMode?: boolean;
  131454. /**
  131455. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131456. */
  131457. handleResize?: boolean;
  131458. /**
  131459. * Allow the panes to popup (default: true)
  131460. */
  131461. enablePopup?: boolean;
  131462. /**
  131463. * Allow the panes to be closed by users (default: true)
  131464. */
  131465. enableClose?: boolean;
  131466. /**
  131467. * Optional list of extensibility entries
  131468. */
  131469. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131470. /**
  131471. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131472. */
  131473. inspectorURL?: string;
  131474. /**
  131475. * Optional initial tab (default to DebugLayerTab.Properties)
  131476. */
  131477. initialTab?: DebugLayerTab;
  131478. }
  131479. interface Scene {
  131480. /**
  131481. * @hidden
  131482. * Backing field
  131483. */
  131484. _debugLayer: DebugLayer;
  131485. /**
  131486. * Gets the debug layer (aka Inspector) associated with the scene
  131487. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131488. */
  131489. debugLayer: DebugLayer;
  131490. }
  131491. /**
  131492. * Enum of inspector action tab
  131493. */
  131494. export enum DebugLayerTab {
  131495. /**
  131496. * Properties tag (default)
  131497. */
  131498. Properties = 0,
  131499. /**
  131500. * Debug tab
  131501. */
  131502. Debug = 1,
  131503. /**
  131504. * Statistics tab
  131505. */
  131506. Statistics = 2,
  131507. /**
  131508. * Tools tab
  131509. */
  131510. Tools = 3,
  131511. /**
  131512. * Settings tab
  131513. */
  131514. Settings = 4
  131515. }
  131516. /**
  131517. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131518. * what is happening in your scene
  131519. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131520. */
  131521. export class DebugLayer {
  131522. /**
  131523. * Define the url to get the inspector script from.
  131524. * By default it uses the babylonjs CDN.
  131525. * @ignoreNaming
  131526. */
  131527. static InspectorURL: string;
  131528. private _scene;
  131529. private BJSINSPECTOR;
  131530. private _onPropertyChangedObservable?;
  131531. /**
  131532. * Observable triggered when a property is changed through the inspector.
  131533. */
  131534. get onPropertyChangedObservable(): any;
  131535. /**
  131536. * Instantiates a new debug layer.
  131537. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131538. * what is happening in your scene
  131539. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131540. * @param scene Defines the scene to inspect
  131541. */
  131542. constructor(scene: Scene);
  131543. /** Creates the inspector window. */
  131544. private _createInspector;
  131545. /**
  131546. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131547. * @param entity defines the entity to select
  131548. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131549. */
  131550. select(entity: any, lineContainerTitles?: string | string[]): void;
  131551. /** Get the inspector from bundle or global */
  131552. private _getGlobalInspector;
  131553. /**
  131554. * Get if the inspector is visible or not.
  131555. * @returns true if visible otherwise, false
  131556. */
  131557. isVisible(): boolean;
  131558. /**
  131559. * Hide the inspector and close its window.
  131560. */
  131561. hide(): void;
  131562. /**
  131563. * Update the scene in the inspector
  131564. */
  131565. setAsActiveScene(): void;
  131566. /**
  131567. * Launch the debugLayer.
  131568. * @param config Define the configuration of the inspector
  131569. * @return a promise fulfilled when the debug layer is visible
  131570. */
  131571. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131572. }
  131573. }
  131574. declare module BABYLON {
  131575. /**
  131576. * Class containing static functions to help procedurally build meshes
  131577. */
  131578. export class BoxBuilder {
  131579. /**
  131580. * Creates a box mesh
  131581. * * The parameter `size` sets the size (float) of each box side (default 1)
  131582. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131583. * * 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)
  131584. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131588. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131589. * @param name defines the name of the mesh
  131590. * @param options defines the options used to create the mesh
  131591. * @param scene defines the hosting scene
  131592. * @returns the box mesh
  131593. */
  131594. static CreateBox(name: string, options: {
  131595. size?: number;
  131596. width?: number;
  131597. height?: number;
  131598. depth?: number;
  131599. faceUV?: Vector4[];
  131600. faceColors?: Color4[];
  131601. sideOrientation?: number;
  131602. frontUVs?: Vector4;
  131603. backUVs?: Vector4;
  131604. wrap?: boolean;
  131605. topBaseAt?: number;
  131606. bottomBaseAt?: number;
  131607. updatable?: boolean;
  131608. }, scene?: Nullable<Scene>): Mesh;
  131609. }
  131610. }
  131611. declare module BABYLON.Debug {
  131612. /**
  131613. * Used to show the physics impostor around the specific mesh
  131614. */
  131615. export class PhysicsViewer {
  131616. /** @hidden */
  131617. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131618. /** @hidden */
  131619. protected _meshes: Array<Nullable<AbstractMesh>>;
  131620. /** @hidden */
  131621. protected _scene: Nullable<Scene>;
  131622. /** @hidden */
  131623. protected _numMeshes: number;
  131624. /** @hidden */
  131625. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131626. private _renderFunction;
  131627. private _utilityLayer;
  131628. private _debugBoxMesh;
  131629. private _debugSphereMesh;
  131630. private _debugCylinderMesh;
  131631. private _debugMaterial;
  131632. private _debugMeshMeshes;
  131633. /**
  131634. * Creates a new PhysicsViewer
  131635. * @param scene defines the hosting scene
  131636. */
  131637. constructor(scene: Scene);
  131638. /** @hidden */
  131639. protected _updateDebugMeshes(): void;
  131640. /**
  131641. * Renders a specified physic impostor
  131642. * @param impostor defines the impostor to render
  131643. * @param targetMesh defines the mesh represented by the impostor
  131644. * @returns the new debug mesh used to render the impostor
  131645. */
  131646. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131647. /**
  131648. * Hides a specified physic impostor
  131649. * @param impostor defines the impostor to hide
  131650. */
  131651. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131652. private _getDebugMaterial;
  131653. private _getDebugBoxMesh;
  131654. private _getDebugSphereMesh;
  131655. private _getDebugCylinderMesh;
  131656. private _getDebugMeshMesh;
  131657. private _getDebugMesh;
  131658. /** Releases all resources */
  131659. dispose(): void;
  131660. }
  131661. }
  131662. declare module BABYLON {
  131663. /**
  131664. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131665. * in order to better appreciate the issue one might have.
  131666. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131667. */
  131668. export class RayHelper {
  131669. /**
  131670. * Defines the ray we are currently tryin to visualize.
  131671. */
  131672. ray: Nullable<Ray>;
  131673. private _renderPoints;
  131674. private _renderLine;
  131675. private _renderFunction;
  131676. private _scene;
  131677. private _onAfterRenderObserver;
  131678. private _onAfterStepObserver;
  131679. private _attachedToMesh;
  131680. private _meshSpaceDirection;
  131681. private _meshSpaceOrigin;
  131682. /**
  131683. * Helper function to create a colored helper in a scene in one line.
  131684. * @param ray Defines the ray we are currently tryin to visualize
  131685. * @param scene Defines the scene the ray is used in
  131686. * @param color Defines the color we want to see the ray in
  131687. * @returns The newly created ray helper.
  131688. */
  131689. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131690. /**
  131691. * Instantiate a new ray helper.
  131692. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131693. * in order to better appreciate the issue one might have.
  131694. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131695. * @param ray Defines the ray we are currently tryin to visualize
  131696. */
  131697. constructor(ray: Ray);
  131698. /**
  131699. * Shows the ray we are willing to debug.
  131700. * @param scene Defines the scene the ray needs to be rendered in
  131701. * @param color Defines the color the ray needs to be rendered in
  131702. */
  131703. show(scene: Scene, color?: Color3): void;
  131704. /**
  131705. * Hides the ray we are debugging.
  131706. */
  131707. hide(): void;
  131708. private _render;
  131709. /**
  131710. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131711. * @param mesh Defines the mesh we want the helper attached to
  131712. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131713. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131714. * @param length Defines the length of the ray
  131715. */
  131716. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131717. /**
  131718. * Detach the ray helper from the mesh it has previously been attached to.
  131719. */
  131720. detachFromMesh(): void;
  131721. private _updateToMesh;
  131722. /**
  131723. * Dispose the helper and release its associated resources.
  131724. */
  131725. dispose(): void;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /**
  131730. * Defines the options associated with the creation of a SkeletonViewer.
  131731. */
  131732. export interface ISkeletonViewerOptions {
  131733. /** Should the system pause animations before building the Viewer? */
  131734. pauseAnimations: boolean;
  131735. /** Should the system return the skeleton to rest before building? */
  131736. returnToRest: boolean;
  131737. /** public Display Mode of the Viewer */
  131738. displayMode: number;
  131739. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131740. displayOptions: ISkeletonViewerDisplayOptions;
  131741. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131742. computeBonesUsingShaders: boolean;
  131743. /** Flag ignore non weighted bones */
  131744. useAllBones: boolean;
  131745. }
  131746. /**
  131747. * Defines how to display the various bone meshes for the viewer.
  131748. */
  131749. export interface ISkeletonViewerDisplayOptions {
  131750. /** How far down to start tapering the bone spurs */
  131751. midStep?: number;
  131752. /** How big is the midStep? */
  131753. midStepFactor?: number;
  131754. /** Base for the Sphere Size */
  131755. sphereBaseSize?: number;
  131756. /** The ratio of the sphere to the longest bone in units */
  131757. sphereScaleUnit?: number;
  131758. /** Ratio for the Sphere Size */
  131759. sphereFactor?: number;
  131760. /** Whether a spur should attach its far end to the child bone position */
  131761. spurFollowsChild?: boolean;
  131762. /** Whether to show local axes or not */
  131763. showLocalAxes?: boolean;
  131764. /** Length of each local axis */
  131765. localAxesSize?: number;
  131766. }
  131767. /**
  131768. * Defines the constructor options for the BoneWeight Shader.
  131769. */
  131770. export interface IBoneWeightShaderOptions {
  131771. /** Skeleton to Map */
  131772. skeleton: Skeleton;
  131773. /** Colors for Uninfluenced bones */
  131774. colorBase?: Color3;
  131775. /** Colors for 0.0-0.25 Weight bones */
  131776. colorZero?: Color3;
  131777. /** Color for 0.25-0.5 Weight Influence */
  131778. colorQuarter?: Color3;
  131779. /** Color for 0.5-0.75 Weight Influence */
  131780. colorHalf?: Color3;
  131781. /** Color for 0.75-1 Weight Influence */
  131782. colorFull?: Color3;
  131783. /** Color for Zero Weight Influence */
  131784. targetBoneIndex?: number;
  131785. }
  131786. /**
  131787. * Simple structure of the gradient steps for the Color Map.
  131788. */
  131789. export interface ISkeletonMapShaderColorMapKnot {
  131790. /** Color of the Knot */
  131791. color: Color3;
  131792. /** Location of the Knot */
  131793. location: number;
  131794. }
  131795. /**
  131796. * Defines the constructor options for the SkeletonMap Shader.
  131797. */
  131798. export interface ISkeletonMapShaderOptions {
  131799. /** Skeleton to Map */
  131800. skeleton: Skeleton;
  131801. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131802. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131803. }
  131804. }
  131805. declare module BABYLON {
  131806. /**
  131807. * Class containing static functions to help procedurally build meshes
  131808. */
  131809. export class RibbonBuilder {
  131810. /**
  131811. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131812. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131813. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131814. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131815. * * 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
  131816. * * 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
  131817. * * 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
  131818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131821. * * 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
  131822. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131823. * * 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
  131824. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131826. * @param name defines the name of the mesh
  131827. * @param options defines the options used to create the mesh
  131828. * @param scene defines the hosting scene
  131829. * @returns the ribbon mesh
  131830. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131832. */
  131833. static CreateRibbon(name: string, options: {
  131834. pathArray: Vector3[][];
  131835. closeArray?: boolean;
  131836. closePath?: boolean;
  131837. offset?: number;
  131838. updatable?: boolean;
  131839. sideOrientation?: number;
  131840. frontUVs?: Vector4;
  131841. backUVs?: Vector4;
  131842. instance?: Mesh;
  131843. invertUV?: boolean;
  131844. uvs?: Vector2[];
  131845. colors?: Color4[];
  131846. }, scene?: Nullable<Scene>): Mesh;
  131847. }
  131848. }
  131849. declare module BABYLON {
  131850. /**
  131851. * Class containing static functions to help procedurally build meshes
  131852. */
  131853. export class ShapeBuilder {
  131854. /**
  131855. * 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.
  131856. * * 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.
  131857. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131858. * * 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.
  131859. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131860. * * 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
  131861. * * 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
  131862. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131867. * @param name defines the name of the mesh
  131868. * @param options defines the options used to create the mesh
  131869. * @param scene defines the hosting scene
  131870. * @returns the extruded shape mesh
  131871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131873. */
  131874. static ExtrudeShape(name: string, options: {
  131875. shape: Vector3[];
  131876. path: Vector3[];
  131877. scale?: number;
  131878. rotation?: number;
  131879. cap?: number;
  131880. updatable?: boolean;
  131881. sideOrientation?: number;
  131882. frontUVs?: Vector4;
  131883. backUVs?: Vector4;
  131884. instance?: Mesh;
  131885. invertUV?: boolean;
  131886. }, scene?: Nullable<Scene>): Mesh;
  131887. /**
  131888. * Creates an custom extruded shape mesh.
  131889. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131890. * * 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.
  131891. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131892. * * 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
  131893. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131894. * * 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
  131895. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131896. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131897. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131898. * * 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
  131899. * * 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
  131900. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131905. * @param name defines the name of the mesh
  131906. * @param options defines the options used to create the mesh
  131907. * @param scene defines the hosting scene
  131908. * @returns the custom extruded shape mesh
  131909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131910. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131912. */
  131913. static ExtrudeShapeCustom(name: string, options: {
  131914. shape: Vector3[];
  131915. path: Vector3[];
  131916. scaleFunction?: any;
  131917. rotationFunction?: any;
  131918. ribbonCloseArray?: boolean;
  131919. ribbonClosePath?: boolean;
  131920. cap?: number;
  131921. updatable?: boolean;
  131922. sideOrientation?: number;
  131923. frontUVs?: Vector4;
  131924. backUVs?: Vector4;
  131925. instance?: Mesh;
  131926. invertUV?: boolean;
  131927. }, scene?: Nullable<Scene>): Mesh;
  131928. private static _ExtrudeShapeGeneric;
  131929. }
  131930. }
  131931. declare module BABYLON.Debug {
  131932. /**
  131933. * Class used to render a debug view of a given skeleton
  131934. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131935. */
  131936. export class SkeletonViewer {
  131937. /** defines the skeleton to render */
  131938. skeleton: Skeleton;
  131939. /** defines the mesh attached to the skeleton */
  131940. mesh: AbstractMesh;
  131941. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131942. autoUpdateBonesMatrices: boolean;
  131943. /** defines the rendering group id to use with the viewer */
  131944. renderingGroupId: number;
  131945. /** is the options for the viewer */
  131946. options: Partial<ISkeletonViewerOptions>;
  131947. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131948. static readonly DISPLAY_LINES: number;
  131949. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131950. static readonly DISPLAY_SPHERES: number;
  131951. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131952. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131953. /** public static method to create a BoneWeight Shader
  131954. * @param options The constructor options
  131955. * @param scene The scene that the shader is scoped to
  131956. * @returns The created ShaderMaterial
  131957. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131958. */
  131959. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131960. /** public static method to create a BoneWeight Shader
  131961. * @param options The constructor options
  131962. * @param scene The scene that the shader is scoped to
  131963. * @returns The created ShaderMaterial
  131964. */
  131965. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131966. /** private static method to create a BoneWeight Shader
  131967. * @param size The size of the buffer to create (usually the bone count)
  131968. * @param colorMap The gradient data to generate
  131969. * @param scene The scene that the shader is scoped to
  131970. * @returns an Array of floats from the color gradient values
  131971. */
  131972. private static _CreateBoneMapColorBuffer;
  131973. /** If SkeletonViewer scene scope. */
  131974. private _scene;
  131975. /** Gets or sets the color used to render the skeleton */
  131976. color: Color3;
  131977. /** Array of the points of the skeleton fo the line view. */
  131978. private _debugLines;
  131979. /** The SkeletonViewers Mesh. */
  131980. private _debugMesh;
  131981. /** The local axes Meshes. */
  131982. private _localAxes;
  131983. /** If SkeletonViewer is enabled. */
  131984. private _isEnabled;
  131985. /** If SkeletonViewer is ready. */
  131986. private _ready;
  131987. /** SkeletonViewer render observable. */
  131988. private _obs;
  131989. /** The Utility Layer to render the gizmos in. */
  131990. private _utilityLayer;
  131991. private _boneIndices;
  131992. /** Gets the Scene. */
  131993. get scene(): Scene;
  131994. /** Gets the utilityLayer. */
  131995. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131996. /** Checks Ready Status. */
  131997. get isReady(): Boolean;
  131998. /** Sets Ready Status. */
  131999. set ready(value: boolean);
  132000. /** Gets the debugMesh */
  132001. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  132002. /** Sets the debugMesh */
  132003. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  132004. /** Gets the displayMode */
  132005. get displayMode(): number;
  132006. /** Sets the displayMode */
  132007. set displayMode(value: number);
  132008. /**
  132009. * Creates a new SkeletonViewer
  132010. * @param skeleton defines the skeleton to render
  132011. * @param mesh defines the mesh attached to the skeleton
  132012. * @param scene defines the hosting scene
  132013. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  132014. * @param renderingGroupId defines the rendering group id to use with the viewer
  132015. * @param options All of the extra constructor options for the SkeletonViewer
  132016. */
  132017. constructor(
  132018. /** defines the skeleton to render */
  132019. skeleton: Skeleton,
  132020. /** defines the mesh attached to the skeleton */
  132021. mesh: AbstractMesh,
  132022. /** The Scene scope*/
  132023. scene: Scene,
  132024. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  132025. autoUpdateBonesMatrices?: boolean,
  132026. /** defines the rendering group id to use with the viewer */
  132027. renderingGroupId?: number,
  132028. /** is the options for the viewer */
  132029. options?: Partial<ISkeletonViewerOptions>);
  132030. /** The Dynamic bindings for the update functions */
  132031. private _bindObs;
  132032. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  132033. update(): void;
  132034. /** Gets or sets a boolean indicating if the viewer is enabled */
  132035. set isEnabled(value: boolean);
  132036. get isEnabled(): boolean;
  132037. private _getBonePosition;
  132038. private _getLinesForBonesWithLength;
  132039. private _getLinesForBonesNoLength;
  132040. /** function to revert the mesh and scene back to the initial state. */
  132041. private _revert;
  132042. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  132043. private _getAbsoluteBindPoseToRef;
  132044. /** function to build and bind sphere joint points and spur bone representations. */
  132045. private _buildSpheresAndSpurs;
  132046. private _buildLocalAxes;
  132047. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  132048. private _displayLinesUpdate;
  132049. /** Changes the displayMode of the skeleton viewer
  132050. * @param mode The displayMode numerical value
  132051. */
  132052. changeDisplayMode(mode: number): void;
  132053. /** Sets a display option of the skeleton viewer
  132054. *
  132055. * | Option | Type | Default | Description |
  132056. * | ---------------- | ------- | ------- | ----------- |
  132057. * | 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`. |
  132058. * | 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`. |
  132059. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132060. * | 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`. |
  132061. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  132062. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  132063. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  132064. *
  132065. * @param option String of the option name
  132066. * @param value The numerical option value
  132067. */
  132068. changeDisplayOptions(option: string, value: number): void;
  132069. /** Release associated resources */
  132070. dispose(): void;
  132071. }
  132072. }
  132073. declare module BABYLON {
  132074. /**
  132075. * Enum for Device Types
  132076. */
  132077. export enum DeviceType {
  132078. /** Generic */
  132079. Generic = 0,
  132080. /** Keyboard */
  132081. Keyboard = 1,
  132082. /** Mouse */
  132083. Mouse = 2,
  132084. /** Touch Pointers */
  132085. Touch = 3,
  132086. /** PS4 Dual Shock */
  132087. DualShock = 4,
  132088. /** Xbox */
  132089. Xbox = 5,
  132090. /** Switch Controller */
  132091. Switch = 6
  132092. }
  132093. /**
  132094. * Enum for All Pointers (Touch/Mouse)
  132095. */
  132096. export enum PointerInput {
  132097. /** Horizontal Axis */
  132098. Horizontal = 0,
  132099. /** Vertical Axis */
  132100. Vertical = 1,
  132101. /** Left Click or Touch */
  132102. LeftClick = 2,
  132103. /** Middle Click */
  132104. MiddleClick = 3,
  132105. /** Right Click */
  132106. RightClick = 4,
  132107. /** Browser Back */
  132108. BrowserBack = 5,
  132109. /** Browser Forward */
  132110. BrowserForward = 6
  132111. }
  132112. /**
  132113. * Enum for Dual Shock Gamepad
  132114. */
  132115. export enum DualShockInput {
  132116. /** Cross */
  132117. Cross = 0,
  132118. /** Circle */
  132119. Circle = 1,
  132120. /** Square */
  132121. Square = 2,
  132122. /** Triangle */
  132123. Triangle = 3,
  132124. /** L1 */
  132125. L1 = 4,
  132126. /** R1 */
  132127. R1 = 5,
  132128. /** L2 */
  132129. L2 = 6,
  132130. /** R2 */
  132131. R2 = 7,
  132132. /** Share */
  132133. Share = 8,
  132134. /** Options */
  132135. Options = 9,
  132136. /** L3 */
  132137. L3 = 10,
  132138. /** R3 */
  132139. R3 = 11,
  132140. /** DPadUp */
  132141. DPadUp = 12,
  132142. /** DPadDown */
  132143. DPadDown = 13,
  132144. /** DPadLeft */
  132145. DPadLeft = 14,
  132146. /** DRight */
  132147. DPadRight = 15,
  132148. /** Home */
  132149. Home = 16,
  132150. /** TouchPad */
  132151. TouchPad = 17,
  132152. /** LStickXAxis */
  132153. LStickXAxis = 18,
  132154. /** LStickYAxis */
  132155. LStickYAxis = 19,
  132156. /** RStickXAxis */
  132157. RStickXAxis = 20,
  132158. /** RStickYAxis */
  132159. RStickYAxis = 21
  132160. }
  132161. /**
  132162. * Enum for Xbox Gamepad
  132163. */
  132164. export enum XboxInput {
  132165. /** A */
  132166. A = 0,
  132167. /** B */
  132168. B = 1,
  132169. /** X */
  132170. X = 2,
  132171. /** Y */
  132172. Y = 3,
  132173. /** LB */
  132174. LB = 4,
  132175. /** RB */
  132176. RB = 5,
  132177. /** LT */
  132178. LT = 6,
  132179. /** RT */
  132180. RT = 7,
  132181. /** Back */
  132182. Back = 8,
  132183. /** Start */
  132184. Start = 9,
  132185. /** LS */
  132186. LS = 10,
  132187. /** RS */
  132188. RS = 11,
  132189. /** DPadUp */
  132190. DPadUp = 12,
  132191. /** DPadDown */
  132192. DPadDown = 13,
  132193. /** DPadLeft */
  132194. DPadLeft = 14,
  132195. /** DRight */
  132196. DPadRight = 15,
  132197. /** Home */
  132198. Home = 16,
  132199. /** LStickXAxis */
  132200. LStickXAxis = 17,
  132201. /** LStickYAxis */
  132202. LStickYAxis = 18,
  132203. /** RStickXAxis */
  132204. RStickXAxis = 19,
  132205. /** RStickYAxis */
  132206. RStickYAxis = 20
  132207. }
  132208. /**
  132209. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  132210. */
  132211. export enum SwitchInput {
  132212. /** B */
  132213. B = 0,
  132214. /** A */
  132215. A = 1,
  132216. /** Y */
  132217. Y = 2,
  132218. /** X */
  132219. X = 3,
  132220. /** L */
  132221. L = 4,
  132222. /** R */
  132223. R = 5,
  132224. /** ZL */
  132225. ZL = 6,
  132226. /** ZR */
  132227. ZR = 7,
  132228. /** Minus */
  132229. Minus = 8,
  132230. /** Plus */
  132231. Plus = 9,
  132232. /** LS */
  132233. LS = 10,
  132234. /** RS */
  132235. RS = 11,
  132236. /** DPadUp */
  132237. DPadUp = 12,
  132238. /** DPadDown */
  132239. DPadDown = 13,
  132240. /** DPadLeft */
  132241. DPadLeft = 14,
  132242. /** DRight */
  132243. DPadRight = 15,
  132244. /** Home */
  132245. Home = 16,
  132246. /** Capture */
  132247. Capture = 17,
  132248. /** LStickXAxis */
  132249. LStickXAxis = 18,
  132250. /** LStickYAxis */
  132251. LStickYAxis = 19,
  132252. /** RStickXAxis */
  132253. RStickXAxis = 20,
  132254. /** RStickYAxis */
  132255. RStickYAxis = 21
  132256. }
  132257. }
  132258. declare module BABYLON {
  132259. /**
  132260. * This class will take all inputs from Keyboard, Pointer, and
  132261. * any Gamepads and provide a polling system that all devices
  132262. * will use. This class assumes that there will only be one
  132263. * pointer device and one keyboard.
  132264. */
  132265. export class DeviceInputSystem implements IDisposable {
  132266. /**
  132267. * Callback to be triggered when a device is connected
  132268. */
  132269. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132270. /**
  132271. * Callback to be triggered when a device is disconnected
  132272. */
  132273. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132274. /**
  132275. * Callback to be triggered when event driven input is updated
  132276. */
  132277. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  132278. private _inputs;
  132279. private _gamepads;
  132280. private _keyboardActive;
  132281. private _pointerActive;
  132282. private _elementToAttachTo;
  132283. private _keyboardDownEvent;
  132284. private _keyboardUpEvent;
  132285. private _pointerMoveEvent;
  132286. private _pointerDownEvent;
  132287. private _pointerUpEvent;
  132288. private _gamepadConnectedEvent;
  132289. private _gamepadDisconnectedEvent;
  132290. private static _MAX_KEYCODES;
  132291. private static _MAX_POINTER_INPUTS;
  132292. private constructor();
  132293. /**
  132294. * Creates a new DeviceInputSystem instance
  132295. * @param engine Engine to pull input element from
  132296. * @returns The new instance
  132297. */
  132298. static Create(engine: Engine): DeviceInputSystem;
  132299. /**
  132300. * Checks for current device input value, given an id and input index
  132301. * @param deviceName Id of connected device
  132302. * @param inputIndex Index of device input
  132303. * @returns Current value of input
  132304. */
  132305. /**
  132306. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  132307. * @param deviceType Enum specifiying device type
  132308. * @param deviceSlot "Slot" or index that device is referenced in
  132309. * @param inputIndex Id of input to be checked
  132310. * @returns Current value of input
  132311. */
  132312. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  132313. /**
  132314. * Dispose of all the eventlisteners
  132315. */
  132316. dispose(): void;
  132317. /**
  132318. * Add device and inputs to device array
  132319. * @param deviceType Enum specifiying device type
  132320. * @param deviceSlot "Slot" or index that device is referenced in
  132321. * @param numberOfInputs Number of input entries to create for given device
  132322. */
  132323. private _registerDevice;
  132324. /**
  132325. * Given a specific device name, remove that device from the device map
  132326. * @param deviceType Enum specifiying device type
  132327. * @param deviceSlot "Slot" or index that device is referenced in
  132328. */
  132329. private _unregisterDevice;
  132330. /**
  132331. * Handle all actions that come from keyboard interaction
  132332. */
  132333. private _handleKeyActions;
  132334. /**
  132335. * Handle all actions that come from pointer interaction
  132336. */
  132337. private _handlePointerActions;
  132338. /**
  132339. * Handle all actions that come from gamepad interaction
  132340. */
  132341. private _handleGamepadActions;
  132342. /**
  132343. * Update all non-event based devices with each frame
  132344. * @param deviceType Enum specifiying device type
  132345. * @param deviceSlot "Slot" or index that device is referenced in
  132346. * @param inputIndex Id of input to be checked
  132347. */
  132348. private _updateDevice;
  132349. /**
  132350. * Gets DeviceType from the device name
  132351. * @param deviceName Name of Device from DeviceInputSystem
  132352. * @returns DeviceType enum value
  132353. */
  132354. private _getGamepadDeviceType;
  132355. }
  132356. }
  132357. declare module BABYLON {
  132358. /**
  132359. * Type to handle enforcement of inputs
  132360. */
  132361. 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;
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * Class that handles all input for a specific device
  132366. */
  132367. export class DeviceSource<T extends DeviceType> {
  132368. /** Type of device */
  132369. readonly deviceType: DeviceType;
  132370. /** "Slot" or index that device is referenced in */
  132371. readonly deviceSlot: number;
  132372. /**
  132373. * Observable to handle device input changes per device
  132374. */
  132375. readonly onInputChangedObservable: Observable<{
  132376. inputIndex: DeviceInput<T>;
  132377. previousState: Nullable<number>;
  132378. currentState: Nullable<number>;
  132379. }>;
  132380. private readonly _deviceInputSystem;
  132381. /**
  132382. * Default Constructor
  132383. * @param deviceInputSystem Reference to DeviceInputSystem
  132384. * @param deviceType Type of device
  132385. * @param deviceSlot "Slot" or index that device is referenced in
  132386. */
  132387. constructor(deviceInputSystem: DeviceInputSystem,
  132388. /** Type of device */
  132389. deviceType: DeviceType,
  132390. /** "Slot" or index that device is referenced in */
  132391. deviceSlot?: number);
  132392. /**
  132393. * Get input for specific input
  132394. * @param inputIndex index of specific input on device
  132395. * @returns Input value from DeviceInputSystem
  132396. */
  132397. getInput(inputIndex: DeviceInput<T>): number;
  132398. }
  132399. /**
  132400. * Class to keep track of devices
  132401. */
  132402. export class DeviceSourceManager implements IDisposable {
  132403. /**
  132404. * Observable to be triggered when before a device is connected
  132405. */
  132406. readonly onBeforeDeviceConnectedObservable: Observable<{
  132407. deviceType: DeviceType;
  132408. deviceSlot: number;
  132409. }>;
  132410. /**
  132411. * Observable to be triggered when before a device is disconnected
  132412. */
  132413. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132414. deviceType: DeviceType;
  132415. deviceSlot: number;
  132416. }>;
  132417. /**
  132418. * Observable to be triggered when after a device is connected
  132419. */
  132420. readonly onAfterDeviceConnectedObservable: Observable<{
  132421. deviceType: DeviceType;
  132422. deviceSlot: number;
  132423. }>;
  132424. /**
  132425. * Observable to be triggered when after a device is disconnected
  132426. */
  132427. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132428. deviceType: DeviceType;
  132429. deviceSlot: number;
  132430. }>;
  132431. private readonly _devices;
  132432. private readonly _firstDevice;
  132433. private readonly _deviceInputSystem;
  132434. /**
  132435. * Default Constructor
  132436. * @param engine engine to pull input element from
  132437. */
  132438. constructor(engine: Engine);
  132439. /**
  132440. * Gets a DeviceSource, given a type and slot
  132441. * @param deviceType Enum specifying device type
  132442. * @param deviceSlot "Slot" or index that device is referenced in
  132443. * @returns DeviceSource object
  132444. */
  132445. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132446. /**
  132447. * Gets an array of DeviceSource objects for a given device type
  132448. * @param deviceType Enum specifying device type
  132449. * @returns Array of DeviceSource objects
  132450. */
  132451. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132452. /**
  132453. * Dispose of DeviceInputSystem and other parts
  132454. */
  132455. dispose(): void;
  132456. /**
  132457. * Function to add device name to device list
  132458. * @param deviceType Enum specifying device type
  132459. * @param deviceSlot "Slot" or index that device is referenced in
  132460. */
  132461. private _addDevice;
  132462. /**
  132463. * Function to remove device name to device list
  132464. * @param deviceType Enum specifying device type
  132465. * @param deviceSlot "Slot" or index that device is referenced in
  132466. */
  132467. private _removeDevice;
  132468. /**
  132469. * Updates array storing first connected device of each type
  132470. * @param type Type of Device
  132471. */
  132472. private _updateFirstDevices;
  132473. }
  132474. }
  132475. declare module BABYLON {
  132476. /**
  132477. * Options to create the null engine
  132478. */
  132479. export class NullEngineOptions {
  132480. /**
  132481. * Render width (Default: 512)
  132482. */
  132483. renderWidth: number;
  132484. /**
  132485. * Render height (Default: 256)
  132486. */
  132487. renderHeight: number;
  132488. /**
  132489. * Texture size (Default: 512)
  132490. */
  132491. textureSize: number;
  132492. /**
  132493. * If delta time between frames should be constant
  132494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132495. */
  132496. deterministicLockstep: boolean;
  132497. /**
  132498. * Maximum about of steps between frames (Default: 4)
  132499. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132500. */
  132501. lockstepMaxSteps: number;
  132502. /**
  132503. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132504. */
  132505. useHighPrecisionMatrix?: boolean;
  132506. }
  132507. /**
  132508. * The null engine class provides support for headless version of babylon.js.
  132509. * This can be used in server side scenario or for testing purposes
  132510. */
  132511. export class NullEngine extends Engine {
  132512. private _options;
  132513. /**
  132514. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132515. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132516. * @returns true if engine is in deterministic lock step mode
  132517. */
  132518. isDeterministicLockStep(): boolean;
  132519. /**
  132520. * Gets the max steps when engine is running in deterministic lock step
  132521. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132522. * @returns the max steps
  132523. */
  132524. getLockstepMaxSteps(): number;
  132525. /**
  132526. * Gets the current hardware scaling level.
  132527. * By default the hardware scaling level is computed from the window device ratio.
  132528. * 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.
  132529. * @returns a number indicating the current hardware scaling level
  132530. */
  132531. getHardwareScalingLevel(): number;
  132532. constructor(options?: NullEngineOptions);
  132533. /**
  132534. * Creates a vertex buffer
  132535. * @param vertices the data for the vertex buffer
  132536. * @returns the new WebGL static buffer
  132537. */
  132538. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132539. /**
  132540. * Creates a new index buffer
  132541. * @param indices defines the content of the index buffer
  132542. * @param updatable defines if the index buffer must be updatable
  132543. * @returns a new webGL buffer
  132544. */
  132545. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132546. /**
  132547. * Clear the current render buffer or the current render target (if any is set up)
  132548. * @param color defines the color to use
  132549. * @param backBuffer defines if the back buffer must be cleared
  132550. * @param depth defines if the depth buffer must be cleared
  132551. * @param stencil defines if the stencil buffer must be cleared
  132552. */
  132553. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132554. /**
  132555. * Gets the current render width
  132556. * @param useScreen defines if screen size must be used (or the current render target if any)
  132557. * @returns a number defining the current render width
  132558. */
  132559. getRenderWidth(useScreen?: boolean): number;
  132560. /**
  132561. * Gets the current render height
  132562. * @param useScreen defines if screen size must be used (or the current render target if any)
  132563. * @returns a number defining the current render height
  132564. */
  132565. getRenderHeight(useScreen?: boolean): number;
  132566. /**
  132567. * Set the WebGL's viewport
  132568. * @param viewport defines the viewport element to be used
  132569. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132570. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132571. */
  132572. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132573. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132574. /**
  132575. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132576. * @param pipelineContext defines the pipeline context to use
  132577. * @param uniformsNames defines the list of uniform names
  132578. * @returns an array of webGL uniform locations
  132579. */
  132580. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132581. /**
  132582. * Gets the lsit of active attributes for a given webGL program
  132583. * @param pipelineContext defines the pipeline context to use
  132584. * @param attributesNames defines the list of attribute names to get
  132585. * @returns an array of indices indicating the offset of each attribute
  132586. */
  132587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132588. /**
  132589. * Binds an effect to the webGL context
  132590. * @param effect defines the effect to bind
  132591. */
  132592. bindSamplers(effect: Effect): void;
  132593. /**
  132594. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132595. * @param effect defines the effect to activate
  132596. */
  132597. enableEffect(effect: Effect): void;
  132598. /**
  132599. * Set various states to the webGL context
  132600. * @param culling defines backface culling state
  132601. * @param zOffset defines the value to apply to zOffset (0 by default)
  132602. * @param force defines if states must be applied even if cache is up to date
  132603. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132604. */
  132605. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132606. /**
  132607. * Set the value of an uniform to an array of int32
  132608. * @param uniform defines the webGL uniform location where to store the value
  132609. * @param array defines the array of int32 to store
  132610. * @returns true if value was set
  132611. */
  132612. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132613. /**
  132614. * Set the value of an uniform to an array of int32 (stored as vec2)
  132615. * @param uniform defines the webGL uniform location where to store the value
  132616. * @param array defines the array of int32 to store
  132617. * @returns true if value was set
  132618. */
  132619. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132620. /**
  132621. * Set the value of an uniform to an array of int32 (stored as vec3)
  132622. * @param uniform defines the webGL uniform location where to store the value
  132623. * @param array defines the array of int32 to store
  132624. * @returns true if value was set
  132625. */
  132626. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132627. /**
  132628. * Set the value of an uniform to an array of int32 (stored as vec4)
  132629. * @param uniform defines the webGL uniform location where to store the value
  132630. * @param array defines the array of int32 to store
  132631. * @returns true if value was set
  132632. */
  132633. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132634. /**
  132635. * Set the value of an uniform to an array of float32
  132636. * @param uniform defines the webGL uniform location where to store the value
  132637. * @param array defines the array of float32 to store
  132638. * @returns true if value was set
  132639. */
  132640. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132641. /**
  132642. * Set the value of an uniform to an array of float32 (stored as vec2)
  132643. * @param uniform defines the webGL uniform location where to store the value
  132644. * @param array defines the array of float32 to store
  132645. * @returns true if value was set
  132646. */
  132647. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132648. /**
  132649. * Set the value of an uniform to an array of float32 (stored as vec3)
  132650. * @param uniform defines the webGL uniform location where to store the value
  132651. * @param array defines the array of float32 to store
  132652. * @returns true if value was set
  132653. */
  132654. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132655. /**
  132656. * Set the value of an uniform to an array of float32 (stored as vec4)
  132657. * @param uniform defines the webGL uniform location where to store the value
  132658. * @param array defines the array of float32 to store
  132659. * @returns true if value was set
  132660. */
  132661. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132662. /**
  132663. * Set the value of an uniform to an array of number
  132664. * @param uniform defines the webGL uniform location where to store the value
  132665. * @param array defines the array of number to store
  132666. * @returns true if value was set
  132667. */
  132668. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132669. /**
  132670. * Set the value of an uniform to an array of number (stored as vec2)
  132671. * @param uniform defines the webGL uniform location where to store the value
  132672. * @param array defines the array of number to store
  132673. * @returns true if value was set
  132674. */
  132675. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132676. /**
  132677. * Set the value of an uniform to an array of number (stored as vec3)
  132678. * @param uniform defines the webGL uniform location where to store the value
  132679. * @param array defines the array of number to store
  132680. * @returns true if value was set
  132681. */
  132682. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132683. /**
  132684. * Set the value of an uniform to an array of number (stored as vec4)
  132685. * @param uniform defines the webGL uniform location where to store the value
  132686. * @param array defines the array of number to store
  132687. * @returns true if value was set
  132688. */
  132689. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132690. /**
  132691. * Set the value of an uniform to an array of float32 (stored as matrices)
  132692. * @param uniform defines the webGL uniform location where to store the value
  132693. * @param matrices defines the array of float32 to store
  132694. * @returns true if value was set
  132695. */
  132696. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132697. /**
  132698. * Set the value of an uniform to a matrix (3x3)
  132699. * @param uniform defines the webGL uniform location where to store the value
  132700. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132701. * @returns true if value was set
  132702. */
  132703. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132704. /**
  132705. * Set the value of an uniform to a matrix (2x2)
  132706. * @param uniform defines the webGL uniform location where to store the value
  132707. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132708. * @returns true if value was set
  132709. */
  132710. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132711. /**
  132712. * Set the value of an uniform to a number (float)
  132713. * @param uniform defines the webGL uniform location where to store the value
  132714. * @param value defines the float number to store
  132715. * @returns true if value was set
  132716. */
  132717. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132718. /**
  132719. * Set the value of an uniform to a vec2
  132720. * @param uniform defines the webGL uniform location where to store the value
  132721. * @param x defines the 1st component of the value
  132722. * @param y defines the 2nd component of the value
  132723. * @returns true if value was set
  132724. */
  132725. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132726. /**
  132727. * Set the value of an uniform to a vec3
  132728. * @param uniform defines the webGL uniform location where to store the value
  132729. * @param x defines the 1st component of the value
  132730. * @param y defines the 2nd component of the value
  132731. * @param z defines the 3rd component of the value
  132732. * @returns true if value was set
  132733. */
  132734. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132735. /**
  132736. * Set the value of an uniform to a boolean
  132737. * @param uniform defines the webGL uniform location where to store the value
  132738. * @param bool defines the boolean to store
  132739. * @returns true if value was set
  132740. */
  132741. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132742. /**
  132743. * Set the value of an uniform to a vec4
  132744. * @param uniform defines the webGL uniform location where to store the value
  132745. * @param x defines the 1st component of the value
  132746. * @param y defines the 2nd component of the value
  132747. * @param z defines the 3rd component of the value
  132748. * @param w defines the 4th component of the value
  132749. * @returns true if value was set
  132750. */
  132751. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132752. /**
  132753. * Sets the current alpha mode
  132754. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132755. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132756. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132757. */
  132758. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132759. /**
  132760. * Bind webGl buffers directly to the webGL context
  132761. * @param vertexBuffers defines the vertex buffer to bind
  132762. * @param indexBuffer defines the index buffer to bind
  132763. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132764. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132765. * @param effect defines the effect associated with the vertex buffer
  132766. */
  132767. bindBuffers(vertexBuffers: {
  132768. [key: string]: VertexBuffer;
  132769. }, indexBuffer: DataBuffer, effect: Effect): void;
  132770. /**
  132771. * Force the entire cache to be cleared
  132772. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132773. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132774. */
  132775. wipeCaches(bruteForce?: boolean): void;
  132776. /**
  132777. * Send a draw order
  132778. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132779. * @param indexStart defines the starting index
  132780. * @param indexCount defines the number of index to draw
  132781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132782. */
  132783. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132784. /**
  132785. * Draw a list of indexed primitives
  132786. * @param fillMode defines the primitive to use
  132787. * @param indexStart defines the starting index
  132788. * @param indexCount defines the number of index to draw
  132789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132790. */
  132791. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132792. /**
  132793. * Draw a list of unindexed primitives
  132794. * @param fillMode defines the primitive to use
  132795. * @param verticesStart defines the index of first vertex to draw
  132796. * @param verticesCount defines the count of vertices to draw
  132797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132798. */
  132799. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132800. /** @hidden */
  132801. _createTexture(): WebGLTexture;
  132802. /** @hidden */
  132803. _releaseTexture(texture: InternalTexture): void;
  132804. /**
  132805. * Usually called from Texture.ts.
  132806. * Passed information to create a WebGLTexture
  132807. * @param urlArg defines a value which contains one of the following:
  132808. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132809. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132810. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132812. * @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)
  132813. * @param scene needed for loading to the correct scene
  132814. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132815. * @param onLoad optional callback to be called upon successful completion
  132816. * @param onError optional callback to be called upon failure
  132817. * @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
  132818. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132819. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132820. * @param forcedExtension defines the extension to use to pick the right loader
  132821. * @param mimeType defines an optional mime type
  132822. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132823. */
  132824. 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;
  132825. /**
  132826. * Creates a new render target texture
  132827. * @param size defines the size of the texture
  132828. * @param options defines the options used to create the texture
  132829. * @returns a new render target texture stored in an InternalTexture
  132830. */
  132831. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132832. /**
  132833. * Update the sampling mode of a given texture
  132834. * @param samplingMode defines the required sampling mode
  132835. * @param texture defines the texture to update
  132836. */
  132837. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132838. /**
  132839. * Binds the frame buffer to the specified texture.
  132840. * @param texture The texture to render to or null for the default canvas
  132841. * @param faceIndex The face of the texture to render to in case of cube texture
  132842. * @param requiredWidth The width of the target to render to
  132843. * @param requiredHeight The height of the target to render to
  132844. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132845. * @param lodLevel defines le lod level to bind to the frame buffer
  132846. */
  132847. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132848. /**
  132849. * Unbind the current render target texture from the webGL context
  132850. * @param texture defines the render target texture to unbind
  132851. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132852. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132853. */
  132854. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132855. /**
  132856. * Creates a dynamic vertex buffer
  132857. * @param vertices the data for the dynamic vertex buffer
  132858. * @returns the new WebGL dynamic buffer
  132859. */
  132860. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132861. /**
  132862. * Update the content of a dynamic texture
  132863. * @param texture defines the texture to update
  132864. * @param canvas defines the canvas containing the source
  132865. * @param invertY defines if data must be stored with Y axis inverted
  132866. * @param premulAlpha defines if alpha is stored as premultiplied
  132867. * @param format defines the format of the data
  132868. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132869. */
  132870. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132871. /**
  132872. * Gets a boolean indicating if all created effects are ready
  132873. * @returns true if all effects are ready
  132874. */
  132875. areAllEffectsReady(): boolean;
  132876. /**
  132877. * @hidden
  132878. * Get the current error code of the webGL context
  132879. * @returns the error code
  132880. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132881. */
  132882. getError(): number;
  132883. /** @hidden */
  132884. _getUnpackAlignement(): number;
  132885. /** @hidden */
  132886. _unpackFlipY(value: boolean): void;
  132887. /**
  132888. * Update a dynamic index buffer
  132889. * @param indexBuffer defines the target index buffer
  132890. * @param indices defines the data to update
  132891. * @param offset defines the offset in the target index buffer where update should start
  132892. */
  132893. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132894. /**
  132895. * Updates a dynamic vertex buffer.
  132896. * @param vertexBuffer the vertex buffer to update
  132897. * @param vertices the data used to update the vertex buffer
  132898. * @param byteOffset the byte offset of the data (optional)
  132899. * @param byteLength the byte length of the data (optional)
  132900. */
  132901. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132902. /** @hidden */
  132903. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132904. /** @hidden */
  132905. _bindTexture(channel: number, texture: InternalTexture): void;
  132906. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132907. /**
  132908. * 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
  132909. */
  132910. releaseEffects(): void;
  132911. displayLoadingUI(): void;
  132912. hideLoadingUI(): void;
  132913. /** @hidden */
  132914. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132915. /** @hidden */
  132916. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132917. /** @hidden */
  132918. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132919. /** @hidden */
  132920. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132921. }
  132922. }
  132923. declare module BABYLON {
  132924. /**
  132925. * @hidden
  132926. **/
  132927. export class _TimeToken {
  132928. _startTimeQuery: Nullable<WebGLQuery>;
  132929. _endTimeQuery: Nullable<WebGLQuery>;
  132930. _timeElapsedQuery: Nullable<WebGLQuery>;
  132931. _timeElapsedQueryEnded: boolean;
  132932. }
  132933. }
  132934. declare module BABYLON {
  132935. /** @hidden */
  132936. export class _OcclusionDataStorage {
  132937. /** @hidden */
  132938. occlusionInternalRetryCounter: number;
  132939. /** @hidden */
  132940. isOcclusionQueryInProgress: boolean;
  132941. /** @hidden */
  132942. isOccluded: boolean;
  132943. /** @hidden */
  132944. occlusionRetryCount: number;
  132945. /** @hidden */
  132946. occlusionType: number;
  132947. /** @hidden */
  132948. occlusionQueryAlgorithmType: number;
  132949. }
  132950. interface Engine {
  132951. /**
  132952. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132953. * @return the new query
  132954. */
  132955. createQuery(): WebGLQuery;
  132956. /**
  132957. * Delete and release a webGL query
  132958. * @param query defines the query to delete
  132959. * @return the current engine
  132960. */
  132961. deleteQuery(query: WebGLQuery): Engine;
  132962. /**
  132963. * Check if a given query has resolved and got its value
  132964. * @param query defines the query to check
  132965. * @returns true if the query got its value
  132966. */
  132967. isQueryResultAvailable(query: WebGLQuery): boolean;
  132968. /**
  132969. * Gets the value of a given query
  132970. * @param query defines the query to check
  132971. * @returns the value of the query
  132972. */
  132973. getQueryResult(query: WebGLQuery): number;
  132974. /**
  132975. * Initiates an occlusion query
  132976. * @param algorithmType defines the algorithm to use
  132977. * @param query defines the query to use
  132978. * @returns the current engine
  132979. * @see https://doc.babylonjs.com/features/occlusionquery
  132980. */
  132981. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132982. /**
  132983. * Ends an occlusion query
  132984. * @see https://doc.babylonjs.com/features/occlusionquery
  132985. * @param algorithmType defines the algorithm to use
  132986. * @returns the current engine
  132987. */
  132988. endOcclusionQuery(algorithmType: number): Engine;
  132989. /**
  132990. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132991. * Please note that only one query can be issued at a time
  132992. * @returns a time token used to track the time span
  132993. */
  132994. startTimeQuery(): Nullable<_TimeToken>;
  132995. /**
  132996. * Ends a time query
  132997. * @param token defines the token used to measure the time span
  132998. * @returns the time spent (in ns)
  132999. */
  133000. endTimeQuery(token: _TimeToken): int;
  133001. /** @hidden */
  133002. _currentNonTimestampToken: Nullable<_TimeToken>;
  133003. /** @hidden */
  133004. _createTimeQuery(): WebGLQuery;
  133005. /** @hidden */
  133006. _deleteTimeQuery(query: WebGLQuery): void;
  133007. /** @hidden */
  133008. _getGlAlgorithmType(algorithmType: number): number;
  133009. /** @hidden */
  133010. _getTimeQueryResult(query: WebGLQuery): any;
  133011. /** @hidden */
  133012. _getTimeQueryAvailability(query: WebGLQuery): any;
  133013. }
  133014. interface AbstractMesh {
  133015. /**
  133016. * Backing filed
  133017. * @hidden
  133018. */
  133019. __occlusionDataStorage: _OcclusionDataStorage;
  133020. /**
  133021. * Access property
  133022. * @hidden
  133023. */
  133024. _occlusionDataStorage: _OcclusionDataStorage;
  133025. /**
  133026. * 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.
  133027. * The default value is -1 which means don't break the query and wait till the result
  133028. * @see https://doc.babylonjs.com/features/occlusionquery
  133029. */
  133030. occlusionRetryCount: number;
  133031. /**
  133032. * 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:
  133033. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  133034. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  133035. * * 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.
  133036. * @see https://doc.babylonjs.com/features/occlusionquery
  133037. */
  133038. occlusionType: number;
  133039. /**
  133040. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  133041. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  133042. * * 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.
  133043. * @see https://doc.babylonjs.com/features/occlusionquery
  133044. */
  133045. occlusionQueryAlgorithmType: number;
  133046. /**
  133047. * 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
  133048. * @see https://doc.babylonjs.com/features/occlusionquery
  133049. */
  133050. isOccluded: boolean;
  133051. /**
  133052. * Flag to check the progress status of the query
  133053. * @see https://doc.babylonjs.com/features/occlusionquery
  133054. */
  133055. isOcclusionQueryInProgress: boolean;
  133056. }
  133057. }
  133058. declare module BABYLON {
  133059. /** @hidden */
  133060. export var _forceTransformFeedbackToBundle: boolean;
  133061. interface Engine {
  133062. /**
  133063. * Creates a webGL transform feedback object
  133064. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  133065. * @returns the webGL transform feedback object
  133066. */
  133067. createTransformFeedback(): WebGLTransformFeedback;
  133068. /**
  133069. * Delete a webGL transform feedback object
  133070. * @param value defines the webGL transform feedback object to delete
  133071. */
  133072. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  133073. /**
  133074. * Bind a webGL transform feedback object to the webgl context
  133075. * @param value defines the webGL transform feedback object to bind
  133076. */
  133077. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  133078. /**
  133079. * Begins a transform feedback operation
  133080. * @param usePoints defines if points or triangles must be used
  133081. */
  133082. beginTransformFeedback(usePoints: boolean): void;
  133083. /**
  133084. * Ends a transform feedback operation
  133085. */
  133086. endTransformFeedback(): void;
  133087. /**
  133088. * Specify the varyings to use with transform feedback
  133089. * @param program defines the associated webGL program
  133090. * @param value defines the list of strings representing the varying names
  133091. */
  133092. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  133093. /**
  133094. * Bind a webGL buffer for a transform feedback operation
  133095. * @param value defines the webGL buffer to bind
  133096. */
  133097. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  133098. }
  133099. }
  133100. declare module BABYLON {
  133101. /**
  133102. * Class used to define an additional view for the engine
  133103. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133104. */
  133105. export class EngineView {
  133106. /** Defines the canvas where to render the view */
  133107. target: HTMLCanvasElement;
  133108. /** Defines an optional camera used to render the view (will use active camera else) */
  133109. camera?: Camera;
  133110. }
  133111. interface Engine {
  133112. /**
  133113. * Gets or sets the HTML element to use for attaching events
  133114. */
  133115. inputElement: Nullable<HTMLElement>;
  133116. /**
  133117. * Gets the current engine view
  133118. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133119. */
  133120. activeView: Nullable<EngineView>;
  133121. /** Gets or sets the list of views */
  133122. views: EngineView[];
  133123. /**
  133124. * Register a new child canvas
  133125. * @param canvas defines the canvas to register
  133126. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  133127. * @returns the associated view
  133128. */
  133129. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  133130. /**
  133131. * Remove a registered child canvas
  133132. * @param canvas defines the canvas to remove
  133133. * @returns the current engine
  133134. */
  133135. unRegisterView(canvas: HTMLCanvasElement): Engine;
  133136. }
  133137. }
  133138. declare module BABYLON {
  133139. interface Engine {
  133140. /** @hidden */
  133141. _excludedCompressedTextures: string[];
  133142. /** @hidden */
  133143. _textureFormatInUse: string;
  133144. /**
  133145. * Gets the list of texture formats supported
  133146. */
  133147. readonly texturesSupported: Array<string>;
  133148. /**
  133149. * Gets the texture format in use
  133150. */
  133151. readonly textureFormatInUse: Nullable<string>;
  133152. /**
  133153. * Set the compressed texture extensions or file names to skip.
  133154. *
  133155. * @param skippedFiles defines the list of those texture files you want to skip
  133156. * Example: [".dds", ".env", "myfile.png"]
  133157. */
  133158. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  133159. /**
  133160. * Set the compressed texture format to use, based on the formats you have, and the formats
  133161. * supported by the hardware / browser.
  133162. *
  133163. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  133164. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  133165. * to API arguments needed to compressed textures. This puts the burden on the container
  133166. * generator to house the arcane code for determining these for current & future formats.
  133167. *
  133168. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133169. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133170. *
  133171. * Note: The result of this call is not taken into account when a texture is base64.
  133172. *
  133173. * @param formatsAvailable defines the list of those format families you have created
  133174. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  133175. *
  133176. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  133177. * @returns The extension selected.
  133178. */
  133179. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  133180. }
  133181. }
  133182. declare module BABYLON {
  133183. /**
  133184. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  133185. */
  133186. export interface CubeMapInfo {
  133187. /**
  133188. * The pixel array for the front face.
  133189. * This is stored in format, left to right, up to down format.
  133190. */
  133191. front: Nullable<ArrayBufferView>;
  133192. /**
  133193. * The pixel array for the back face.
  133194. * This is stored in format, left to right, up to down format.
  133195. */
  133196. back: Nullable<ArrayBufferView>;
  133197. /**
  133198. * The pixel array for the left face.
  133199. * This is stored in format, left to right, up to down format.
  133200. */
  133201. left: Nullable<ArrayBufferView>;
  133202. /**
  133203. * The pixel array for the right face.
  133204. * This is stored in format, left to right, up to down format.
  133205. */
  133206. right: Nullable<ArrayBufferView>;
  133207. /**
  133208. * The pixel array for the up face.
  133209. * This is stored in format, left to right, up to down format.
  133210. */
  133211. up: Nullable<ArrayBufferView>;
  133212. /**
  133213. * The pixel array for the down face.
  133214. * This is stored in format, left to right, up to down format.
  133215. */
  133216. down: Nullable<ArrayBufferView>;
  133217. /**
  133218. * The size of the cubemap stored.
  133219. *
  133220. * Each faces will be size * size pixels.
  133221. */
  133222. size: number;
  133223. /**
  133224. * The format of the texture.
  133225. *
  133226. * RGBA, RGB.
  133227. */
  133228. format: number;
  133229. /**
  133230. * The type of the texture data.
  133231. *
  133232. * UNSIGNED_INT, FLOAT.
  133233. */
  133234. type: number;
  133235. /**
  133236. * Specifies whether the texture is in gamma space.
  133237. */
  133238. gammaSpace: boolean;
  133239. }
  133240. /**
  133241. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  133242. */
  133243. export class PanoramaToCubeMapTools {
  133244. private static FACE_LEFT;
  133245. private static FACE_RIGHT;
  133246. private static FACE_FRONT;
  133247. private static FACE_BACK;
  133248. private static FACE_DOWN;
  133249. private static FACE_UP;
  133250. /**
  133251. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  133252. *
  133253. * @param float32Array The source data.
  133254. * @param inputWidth The width of the input panorama.
  133255. * @param inputHeight The height of the input panorama.
  133256. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  133257. * @return The cubemap data
  133258. */
  133259. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  133260. private static CreateCubemapTexture;
  133261. private static CalcProjectionSpherical;
  133262. }
  133263. }
  133264. declare module BABYLON {
  133265. /**
  133266. * Helper class dealing with the extraction of spherical polynomial dataArray
  133267. * from a cube map.
  133268. */
  133269. export class CubeMapToSphericalPolynomialTools {
  133270. private static FileFaces;
  133271. /**
  133272. * Converts a texture to the according Spherical Polynomial data.
  133273. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133274. *
  133275. * @param texture The texture to extract the information from.
  133276. * @return The Spherical Polynomial data.
  133277. */
  133278. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  133279. /**
  133280. * Converts a cubemap to the according Spherical Polynomial data.
  133281. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133282. *
  133283. * @param cubeInfo The Cube map to extract the information from.
  133284. * @return The Spherical Polynomial data.
  133285. */
  133286. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  133287. }
  133288. }
  133289. declare module BABYLON {
  133290. interface BaseTexture {
  133291. /**
  133292. * Get the polynomial representation of the texture data.
  133293. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  133294. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  133295. */
  133296. sphericalPolynomial: Nullable<SphericalPolynomial>;
  133297. }
  133298. }
  133299. declare module BABYLON {
  133300. /** @hidden */
  133301. export var rgbdEncodePixelShader: {
  133302. name: string;
  133303. shader: string;
  133304. };
  133305. }
  133306. declare module BABYLON {
  133307. /** @hidden */
  133308. export var rgbdDecodePixelShader: {
  133309. name: string;
  133310. shader: string;
  133311. };
  133312. }
  133313. declare module BABYLON {
  133314. /**
  133315. * Raw texture data and descriptor sufficient for WebGL texture upload
  133316. */
  133317. export interface EnvironmentTextureInfo {
  133318. /**
  133319. * Version of the environment map
  133320. */
  133321. version: number;
  133322. /**
  133323. * Width of image
  133324. */
  133325. width: number;
  133326. /**
  133327. * Irradiance information stored in the file.
  133328. */
  133329. irradiance: any;
  133330. /**
  133331. * Specular information stored in the file.
  133332. */
  133333. specular: any;
  133334. }
  133335. /**
  133336. * Defines One Image in the file. It requires only the position in the file
  133337. * as well as the length.
  133338. */
  133339. interface BufferImageData {
  133340. /**
  133341. * Length of the image data.
  133342. */
  133343. length: number;
  133344. /**
  133345. * Position of the data from the null terminator delimiting the end of the JSON.
  133346. */
  133347. position: number;
  133348. }
  133349. /**
  133350. * Defines the specular data enclosed in the file.
  133351. * This corresponds to the version 1 of the data.
  133352. */
  133353. export interface EnvironmentTextureSpecularInfoV1 {
  133354. /**
  133355. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133356. */
  133357. specularDataPosition?: number;
  133358. /**
  133359. * This contains all the images data needed to reconstruct the cubemap.
  133360. */
  133361. mipmaps: Array<BufferImageData>;
  133362. /**
  133363. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133364. */
  133365. lodGenerationScale: number;
  133366. }
  133367. /**
  133368. * Sets of helpers addressing the serialization and deserialization of environment texture
  133369. * stored in a BabylonJS env file.
  133370. * Those files are usually stored as .env files.
  133371. */
  133372. export class EnvironmentTextureTools {
  133373. /**
  133374. * Magic number identifying the env file.
  133375. */
  133376. private static _MagicBytes;
  133377. /**
  133378. * Gets the environment info from an env file.
  133379. * @param data The array buffer containing the .env bytes.
  133380. * @returns the environment file info (the json header) if successfully parsed.
  133381. */
  133382. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133383. /**
  133384. * Creates an environment texture from a loaded cube texture.
  133385. * @param texture defines the cube texture to convert in env file
  133386. * @return a promise containing the environment data if succesfull.
  133387. */
  133388. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133389. /**
  133390. * Creates a JSON representation of the spherical data.
  133391. * @param texture defines the texture containing the polynomials
  133392. * @return the JSON representation of the spherical info
  133393. */
  133394. private static _CreateEnvTextureIrradiance;
  133395. /**
  133396. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133397. * @param data the image data
  133398. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133399. * @return the views described by info providing access to the underlying buffer
  133400. */
  133401. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133402. /**
  133403. * Uploads the texture info contained in the env file to the GPU.
  133404. * @param texture defines the internal texture to upload to
  133405. * @param data defines the data to load
  133406. * @param info defines the texture info retrieved through the GetEnvInfo method
  133407. * @returns a promise
  133408. */
  133409. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133410. private static _OnImageReadyAsync;
  133411. /**
  133412. * Uploads the levels of image data to the GPU.
  133413. * @param texture defines the internal texture to upload to
  133414. * @param imageData defines the array buffer views of image data [mipmap][face]
  133415. * @returns a promise
  133416. */
  133417. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133418. /**
  133419. * Uploads spherical polynomials information to the texture.
  133420. * @param texture defines the texture we are trying to upload the information to
  133421. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133422. */
  133423. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133424. /** @hidden */
  133425. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133426. }
  133427. }
  133428. declare module BABYLON {
  133429. /**
  133430. * Class used to inline functions in shader code
  133431. */
  133432. export class ShaderCodeInliner {
  133433. private static readonly _RegexpFindFunctionNameAndType;
  133434. private _sourceCode;
  133435. private _functionDescr;
  133436. private _numMaxIterations;
  133437. /** Gets or sets the token used to mark the functions to inline */
  133438. inlineToken: string;
  133439. /** Gets or sets the debug mode */
  133440. debug: boolean;
  133441. /** Gets the code after the inlining process */
  133442. get code(): string;
  133443. /**
  133444. * Initializes the inliner
  133445. * @param sourceCode shader code source to inline
  133446. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133447. */
  133448. constructor(sourceCode: string, numMaxIterations?: number);
  133449. /**
  133450. * Start the processing of the shader code
  133451. */
  133452. processCode(): void;
  133453. private _collectFunctions;
  133454. private _processInlining;
  133455. private _extractBetweenMarkers;
  133456. private _skipWhitespaces;
  133457. private _removeComments;
  133458. private _replaceFunctionCallsByCode;
  133459. private _findBackward;
  133460. private _escapeRegExp;
  133461. private _replaceNames;
  133462. }
  133463. }
  133464. declare module BABYLON {
  133465. /**
  133466. * Container for accessors for natively-stored mesh data buffers.
  133467. */
  133468. class NativeDataBuffer extends DataBuffer {
  133469. /**
  133470. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133471. */
  133472. nativeIndexBuffer?: any;
  133473. /**
  133474. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133475. */
  133476. nativeVertexBuffer?: any;
  133477. }
  133478. /** @hidden */
  133479. class NativeTexture extends InternalTexture {
  133480. getInternalTexture(): InternalTexture;
  133481. getViewCount(): number;
  133482. }
  133483. /** @hidden */
  133484. export class NativeEngine extends Engine {
  133485. private readonly _native;
  133486. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133487. private readonly INVALID_HANDLE;
  133488. private _boundBuffersVertexArray;
  133489. private _currentDepthTest;
  133490. getHardwareScalingLevel(): number;
  133491. constructor();
  133492. dispose(): void;
  133493. /**
  133494. * Can be used to override the current requestAnimationFrame requester.
  133495. * @hidden
  133496. */
  133497. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133498. /**
  133499. * Override default engine behavior.
  133500. * @param color
  133501. * @param backBuffer
  133502. * @param depth
  133503. * @param stencil
  133504. */
  133505. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133506. /**
  133507. * Gets host document
  133508. * @returns the host document object
  133509. */
  133510. getHostDocument(): Nullable<Document>;
  133511. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133512. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133513. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133514. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133515. [key: string]: VertexBuffer;
  133516. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133517. bindBuffers(vertexBuffers: {
  133518. [key: string]: VertexBuffer;
  133519. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133520. recordVertexArrayObject(vertexBuffers: {
  133521. [key: string]: VertexBuffer;
  133522. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133523. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133524. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133525. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133526. /**
  133527. * Draw a list of indexed primitives
  133528. * @param fillMode defines the primitive to use
  133529. * @param indexStart defines the starting index
  133530. * @param indexCount defines the number of index to draw
  133531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133532. */
  133533. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133534. /**
  133535. * Draw a list of unindexed primitives
  133536. * @param fillMode defines the primitive to use
  133537. * @param verticesStart defines the index of first vertex to draw
  133538. * @param verticesCount defines the count of vertices to draw
  133539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133540. */
  133541. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133542. createPipelineContext(): IPipelineContext;
  133543. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133544. /** @hidden */
  133545. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133546. /** @hidden */
  133547. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133548. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133549. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133550. protected _setProgram(program: WebGLProgram): void;
  133551. _releaseEffect(effect: Effect): void;
  133552. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133553. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133554. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133555. bindSamplers(effect: Effect): void;
  133556. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133557. getRenderWidth(useScreen?: boolean): number;
  133558. getRenderHeight(useScreen?: boolean): number;
  133559. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133560. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133561. /**
  133562. * Set the z offset to apply to current rendering
  133563. * @param value defines the offset to apply
  133564. */
  133565. setZOffset(value: number): void;
  133566. /**
  133567. * Gets the current value of the zOffset
  133568. * @returns the current zOffset state
  133569. */
  133570. getZOffset(): number;
  133571. /**
  133572. * Enable or disable depth buffering
  133573. * @param enable defines the state to set
  133574. */
  133575. setDepthBuffer(enable: boolean): void;
  133576. /**
  133577. * Gets a boolean indicating if depth writing is enabled
  133578. * @returns the current depth writing state
  133579. */
  133580. getDepthWrite(): boolean;
  133581. setDepthFunctionToGreater(): void;
  133582. setDepthFunctionToGreaterOrEqual(): void;
  133583. setDepthFunctionToLess(): void;
  133584. setDepthFunctionToLessOrEqual(): void;
  133585. /**
  133586. * Enable or disable depth writing
  133587. * @param enable defines the state to set
  133588. */
  133589. setDepthWrite(enable: boolean): void;
  133590. /**
  133591. * Enable or disable color writing
  133592. * @param enable defines the state to set
  133593. */
  133594. setColorWrite(enable: boolean): void;
  133595. /**
  133596. * Gets a boolean indicating if color writing is enabled
  133597. * @returns the current color writing state
  133598. */
  133599. getColorWrite(): boolean;
  133600. /**
  133601. * Sets alpha constants used by some alpha blending modes
  133602. * @param r defines the red component
  133603. * @param g defines the green component
  133604. * @param b defines the blue component
  133605. * @param a defines the alpha component
  133606. */
  133607. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133608. /**
  133609. * Sets the current alpha mode
  133610. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133611. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133612. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133613. */
  133614. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133615. /**
  133616. * Gets the current alpha mode
  133617. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133618. * @returns the current alpha mode
  133619. */
  133620. getAlphaMode(): number;
  133621. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133622. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133623. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133624. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133625. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133626. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133627. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133628. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133629. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133630. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133631. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133632. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133633. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133634. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133635. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133636. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133637. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133638. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133639. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133641. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133642. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133643. wipeCaches(bruteForce?: boolean): void;
  133644. _createTexture(): WebGLTexture;
  133645. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133646. /**
  133647. * Usually called from Texture.ts.
  133648. * Passed information to create a WebGLTexture
  133649. * @param url defines a value which contains one of the following:
  133650. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133651. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133652. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133654. * @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)
  133655. * @param scene needed for loading to the correct scene
  133656. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133657. * @param onLoad optional callback to be called upon successful completion
  133658. * @param onError optional callback to be called upon failure
  133659. * @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
  133660. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133661. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133662. * @param forcedExtension defines the extension to use to pick the right loader
  133663. * @param mimeType defines an optional mime type
  133664. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133665. */
  133666. 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;
  133667. /**
  133668. * Creates a cube texture
  133669. * @param rootUrl defines the url where the files to load is located
  133670. * @param scene defines the current scene
  133671. * @param files defines the list of files to load (1 per face)
  133672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133673. * @param onLoad defines an optional callback raised when the texture is loaded
  133674. * @param onError defines an optional callback raised if there is an issue to load the texture
  133675. * @param format defines the format of the data
  133676. * @param forcedExtension defines the extension to use to pick the right loader
  133677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133680. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133681. * @returns the cube texture as an InternalTexture
  133682. */
  133683. 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;
  133684. private _getSamplingFilter;
  133685. private static _GetNativeTextureFormat;
  133686. createRenderTargetTexture(size: number | {
  133687. width: number;
  133688. height: number;
  133689. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133690. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133692. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133693. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133694. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133695. /**
  133696. * Updates a dynamic vertex buffer.
  133697. * @param vertexBuffer the vertex buffer to update
  133698. * @param data the data used to update the vertex buffer
  133699. * @param byteOffset the byte offset of the data (optional)
  133700. * @param byteLength the byte length of the data (optional)
  133701. */
  133702. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133703. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133704. private _updateAnisotropicLevel;
  133705. private _getAddressMode;
  133706. /** @hidden */
  133707. _bindTexture(channel: number, texture: InternalTexture): void;
  133708. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133709. releaseEffects(): void;
  133710. /** @hidden */
  133711. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133712. /** @hidden */
  133713. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133714. /** @hidden */
  133715. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133716. /** @hidden */
  133717. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133718. }
  133719. }
  133720. declare module BABYLON {
  133721. /**
  133722. * Gather the list of clipboard event types as constants.
  133723. */
  133724. export class ClipboardEventTypes {
  133725. /**
  133726. * The clipboard event is fired when a copy command is active (pressed).
  133727. */
  133728. static readonly COPY: number;
  133729. /**
  133730. * The clipboard event is fired when a cut command is active (pressed).
  133731. */
  133732. static readonly CUT: number;
  133733. /**
  133734. * The clipboard event is fired when a paste command is active (pressed).
  133735. */
  133736. static readonly PASTE: number;
  133737. }
  133738. /**
  133739. * This class is used to store clipboard related info for the onClipboardObservable event.
  133740. */
  133741. export class ClipboardInfo {
  133742. /**
  133743. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133744. */
  133745. type: number;
  133746. /**
  133747. * Defines the related dom event
  133748. */
  133749. event: ClipboardEvent;
  133750. /**
  133751. *Creates an instance of ClipboardInfo.
  133752. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133753. * @param event Defines the related dom event
  133754. */
  133755. constructor(
  133756. /**
  133757. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133758. */
  133759. type: number,
  133760. /**
  133761. * Defines the related dom event
  133762. */
  133763. event: ClipboardEvent);
  133764. /**
  133765. * Get the clipboard event's type from the keycode.
  133766. * @param keyCode Defines the keyCode for the current keyboard event.
  133767. * @return {number}
  133768. */
  133769. static GetTypeFromCharacter(keyCode: number): number;
  133770. }
  133771. }
  133772. declare module BABYLON {
  133773. /**
  133774. * Google Daydream controller
  133775. */
  133776. export class DaydreamController extends WebVRController {
  133777. /**
  133778. * Base Url for the controller model.
  133779. */
  133780. static MODEL_BASE_URL: string;
  133781. /**
  133782. * File name for the controller model.
  133783. */
  133784. static MODEL_FILENAME: string;
  133785. /**
  133786. * Gamepad Id prefix used to identify Daydream Controller.
  133787. */
  133788. static readonly GAMEPAD_ID_PREFIX: string;
  133789. /**
  133790. * Creates a new DaydreamController from a gamepad
  133791. * @param vrGamepad the gamepad that the controller should be created from
  133792. */
  133793. constructor(vrGamepad: any);
  133794. /**
  133795. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133796. * @param scene scene in which to add meshes
  133797. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133798. */
  133799. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133800. /**
  133801. * Called once for each button that changed state since the last frame
  133802. * @param buttonIdx Which button index changed
  133803. * @param state New state of the button
  133804. * @param changes Which properties on the state changed since last frame
  133805. */
  133806. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133807. }
  133808. }
  133809. declare module BABYLON {
  133810. /**
  133811. * Gear VR Controller
  133812. */
  133813. export class GearVRController extends WebVRController {
  133814. /**
  133815. * Base Url for the controller model.
  133816. */
  133817. static MODEL_BASE_URL: string;
  133818. /**
  133819. * File name for the controller model.
  133820. */
  133821. static MODEL_FILENAME: string;
  133822. /**
  133823. * Gamepad Id prefix used to identify this controller.
  133824. */
  133825. static readonly GAMEPAD_ID_PREFIX: string;
  133826. private readonly _buttonIndexToObservableNameMap;
  133827. /**
  133828. * Creates a new GearVRController from a gamepad
  133829. * @param vrGamepad the gamepad that the controller should be created from
  133830. */
  133831. constructor(vrGamepad: any);
  133832. /**
  133833. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133834. * @param scene scene in which to add meshes
  133835. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133836. */
  133837. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133838. /**
  133839. * Called once for each button that changed state since the last frame
  133840. * @param buttonIdx Which button index changed
  133841. * @param state New state of the button
  133842. * @param changes Which properties on the state changed since last frame
  133843. */
  133844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133845. }
  133846. }
  133847. declare module BABYLON {
  133848. /**
  133849. * Generic Controller
  133850. */
  133851. export class GenericController extends WebVRController {
  133852. /**
  133853. * Base Url for the controller model.
  133854. */
  133855. static readonly MODEL_BASE_URL: string;
  133856. /**
  133857. * File name for the controller model.
  133858. */
  133859. static readonly MODEL_FILENAME: string;
  133860. /**
  133861. * Creates a new GenericController from a gamepad
  133862. * @param vrGamepad the gamepad that the controller should be created from
  133863. */
  133864. constructor(vrGamepad: any);
  133865. /**
  133866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133867. * @param scene scene in which to add meshes
  133868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133869. */
  133870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133871. /**
  133872. * Called once for each button that changed state since the last frame
  133873. * @param buttonIdx Which button index changed
  133874. * @param state New state of the button
  133875. * @param changes Which properties on the state changed since last frame
  133876. */
  133877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133878. }
  133879. }
  133880. declare module BABYLON {
  133881. /**
  133882. * Oculus Touch Controller
  133883. */
  133884. export class OculusTouchController extends WebVRController {
  133885. /**
  133886. * Base Url for the controller model.
  133887. */
  133888. static MODEL_BASE_URL: string;
  133889. /**
  133890. * File name for the left controller model.
  133891. */
  133892. static MODEL_LEFT_FILENAME: string;
  133893. /**
  133894. * File name for the right controller model.
  133895. */
  133896. static MODEL_RIGHT_FILENAME: string;
  133897. /**
  133898. * Base Url for the Quest controller model.
  133899. */
  133900. static QUEST_MODEL_BASE_URL: string;
  133901. /**
  133902. * @hidden
  133903. * If the controllers are running on a device that needs the updated Quest controller models
  133904. */
  133905. static _IsQuest: boolean;
  133906. /**
  133907. * Fired when the secondary trigger on this controller is modified
  133908. */
  133909. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133910. /**
  133911. * Fired when the thumb rest on this controller is modified
  133912. */
  133913. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133914. /**
  133915. * Creates a new OculusTouchController from a gamepad
  133916. * @param vrGamepad the gamepad that the controller should be created from
  133917. */
  133918. constructor(vrGamepad: any);
  133919. /**
  133920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133921. * @param scene scene in which to add meshes
  133922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133923. */
  133924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133925. /**
  133926. * Fired when the A button on this controller is modified
  133927. */
  133928. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133929. /**
  133930. * Fired when the B button on this controller is modified
  133931. */
  133932. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133933. /**
  133934. * Fired when the X button on this controller is modified
  133935. */
  133936. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133937. /**
  133938. * Fired when the Y button on this controller is modified
  133939. */
  133940. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133941. /**
  133942. * Called once for each button that changed state since the last frame
  133943. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133944. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133945. * 2) secondary trigger (same)
  133946. * 3) A (right) X (left), touch, pressed = value
  133947. * 4) B / Y
  133948. * 5) thumb rest
  133949. * @param buttonIdx Which button index changed
  133950. * @param state New state of the button
  133951. * @param changes Which properties on the state changed since last frame
  133952. */
  133953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133954. }
  133955. }
  133956. declare module BABYLON {
  133957. /**
  133958. * Vive Controller
  133959. */
  133960. export class ViveController extends WebVRController {
  133961. /**
  133962. * Base Url for the controller model.
  133963. */
  133964. static MODEL_BASE_URL: string;
  133965. /**
  133966. * File name for the controller model.
  133967. */
  133968. static MODEL_FILENAME: string;
  133969. /**
  133970. * Creates a new ViveController from a gamepad
  133971. * @param vrGamepad the gamepad that the controller should be created from
  133972. */
  133973. constructor(vrGamepad: any);
  133974. /**
  133975. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133976. * @param scene scene in which to add meshes
  133977. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133978. */
  133979. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133980. /**
  133981. * Fired when the left button on this controller is modified
  133982. */
  133983. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133984. /**
  133985. * Fired when the right button on this controller is modified
  133986. */
  133987. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133988. /**
  133989. * Fired when the menu button on this controller is modified
  133990. */
  133991. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133992. /**
  133993. * Called once for each button that changed state since the last frame
  133994. * Vive mapping:
  133995. * 0: touchpad
  133996. * 1: trigger
  133997. * 2: left AND right buttons
  133998. * 3: menu button
  133999. * @param buttonIdx Which button index changed
  134000. * @param state New state of the button
  134001. * @param changes Which properties on the state changed since last frame
  134002. */
  134003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134004. }
  134005. }
  134006. declare module BABYLON {
  134007. /**
  134008. * Defines the WindowsMotionController object that the state of the windows motion controller
  134009. */
  134010. export class WindowsMotionController extends WebVRController {
  134011. /**
  134012. * The base url used to load the left and right controller models
  134013. */
  134014. static MODEL_BASE_URL: string;
  134015. /**
  134016. * The name of the left controller model file
  134017. */
  134018. static MODEL_LEFT_FILENAME: string;
  134019. /**
  134020. * The name of the right controller model file
  134021. */
  134022. static MODEL_RIGHT_FILENAME: string;
  134023. /**
  134024. * The controller name prefix for this controller type
  134025. */
  134026. static readonly GAMEPAD_ID_PREFIX: string;
  134027. /**
  134028. * The controller id pattern for this controller type
  134029. */
  134030. private static readonly GAMEPAD_ID_PATTERN;
  134031. private _loadedMeshInfo;
  134032. protected readonly _mapping: {
  134033. buttons: string[];
  134034. buttonMeshNames: {
  134035. trigger: string;
  134036. menu: string;
  134037. grip: string;
  134038. thumbstick: string;
  134039. trackpad: string;
  134040. };
  134041. buttonObservableNames: {
  134042. trigger: string;
  134043. menu: string;
  134044. grip: string;
  134045. thumbstick: string;
  134046. trackpad: string;
  134047. };
  134048. axisMeshNames: string[];
  134049. pointingPoseMeshName: string;
  134050. };
  134051. /**
  134052. * Fired when the trackpad on this controller is clicked
  134053. */
  134054. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134055. /**
  134056. * Fired when the trackpad on this controller is modified
  134057. */
  134058. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134059. /**
  134060. * The current x and y values of this controller's trackpad
  134061. */
  134062. trackpad: StickValues;
  134063. /**
  134064. * Creates a new WindowsMotionController from a gamepad
  134065. * @param vrGamepad the gamepad that the controller should be created from
  134066. */
  134067. constructor(vrGamepad: any);
  134068. /**
  134069. * Fired when the trigger on this controller is modified
  134070. */
  134071. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134072. /**
  134073. * Fired when the menu button on this controller is modified
  134074. */
  134075. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134076. /**
  134077. * Fired when the grip button on this controller is modified
  134078. */
  134079. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134080. /**
  134081. * Fired when the thumbstick button on this controller is modified
  134082. */
  134083. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134084. /**
  134085. * Fired when the touchpad button on this controller is modified
  134086. */
  134087. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134088. /**
  134089. * Fired when the touchpad values on this controller are modified
  134090. */
  134091. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  134092. protected _updateTrackpad(): void;
  134093. /**
  134094. * Called once per frame by the engine.
  134095. */
  134096. update(): void;
  134097. /**
  134098. * Called once for each button that changed state since the last frame
  134099. * @param buttonIdx Which button index changed
  134100. * @param state New state of the button
  134101. * @param changes Which properties on the state changed since last frame
  134102. */
  134103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134104. /**
  134105. * Moves the buttons on the controller mesh based on their current state
  134106. * @param buttonName the name of the button to move
  134107. * @param buttonValue the value of the button which determines the buttons new position
  134108. */
  134109. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  134110. /**
  134111. * Moves the axis on the controller mesh based on its current state
  134112. * @param axis the index of the axis
  134113. * @param axisValue the value of the axis which determines the meshes new position
  134114. * @hidden
  134115. */
  134116. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  134117. /**
  134118. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  134119. * @param scene scene in which to add meshes
  134120. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  134121. */
  134122. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  134123. /**
  134124. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  134125. * can be transformed by button presses and axes values, based on this._mapping.
  134126. *
  134127. * @param scene scene in which the meshes exist
  134128. * @param meshes list of meshes that make up the controller model to process
  134129. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  134130. */
  134131. private processModel;
  134132. private createMeshInfo;
  134133. /**
  134134. * Gets the ray of the controller in the direction the controller is pointing
  134135. * @param length the length the resulting ray should be
  134136. * @returns a ray in the direction the controller is pointing
  134137. */
  134138. getForwardRay(length?: number): Ray;
  134139. /**
  134140. * Disposes of the controller
  134141. */
  134142. dispose(): void;
  134143. }
  134144. /**
  134145. * This class represents a new windows motion controller in XR.
  134146. */
  134147. export class XRWindowsMotionController extends WindowsMotionController {
  134148. /**
  134149. * Changing the original WIndowsMotionController mapping to fir the new mapping
  134150. */
  134151. protected readonly _mapping: {
  134152. buttons: string[];
  134153. buttonMeshNames: {
  134154. trigger: string;
  134155. menu: string;
  134156. grip: string;
  134157. thumbstick: string;
  134158. trackpad: string;
  134159. };
  134160. buttonObservableNames: {
  134161. trigger: string;
  134162. menu: string;
  134163. grip: string;
  134164. thumbstick: string;
  134165. trackpad: string;
  134166. };
  134167. axisMeshNames: string[];
  134168. pointingPoseMeshName: string;
  134169. };
  134170. /**
  134171. * Construct a new XR-Based windows motion controller
  134172. *
  134173. * @param gamepadInfo the gamepad object from the browser
  134174. */
  134175. constructor(gamepadInfo: any);
  134176. /**
  134177. * holds the thumbstick values (X,Y)
  134178. */
  134179. thumbstickValues: StickValues;
  134180. /**
  134181. * Fired when the thumbstick on this controller is clicked
  134182. */
  134183. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  134184. /**
  134185. * Fired when the thumbstick on this controller is modified
  134186. */
  134187. onThumbstickValuesChangedObservable: Observable<StickValues>;
  134188. /**
  134189. * Fired when the touchpad button on this controller is modified
  134190. */
  134191. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134192. /**
  134193. * Fired when the touchpad values on this controller are modified
  134194. */
  134195. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134196. /**
  134197. * Fired when the thumbstick button on this controller is modified
  134198. * here to prevent breaking changes
  134199. */
  134200. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134201. /**
  134202. * updating the thumbstick(!) and not the trackpad.
  134203. * This is named this way due to the difference between WebVR and XR and to avoid
  134204. * changing the parent class.
  134205. */
  134206. protected _updateTrackpad(): void;
  134207. /**
  134208. * Disposes the class with joy
  134209. */
  134210. dispose(): void;
  134211. }
  134212. }
  134213. declare module BABYLON {
  134214. /**
  134215. * Class containing static functions to help procedurally build meshes
  134216. */
  134217. export class PolyhedronBuilder {
  134218. /**
  134219. * Creates a polyhedron mesh
  134220. * * 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
  134221. * * The parameter `size` (positive float, default 1) sets the polygon size
  134222. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134223. * * 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`
  134224. * * 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
  134225. * * 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)`)
  134226. * * 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
  134227. * * 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
  134228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134231. * @param name defines the name of the mesh
  134232. * @param options defines the options used to create the mesh
  134233. * @param scene defines the hosting scene
  134234. * @returns the polyhedron mesh
  134235. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134236. */
  134237. static CreatePolyhedron(name: string, options: {
  134238. type?: number;
  134239. size?: number;
  134240. sizeX?: number;
  134241. sizeY?: number;
  134242. sizeZ?: number;
  134243. custom?: any;
  134244. faceUV?: Vector4[];
  134245. faceColors?: Color4[];
  134246. flat?: boolean;
  134247. updatable?: boolean;
  134248. sideOrientation?: number;
  134249. frontUVs?: Vector4;
  134250. backUVs?: Vector4;
  134251. }, scene?: Nullable<Scene>): Mesh;
  134252. }
  134253. }
  134254. declare module BABYLON {
  134255. /**
  134256. * Gizmo that enables scaling a mesh along 3 axis
  134257. */
  134258. export class ScaleGizmo extends Gizmo {
  134259. /**
  134260. * Internal gizmo used for interactions on the x axis
  134261. */
  134262. xGizmo: AxisScaleGizmo;
  134263. /**
  134264. * Internal gizmo used for interactions on the y axis
  134265. */
  134266. yGizmo: AxisScaleGizmo;
  134267. /**
  134268. * Internal gizmo used for interactions on the z axis
  134269. */
  134270. zGizmo: AxisScaleGizmo;
  134271. /**
  134272. * Internal gizmo used to scale all axis equally
  134273. */
  134274. uniformScaleGizmo: AxisScaleGizmo;
  134275. private _meshAttached;
  134276. private _nodeAttached;
  134277. private _snapDistance;
  134278. private _uniformScalingMesh;
  134279. private _octahedron;
  134280. private _sensitivity;
  134281. /** Fires an event when any of it's sub gizmos are dragged */
  134282. onDragStartObservable: Observable<unknown>;
  134283. /** Fires an event when any of it's sub gizmos are released from dragging */
  134284. onDragEndObservable: Observable<unknown>;
  134285. get attachedMesh(): Nullable<AbstractMesh>;
  134286. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134287. get attachedNode(): Nullable<Node>;
  134288. set attachedNode(node: Nullable<Node>);
  134289. /**
  134290. * True when the mouse pointer is hovering a gizmo mesh
  134291. */
  134292. get isHovered(): boolean;
  134293. /**
  134294. * Creates a ScaleGizmo
  134295. * @param gizmoLayer The utility layer the gizmo will be added to
  134296. * @param thickness display gizmo axis thickness
  134297. */
  134298. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134299. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134300. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134301. /**
  134302. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134303. */
  134304. set snapDistance(value: number);
  134305. get snapDistance(): number;
  134306. /**
  134307. * Ratio for the scale of the gizmo (Default: 1)
  134308. */
  134309. set scaleRatio(value: number);
  134310. get scaleRatio(): number;
  134311. /**
  134312. * Sensitivity factor for dragging (Default: 1)
  134313. */
  134314. set sensitivity(value: number);
  134315. get sensitivity(): number;
  134316. /**
  134317. * Disposes of the gizmo
  134318. */
  134319. dispose(): void;
  134320. }
  134321. }
  134322. declare module BABYLON {
  134323. /**
  134324. * Single axis scale gizmo
  134325. */
  134326. export class AxisScaleGizmo extends Gizmo {
  134327. /**
  134328. * Drag behavior responsible for the gizmos dragging interactions
  134329. */
  134330. dragBehavior: PointerDragBehavior;
  134331. private _pointerObserver;
  134332. /**
  134333. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134334. */
  134335. snapDistance: number;
  134336. /**
  134337. * Event that fires each time the gizmo snaps to a new location.
  134338. * * snapDistance is the the change in distance
  134339. */
  134340. onSnapObservable: Observable<{
  134341. snapDistance: number;
  134342. }>;
  134343. /**
  134344. * If the scaling operation should be done on all axis (default: false)
  134345. */
  134346. uniformScaling: boolean;
  134347. /**
  134348. * Custom sensitivity value for the drag strength
  134349. */
  134350. sensitivity: number;
  134351. private _isEnabled;
  134352. private _parent;
  134353. private _arrow;
  134354. private _coloredMaterial;
  134355. private _hoverMaterial;
  134356. /**
  134357. * Creates an AxisScaleGizmo
  134358. * @param gizmoLayer The utility layer the gizmo will be added to
  134359. * @param dragAxis The axis which the gizmo will be able to scale on
  134360. * @param color The color of the gizmo
  134361. * @param thickness display gizmo axis thickness
  134362. */
  134363. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134364. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134365. /**
  134366. * If the gizmo is enabled
  134367. */
  134368. set isEnabled(value: boolean);
  134369. get isEnabled(): boolean;
  134370. /**
  134371. * Disposes of the gizmo
  134372. */
  134373. dispose(): void;
  134374. /**
  134375. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134376. * @param mesh The mesh to replace the default mesh of the gizmo
  134377. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134378. */
  134379. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134380. }
  134381. }
  134382. declare module BABYLON {
  134383. /**
  134384. * Bounding box gizmo
  134385. */
  134386. export class BoundingBoxGizmo extends Gizmo {
  134387. private _lineBoundingBox;
  134388. private _rotateSpheresParent;
  134389. private _scaleBoxesParent;
  134390. private _boundingDimensions;
  134391. private _renderObserver;
  134392. private _pointerObserver;
  134393. private _scaleDragSpeed;
  134394. private _tmpQuaternion;
  134395. private _tmpVector;
  134396. private _tmpRotationMatrix;
  134397. /**
  134398. * 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)
  134399. */
  134400. ignoreChildren: boolean;
  134401. /**
  134402. * 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)
  134403. */
  134404. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134405. /**
  134406. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134407. */
  134408. rotationSphereSize: number;
  134409. /**
  134410. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134411. */
  134412. scaleBoxSize: number;
  134413. /**
  134414. * 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)
  134415. */
  134416. fixedDragMeshScreenSize: boolean;
  134417. /**
  134418. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134419. */
  134420. fixedDragMeshScreenSizeDistanceFactor: number;
  134421. /**
  134422. * Fired when a rotation sphere or scale box is dragged
  134423. */
  134424. onDragStartObservable: Observable<{}>;
  134425. /**
  134426. * Fired when a scale box is dragged
  134427. */
  134428. onScaleBoxDragObservable: Observable<{}>;
  134429. /**
  134430. * Fired when a scale box drag is ended
  134431. */
  134432. onScaleBoxDragEndObservable: Observable<{}>;
  134433. /**
  134434. * Fired when a rotation sphere is dragged
  134435. */
  134436. onRotationSphereDragObservable: Observable<{}>;
  134437. /**
  134438. * Fired when a rotation sphere drag is ended
  134439. */
  134440. onRotationSphereDragEndObservable: Observable<{}>;
  134441. /**
  134442. * 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)
  134443. */
  134444. scalePivot: Nullable<Vector3>;
  134445. /**
  134446. * Mesh used as a pivot to rotate the attached node
  134447. */
  134448. private _anchorMesh;
  134449. private _existingMeshScale;
  134450. private _dragMesh;
  134451. private pointerDragBehavior;
  134452. private coloredMaterial;
  134453. private hoverColoredMaterial;
  134454. /**
  134455. * Sets the color of the bounding box gizmo
  134456. * @param color the color to set
  134457. */
  134458. setColor(color: Color3): void;
  134459. /**
  134460. * Creates an BoundingBoxGizmo
  134461. * @param gizmoLayer The utility layer the gizmo will be added to
  134462. * @param color The color of the gizmo
  134463. */
  134464. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134465. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134466. private _selectNode;
  134467. /**
  134468. * Updates the bounding box information for the Gizmo
  134469. */
  134470. updateBoundingBox(): void;
  134471. private _updateRotationSpheres;
  134472. private _updateScaleBoxes;
  134473. /**
  134474. * Enables rotation on the specified axis and disables rotation on the others
  134475. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134476. */
  134477. setEnabledRotationAxis(axis: string): void;
  134478. /**
  134479. * Enables/disables scaling
  134480. * @param enable if scaling should be enabled
  134481. * @param homogeneousScaling defines if scaling should only be homogeneous
  134482. */
  134483. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134484. private _updateDummy;
  134485. /**
  134486. * Enables a pointer drag behavior on the bounding box of the gizmo
  134487. */
  134488. enableDragBehavior(): void;
  134489. /**
  134490. * Disposes of the gizmo
  134491. */
  134492. dispose(): void;
  134493. /**
  134494. * 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)
  134495. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134496. * @returns the bounding box mesh with the passed in mesh as a child
  134497. */
  134498. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134499. /**
  134500. * CustomMeshes are not supported by this gizmo
  134501. * @param mesh The mesh to replace the default mesh of the gizmo
  134502. */
  134503. setCustomMesh(mesh: Mesh): void;
  134504. }
  134505. }
  134506. declare module BABYLON {
  134507. /**
  134508. * Single plane rotation gizmo
  134509. */
  134510. export class PlaneRotationGizmo extends Gizmo {
  134511. /**
  134512. * Drag behavior responsible for the gizmos dragging interactions
  134513. */
  134514. dragBehavior: PointerDragBehavior;
  134515. private _pointerObserver;
  134516. /**
  134517. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134518. */
  134519. snapDistance: number;
  134520. /**
  134521. * Event that fires each time the gizmo snaps to a new location.
  134522. * * snapDistance is the the change in distance
  134523. */
  134524. onSnapObservable: Observable<{
  134525. snapDistance: number;
  134526. }>;
  134527. private _isEnabled;
  134528. private _parent;
  134529. /**
  134530. * Creates a PlaneRotationGizmo
  134531. * @param gizmoLayer The utility layer the gizmo will be added to
  134532. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134533. * @param color The color of the gizmo
  134534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134536. * @param thickness display gizmo axis thickness
  134537. */
  134538. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134539. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134540. /**
  134541. * If the gizmo is enabled
  134542. */
  134543. set isEnabled(value: boolean);
  134544. get isEnabled(): boolean;
  134545. /**
  134546. * Disposes of the gizmo
  134547. */
  134548. dispose(): void;
  134549. }
  134550. }
  134551. declare module BABYLON {
  134552. /**
  134553. * Gizmo that enables rotating a mesh along 3 axis
  134554. */
  134555. export class RotationGizmo extends Gizmo {
  134556. /**
  134557. * Internal gizmo used for interactions on the x axis
  134558. */
  134559. xGizmo: PlaneRotationGizmo;
  134560. /**
  134561. * Internal gizmo used for interactions on the y axis
  134562. */
  134563. yGizmo: PlaneRotationGizmo;
  134564. /**
  134565. * Internal gizmo used for interactions on the z axis
  134566. */
  134567. zGizmo: PlaneRotationGizmo;
  134568. /** Fires an event when any of it's sub gizmos are dragged */
  134569. onDragStartObservable: Observable<unknown>;
  134570. /** Fires an event when any of it's sub gizmos are released from dragging */
  134571. onDragEndObservable: Observable<unknown>;
  134572. private _meshAttached;
  134573. private _nodeAttached;
  134574. get attachedMesh(): Nullable<AbstractMesh>;
  134575. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134576. get attachedNode(): Nullable<Node>;
  134577. set attachedNode(node: Nullable<Node>);
  134578. /**
  134579. * True when the mouse pointer is hovering a gizmo mesh
  134580. */
  134581. get isHovered(): boolean;
  134582. /**
  134583. * Creates a RotationGizmo
  134584. * @param gizmoLayer The utility layer the gizmo will be added to
  134585. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134586. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134587. * @param thickness display gizmo axis thickness
  134588. */
  134589. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134590. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134591. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134592. /**
  134593. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134594. */
  134595. set snapDistance(value: number);
  134596. get snapDistance(): number;
  134597. /**
  134598. * Ratio for the scale of the gizmo (Default: 1)
  134599. */
  134600. set scaleRatio(value: number);
  134601. get scaleRatio(): number;
  134602. /**
  134603. * Disposes of the gizmo
  134604. */
  134605. dispose(): void;
  134606. /**
  134607. * CustomMeshes are not supported by this gizmo
  134608. * @param mesh The mesh to replace the default mesh of the gizmo
  134609. */
  134610. setCustomMesh(mesh: Mesh): void;
  134611. }
  134612. }
  134613. declare module BABYLON {
  134614. /**
  134615. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134616. */
  134617. export class GizmoManager implements IDisposable {
  134618. private scene;
  134619. /**
  134620. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134621. */
  134622. gizmos: {
  134623. positionGizmo: Nullable<PositionGizmo>;
  134624. rotationGizmo: Nullable<RotationGizmo>;
  134625. scaleGizmo: Nullable<ScaleGizmo>;
  134626. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134627. };
  134628. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134629. clearGizmoOnEmptyPointerEvent: boolean;
  134630. /** Fires an event when the manager is attached to a mesh */
  134631. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134632. /** Fires an event when the manager is attached to a node */
  134633. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134634. private _gizmosEnabled;
  134635. private _pointerObserver;
  134636. private _attachedMesh;
  134637. private _attachedNode;
  134638. private _boundingBoxColor;
  134639. private _defaultUtilityLayer;
  134640. private _defaultKeepDepthUtilityLayer;
  134641. private _thickness;
  134642. /**
  134643. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134644. */
  134645. boundingBoxDragBehavior: SixDofDragBehavior;
  134646. /**
  134647. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134648. */
  134649. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134650. /**
  134651. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134652. */
  134653. attachableNodes: Nullable<Array<Node>>;
  134654. /**
  134655. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134656. */
  134657. usePointerToAttachGizmos: boolean;
  134658. /**
  134659. * Utility layer that the bounding box gizmo belongs to
  134660. */
  134661. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134662. /**
  134663. * Utility layer that all gizmos besides bounding box belong to
  134664. */
  134665. get utilityLayer(): UtilityLayerRenderer;
  134666. /**
  134667. * True when the mouse pointer is hovering a gizmo mesh
  134668. */
  134669. get isHovered(): boolean;
  134670. /**
  134671. * Instatiates a gizmo manager
  134672. * @param scene the scene to overlay the gizmos on top of
  134673. * @param thickness display gizmo axis thickness
  134674. */
  134675. constructor(scene: Scene, thickness?: number);
  134676. /**
  134677. * Attaches a set of gizmos to the specified mesh
  134678. * @param mesh The mesh the gizmo's should be attached to
  134679. */
  134680. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134681. /**
  134682. * Attaches a set of gizmos to the specified node
  134683. * @param node The node the gizmo's should be attached to
  134684. */
  134685. attachToNode(node: Nullable<Node>): void;
  134686. /**
  134687. * If the position gizmo is enabled
  134688. */
  134689. set positionGizmoEnabled(value: boolean);
  134690. get positionGizmoEnabled(): boolean;
  134691. /**
  134692. * If the rotation gizmo is enabled
  134693. */
  134694. set rotationGizmoEnabled(value: boolean);
  134695. get rotationGizmoEnabled(): boolean;
  134696. /**
  134697. * If the scale gizmo is enabled
  134698. */
  134699. set scaleGizmoEnabled(value: boolean);
  134700. get scaleGizmoEnabled(): boolean;
  134701. /**
  134702. * If the boundingBox gizmo is enabled
  134703. */
  134704. set boundingBoxGizmoEnabled(value: boolean);
  134705. get boundingBoxGizmoEnabled(): boolean;
  134706. /**
  134707. * Disposes of the gizmo manager
  134708. */
  134709. dispose(): void;
  134710. }
  134711. }
  134712. declare module BABYLON {
  134713. /**
  134714. * A directional light is defined by a direction (what a surprise!).
  134715. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134716. * 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.
  134717. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134718. */
  134719. export class DirectionalLight extends ShadowLight {
  134720. private _shadowFrustumSize;
  134721. /**
  134722. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134723. */
  134724. get shadowFrustumSize(): number;
  134725. /**
  134726. * Specifies a fix frustum size for the shadow generation.
  134727. */
  134728. set shadowFrustumSize(value: number);
  134729. private _shadowOrthoScale;
  134730. /**
  134731. * Gets the shadow projection scale against the optimal computed one.
  134732. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134733. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134734. */
  134735. get shadowOrthoScale(): number;
  134736. /**
  134737. * Sets the shadow projection scale against the optimal computed one.
  134738. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134739. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134740. */
  134741. set shadowOrthoScale(value: number);
  134742. /**
  134743. * Automatically compute the projection matrix to best fit (including all the casters)
  134744. * on each frame.
  134745. */
  134746. autoUpdateExtends: boolean;
  134747. /**
  134748. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134749. * on each frame. autoUpdateExtends must be set to true for this to work
  134750. */
  134751. autoCalcShadowZBounds: boolean;
  134752. private _orthoLeft;
  134753. private _orthoRight;
  134754. private _orthoTop;
  134755. private _orthoBottom;
  134756. /**
  134757. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134758. * The directional light is emitted from everywhere in the given direction.
  134759. * It can cast shadows.
  134760. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134761. * @param name The friendly name of the light
  134762. * @param direction The direction of the light
  134763. * @param scene The scene the light belongs to
  134764. */
  134765. constructor(name: string, direction: Vector3, scene: Scene);
  134766. /**
  134767. * Returns the string "DirectionalLight".
  134768. * @return The class name
  134769. */
  134770. getClassName(): string;
  134771. /**
  134772. * Returns the integer 1.
  134773. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134774. */
  134775. getTypeID(): number;
  134776. /**
  134777. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134778. * Returns the DirectionalLight Shadow projection matrix.
  134779. */
  134780. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134781. /**
  134782. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134783. * Returns the DirectionalLight Shadow projection matrix.
  134784. */
  134785. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134786. /**
  134787. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134788. * Returns the DirectionalLight Shadow projection matrix.
  134789. */
  134790. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134791. protected _buildUniformLayout(): void;
  134792. /**
  134793. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134794. * @param effect The effect to update
  134795. * @param lightIndex The index of the light in the effect to update
  134796. * @returns The directional light
  134797. */
  134798. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134799. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134800. /**
  134801. * Gets the minZ used for shadow according to both the scene and the light.
  134802. *
  134803. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134804. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134805. * @param activeCamera The camera we are returning the min for
  134806. * @returns the depth min z
  134807. */
  134808. getDepthMinZ(activeCamera: Camera): number;
  134809. /**
  134810. * Gets the maxZ used for shadow according to both the scene and the light.
  134811. *
  134812. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134813. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134814. * @param activeCamera The camera we are returning the max for
  134815. * @returns the depth max z
  134816. */
  134817. getDepthMaxZ(activeCamera: Camera): number;
  134818. /**
  134819. * Prepares the list of defines specific to the light type.
  134820. * @param defines the list of defines
  134821. * @param lightIndex defines the index of the light for the effect
  134822. */
  134823. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134824. }
  134825. }
  134826. declare module BABYLON {
  134827. /**
  134828. * Class containing static functions to help procedurally build meshes
  134829. */
  134830. export class HemisphereBuilder {
  134831. /**
  134832. * Creates a hemisphere mesh
  134833. * @param name defines the name of the mesh
  134834. * @param options defines the options used to create the mesh
  134835. * @param scene defines the hosting scene
  134836. * @returns the hemisphere mesh
  134837. */
  134838. static CreateHemisphere(name: string, options: {
  134839. segments?: number;
  134840. diameter?: number;
  134841. sideOrientation?: number;
  134842. }, scene: any): Mesh;
  134843. }
  134844. }
  134845. declare module BABYLON {
  134846. /**
  134847. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134848. * These values define a cone of light starting from the position, emitting toward the direction.
  134849. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134850. * and the exponent defines the speed of the decay of the light with distance (reach).
  134851. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134852. */
  134853. export class SpotLight extends ShadowLight {
  134854. private _angle;
  134855. private _innerAngle;
  134856. private _cosHalfAngle;
  134857. private _lightAngleScale;
  134858. private _lightAngleOffset;
  134859. /**
  134860. * Gets the cone angle of the spot light in Radians.
  134861. */
  134862. get angle(): number;
  134863. /**
  134864. * Sets the cone angle of the spot light in Radians.
  134865. */
  134866. set angle(value: number);
  134867. /**
  134868. * Only used in gltf falloff mode, this defines the angle where
  134869. * the directional falloff will start before cutting at angle which could be seen
  134870. * as outer angle.
  134871. */
  134872. get innerAngle(): number;
  134873. /**
  134874. * Only used in gltf falloff mode, this defines the angle where
  134875. * the directional falloff will start before cutting at angle which could be seen
  134876. * as outer angle.
  134877. */
  134878. set innerAngle(value: number);
  134879. private _shadowAngleScale;
  134880. /**
  134881. * Allows scaling the angle of the light for shadow generation only.
  134882. */
  134883. get shadowAngleScale(): number;
  134884. /**
  134885. * Allows scaling the angle of the light for shadow generation only.
  134886. */
  134887. set shadowAngleScale(value: number);
  134888. /**
  134889. * The light decay speed with the distance from the emission spot.
  134890. */
  134891. exponent: number;
  134892. private _projectionTextureMatrix;
  134893. /**
  134894. * Allows reading the projecton texture
  134895. */
  134896. get projectionTextureMatrix(): Matrix;
  134897. protected _projectionTextureLightNear: number;
  134898. /**
  134899. * Gets the near clip of the Spotlight for texture projection.
  134900. */
  134901. get projectionTextureLightNear(): number;
  134902. /**
  134903. * Sets the near clip of the Spotlight for texture projection.
  134904. */
  134905. set projectionTextureLightNear(value: number);
  134906. protected _projectionTextureLightFar: number;
  134907. /**
  134908. * Gets the far clip of the Spotlight for texture projection.
  134909. */
  134910. get projectionTextureLightFar(): number;
  134911. /**
  134912. * Sets the far clip of the Spotlight for texture projection.
  134913. */
  134914. set projectionTextureLightFar(value: number);
  134915. protected _projectionTextureUpDirection: Vector3;
  134916. /**
  134917. * Gets the Up vector of the Spotlight for texture projection.
  134918. */
  134919. get projectionTextureUpDirection(): Vector3;
  134920. /**
  134921. * Sets the Up vector of the Spotlight for texture projection.
  134922. */
  134923. set projectionTextureUpDirection(value: Vector3);
  134924. private _projectionTexture;
  134925. /**
  134926. * Gets the projection texture of the light.
  134927. */
  134928. get projectionTexture(): Nullable<BaseTexture>;
  134929. /**
  134930. * Sets the projection texture of the light.
  134931. */
  134932. set projectionTexture(value: Nullable<BaseTexture>);
  134933. private _projectionTextureViewLightDirty;
  134934. private _projectionTextureProjectionLightDirty;
  134935. private _projectionTextureDirty;
  134936. private _projectionTextureViewTargetVector;
  134937. private _projectionTextureViewLightMatrix;
  134938. private _projectionTextureProjectionLightMatrix;
  134939. private _projectionTextureScalingMatrix;
  134940. /**
  134941. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134942. * It can cast shadows.
  134943. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134944. * @param name The light friendly name
  134945. * @param position The position of the spot light in the scene
  134946. * @param direction The direction of the light in the scene
  134947. * @param angle The cone angle of the light in Radians
  134948. * @param exponent The light decay speed with the distance from the emission spot
  134949. * @param scene The scene the lights belongs to
  134950. */
  134951. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134952. /**
  134953. * Returns the string "SpotLight".
  134954. * @returns the class name
  134955. */
  134956. getClassName(): string;
  134957. /**
  134958. * Returns the integer 2.
  134959. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134960. */
  134961. getTypeID(): number;
  134962. /**
  134963. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134964. */
  134965. protected _setDirection(value: Vector3): void;
  134966. /**
  134967. * Overrides the position setter to recompute the projection texture view light Matrix.
  134968. */
  134969. protected _setPosition(value: Vector3): void;
  134970. /**
  134971. * 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.
  134972. * Returns the SpotLight.
  134973. */
  134974. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134975. protected _computeProjectionTextureViewLightMatrix(): void;
  134976. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134977. /**
  134978. * Main function for light texture projection matrix computing.
  134979. */
  134980. protected _computeProjectionTextureMatrix(): void;
  134981. protected _buildUniformLayout(): void;
  134982. private _computeAngleValues;
  134983. /**
  134984. * Sets the passed Effect "effect" with the Light textures.
  134985. * @param effect The effect to update
  134986. * @param lightIndex The index of the light in the effect to update
  134987. * @returns The light
  134988. */
  134989. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134990. /**
  134991. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134992. * @param effect The effect to update
  134993. * @param lightIndex The index of the light in the effect to update
  134994. * @returns The spot light
  134995. */
  134996. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134997. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134998. /**
  134999. * Disposes the light and the associated resources.
  135000. */
  135001. dispose(): void;
  135002. /**
  135003. * Prepares the list of defines specific to the light type.
  135004. * @param defines the list of defines
  135005. * @param lightIndex defines the index of the light for the effect
  135006. */
  135007. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135008. }
  135009. }
  135010. declare module BABYLON {
  135011. /**
  135012. * Gizmo that enables viewing a light
  135013. */
  135014. export class LightGizmo extends Gizmo {
  135015. private _lightMesh;
  135016. private _material;
  135017. private _cachedPosition;
  135018. private _cachedForward;
  135019. private _attachedMeshParent;
  135020. private _pointerObserver;
  135021. /**
  135022. * Event that fires each time the gizmo is clicked
  135023. */
  135024. onClickedObservable: Observable<Light>;
  135025. /**
  135026. * Creates a LightGizmo
  135027. * @param gizmoLayer The utility layer the gizmo will be added to
  135028. */
  135029. constructor(gizmoLayer?: UtilityLayerRenderer);
  135030. private _light;
  135031. /**
  135032. * The light that the gizmo is attached to
  135033. */
  135034. set light(light: Nullable<Light>);
  135035. get light(): Nullable<Light>;
  135036. /**
  135037. * Gets the material used to render the light gizmo
  135038. */
  135039. get material(): StandardMaterial;
  135040. /**
  135041. * @hidden
  135042. * Updates the gizmo to match the attached mesh's position/rotation
  135043. */
  135044. protected _update(): void;
  135045. private static _Scale;
  135046. /**
  135047. * Creates the lines for a light mesh
  135048. */
  135049. private static _CreateLightLines;
  135050. /**
  135051. * Disposes of the light gizmo
  135052. */
  135053. dispose(): void;
  135054. private static _CreateHemisphericLightMesh;
  135055. private static _CreatePointLightMesh;
  135056. private static _CreateSpotLightMesh;
  135057. private static _CreateDirectionalLightMesh;
  135058. }
  135059. }
  135060. declare module BABYLON {
  135061. /**
  135062. * Gizmo that enables viewing a camera
  135063. */
  135064. export class CameraGizmo extends Gizmo {
  135065. private _cameraMesh;
  135066. private _cameraLinesMesh;
  135067. private _material;
  135068. private _pointerObserver;
  135069. /**
  135070. * Event that fires each time the gizmo is clicked
  135071. */
  135072. onClickedObservable: Observable<Camera>;
  135073. /**
  135074. * Creates a CameraGizmo
  135075. * @param gizmoLayer The utility layer the gizmo will be added to
  135076. */
  135077. constructor(gizmoLayer?: UtilityLayerRenderer);
  135078. private _camera;
  135079. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  135080. get displayFrustum(): boolean;
  135081. set displayFrustum(value: boolean);
  135082. /**
  135083. * The camera that the gizmo is attached to
  135084. */
  135085. set camera(camera: Nullable<Camera>);
  135086. get camera(): Nullable<Camera>;
  135087. /**
  135088. * Gets the material used to render the camera gizmo
  135089. */
  135090. get material(): StandardMaterial;
  135091. /**
  135092. * @hidden
  135093. * Updates the gizmo to match the attached mesh's position/rotation
  135094. */
  135095. protected _update(): void;
  135096. private static _Scale;
  135097. private _invProjection;
  135098. /**
  135099. * Disposes of the camera gizmo
  135100. */
  135101. dispose(): void;
  135102. private static _CreateCameraMesh;
  135103. private static _CreateCameraFrustum;
  135104. }
  135105. }
  135106. declare module BABYLON {
  135107. /** @hidden */
  135108. export var backgroundFragmentDeclaration: {
  135109. name: string;
  135110. shader: string;
  135111. };
  135112. }
  135113. declare module BABYLON {
  135114. /** @hidden */
  135115. export var backgroundUboDeclaration: {
  135116. name: string;
  135117. shader: string;
  135118. };
  135119. }
  135120. declare module BABYLON {
  135121. /** @hidden */
  135122. export var backgroundPixelShader: {
  135123. name: string;
  135124. shader: string;
  135125. };
  135126. }
  135127. declare module BABYLON {
  135128. /** @hidden */
  135129. export var backgroundVertexDeclaration: {
  135130. name: string;
  135131. shader: string;
  135132. };
  135133. }
  135134. declare module BABYLON {
  135135. /** @hidden */
  135136. export var backgroundVertexShader: {
  135137. name: string;
  135138. shader: string;
  135139. };
  135140. }
  135141. declare module BABYLON {
  135142. /**
  135143. * Background material used to create an efficient environement around your scene.
  135144. */
  135145. export class BackgroundMaterial extends PushMaterial {
  135146. /**
  135147. * Standard reflectance value at parallel view angle.
  135148. */
  135149. static StandardReflectance0: number;
  135150. /**
  135151. * Standard reflectance value at grazing angle.
  135152. */
  135153. static StandardReflectance90: number;
  135154. protected _primaryColor: Color3;
  135155. /**
  135156. * Key light Color (multiply against the environement texture)
  135157. */
  135158. primaryColor: Color3;
  135159. protected __perceptualColor: Nullable<Color3>;
  135160. /**
  135161. * Experimental Internal Use Only.
  135162. *
  135163. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  135164. * This acts as a helper to set the primary color to a more "human friendly" value.
  135165. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  135166. * output color as close as possible from the chosen value.
  135167. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  135168. * part of lighting setup.)
  135169. */
  135170. get _perceptualColor(): Nullable<Color3>;
  135171. set _perceptualColor(value: Nullable<Color3>);
  135172. protected _primaryColorShadowLevel: float;
  135173. /**
  135174. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  135175. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  135176. */
  135177. get primaryColorShadowLevel(): float;
  135178. set primaryColorShadowLevel(value: float);
  135179. protected _primaryColorHighlightLevel: float;
  135180. /**
  135181. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  135182. * The primary color is used at the level chosen to define what the white area would look.
  135183. */
  135184. get primaryColorHighlightLevel(): float;
  135185. set primaryColorHighlightLevel(value: float);
  135186. protected _reflectionTexture: Nullable<BaseTexture>;
  135187. /**
  135188. * Reflection Texture used in the material.
  135189. * Should be author in a specific way for the best result (refer to the documentation).
  135190. */
  135191. reflectionTexture: Nullable<BaseTexture>;
  135192. protected _reflectionBlur: float;
  135193. /**
  135194. * Reflection Texture level of blur.
  135195. *
  135196. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  135197. * texture twice.
  135198. */
  135199. reflectionBlur: float;
  135200. protected _diffuseTexture: Nullable<BaseTexture>;
  135201. /**
  135202. * Diffuse Texture used in the material.
  135203. * Should be author in a specific way for the best result (refer to the documentation).
  135204. */
  135205. diffuseTexture: Nullable<BaseTexture>;
  135206. protected _shadowLights: Nullable<IShadowLight[]>;
  135207. /**
  135208. * Specify the list of lights casting shadow on the material.
  135209. * All scene shadow lights will be included if null.
  135210. */
  135211. shadowLights: Nullable<IShadowLight[]>;
  135212. protected _shadowLevel: float;
  135213. /**
  135214. * Helps adjusting the shadow to a softer level if required.
  135215. * 0 means black shadows and 1 means no shadows.
  135216. */
  135217. shadowLevel: float;
  135218. protected _sceneCenter: Vector3;
  135219. /**
  135220. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  135221. * It is usually zero but might be interesting to modify according to your setup.
  135222. */
  135223. sceneCenter: Vector3;
  135224. protected _opacityFresnel: boolean;
  135225. /**
  135226. * This helps specifying that the material is falling off to the sky box at grazing angle.
  135227. * This helps ensuring a nice transition when the camera goes under the ground.
  135228. */
  135229. opacityFresnel: boolean;
  135230. protected _reflectionFresnel: boolean;
  135231. /**
  135232. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  135233. * This helps adding a mirror texture on the ground.
  135234. */
  135235. reflectionFresnel: boolean;
  135236. protected _reflectionFalloffDistance: number;
  135237. /**
  135238. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  135239. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  135240. */
  135241. reflectionFalloffDistance: number;
  135242. protected _reflectionAmount: number;
  135243. /**
  135244. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  135245. */
  135246. reflectionAmount: number;
  135247. protected _reflectionReflectance0: number;
  135248. /**
  135249. * This specifies the weight of the reflection at grazing angle.
  135250. */
  135251. reflectionReflectance0: number;
  135252. protected _reflectionReflectance90: number;
  135253. /**
  135254. * This specifies the weight of the reflection at a perpendicular point of view.
  135255. */
  135256. reflectionReflectance90: number;
  135257. /**
  135258. * Sets the reflection reflectance fresnel values according to the default standard
  135259. * empirically know to work well :-)
  135260. */
  135261. set reflectionStandardFresnelWeight(value: number);
  135262. protected _useRGBColor: boolean;
  135263. /**
  135264. * Helps to directly use the maps channels instead of their level.
  135265. */
  135266. useRGBColor: boolean;
  135267. protected _enableNoise: boolean;
  135268. /**
  135269. * This helps reducing the banding effect that could occur on the background.
  135270. */
  135271. enableNoise: boolean;
  135272. /**
  135273. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135274. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  135275. * Recommended to be keep at 1.0 except for special cases.
  135276. */
  135277. get fovMultiplier(): number;
  135278. set fovMultiplier(value: number);
  135279. private _fovMultiplier;
  135280. /**
  135281. * Enable the FOV adjustment feature controlled by fovMultiplier.
  135282. */
  135283. useEquirectangularFOV: boolean;
  135284. private _maxSimultaneousLights;
  135285. /**
  135286. * Number of Simultaneous lights allowed on the material.
  135287. */
  135288. maxSimultaneousLights: int;
  135289. private _shadowOnly;
  135290. /**
  135291. * Make the material only render shadows
  135292. */
  135293. shadowOnly: boolean;
  135294. /**
  135295. * Default configuration related to image processing available in the Background Material.
  135296. */
  135297. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135298. /**
  135299. * Keep track of the image processing observer to allow dispose and replace.
  135300. */
  135301. private _imageProcessingObserver;
  135302. /**
  135303. * Attaches a new image processing configuration to the PBR Material.
  135304. * @param configuration (if null the scene configuration will be use)
  135305. */
  135306. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135307. /**
  135308. * Gets the image processing configuration used either in this material.
  135309. */
  135310. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  135311. /**
  135312. * Sets the Default image processing configuration used either in the this material.
  135313. *
  135314. * If sets to null, the scene one is in use.
  135315. */
  135316. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135317. /**
  135318. * Gets wether the color curves effect is enabled.
  135319. */
  135320. get cameraColorCurvesEnabled(): boolean;
  135321. /**
  135322. * Sets wether the color curves effect is enabled.
  135323. */
  135324. set cameraColorCurvesEnabled(value: boolean);
  135325. /**
  135326. * Gets wether the color grading effect is enabled.
  135327. */
  135328. get cameraColorGradingEnabled(): boolean;
  135329. /**
  135330. * Gets wether the color grading effect is enabled.
  135331. */
  135332. set cameraColorGradingEnabled(value: boolean);
  135333. /**
  135334. * Gets wether tonemapping is enabled or not.
  135335. */
  135336. get cameraToneMappingEnabled(): boolean;
  135337. /**
  135338. * Sets wether tonemapping is enabled or not
  135339. */
  135340. set cameraToneMappingEnabled(value: boolean);
  135341. /**
  135342. * The camera exposure used on this material.
  135343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135344. * This corresponds to a photographic exposure.
  135345. */
  135346. get cameraExposure(): float;
  135347. /**
  135348. * The camera exposure used on this material.
  135349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135350. * This corresponds to a photographic exposure.
  135351. */
  135352. set cameraExposure(value: float);
  135353. /**
  135354. * Gets The camera contrast used on this material.
  135355. */
  135356. get cameraContrast(): float;
  135357. /**
  135358. * Sets The camera contrast used on this material.
  135359. */
  135360. set cameraContrast(value: float);
  135361. /**
  135362. * Gets the Color Grading 2D Lookup Texture.
  135363. */
  135364. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135365. /**
  135366. * Sets the Color Grading 2D Lookup Texture.
  135367. */
  135368. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135369. /**
  135370. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135371. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135372. * 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;
  135373. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135374. */
  135375. get cameraColorCurves(): Nullable<ColorCurves>;
  135376. /**
  135377. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135378. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135379. * 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;
  135380. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135381. */
  135382. set cameraColorCurves(value: Nullable<ColorCurves>);
  135383. /**
  135384. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135385. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135386. */
  135387. switchToBGR: boolean;
  135388. private _renderTargets;
  135389. private _reflectionControls;
  135390. private _white;
  135391. private _primaryShadowColor;
  135392. private _primaryHighlightColor;
  135393. /**
  135394. * Instantiates a Background Material in the given scene
  135395. * @param name The friendly name of the material
  135396. * @param scene The scene to add the material to
  135397. */
  135398. constructor(name: string, scene: Scene);
  135399. /**
  135400. * Gets a boolean indicating that current material needs to register RTT
  135401. */
  135402. get hasRenderTargetTextures(): boolean;
  135403. /**
  135404. * The entire material has been created in order to prevent overdraw.
  135405. * @returns false
  135406. */
  135407. needAlphaTesting(): boolean;
  135408. /**
  135409. * The entire material has been created in order to prevent overdraw.
  135410. * @returns true if blending is enable
  135411. */
  135412. needAlphaBlending(): boolean;
  135413. /**
  135414. * Checks wether the material is ready to be rendered for a given mesh.
  135415. * @param mesh The mesh to render
  135416. * @param subMesh The submesh to check against
  135417. * @param useInstances Specify wether or not the material is used with instances
  135418. * @returns true if all the dependencies are ready (Textures, Effects...)
  135419. */
  135420. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135421. /**
  135422. * Compute the primary color according to the chosen perceptual color.
  135423. */
  135424. private _computePrimaryColorFromPerceptualColor;
  135425. /**
  135426. * Compute the highlights and shadow colors according to their chosen levels.
  135427. */
  135428. private _computePrimaryColors;
  135429. /**
  135430. * Build the uniform buffer used in the material.
  135431. */
  135432. buildUniformLayout(): void;
  135433. /**
  135434. * Unbind the material.
  135435. */
  135436. unbind(): void;
  135437. /**
  135438. * Bind only the world matrix to the material.
  135439. * @param world The world matrix to bind.
  135440. */
  135441. bindOnlyWorldMatrix(world: Matrix): void;
  135442. /**
  135443. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135444. * @param world The world matrix to bind.
  135445. * @param subMesh The submesh to bind for.
  135446. */
  135447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135448. /**
  135449. * Checks to see if a texture is used in the material.
  135450. * @param texture - Base texture to use.
  135451. * @returns - Boolean specifying if a texture is used in the material.
  135452. */
  135453. hasTexture(texture: BaseTexture): boolean;
  135454. /**
  135455. * Dispose the material.
  135456. * @param forceDisposeEffect Force disposal of the associated effect.
  135457. * @param forceDisposeTextures Force disposal of the associated textures.
  135458. */
  135459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135460. /**
  135461. * Clones the material.
  135462. * @param name The cloned name.
  135463. * @returns The cloned material.
  135464. */
  135465. clone(name: string): BackgroundMaterial;
  135466. /**
  135467. * Serializes the current material to its JSON representation.
  135468. * @returns The JSON representation.
  135469. */
  135470. serialize(): any;
  135471. /**
  135472. * Gets the class name of the material
  135473. * @returns "BackgroundMaterial"
  135474. */
  135475. getClassName(): string;
  135476. /**
  135477. * Parse a JSON input to create back a background material.
  135478. * @param source The JSON data to parse
  135479. * @param scene The scene to create the parsed material in
  135480. * @param rootUrl The root url of the assets the material depends upon
  135481. * @returns the instantiated BackgroundMaterial.
  135482. */
  135483. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135484. }
  135485. }
  135486. declare module BABYLON {
  135487. /**
  135488. * Represents the different options available during the creation of
  135489. * a Environment helper.
  135490. *
  135491. * This can control the default ground, skybox and image processing setup of your scene.
  135492. */
  135493. export interface IEnvironmentHelperOptions {
  135494. /**
  135495. * Specifies whether or not to create a ground.
  135496. * True by default.
  135497. */
  135498. createGround: boolean;
  135499. /**
  135500. * Specifies the ground size.
  135501. * 15 by default.
  135502. */
  135503. groundSize: number;
  135504. /**
  135505. * The texture used on the ground for the main color.
  135506. * Comes from the BabylonJS CDN by default.
  135507. *
  135508. * Remarks: Can be either a texture or a url.
  135509. */
  135510. groundTexture: string | BaseTexture;
  135511. /**
  135512. * The color mixed in the ground texture by default.
  135513. * BabylonJS clearColor by default.
  135514. */
  135515. groundColor: Color3;
  135516. /**
  135517. * Specifies the ground opacity.
  135518. * 1 by default.
  135519. */
  135520. groundOpacity: number;
  135521. /**
  135522. * Enables the ground to receive shadows.
  135523. * True by default.
  135524. */
  135525. enableGroundShadow: boolean;
  135526. /**
  135527. * Helps preventing the shadow to be fully black on the ground.
  135528. * 0.5 by default.
  135529. */
  135530. groundShadowLevel: number;
  135531. /**
  135532. * Creates a mirror texture attach to the ground.
  135533. * false by default.
  135534. */
  135535. enableGroundMirror: boolean;
  135536. /**
  135537. * Specifies the ground mirror size ratio.
  135538. * 0.3 by default as the default kernel is 64.
  135539. */
  135540. groundMirrorSizeRatio: number;
  135541. /**
  135542. * Specifies the ground mirror blur kernel size.
  135543. * 64 by default.
  135544. */
  135545. groundMirrorBlurKernel: number;
  135546. /**
  135547. * Specifies the ground mirror visibility amount.
  135548. * 1 by default
  135549. */
  135550. groundMirrorAmount: number;
  135551. /**
  135552. * Specifies the ground mirror reflectance weight.
  135553. * This uses the standard weight of the background material to setup the fresnel effect
  135554. * of the mirror.
  135555. * 1 by default.
  135556. */
  135557. groundMirrorFresnelWeight: number;
  135558. /**
  135559. * Specifies the ground mirror Falloff distance.
  135560. * This can helps reducing the size of the reflection.
  135561. * 0 by Default.
  135562. */
  135563. groundMirrorFallOffDistance: number;
  135564. /**
  135565. * Specifies the ground mirror texture type.
  135566. * Unsigned Int by Default.
  135567. */
  135568. groundMirrorTextureType: number;
  135569. /**
  135570. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135571. * the shown objects.
  135572. */
  135573. groundYBias: number;
  135574. /**
  135575. * Specifies whether or not to create a skybox.
  135576. * True by default.
  135577. */
  135578. createSkybox: boolean;
  135579. /**
  135580. * Specifies the skybox size.
  135581. * 20 by default.
  135582. */
  135583. skyboxSize: number;
  135584. /**
  135585. * The texture used on the skybox for the main color.
  135586. * Comes from the BabylonJS CDN by default.
  135587. *
  135588. * Remarks: Can be either a texture or a url.
  135589. */
  135590. skyboxTexture: string | BaseTexture;
  135591. /**
  135592. * The color mixed in the skybox texture by default.
  135593. * BabylonJS clearColor by default.
  135594. */
  135595. skyboxColor: Color3;
  135596. /**
  135597. * The background rotation around the Y axis of the scene.
  135598. * This helps aligning the key lights of your scene with the background.
  135599. * 0 by default.
  135600. */
  135601. backgroundYRotation: number;
  135602. /**
  135603. * Compute automatically the size of the elements to best fit with the scene.
  135604. */
  135605. sizeAuto: boolean;
  135606. /**
  135607. * Default position of the rootMesh if autoSize is not true.
  135608. */
  135609. rootPosition: Vector3;
  135610. /**
  135611. * Sets up the image processing in the scene.
  135612. * true by default.
  135613. */
  135614. setupImageProcessing: boolean;
  135615. /**
  135616. * The texture used as your environment texture in the scene.
  135617. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135618. *
  135619. * Remarks: Can be either a texture or a url.
  135620. */
  135621. environmentTexture: string | BaseTexture;
  135622. /**
  135623. * The value of the exposure to apply to the scene.
  135624. * 0.6 by default if setupImageProcessing is true.
  135625. */
  135626. cameraExposure: number;
  135627. /**
  135628. * The value of the contrast to apply to the scene.
  135629. * 1.6 by default if setupImageProcessing is true.
  135630. */
  135631. cameraContrast: number;
  135632. /**
  135633. * Specifies whether or not tonemapping should be enabled in the scene.
  135634. * true by default if setupImageProcessing is true.
  135635. */
  135636. toneMappingEnabled: boolean;
  135637. }
  135638. /**
  135639. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135640. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135641. * It also helps with the default setup of your imageProcessing configuration.
  135642. */
  135643. export class EnvironmentHelper {
  135644. /**
  135645. * Default ground texture URL.
  135646. */
  135647. private static _groundTextureCDNUrl;
  135648. /**
  135649. * Default skybox texture URL.
  135650. */
  135651. private static _skyboxTextureCDNUrl;
  135652. /**
  135653. * Default environment texture URL.
  135654. */
  135655. private static _environmentTextureCDNUrl;
  135656. /**
  135657. * Creates the default options for the helper.
  135658. */
  135659. private static _getDefaultOptions;
  135660. private _rootMesh;
  135661. /**
  135662. * Gets the root mesh created by the helper.
  135663. */
  135664. get rootMesh(): Mesh;
  135665. private _skybox;
  135666. /**
  135667. * Gets the skybox created by the helper.
  135668. */
  135669. get skybox(): Nullable<Mesh>;
  135670. private _skyboxTexture;
  135671. /**
  135672. * Gets the skybox texture created by the helper.
  135673. */
  135674. get skyboxTexture(): Nullable<BaseTexture>;
  135675. private _skyboxMaterial;
  135676. /**
  135677. * Gets the skybox material created by the helper.
  135678. */
  135679. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135680. private _ground;
  135681. /**
  135682. * Gets the ground mesh created by the helper.
  135683. */
  135684. get ground(): Nullable<Mesh>;
  135685. private _groundTexture;
  135686. /**
  135687. * Gets the ground texture created by the helper.
  135688. */
  135689. get groundTexture(): Nullable<BaseTexture>;
  135690. private _groundMirror;
  135691. /**
  135692. * Gets the ground mirror created by the helper.
  135693. */
  135694. get groundMirror(): Nullable<MirrorTexture>;
  135695. /**
  135696. * Gets the ground mirror render list to helps pushing the meshes
  135697. * you wish in the ground reflection.
  135698. */
  135699. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135700. private _groundMaterial;
  135701. /**
  135702. * Gets the ground material created by the helper.
  135703. */
  135704. get groundMaterial(): Nullable<BackgroundMaterial>;
  135705. /**
  135706. * Stores the creation options.
  135707. */
  135708. private readonly _scene;
  135709. private _options;
  135710. /**
  135711. * This observable will be notified with any error during the creation of the environment,
  135712. * mainly texture creation errors.
  135713. */
  135714. onErrorObservable: Observable<{
  135715. message?: string;
  135716. exception?: any;
  135717. }>;
  135718. /**
  135719. * constructor
  135720. * @param options Defines the options we want to customize the helper
  135721. * @param scene The scene to add the material to
  135722. */
  135723. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135724. /**
  135725. * Updates the background according to the new options
  135726. * @param options
  135727. */
  135728. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135729. /**
  135730. * Sets the primary color of all the available elements.
  135731. * @param color the main color to affect to the ground and the background
  135732. */
  135733. setMainColor(color: Color3): void;
  135734. /**
  135735. * Setup the image processing according to the specified options.
  135736. */
  135737. private _setupImageProcessing;
  135738. /**
  135739. * Setup the environment texture according to the specified options.
  135740. */
  135741. private _setupEnvironmentTexture;
  135742. /**
  135743. * Setup the background according to the specified options.
  135744. */
  135745. private _setupBackground;
  135746. /**
  135747. * Get the scene sizes according to the setup.
  135748. */
  135749. private _getSceneSize;
  135750. /**
  135751. * Setup the ground according to the specified options.
  135752. */
  135753. private _setupGround;
  135754. /**
  135755. * Setup the ground material according to the specified options.
  135756. */
  135757. private _setupGroundMaterial;
  135758. /**
  135759. * Setup the ground diffuse texture according to the specified options.
  135760. */
  135761. private _setupGroundDiffuseTexture;
  135762. /**
  135763. * Setup the ground mirror texture according to the specified options.
  135764. */
  135765. private _setupGroundMirrorTexture;
  135766. /**
  135767. * Setup the ground to receive the mirror texture.
  135768. */
  135769. private _setupMirrorInGroundMaterial;
  135770. /**
  135771. * Setup the skybox according to the specified options.
  135772. */
  135773. private _setupSkybox;
  135774. /**
  135775. * Setup the skybox material according to the specified options.
  135776. */
  135777. private _setupSkyboxMaterial;
  135778. /**
  135779. * Setup the skybox reflection texture according to the specified options.
  135780. */
  135781. private _setupSkyboxReflectionTexture;
  135782. private _errorHandler;
  135783. /**
  135784. * Dispose all the elements created by the Helper.
  135785. */
  135786. dispose(): void;
  135787. }
  135788. }
  135789. declare module BABYLON {
  135790. /**
  135791. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135792. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135793. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135794. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135795. */
  135796. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135797. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135798. /**
  135799. * Define the source as a Monoscopic panoramic 360/180.
  135800. */
  135801. static readonly MODE_MONOSCOPIC: number;
  135802. /**
  135803. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135804. */
  135805. static readonly MODE_TOPBOTTOM: number;
  135806. /**
  135807. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135808. */
  135809. static readonly MODE_SIDEBYSIDE: number;
  135810. private _halfDome;
  135811. protected _useDirectMapping: boolean;
  135812. /**
  135813. * The texture being displayed on the sphere
  135814. */
  135815. protected _texture: T;
  135816. /**
  135817. * Gets the texture being displayed on the sphere
  135818. */
  135819. get texture(): T;
  135820. /**
  135821. * Sets the texture being displayed on the sphere
  135822. */
  135823. set texture(newTexture: T);
  135824. /**
  135825. * The skybox material
  135826. */
  135827. protected _material: BackgroundMaterial;
  135828. /**
  135829. * The surface used for the dome
  135830. */
  135831. protected _mesh: Mesh;
  135832. /**
  135833. * Gets the mesh used for the dome.
  135834. */
  135835. get mesh(): Mesh;
  135836. /**
  135837. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135838. */
  135839. private _halfDomeMask;
  135840. /**
  135841. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135842. * Also see the options.resolution property.
  135843. */
  135844. get fovMultiplier(): number;
  135845. set fovMultiplier(value: number);
  135846. protected _textureMode: number;
  135847. /**
  135848. * Gets or set the current texture mode for the texture. It can be:
  135849. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135850. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135851. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135852. */
  135853. get textureMode(): number;
  135854. /**
  135855. * Sets the current texture mode for the texture. It can be:
  135856. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135857. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135858. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135859. */
  135860. set textureMode(value: number);
  135861. /**
  135862. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135863. */
  135864. get halfDome(): boolean;
  135865. /**
  135866. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135867. */
  135868. set halfDome(enabled: boolean);
  135869. /**
  135870. * Oberserver used in Stereoscopic VR Mode.
  135871. */
  135872. private _onBeforeCameraRenderObserver;
  135873. /**
  135874. * Observable raised when an error occured while loading the 360 image
  135875. */
  135876. onLoadErrorObservable: Observable<string>;
  135877. /**
  135878. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135879. * @param name Element's name, child elements will append suffixes for their own names.
  135880. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135881. * @param options An object containing optional or exposed sub element properties
  135882. */
  135883. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135884. resolution?: number;
  135885. clickToPlay?: boolean;
  135886. autoPlay?: boolean;
  135887. loop?: boolean;
  135888. size?: number;
  135889. poster?: string;
  135890. faceForward?: boolean;
  135891. useDirectMapping?: boolean;
  135892. halfDomeMode?: boolean;
  135893. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135894. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135895. protected _changeTextureMode(value: number): void;
  135896. /**
  135897. * Releases resources associated with this node.
  135898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135900. */
  135901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135902. }
  135903. }
  135904. declare module BABYLON {
  135905. /**
  135906. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135907. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135908. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135909. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135910. */
  135911. export class PhotoDome extends TextureDome<Texture> {
  135912. /**
  135913. * Define the image as a Monoscopic panoramic 360 image.
  135914. */
  135915. static readonly MODE_MONOSCOPIC: number;
  135916. /**
  135917. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135918. */
  135919. static readonly MODE_TOPBOTTOM: number;
  135920. /**
  135921. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135922. */
  135923. static readonly MODE_SIDEBYSIDE: number;
  135924. /**
  135925. * Gets or sets the texture being displayed on the sphere
  135926. */
  135927. get photoTexture(): Texture;
  135928. /**
  135929. * sets the texture being displayed on the sphere
  135930. */
  135931. set photoTexture(value: Texture);
  135932. /**
  135933. * Gets the current video mode for the video. It can be:
  135934. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135935. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135936. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135937. */
  135938. get imageMode(): number;
  135939. /**
  135940. * Sets the current video mode for the video. It can be:
  135941. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135942. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135943. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135944. */
  135945. set imageMode(value: number);
  135946. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135947. }
  135948. }
  135949. declare module BABYLON {
  135950. /**
  135951. * Class used to host RGBD texture specific utilities
  135952. */
  135953. export class RGBDTextureTools {
  135954. /**
  135955. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135956. * @param texture the texture to expand.
  135957. */
  135958. static ExpandRGBDTexture(texture: Texture): void;
  135959. }
  135960. }
  135961. declare module BABYLON {
  135962. /**
  135963. * Class used to host texture specific utilities
  135964. */
  135965. export class BRDFTextureTools {
  135966. /**
  135967. * Prevents texture cache collision
  135968. */
  135969. private static _instanceNumber;
  135970. /**
  135971. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135972. * @param scene defines the hosting scene
  135973. * @returns the environment BRDF texture
  135974. */
  135975. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135976. private static _environmentBRDFBase64Texture;
  135977. }
  135978. }
  135979. declare module BABYLON {
  135980. /**
  135981. * @hidden
  135982. */
  135983. export interface IMaterialClearCoatDefines {
  135984. CLEARCOAT: boolean;
  135985. CLEARCOAT_DEFAULTIOR: boolean;
  135986. CLEARCOAT_TEXTURE: boolean;
  135987. CLEARCOAT_TEXTUREDIRECTUV: number;
  135988. CLEARCOAT_BUMP: boolean;
  135989. CLEARCOAT_BUMPDIRECTUV: number;
  135990. CLEARCOAT_REMAP_F0: boolean;
  135991. CLEARCOAT_TINT: boolean;
  135992. CLEARCOAT_TINT_TEXTURE: boolean;
  135993. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135994. /** @hidden */
  135995. _areTexturesDirty: boolean;
  135996. }
  135997. /**
  135998. * Define the code related to the clear coat parameters of the pbr material.
  135999. */
  136000. export class PBRClearCoatConfiguration {
  136001. /**
  136002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136003. * The default fits with a polyurethane material.
  136004. */
  136005. private static readonly _DefaultIndexOfRefraction;
  136006. private _isEnabled;
  136007. /**
  136008. * Defines if the clear coat is enabled in the material.
  136009. */
  136010. isEnabled: boolean;
  136011. /**
  136012. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  136013. */
  136014. intensity: number;
  136015. /**
  136016. * Defines the clear coat layer roughness.
  136017. */
  136018. roughness: number;
  136019. private _indexOfRefraction;
  136020. /**
  136021. * Defines the index of refraction of the clear coat.
  136022. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136023. * The default fits with a polyurethane material.
  136024. * Changing the default value is more performance intensive.
  136025. */
  136026. indexOfRefraction: number;
  136027. private _texture;
  136028. /**
  136029. * Stores the clear coat values in a texture.
  136030. */
  136031. texture: Nullable<BaseTexture>;
  136032. private _remapF0OnInterfaceChange;
  136033. /**
  136034. * Defines if the F0 value should be remapped to account for the interface change in the material.
  136035. */
  136036. remapF0OnInterfaceChange: boolean;
  136037. private _bumpTexture;
  136038. /**
  136039. * Define the clear coat specific bump texture.
  136040. */
  136041. bumpTexture: Nullable<BaseTexture>;
  136042. private _isTintEnabled;
  136043. /**
  136044. * Defines if the clear coat tint is enabled in the material.
  136045. */
  136046. isTintEnabled: boolean;
  136047. /**
  136048. * Defines the clear coat tint of the material.
  136049. * This is only use if tint is enabled
  136050. */
  136051. tintColor: Color3;
  136052. /**
  136053. * Defines the distance at which the tint color should be found in the
  136054. * clear coat media.
  136055. * This is only use if tint is enabled
  136056. */
  136057. tintColorAtDistance: number;
  136058. /**
  136059. * Defines the clear coat layer thickness.
  136060. * This is only use if tint is enabled
  136061. */
  136062. tintThickness: number;
  136063. private _tintTexture;
  136064. /**
  136065. * Stores the clear tint values in a texture.
  136066. * rgb is tint
  136067. * a is a thickness factor
  136068. */
  136069. tintTexture: Nullable<BaseTexture>;
  136070. /** @hidden */
  136071. private _internalMarkAllSubMeshesAsTexturesDirty;
  136072. /** @hidden */
  136073. _markAllSubMeshesAsTexturesDirty(): void;
  136074. /**
  136075. * Instantiate a new istance of clear coat configuration.
  136076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136077. */
  136078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136079. /**
  136080. * Gets wehter the submesh is ready to be used or not.
  136081. * @param defines the list of "defines" to update.
  136082. * @param scene defines the scene the material belongs to.
  136083. * @param engine defines the engine the material belongs to.
  136084. * @param disableBumpMap defines wether the material disables bump or not.
  136085. * @returns - boolean indicating that the submesh is ready or not.
  136086. */
  136087. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  136088. /**
  136089. * Checks to see if a texture is used in the material.
  136090. * @param defines the list of "defines" to update.
  136091. * @param scene defines the scene to the material belongs to.
  136092. */
  136093. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  136094. /**
  136095. * Binds the material data.
  136096. * @param uniformBuffer defines the Uniform buffer to fill in.
  136097. * @param scene defines the scene the material belongs to.
  136098. * @param engine defines the engine the material belongs to.
  136099. * @param disableBumpMap defines wether the material disables bump or not.
  136100. * @param isFrozen defines wether the material is frozen or not.
  136101. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136102. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136103. */
  136104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  136105. /**
  136106. * Checks to see if a texture is used in the material.
  136107. * @param texture - Base texture to use.
  136108. * @returns - Boolean specifying if a texture is used in the material.
  136109. */
  136110. hasTexture(texture: BaseTexture): boolean;
  136111. /**
  136112. * Returns an array of the actively used textures.
  136113. * @param activeTextures Array of BaseTextures
  136114. */
  136115. getActiveTextures(activeTextures: BaseTexture[]): void;
  136116. /**
  136117. * Returns the animatable textures.
  136118. * @param animatables Array of animatable textures.
  136119. */
  136120. getAnimatables(animatables: IAnimatable[]): void;
  136121. /**
  136122. * Disposes the resources of the material.
  136123. * @param forceDisposeTextures - Forces the disposal of all textures.
  136124. */
  136125. dispose(forceDisposeTextures?: boolean): void;
  136126. /**
  136127. * Get the current class name of the texture useful for serialization or dynamic coding.
  136128. * @returns "PBRClearCoatConfiguration"
  136129. */
  136130. getClassName(): string;
  136131. /**
  136132. * Add fallbacks to the effect fallbacks list.
  136133. * @param defines defines the Base texture to use.
  136134. * @param fallbacks defines the current fallback list.
  136135. * @param currentRank defines the current fallback rank.
  136136. * @returns the new fallback rank.
  136137. */
  136138. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136139. /**
  136140. * Add the required uniforms to the current list.
  136141. * @param uniforms defines the current uniform list.
  136142. */
  136143. static AddUniforms(uniforms: string[]): void;
  136144. /**
  136145. * Add the required samplers to the current list.
  136146. * @param samplers defines the current sampler list.
  136147. */
  136148. static AddSamplers(samplers: string[]): void;
  136149. /**
  136150. * Add the required uniforms to the current buffer.
  136151. * @param uniformBuffer defines the current uniform buffer.
  136152. */
  136153. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136154. /**
  136155. * Makes a duplicate of the current configuration into another one.
  136156. * @param clearCoatConfiguration define the config where to copy the info
  136157. */
  136158. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  136159. /**
  136160. * Serializes this clear coat configuration.
  136161. * @returns - An object with the serialized config.
  136162. */
  136163. serialize(): any;
  136164. /**
  136165. * Parses a anisotropy Configuration from a serialized object.
  136166. * @param source - Serialized object.
  136167. * @param scene Defines the scene we are parsing for
  136168. * @param rootUrl Defines the rootUrl to load from
  136169. */
  136170. parse(source: any, scene: Scene, rootUrl: string): void;
  136171. }
  136172. }
  136173. declare module BABYLON {
  136174. /**
  136175. * @hidden
  136176. */
  136177. export interface IMaterialAnisotropicDefines {
  136178. ANISOTROPIC: boolean;
  136179. ANISOTROPIC_TEXTURE: boolean;
  136180. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136181. MAINUV1: boolean;
  136182. _areTexturesDirty: boolean;
  136183. _needUVs: boolean;
  136184. }
  136185. /**
  136186. * Define the code related to the anisotropic parameters of the pbr material.
  136187. */
  136188. export class PBRAnisotropicConfiguration {
  136189. private _isEnabled;
  136190. /**
  136191. * Defines if the anisotropy is enabled in the material.
  136192. */
  136193. isEnabled: boolean;
  136194. /**
  136195. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  136196. */
  136197. intensity: number;
  136198. /**
  136199. * Defines if the effect is along the tangents, bitangents or in between.
  136200. * By default, the effect is "strectching" the highlights along the tangents.
  136201. */
  136202. direction: Vector2;
  136203. private _texture;
  136204. /**
  136205. * Stores the anisotropy values in a texture.
  136206. * rg is direction (like normal from -1 to 1)
  136207. * b is a intensity
  136208. */
  136209. texture: Nullable<BaseTexture>;
  136210. /** @hidden */
  136211. private _internalMarkAllSubMeshesAsTexturesDirty;
  136212. /** @hidden */
  136213. _markAllSubMeshesAsTexturesDirty(): void;
  136214. /**
  136215. * Instantiate a new istance of anisotropy configuration.
  136216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136217. */
  136218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136219. /**
  136220. * Specifies that the submesh is ready to be used.
  136221. * @param defines the list of "defines" to update.
  136222. * @param scene defines the scene the material belongs to.
  136223. * @returns - boolean indicating that the submesh is ready or not.
  136224. */
  136225. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  136226. /**
  136227. * Checks to see if a texture is used in the material.
  136228. * @param defines the list of "defines" to update.
  136229. * @param mesh the mesh we are preparing the defines for.
  136230. * @param scene defines the scene the material belongs to.
  136231. */
  136232. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  136233. /**
  136234. * Binds the material data.
  136235. * @param uniformBuffer defines the Uniform buffer to fill in.
  136236. * @param scene defines the scene the material belongs to.
  136237. * @param isFrozen defines wether the material is frozen or not.
  136238. */
  136239. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136240. /**
  136241. * Checks to see if a texture is used in the material.
  136242. * @param texture - Base texture to use.
  136243. * @returns - Boolean specifying if a texture is used in the material.
  136244. */
  136245. hasTexture(texture: BaseTexture): boolean;
  136246. /**
  136247. * Returns an array of the actively used textures.
  136248. * @param activeTextures Array of BaseTextures
  136249. */
  136250. getActiveTextures(activeTextures: BaseTexture[]): void;
  136251. /**
  136252. * Returns the animatable textures.
  136253. * @param animatables Array of animatable textures.
  136254. */
  136255. getAnimatables(animatables: IAnimatable[]): void;
  136256. /**
  136257. * Disposes the resources of the material.
  136258. * @param forceDisposeTextures - Forces the disposal of all textures.
  136259. */
  136260. dispose(forceDisposeTextures?: boolean): void;
  136261. /**
  136262. * Get the current class name of the texture useful for serialization or dynamic coding.
  136263. * @returns "PBRAnisotropicConfiguration"
  136264. */
  136265. getClassName(): string;
  136266. /**
  136267. * Add fallbacks to the effect fallbacks list.
  136268. * @param defines defines the Base texture to use.
  136269. * @param fallbacks defines the current fallback list.
  136270. * @param currentRank defines the current fallback rank.
  136271. * @returns the new fallback rank.
  136272. */
  136273. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136274. /**
  136275. * Add the required uniforms to the current list.
  136276. * @param uniforms defines the current uniform list.
  136277. */
  136278. static AddUniforms(uniforms: string[]): void;
  136279. /**
  136280. * Add the required uniforms to the current buffer.
  136281. * @param uniformBuffer defines the current uniform buffer.
  136282. */
  136283. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136284. /**
  136285. * Add the required samplers to the current list.
  136286. * @param samplers defines the current sampler list.
  136287. */
  136288. static AddSamplers(samplers: string[]): void;
  136289. /**
  136290. * Makes a duplicate of the current configuration into another one.
  136291. * @param anisotropicConfiguration define the config where to copy the info
  136292. */
  136293. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  136294. /**
  136295. * Serializes this anisotropy configuration.
  136296. * @returns - An object with the serialized config.
  136297. */
  136298. serialize(): any;
  136299. /**
  136300. * Parses a anisotropy Configuration from a serialized object.
  136301. * @param source - Serialized object.
  136302. * @param scene Defines the scene we are parsing for
  136303. * @param rootUrl Defines the rootUrl to load from
  136304. */
  136305. parse(source: any, scene: Scene, rootUrl: string): void;
  136306. }
  136307. }
  136308. declare module BABYLON {
  136309. /**
  136310. * @hidden
  136311. */
  136312. export interface IMaterialBRDFDefines {
  136313. BRDF_V_HEIGHT_CORRELATED: boolean;
  136314. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136315. SPHERICAL_HARMONICS: boolean;
  136316. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136317. /** @hidden */
  136318. _areMiscDirty: boolean;
  136319. }
  136320. /**
  136321. * Define the code related to the BRDF parameters of the pbr material.
  136322. */
  136323. export class PBRBRDFConfiguration {
  136324. /**
  136325. * Default value used for the energy conservation.
  136326. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136327. */
  136328. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136329. /**
  136330. * Default value used for the Smith Visibility Height Correlated mode.
  136331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136332. */
  136333. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136334. /**
  136335. * Default value used for the IBL diffuse part.
  136336. * This can help switching back to the polynomials mode globally which is a tiny bit
  136337. * less GPU intensive at the drawback of a lower quality.
  136338. */
  136339. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136340. /**
  136341. * Default value used for activating energy conservation for the specular workflow.
  136342. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136343. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136344. */
  136345. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136346. private _useEnergyConservation;
  136347. /**
  136348. * Defines if the material uses energy conservation.
  136349. */
  136350. useEnergyConservation: boolean;
  136351. private _useSmithVisibilityHeightCorrelated;
  136352. /**
  136353. * LEGACY Mode set to false
  136354. * Defines if the material uses height smith correlated visibility term.
  136355. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136356. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136357. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136358. * Not relying on height correlated will also disable energy conservation.
  136359. */
  136360. useSmithVisibilityHeightCorrelated: boolean;
  136361. private _useSphericalHarmonics;
  136362. /**
  136363. * LEGACY Mode set to false
  136364. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136365. * diffuse part of the IBL.
  136366. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136367. * to the ground truth.
  136368. */
  136369. useSphericalHarmonics: boolean;
  136370. private _useSpecularGlossinessInputEnergyConservation;
  136371. /**
  136372. * Defines if the material uses energy conservation, when the specular workflow is active.
  136373. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136374. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136375. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136376. */
  136377. useSpecularGlossinessInputEnergyConservation: boolean;
  136378. /** @hidden */
  136379. private _internalMarkAllSubMeshesAsMiscDirty;
  136380. /** @hidden */
  136381. _markAllSubMeshesAsMiscDirty(): void;
  136382. /**
  136383. * Instantiate a new istance of clear coat configuration.
  136384. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136385. */
  136386. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136387. /**
  136388. * Checks to see if a texture is used in the material.
  136389. * @param defines the list of "defines" to update.
  136390. */
  136391. prepareDefines(defines: IMaterialBRDFDefines): void;
  136392. /**
  136393. * Get the current class name of the texture useful for serialization or dynamic coding.
  136394. * @returns "PBRClearCoatConfiguration"
  136395. */
  136396. getClassName(): string;
  136397. /**
  136398. * Makes a duplicate of the current configuration into another one.
  136399. * @param brdfConfiguration define the config where to copy the info
  136400. */
  136401. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136402. /**
  136403. * Serializes this BRDF configuration.
  136404. * @returns - An object with the serialized config.
  136405. */
  136406. serialize(): any;
  136407. /**
  136408. * Parses a anisotropy Configuration from a serialized object.
  136409. * @param source - Serialized object.
  136410. * @param scene Defines the scene we are parsing for
  136411. * @param rootUrl Defines the rootUrl to load from
  136412. */
  136413. parse(source: any, scene: Scene, rootUrl: string): void;
  136414. }
  136415. }
  136416. declare module BABYLON {
  136417. /**
  136418. * @hidden
  136419. */
  136420. export interface IMaterialSheenDefines {
  136421. SHEEN: boolean;
  136422. SHEEN_TEXTURE: boolean;
  136423. SHEEN_TEXTUREDIRECTUV: number;
  136424. SHEEN_LINKWITHALBEDO: boolean;
  136425. SHEEN_ROUGHNESS: boolean;
  136426. SHEEN_ALBEDOSCALING: boolean;
  136427. /** @hidden */
  136428. _areTexturesDirty: boolean;
  136429. }
  136430. /**
  136431. * Define the code related to the Sheen parameters of the pbr material.
  136432. */
  136433. export class PBRSheenConfiguration {
  136434. private _isEnabled;
  136435. /**
  136436. * Defines if the material uses sheen.
  136437. */
  136438. isEnabled: boolean;
  136439. private _linkSheenWithAlbedo;
  136440. /**
  136441. * Defines if the sheen is linked to the sheen color.
  136442. */
  136443. linkSheenWithAlbedo: boolean;
  136444. /**
  136445. * Defines the sheen intensity.
  136446. */
  136447. intensity: number;
  136448. /**
  136449. * Defines the sheen color.
  136450. */
  136451. color: Color3;
  136452. private _texture;
  136453. /**
  136454. * Stores the sheen tint values in a texture.
  136455. * rgb is tint
  136456. * a is a intensity or roughness if roughness has been defined
  136457. */
  136458. texture: Nullable<BaseTexture>;
  136459. private _roughness;
  136460. /**
  136461. * Defines the sheen roughness.
  136462. * It is not taken into account if linkSheenWithAlbedo is true.
  136463. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136464. */
  136465. roughness: Nullable<number>;
  136466. private _albedoScaling;
  136467. /**
  136468. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136469. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136470. * making it easier to setup and tweak the effect
  136471. */
  136472. albedoScaling: boolean;
  136473. /** @hidden */
  136474. private _internalMarkAllSubMeshesAsTexturesDirty;
  136475. /** @hidden */
  136476. _markAllSubMeshesAsTexturesDirty(): void;
  136477. /**
  136478. * Instantiate a new istance of clear coat configuration.
  136479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136480. */
  136481. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136482. /**
  136483. * Specifies that the submesh is ready to be used.
  136484. * @param defines the list of "defines" to update.
  136485. * @param scene defines the scene the material belongs to.
  136486. * @returns - boolean indicating that the submesh is ready or not.
  136487. */
  136488. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136489. /**
  136490. * Checks to see if a texture is used in the material.
  136491. * @param defines the list of "defines" to update.
  136492. * @param scene defines the scene the material belongs to.
  136493. */
  136494. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136495. /**
  136496. * Binds the material data.
  136497. * @param uniformBuffer defines the Uniform buffer to fill in.
  136498. * @param scene defines the scene the material belongs to.
  136499. * @param isFrozen defines wether the material is frozen or not.
  136500. */
  136501. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136502. /**
  136503. * Checks to see if a texture is used in the material.
  136504. * @param texture - Base texture to use.
  136505. * @returns - Boolean specifying if a texture is used in the material.
  136506. */
  136507. hasTexture(texture: BaseTexture): boolean;
  136508. /**
  136509. * Returns an array of the actively used textures.
  136510. * @param activeTextures Array of BaseTextures
  136511. */
  136512. getActiveTextures(activeTextures: BaseTexture[]): void;
  136513. /**
  136514. * Returns the animatable textures.
  136515. * @param animatables Array of animatable textures.
  136516. */
  136517. getAnimatables(animatables: IAnimatable[]): void;
  136518. /**
  136519. * Disposes the resources of the material.
  136520. * @param forceDisposeTextures - Forces the disposal of all textures.
  136521. */
  136522. dispose(forceDisposeTextures?: boolean): void;
  136523. /**
  136524. * Get the current class name of the texture useful for serialization or dynamic coding.
  136525. * @returns "PBRSheenConfiguration"
  136526. */
  136527. getClassName(): string;
  136528. /**
  136529. * Add fallbacks to the effect fallbacks list.
  136530. * @param defines defines the Base texture to use.
  136531. * @param fallbacks defines the current fallback list.
  136532. * @param currentRank defines the current fallback rank.
  136533. * @returns the new fallback rank.
  136534. */
  136535. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136536. /**
  136537. * Add the required uniforms to the current list.
  136538. * @param uniforms defines the current uniform list.
  136539. */
  136540. static AddUniforms(uniforms: string[]): void;
  136541. /**
  136542. * Add the required uniforms to the current buffer.
  136543. * @param uniformBuffer defines the current uniform buffer.
  136544. */
  136545. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136546. /**
  136547. * Add the required samplers to the current list.
  136548. * @param samplers defines the current sampler list.
  136549. */
  136550. static AddSamplers(samplers: string[]): void;
  136551. /**
  136552. * Makes a duplicate of the current configuration into another one.
  136553. * @param sheenConfiguration define the config where to copy the info
  136554. */
  136555. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136556. /**
  136557. * Serializes this BRDF configuration.
  136558. * @returns - An object with the serialized config.
  136559. */
  136560. serialize(): any;
  136561. /**
  136562. * Parses a anisotropy Configuration from a serialized object.
  136563. * @param source - Serialized object.
  136564. * @param scene Defines the scene we are parsing for
  136565. * @param rootUrl Defines the rootUrl to load from
  136566. */
  136567. parse(source: any, scene: Scene, rootUrl: string): void;
  136568. }
  136569. }
  136570. declare module BABYLON {
  136571. /**
  136572. * @hidden
  136573. */
  136574. export interface IMaterialSubSurfaceDefines {
  136575. SUBSURFACE: boolean;
  136576. SS_REFRACTION: boolean;
  136577. SS_TRANSLUCENCY: boolean;
  136578. SS_SCATTERING: boolean;
  136579. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136580. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136581. SS_REFRACTIONMAP_3D: boolean;
  136582. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136583. SS_LODINREFRACTIONALPHA: boolean;
  136584. SS_GAMMAREFRACTION: boolean;
  136585. SS_RGBDREFRACTION: boolean;
  136586. SS_LINEARSPECULARREFRACTION: boolean;
  136587. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136588. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136589. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136590. /** @hidden */
  136591. _areTexturesDirty: boolean;
  136592. }
  136593. /**
  136594. * Define the code related to the sub surface parameters of the pbr material.
  136595. */
  136596. export class PBRSubSurfaceConfiguration {
  136597. private _isRefractionEnabled;
  136598. /**
  136599. * Defines if the refraction is enabled in the material.
  136600. */
  136601. isRefractionEnabled: boolean;
  136602. private _isTranslucencyEnabled;
  136603. /**
  136604. * Defines if the translucency is enabled in the material.
  136605. */
  136606. isTranslucencyEnabled: boolean;
  136607. private _isScatteringEnabled;
  136608. /**
  136609. * Defines if the sub surface scattering is enabled in the material.
  136610. */
  136611. isScatteringEnabled: boolean;
  136612. private _scatteringDiffusionProfileIndex;
  136613. /**
  136614. * Diffusion profile for subsurface scattering.
  136615. * Useful for better scattering in the skins or foliages.
  136616. */
  136617. get scatteringDiffusionProfile(): Nullable<Color3>;
  136618. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136619. /**
  136620. * Defines the refraction intensity of the material.
  136621. * The refraction when enabled replaces the Diffuse part of the material.
  136622. * The intensity helps transitionning between diffuse and refraction.
  136623. */
  136624. refractionIntensity: number;
  136625. /**
  136626. * Defines the translucency intensity of the material.
  136627. * When translucency has been enabled, this defines how much of the "translucency"
  136628. * is addded to the diffuse part of the material.
  136629. */
  136630. translucencyIntensity: number;
  136631. /**
  136632. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136633. */
  136634. useAlbedoToTintRefraction: boolean;
  136635. private _thicknessTexture;
  136636. /**
  136637. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136638. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136639. * 0 would mean minimumThickness
  136640. * 1 would mean maximumThickness
  136641. * The other channels might be use as a mask to vary the different effects intensity.
  136642. */
  136643. thicknessTexture: Nullable<BaseTexture>;
  136644. private _refractionTexture;
  136645. /**
  136646. * Defines the texture to use for refraction.
  136647. */
  136648. refractionTexture: Nullable<BaseTexture>;
  136649. private _indexOfRefraction;
  136650. /**
  136651. * Index of refraction of the material base layer.
  136652. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136653. *
  136654. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136655. *
  136656. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136657. */
  136658. indexOfRefraction: number;
  136659. private _volumeIndexOfRefraction;
  136660. /**
  136661. * Index of refraction of the material's volume.
  136662. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136663. *
  136664. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136665. * the volume will use the same IOR as the surface.
  136666. */
  136667. get volumeIndexOfRefraction(): number;
  136668. set volumeIndexOfRefraction(value: number);
  136669. private _invertRefractionY;
  136670. /**
  136671. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136672. */
  136673. invertRefractionY: boolean;
  136674. private _linkRefractionWithTransparency;
  136675. /**
  136676. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136677. * Materials half opaque for instance using refraction could benefit from this control.
  136678. */
  136679. linkRefractionWithTransparency: boolean;
  136680. /**
  136681. * Defines the minimum thickness stored in the thickness map.
  136682. * If no thickness map is defined, this value will be used to simulate thickness.
  136683. */
  136684. minimumThickness: number;
  136685. /**
  136686. * Defines the maximum thickness stored in the thickness map.
  136687. */
  136688. maximumThickness: number;
  136689. /**
  136690. * Defines the volume tint of the material.
  136691. * This is used for both translucency and scattering.
  136692. */
  136693. tintColor: Color3;
  136694. /**
  136695. * Defines the distance at which the tint color should be found in the media.
  136696. * This is used for refraction only.
  136697. */
  136698. tintColorAtDistance: number;
  136699. /**
  136700. * Defines how far each channel transmit through the media.
  136701. * It is defined as a color to simplify it selection.
  136702. */
  136703. diffusionDistance: Color3;
  136704. private _useMaskFromThicknessTexture;
  136705. /**
  136706. * Stores the intensity of the different subsurface effects in the thickness texture.
  136707. * * the green channel is the translucency intensity.
  136708. * * the blue channel is the scattering intensity.
  136709. * * the alpha channel is the refraction intensity.
  136710. */
  136711. useMaskFromThicknessTexture: boolean;
  136712. private _scene;
  136713. /** @hidden */
  136714. private _internalMarkAllSubMeshesAsTexturesDirty;
  136715. private _internalMarkScenePrePassDirty;
  136716. /** @hidden */
  136717. _markAllSubMeshesAsTexturesDirty(): void;
  136718. /** @hidden */
  136719. _markScenePrePassDirty(): void;
  136720. /**
  136721. * Instantiate a new istance of sub surface configuration.
  136722. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136723. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136724. * @param scene The scene
  136725. */
  136726. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136727. /**
  136728. * Gets wehter the submesh is ready to be used or not.
  136729. * @param defines the list of "defines" to update.
  136730. * @param scene defines the scene the material belongs to.
  136731. * @returns - boolean indicating that the submesh is ready or not.
  136732. */
  136733. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136734. /**
  136735. * Checks to see if a texture is used in the material.
  136736. * @param defines the list of "defines" to update.
  136737. * @param scene defines the scene to the material belongs to.
  136738. */
  136739. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136740. /**
  136741. * Binds the material data.
  136742. * @param uniformBuffer defines the Uniform buffer to fill in.
  136743. * @param scene defines the scene the material belongs to.
  136744. * @param engine defines the engine the material belongs to.
  136745. * @param isFrozen defines whether the material is frozen or not.
  136746. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136747. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136748. */
  136749. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136750. /**
  136751. * Unbinds the material from the mesh.
  136752. * @param activeEffect defines the effect that should be unbound from.
  136753. * @returns true if unbound, otherwise false
  136754. */
  136755. unbind(activeEffect: Effect): boolean;
  136756. /**
  136757. * Returns the texture used for refraction or null if none is used.
  136758. * @param scene defines the scene the material belongs to.
  136759. * @returns - Refraction texture if present. If no refraction texture and refraction
  136760. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136761. */
  136762. private _getRefractionTexture;
  136763. /**
  136764. * Returns true if alpha blending should be disabled.
  136765. */
  136766. get disableAlphaBlending(): boolean;
  136767. /**
  136768. * Fills the list of render target textures.
  136769. * @param renderTargets the list of render targets to update
  136770. */
  136771. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136772. /**
  136773. * Checks to see if a texture is used in the material.
  136774. * @param texture - Base texture to use.
  136775. * @returns - Boolean specifying if a texture is used in the material.
  136776. */
  136777. hasTexture(texture: BaseTexture): boolean;
  136778. /**
  136779. * Gets a boolean indicating that current material needs to register RTT
  136780. * @returns true if this uses a render target otherwise false.
  136781. */
  136782. hasRenderTargetTextures(): boolean;
  136783. /**
  136784. * Returns an array of the actively used textures.
  136785. * @param activeTextures Array of BaseTextures
  136786. */
  136787. getActiveTextures(activeTextures: BaseTexture[]): void;
  136788. /**
  136789. * Returns the animatable textures.
  136790. * @param animatables Array of animatable textures.
  136791. */
  136792. getAnimatables(animatables: IAnimatable[]): void;
  136793. /**
  136794. * Disposes the resources of the material.
  136795. * @param forceDisposeTextures - Forces the disposal of all textures.
  136796. */
  136797. dispose(forceDisposeTextures?: boolean): void;
  136798. /**
  136799. * Get the current class name of the texture useful for serialization or dynamic coding.
  136800. * @returns "PBRSubSurfaceConfiguration"
  136801. */
  136802. getClassName(): string;
  136803. /**
  136804. * Add fallbacks to the effect fallbacks list.
  136805. * @param defines defines the Base texture to use.
  136806. * @param fallbacks defines the current fallback list.
  136807. * @param currentRank defines the current fallback rank.
  136808. * @returns the new fallback rank.
  136809. */
  136810. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136811. /**
  136812. * Add the required uniforms to the current list.
  136813. * @param uniforms defines the current uniform list.
  136814. */
  136815. static AddUniforms(uniforms: string[]): void;
  136816. /**
  136817. * Add the required samplers to the current list.
  136818. * @param samplers defines the current sampler list.
  136819. */
  136820. static AddSamplers(samplers: string[]): void;
  136821. /**
  136822. * Add the required uniforms to the current buffer.
  136823. * @param uniformBuffer defines the current uniform buffer.
  136824. */
  136825. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136826. /**
  136827. * Makes a duplicate of the current configuration into another one.
  136828. * @param configuration define the config where to copy the info
  136829. */
  136830. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136831. /**
  136832. * Serializes this Sub Surface configuration.
  136833. * @returns - An object with the serialized config.
  136834. */
  136835. serialize(): any;
  136836. /**
  136837. * Parses a anisotropy Configuration from a serialized object.
  136838. * @param source - Serialized object.
  136839. * @param scene Defines the scene we are parsing for
  136840. * @param rootUrl Defines the rootUrl to load from
  136841. */
  136842. parse(source: any, scene: Scene, rootUrl: string): void;
  136843. }
  136844. }
  136845. declare module BABYLON {
  136846. /** @hidden */
  136847. export var pbrFragmentDeclaration: {
  136848. name: string;
  136849. shader: string;
  136850. };
  136851. }
  136852. declare module BABYLON {
  136853. /** @hidden */
  136854. export var pbrUboDeclaration: {
  136855. name: string;
  136856. shader: string;
  136857. };
  136858. }
  136859. declare module BABYLON {
  136860. /** @hidden */
  136861. export var pbrFragmentExtraDeclaration: {
  136862. name: string;
  136863. shader: string;
  136864. };
  136865. }
  136866. declare module BABYLON {
  136867. /** @hidden */
  136868. export var pbrFragmentSamplersDeclaration: {
  136869. name: string;
  136870. shader: string;
  136871. };
  136872. }
  136873. declare module BABYLON {
  136874. /** @hidden */
  136875. export var subSurfaceScatteringFunctions: {
  136876. name: string;
  136877. shader: string;
  136878. };
  136879. }
  136880. declare module BABYLON {
  136881. /** @hidden */
  136882. export var importanceSampling: {
  136883. name: string;
  136884. shader: string;
  136885. };
  136886. }
  136887. declare module BABYLON {
  136888. /** @hidden */
  136889. export var pbrHelperFunctions: {
  136890. name: string;
  136891. shader: string;
  136892. };
  136893. }
  136894. declare module BABYLON {
  136895. /** @hidden */
  136896. export var harmonicsFunctions: {
  136897. name: string;
  136898. shader: string;
  136899. };
  136900. }
  136901. declare module BABYLON {
  136902. /** @hidden */
  136903. export var pbrDirectLightingSetupFunctions: {
  136904. name: string;
  136905. shader: string;
  136906. };
  136907. }
  136908. declare module BABYLON {
  136909. /** @hidden */
  136910. export var pbrDirectLightingFalloffFunctions: {
  136911. name: string;
  136912. shader: string;
  136913. };
  136914. }
  136915. declare module BABYLON {
  136916. /** @hidden */
  136917. export var pbrBRDFFunctions: {
  136918. name: string;
  136919. shader: string;
  136920. };
  136921. }
  136922. declare module BABYLON {
  136923. /** @hidden */
  136924. export var hdrFilteringFunctions: {
  136925. name: string;
  136926. shader: string;
  136927. };
  136928. }
  136929. declare module BABYLON {
  136930. /** @hidden */
  136931. export var pbrDirectLightingFunctions: {
  136932. name: string;
  136933. shader: string;
  136934. };
  136935. }
  136936. declare module BABYLON {
  136937. /** @hidden */
  136938. export var pbrIBLFunctions: {
  136939. name: string;
  136940. shader: string;
  136941. };
  136942. }
  136943. declare module BABYLON {
  136944. /** @hidden */
  136945. export var pbrBlockAlbedoOpacity: {
  136946. name: string;
  136947. shader: string;
  136948. };
  136949. }
  136950. declare module BABYLON {
  136951. /** @hidden */
  136952. export var pbrBlockReflectivity: {
  136953. name: string;
  136954. shader: string;
  136955. };
  136956. }
  136957. declare module BABYLON {
  136958. /** @hidden */
  136959. export var pbrBlockAmbientOcclusion: {
  136960. name: string;
  136961. shader: string;
  136962. };
  136963. }
  136964. declare module BABYLON {
  136965. /** @hidden */
  136966. export var pbrBlockAlphaFresnel: {
  136967. name: string;
  136968. shader: string;
  136969. };
  136970. }
  136971. declare module BABYLON {
  136972. /** @hidden */
  136973. export var pbrBlockAnisotropic: {
  136974. name: string;
  136975. shader: string;
  136976. };
  136977. }
  136978. declare module BABYLON {
  136979. /** @hidden */
  136980. export var pbrBlockReflection: {
  136981. name: string;
  136982. shader: string;
  136983. };
  136984. }
  136985. declare module BABYLON {
  136986. /** @hidden */
  136987. export var pbrBlockSheen: {
  136988. name: string;
  136989. shader: string;
  136990. };
  136991. }
  136992. declare module BABYLON {
  136993. /** @hidden */
  136994. export var pbrBlockClearcoat: {
  136995. name: string;
  136996. shader: string;
  136997. };
  136998. }
  136999. declare module BABYLON {
  137000. /** @hidden */
  137001. export var pbrBlockSubSurface: {
  137002. name: string;
  137003. shader: string;
  137004. };
  137005. }
  137006. declare module BABYLON {
  137007. /** @hidden */
  137008. export var pbrBlockNormalGeometric: {
  137009. name: string;
  137010. shader: string;
  137011. };
  137012. }
  137013. declare module BABYLON {
  137014. /** @hidden */
  137015. export var pbrBlockNormalFinal: {
  137016. name: string;
  137017. shader: string;
  137018. };
  137019. }
  137020. declare module BABYLON {
  137021. /** @hidden */
  137022. export var pbrBlockLightmapInit: {
  137023. name: string;
  137024. shader: string;
  137025. };
  137026. }
  137027. declare module BABYLON {
  137028. /** @hidden */
  137029. export var pbrBlockGeometryInfo: {
  137030. name: string;
  137031. shader: string;
  137032. };
  137033. }
  137034. declare module BABYLON {
  137035. /** @hidden */
  137036. export var pbrBlockReflectance0: {
  137037. name: string;
  137038. shader: string;
  137039. };
  137040. }
  137041. declare module BABYLON {
  137042. /** @hidden */
  137043. export var pbrBlockReflectance: {
  137044. name: string;
  137045. shader: string;
  137046. };
  137047. }
  137048. declare module BABYLON {
  137049. /** @hidden */
  137050. export var pbrBlockDirectLighting: {
  137051. name: string;
  137052. shader: string;
  137053. };
  137054. }
  137055. declare module BABYLON {
  137056. /** @hidden */
  137057. export var pbrBlockFinalLitComponents: {
  137058. name: string;
  137059. shader: string;
  137060. };
  137061. }
  137062. declare module BABYLON {
  137063. /** @hidden */
  137064. export var pbrBlockFinalUnlitComponents: {
  137065. name: string;
  137066. shader: string;
  137067. };
  137068. }
  137069. declare module BABYLON {
  137070. /** @hidden */
  137071. export var pbrBlockFinalColorComposition: {
  137072. name: string;
  137073. shader: string;
  137074. };
  137075. }
  137076. declare module BABYLON {
  137077. /** @hidden */
  137078. export var pbrBlockImageProcessing: {
  137079. name: string;
  137080. shader: string;
  137081. };
  137082. }
  137083. declare module BABYLON {
  137084. /** @hidden */
  137085. export var pbrDebug: {
  137086. name: string;
  137087. shader: string;
  137088. };
  137089. }
  137090. declare module BABYLON {
  137091. /** @hidden */
  137092. export var pbrPixelShader: {
  137093. name: string;
  137094. shader: string;
  137095. };
  137096. }
  137097. declare module BABYLON {
  137098. /** @hidden */
  137099. export var pbrVertexDeclaration: {
  137100. name: string;
  137101. shader: string;
  137102. };
  137103. }
  137104. declare module BABYLON {
  137105. /** @hidden */
  137106. export var pbrVertexShader: {
  137107. name: string;
  137108. shader: string;
  137109. };
  137110. }
  137111. declare module BABYLON {
  137112. /**
  137113. * Manages the defines for the PBR Material.
  137114. * @hidden
  137115. */
  137116. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  137117. PBR: boolean;
  137118. NUM_SAMPLES: string;
  137119. REALTIME_FILTERING: boolean;
  137120. MAINUV1: boolean;
  137121. MAINUV2: boolean;
  137122. UV1: boolean;
  137123. UV2: boolean;
  137124. ALBEDO: boolean;
  137125. GAMMAALBEDO: boolean;
  137126. ALBEDODIRECTUV: number;
  137127. VERTEXCOLOR: boolean;
  137128. DETAIL: boolean;
  137129. DETAILDIRECTUV: number;
  137130. DETAIL_NORMALBLENDMETHOD: number;
  137131. AMBIENT: boolean;
  137132. AMBIENTDIRECTUV: number;
  137133. AMBIENTINGRAYSCALE: boolean;
  137134. OPACITY: boolean;
  137135. VERTEXALPHA: boolean;
  137136. OPACITYDIRECTUV: number;
  137137. OPACITYRGB: boolean;
  137138. ALPHATEST: boolean;
  137139. DEPTHPREPASS: boolean;
  137140. ALPHABLEND: boolean;
  137141. ALPHAFROMALBEDO: boolean;
  137142. ALPHATESTVALUE: string;
  137143. SPECULAROVERALPHA: boolean;
  137144. RADIANCEOVERALPHA: boolean;
  137145. ALPHAFRESNEL: boolean;
  137146. LINEARALPHAFRESNEL: boolean;
  137147. PREMULTIPLYALPHA: boolean;
  137148. EMISSIVE: boolean;
  137149. EMISSIVEDIRECTUV: number;
  137150. REFLECTIVITY: boolean;
  137151. REFLECTIVITYDIRECTUV: number;
  137152. SPECULARTERM: boolean;
  137153. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  137154. MICROSURFACEAUTOMATIC: boolean;
  137155. LODBASEDMICROSFURACE: boolean;
  137156. MICROSURFACEMAP: boolean;
  137157. MICROSURFACEMAPDIRECTUV: number;
  137158. METALLICWORKFLOW: boolean;
  137159. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  137160. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  137161. METALLNESSSTOREINMETALMAPBLUE: boolean;
  137162. AOSTOREINMETALMAPRED: boolean;
  137163. METALLIC_REFLECTANCE: boolean;
  137164. METALLIC_REFLECTANCEDIRECTUV: number;
  137165. ENVIRONMENTBRDF: boolean;
  137166. ENVIRONMENTBRDF_RGBD: boolean;
  137167. NORMAL: boolean;
  137168. TANGENT: boolean;
  137169. BUMP: boolean;
  137170. BUMPDIRECTUV: number;
  137171. OBJECTSPACE_NORMALMAP: boolean;
  137172. PARALLAX: boolean;
  137173. PARALLAXOCCLUSION: boolean;
  137174. NORMALXYSCALE: boolean;
  137175. LIGHTMAP: boolean;
  137176. LIGHTMAPDIRECTUV: number;
  137177. USELIGHTMAPASSHADOWMAP: boolean;
  137178. GAMMALIGHTMAP: boolean;
  137179. RGBDLIGHTMAP: boolean;
  137180. REFLECTION: boolean;
  137181. REFLECTIONMAP_3D: boolean;
  137182. REFLECTIONMAP_SPHERICAL: boolean;
  137183. REFLECTIONMAP_PLANAR: boolean;
  137184. REFLECTIONMAP_CUBIC: boolean;
  137185. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  137186. REFLECTIONMAP_PROJECTION: boolean;
  137187. REFLECTIONMAP_SKYBOX: boolean;
  137188. REFLECTIONMAP_EXPLICIT: boolean;
  137189. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  137190. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  137191. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  137192. INVERTCUBICMAP: boolean;
  137193. USESPHERICALFROMREFLECTIONMAP: boolean;
  137194. USEIRRADIANCEMAP: boolean;
  137195. SPHERICAL_HARMONICS: boolean;
  137196. USESPHERICALINVERTEX: boolean;
  137197. REFLECTIONMAP_OPPOSITEZ: boolean;
  137198. LODINREFLECTIONALPHA: boolean;
  137199. GAMMAREFLECTION: boolean;
  137200. RGBDREFLECTION: boolean;
  137201. LINEARSPECULARREFLECTION: boolean;
  137202. RADIANCEOCCLUSION: boolean;
  137203. HORIZONOCCLUSION: boolean;
  137204. INSTANCES: boolean;
  137205. THIN_INSTANCES: boolean;
  137206. PREPASS: boolean;
  137207. PREPASS_IRRADIANCE: boolean;
  137208. PREPASS_IRRADIANCE_INDEX: number;
  137209. PREPASS_ALBEDO: boolean;
  137210. PREPASS_ALBEDO_INDEX: number;
  137211. PREPASS_DEPTHNORMAL: boolean;
  137212. PREPASS_DEPTHNORMAL_INDEX: number;
  137213. PREPASS_POSITION: boolean;
  137214. PREPASS_POSITION_INDEX: number;
  137215. PREPASS_VELOCITY: boolean;
  137216. PREPASS_VELOCITY_INDEX: number;
  137217. PREPASS_REFLECTIVITY: boolean;
  137218. PREPASS_REFLECTIVITY_INDEX: number;
  137219. SCENE_MRT_COUNT: number;
  137220. NUM_BONE_INFLUENCERS: number;
  137221. BonesPerMesh: number;
  137222. BONETEXTURE: boolean;
  137223. BONES_VELOCITY_ENABLED: boolean;
  137224. NONUNIFORMSCALING: boolean;
  137225. MORPHTARGETS: boolean;
  137226. MORPHTARGETS_NORMAL: boolean;
  137227. MORPHTARGETS_TANGENT: boolean;
  137228. MORPHTARGETS_UV: boolean;
  137229. NUM_MORPH_INFLUENCERS: number;
  137230. IMAGEPROCESSING: boolean;
  137231. VIGNETTE: boolean;
  137232. VIGNETTEBLENDMODEMULTIPLY: boolean;
  137233. VIGNETTEBLENDMODEOPAQUE: boolean;
  137234. TONEMAPPING: boolean;
  137235. TONEMAPPING_ACES: boolean;
  137236. CONTRAST: boolean;
  137237. COLORCURVES: boolean;
  137238. COLORGRADING: boolean;
  137239. COLORGRADING3D: boolean;
  137240. SAMPLER3DGREENDEPTH: boolean;
  137241. SAMPLER3DBGRMAP: boolean;
  137242. IMAGEPROCESSINGPOSTPROCESS: boolean;
  137243. EXPOSURE: boolean;
  137244. MULTIVIEW: boolean;
  137245. USEPHYSICALLIGHTFALLOFF: boolean;
  137246. USEGLTFLIGHTFALLOFF: boolean;
  137247. TWOSIDEDLIGHTING: boolean;
  137248. SHADOWFLOAT: boolean;
  137249. CLIPPLANE: boolean;
  137250. CLIPPLANE2: boolean;
  137251. CLIPPLANE3: boolean;
  137252. CLIPPLANE4: boolean;
  137253. CLIPPLANE5: boolean;
  137254. CLIPPLANE6: boolean;
  137255. POINTSIZE: boolean;
  137256. FOG: boolean;
  137257. LOGARITHMICDEPTH: boolean;
  137258. FORCENORMALFORWARD: boolean;
  137259. SPECULARAA: boolean;
  137260. CLEARCOAT: boolean;
  137261. CLEARCOAT_DEFAULTIOR: boolean;
  137262. CLEARCOAT_TEXTURE: boolean;
  137263. CLEARCOAT_TEXTUREDIRECTUV: number;
  137264. CLEARCOAT_BUMP: boolean;
  137265. CLEARCOAT_BUMPDIRECTUV: number;
  137266. CLEARCOAT_REMAP_F0: boolean;
  137267. CLEARCOAT_TINT: boolean;
  137268. CLEARCOAT_TINT_TEXTURE: boolean;
  137269. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  137270. ANISOTROPIC: boolean;
  137271. ANISOTROPIC_TEXTURE: boolean;
  137272. ANISOTROPIC_TEXTUREDIRECTUV: number;
  137273. BRDF_V_HEIGHT_CORRELATED: boolean;
  137274. MS_BRDF_ENERGY_CONSERVATION: boolean;
  137275. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  137276. SHEEN: boolean;
  137277. SHEEN_TEXTURE: boolean;
  137278. SHEEN_TEXTUREDIRECTUV: number;
  137279. SHEEN_LINKWITHALBEDO: boolean;
  137280. SHEEN_ROUGHNESS: boolean;
  137281. SHEEN_ALBEDOSCALING: boolean;
  137282. SUBSURFACE: boolean;
  137283. SS_REFRACTION: boolean;
  137284. SS_TRANSLUCENCY: boolean;
  137285. SS_SCATTERING: boolean;
  137286. SS_THICKNESSANDMASK_TEXTURE: boolean;
  137287. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  137288. SS_REFRACTIONMAP_3D: boolean;
  137289. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  137290. SS_LODINREFRACTIONALPHA: boolean;
  137291. SS_GAMMAREFRACTION: boolean;
  137292. SS_RGBDREFRACTION: boolean;
  137293. SS_LINEARSPECULARREFRACTION: boolean;
  137294. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  137295. SS_ALBEDOFORREFRACTIONTINT: boolean;
  137296. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  137297. UNLIT: boolean;
  137298. DEBUGMODE: number;
  137299. /**
  137300. * Initializes the PBR Material defines.
  137301. */
  137302. constructor();
  137303. /**
  137304. * Resets the PBR Material defines.
  137305. */
  137306. reset(): void;
  137307. }
  137308. /**
  137309. * The Physically based material base class of BJS.
  137310. *
  137311. * This offers the main features of a standard PBR material.
  137312. * For more information, please refer to the documentation :
  137313. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137314. */
  137315. export abstract class PBRBaseMaterial extends PushMaterial {
  137316. /**
  137317. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137318. */
  137319. static readonly PBRMATERIAL_OPAQUE: number;
  137320. /**
  137321. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137322. */
  137323. static readonly PBRMATERIAL_ALPHATEST: number;
  137324. /**
  137325. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137326. */
  137327. static readonly PBRMATERIAL_ALPHABLEND: number;
  137328. /**
  137329. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137330. * They are also discarded below the alpha cutoff threshold to improve performances.
  137331. */
  137332. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137333. /**
  137334. * Defines the default value of how much AO map is occluding the analytical lights
  137335. * (point spot...).
  137336. */
  137337. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137338. /**
  137339. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137340. */
  137341. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137342. /**
  137343. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137344. * to enhance interoperability with other engines.
  137345. */
  137346. static readonly LIGHTFALLOFF_GLTF: number;
  137347. /**
  137348. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137349. * to enhance interoperability with other materials.
  137350. */
  137351. static readonly LIGHTFALLOFF_STANDARD: number;
  137352. /**
  137353. * Intensity of the direct lights e.g. the four lights available in your scene.
  137354. * This impacts both the direct diffuse and specular highlights.
  137355. */
  137356. protected _directIntensity: number;
  137357. /**
  137358. * Intensity of the emissive part of the material.
  137359. * This helps controlling the emissive effect without modifying the emissive color.
  137360. */
  137361. protected _emissiveIntensity: number;
  137362. /**
  137363. * Intensity of the environment e.g. how much the environment will light the object
  137364. * either through harmonics for rough material or through the refelction for shiny ones.
  137365. */
  137366. protected _environmentIntensity: number;
  137367. /**
  137368. * This is a special control allowing the reduction of the specular highlights coming from the
  137369. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137370. */
  137371. protected _specularIntensity: number;
  137372. /**
  137373. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137374. */
  137375. private _lightingInfos;
  137376. /**
  137377. * Debug Control allowing disabling the bump map on this material.
  137378. */
  137379. protected _disableBumpMap: boolean;
  137380. /**
  137381. * AKA Diffuse Texture in standard nomenclature.
  137382. */
  137383. protected _albedoTexture: Nullable<BaseTexture>;
  137384. /**
  137385. * AKA Occlusion Texture in other nomenclature.
  137386. */
  137387. protected _ambientTexture: Nullable<BaseTexture>;
  137388. /**
  137389. * AKA Occlusion Texture Intensity in other nomenclature.
  137390. */
  137391. protected _ambientTextureStrength: number;
  137392. /**
  137393. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137394. * 1 means it completely occludes it
  137395. * 0 mean it has no impact
  137396. */
  137397. protected _ambientTextureImpactOnAnalyticalLights: number;
  137398. /**
  137399. * Stores the alpha values in a texture.
  137400. */
  137401. protected _opacityTexture: Nullable<BaseTexture>;
  137402. /**
  137403. * Stores the reflection values in a texture.
  137404. */
  137405. protected _reflectionTexture: Nullable<BaseTexture>;
  137406. /**
  137407. * Stores the emissive values in a texture.
  137408. */
  137409. protected _emissiveTexture: Nullable<BaseTexture>;
  137410. /**
  137411. * AKA Specular texture in other nomenclature.
  137412. */
  137413. protected _reflectivityTexture: Nullable<BaseTexture>;
  137414. /**
  137415. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137416. */
  137417. protected _metallicTexture: Nullable<BaseTexture>;
  137418. /**
  137419. * Specifies the metallic scalar of the metallic/roughness workflow.
  137420. * Can also be used to scale the metalness values of the metallic texture.
  137421. */
  137422. protected _metallic: Nullable<number>;
  137423. /**
  137424. * Specifies the roughness scalar of the metallic/roughness workflow.
  137425. * Can also be used to scale the roughness values of the metallic texture.
  137426. */
  137427. protected _roughness: Nullable<number>;
  137428. /**
  137429. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137430. * By default the indexOfrefraction is used to compute F0;
  137431. *
  137432. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137433. *
  137434. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137435. * F90 = metallicReflectanceColor;
  137436. */
  137437. protected _metallicF0Factor: number;
  137438. /**
  137439. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137440. * By default the F90 is always 1;
  137441. *
  137442. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137443. *
  137444. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137445. * F90 = metallicReflectanceColor;
  137446. */
  137447. protected _metallicReflectanceColor: Color3;
  137448. /**
  137449. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137450. * This is multiply against the scalar values defined in the material.
  137451. */
  137452. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137453. /**
  137454. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137455. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137456. */
  137457. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137458. /**
  137459. * Stores surface normal data used to displace a mesh in a texture.
  137460. */
  137461. protected _bumpTexture: Nullable<BaseTexture>;
  137462. /**
  137463. * Stores the pre-calculated light information of a mesh in a texture.
  137464. */
  137465. protected _lightmapTexture: Nullable<BaseTexture>;
  137466. /**
  137467. * The color of a material in ambient lighting.
  137468. */
  137469. protected _ambientColor: Color3;
  137470. /**
  137471. * AKA Diffuse Color in other nomenclature.
  137472. */
  137473. protected _albedoColor: Color3;
  137474. /**
  137475. * AKA Specular Color in other nomenclature.
  137476. */
  137477. protected _reflectivityColor: Color3;
  137478. /**
  137479. * The color applied when light is reflected from a material.
  137480. */
  137481. protected _reflectionColor: Color3;
  137482. /**
  137483. * The color applied when light is emitted from a material.
  137484. */
  137485. protected _emissiveColor: Color3;
  137486. /**
  137487. * AKA Glossiness in other nomenclature.
  137488. */
  137489. protected _microSurface: number;
  137490. /**
  137491. * Specifies that the material will use the light map as a show map.
  137492. */
  137493. protected _useLightmapAsShadowmap: boolean;
  137494. /**
  137495. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137496. * makes the reflect vector face the model (under horizon).
  137497. */
  137498. protected _useHorizonOcclusion: boolean;
  137499. /**
  137500. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137501. * too much the area relying on ambient texture to define their ambient occlusion.
  137502. */
  137503. protected _useRadianceOcclusion: boolean;
  137504. /**
  137505. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137506. */
  137507. protected _useAlphaFromAlbedoTexture: boolean;
  137508. /**
  137509. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137510. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137511. */
  137512. protected _useSpecularOverAlpha: boolean;
  137513. /**
  137514. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137515. */
  137516. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137517. /**
  137518. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137519. */
  137520. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137521. /**
  137522. * Specifies if the metallic texture contains the roughness information in its green channel.
  137523. */
  137524. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137525. /**
  137526. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137527. */
  137528. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137529. /**
  137530. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137531. */
  137532. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137533. /**
  137534. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137535. */
  137536. protected _useAmbientInGrayScale: boolean;
  137537. /**
  137538. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137539. * The material will try to infer what glossiness each pixel should be.
  137540. */
  137541. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137542. /**
  137543. * Defines the falloff type used in this material.
  137544. * It by default is Physical.
  137545. */
  137546. protected _lightFalloff: number;
  137547. /**
  137548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137550. */
  137551. protected _useRadianceOverAlpha: boolean;
  137552. /**
  137553. * Allows using an object space normal map (instead of tangent space).
  137554. */
  137555. protected _useObjectSpaceNormalMap: boolean;
  137556. /**
  137557. * Allows using the bump map in parallax mode.
  137558. */
  137559. protected _useParallax: boolean;
  137560. /**
  137561. * Allows using the bump map in parallax occlusion mode.
  137562. */
  137563. protected _useParallaxOcclusion: boolean;
  137564. /**
  137565. * Controls the scale bias of the parallax mode.
  137566. */
  137567. protected _parallaxScaleBias: number;
  137568. /**
  137569. * If sets to true, disables all the lights affecting the material.
  137570. */
  137571. protected _disableLighting: boolean;
  137572. /**
  137573. * Number of Simultaneous lights allowed on the material.
  137574. */
  137575. protected _maxSimultaneousLights: number;
  137576. /**
  137577. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137578. */
  137579. protected _invertNormalMapX: boolean;
  137580. /**
  137581. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137582. */
  137583. protected _invertNormalMapY: boolean;
  137584. /**
  137585. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137586. */
  137587. protected _twoSidedLighting: boolean;
  137588. /**
  137589. * Defines the alpha limits in alpha test mode.
  137590. */
  137591. protected _alphaCutOff: number;
  137592. /**
  137593. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137594. */
  137595. protected _forceAlphaTest: boolean;
  137596. /**
  137597. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137598. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137599. */
  137600. protected _useAlphaFresnel: boolean;
  137601. /**
  137602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137603. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137604. */
  137605. protected _useLinearAlphaFresnel: boolean;
  137606. /**
  137607. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137608. * from cos thetav and roughness:
  137609. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137610. */
  137611. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137612. /**
  137613. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137614. */
  137615. protected _forceIrradianceInFragment: boolean;
  137616. private _realTimeFiltering;
  137617. /**
  137618. * Enables realtime filtering on the texture.
  137619. */
  137620. get realTimeFiltering(): boolean;
  137621. set realTimeFiltering(b: boolean);
  137622. private _realTimeFilteringQuality;
  137623. /**
  137624. * Quality switch for realtime filtering
  137625. */
  137626. get realTimeFilteringQuality(): number;
  137627. set realTimeFilteringQuality(n: number);
  137628. /**
  137629. * Can this material render to several textures at once
  137630. */
  137631. get canRenderToMRT(): boolean;
  137632. /**
  137633. * Force normal to face away from face.
  137634. */
  137635. protected _forceNormalForward: boolean;
  137636. /**
  137637. * Enables specular anti aliasing in the PBR shader.
  137638. * It will both interacts on the Geometry for analytical and IBL lighting.
  137639. * It also prefilter the roughness map based on the bump values.
  137640. */
  137641. protected _enableSpecularAntiAliasing: boolean;
  137642. /**
  137643. * Default configuration related to image processing available in the PBR Material.
  137644. */
  137645. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137646. /**
  137647. * Keep track of the image processing observer to allow dispose and replace.
  137648. */
  137649. private _imageProcessingObserver;
  137650. /**
  137651. * Attaches a new image processing configuration to the PBR Material.
  137652. * @param configuration
  137653. */
  137654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137655. /**
  137656. * Stores the available render targets.
  137657. */
  137658. private _renderTargets;
  137659. /**
  137660. * Sets the global ambient color for the material used in lighting calculations.
  137661. */
  137662. private _globalAmbientColor;
  137663. /**
  137664. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137665. */
  137666. private _useLogarithmicDepth;
  137667. /**
  137668. * If set to true, no lighting calculations will be applied.
  137669. */
  137670. private _unlit;
  137671. private _debugMode;
  137672. /**
  137673. * @hidden
  137674. * This is reserved for the inspector.
  137675. * Defines the material debug mode.
  137676. * It helps seeing only some components of the material while troubleshooting.
  137677. */
  137678. debugMode: number;
  137679. /**
  137680. * @hidden
  137681. * This is reserved for the inspector.
  137682. * Specify from where on screen the debug mode should start.
  137683. * The value goes from -1 (full screen) to 1 (not visible)
  137684. * It helps with side by side comparison against the final render
  137685. * This defaults to -1
  137686. */
  137687. private debugLimit;
  137688. /**
  137689. * @hidden
  137690. * This is reserved for the inspector.
  137691. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137692. * You can use the factor to better multiply the final value.
  137693. */
  137694. private debugFactor;
  137695. /**
  137696. * Defines the clear coat layer parameters for the material.
  137697. */
  137698. readonly clearCoat: PBRClearCoatConfiguration;
  137699. /**
  137700. * Defines the anisotropic parameters for the material.
  137701. */
  137702. readonly anisotropy: PBRAnisotropicConfiguration;
  137703. /**
  137704. * Defines the BRDF parameters for the material.
  137705. */
  137706. readonly brdf: PBRBRDFConfiguration;
  137707. /**
  137708. * Defines the Sheen parameters for the material.
  137709. */
  137710. readonly sheen: PBRSheenConfiguration;
  137711. /**
  137712. * Defines the SubSurface parameters for the material.
  137713. */
  137714. readonly subSurface: PBRSubSurfaceConfiguration;
  137715. /**
  137716. * Defines additionnal PrePass parameters for the material.
  137717. */
  137718. readonly prePassConfiguration: PrePassConfiguration;
  137719. /**
  137720. * Defines the detail map parameters for the material.
  137721. */
  137722. readonly detailMap: DetailMapConfiguration;
  137723. protected _rebuildInParallel: boolean;
  137724. /**
  137725. * Instantiates a new PBRMaterial instance.
  137726. *
  137727. * @param name The material name
  137728. * @param scene The scene the material will be use in.
  137729. */
  137730. constructor(name: string, scene: Scene);
  137731. /**
  137732. * Gets a boolean indicating that current material needs to register RTT
  137733. */
  137734. get hasRenderTargetTextures(): boolean;
  137735. /**
  137736. * Gets the name of the material class.
  137737. */
  137738. getClassName(): string;
  137739. /**
  137740. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137741. */
  137742. get useLogarithmicDepth(): boolean;
  137743. /**
  137744. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137745. */
  137746. set useLogarithmicDepth(value: boolean);
  137747. /**
  137748. * Returns true if alpha blending should be disabled.
  137749. */
  137750. protected get _disableAlphaBlending(): boolean;
  137751. /**
  137752. * Specifies whether or not this material should be rendered in alpha blend mode.
  137753. */
  137754. needAlphaBlending(): boolean;
  137755. /**
  137756. * Specifies whether or not this material should be rendered in alpha test mode.
  137757. */
  137758. needAlphaTesting(): boolean;
  137759. /**
  137760. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137761. */
  137762. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137763. /**
  137764. * Gets the texture used for the alpha test.
  137765. */
  137766. getAlphaTestTexture(): Nullable<BaseTexture>;
  137767. /**
  137768. * Specifies that the submesh is ready to be used.
  137769. * @param mesh - BJS mesh.
  137770. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137771. * @param useInstances - Specifies that instances should be used.
  137772. * @returns - boolean indicating that the submesh is ready or not.
  137773. */
  137774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137775. /**
  137776. * Specifies if the material uses metallic roughness workflow.
  137777. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137778. */
  137779. isMetallicWorkflow(): boolean;
  137780. private _prepareEffect;
  137781. private _prepareDefines;
  137782. /**
  137783. * Force shader compilation
  137784. */
  137785. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137786. /**
  137787. * Initializes the uniform buffer layout for the shader.
  137788. */
  137789. buildUniformLayout(): void;
  137790. /**
  137791. * Unbinds the material from the mesh
  137792. */
  137793. unbind(): void;
  137794. /**
  137795. * Binds the submesh data.
  137796. * @param world - The world matrix.
  137797. * @param mesh - The BJS mesh.
  137798. * @param subMesh - A submesh of the BJS mesh.
  137799. */
  137800. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137801. /**
  137802. * Returns the animatable textures.
  137803. * @returns - Array of animatable textures.
  137804. */
  137805. getAnimatables(): IAnimatable[];
  137806. /**
  137807. * Returns the texture used for reflections.
  137808. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137809. */
  137810. private _getReflectionTexture;
  137811. /**
  137812. * Returns an array of the actively used textures.
  137813. * @returns - Array of BaseTextures
  137814. */
  137815. getActiveTextures(): BaseTexture[];
  137816. /**
  137817. * Checks to see if a texture is used in the material.
  137818. * @param texture - Base texture to use.
  137819. * @returns - Boolean specifying if a texture is used in the material.
  137820. */
  137821. hasTexture(texture: BaseTexture): boolean;
  137822. /**
  137823. * Sets the required values to the prepass renderer.
  137824. * @param prePassRenderer defines the prepass renderer to setup
  137825. */
  137826. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137827. /**
  137828. * Disposes the resources of the material.
  137829. * @param forceDisposeEffect - Forces the disposal of effects.
  137830. * @param forceDisposeTextures - Forces the disposal of all textures.
  137831. */
  137832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137833. }
  137834. }
  137835. declare module BABYLON {
  137836. /**
  137837. * The Physically based material of BJS.
  137838. *
  137839. * This offers the main features of a standard PBR material.
  137840. * For more information, please refer to the documentation :
  137841. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137842. */
  137843. export class PBRMaterial extends PBRBaseMaterial {
  137844. /**
  137845. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137846. */
  137847. static readonly PBRMATERIAL_OPAQUE: number;
  137848. /**
  137849. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137850. */
  137851. static readonly PBRMATERIAL_ALPHATEST: number;
  137852. /**
  137853. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137854. */
  137855. static readonly PBRMATERIAL_ALPHABLEND: number;
  137856. /**
  137857. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137858. * They are also discarded below the alpha cutoff threshold to improve performances.
  137859. */
  137860. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137861. /**
  137862. * Defines the default value of how much AO map is occluding the analytical lights
  137863. * (point spot...).
  137864. */
  137865. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137866. /**
  137867. * Intensity of the direct lights e.g. the four lights available in your scene.
  137868. * This impacts both the direct diffuse and specular highlights.
  137869. */
  137870. directIntensity: number;
  137871. /**
  137872. * Intensity of the emissive part of the material.
  137873. * This helps controlling the emissive effect without modifying the emissive color.
  137874. */
  137875. emissiveIntensity: number;
  137876. /**
  137877. * Intensity of the environment e.g. how much the environment will light the object
  137878. * either through harmonics for rough material or through the refelction for shiny ones.
  137879. */
  137880. environmentIntensity: number;
  137881. /**
  137882. * This is a special control allowing the reduction of the specular highlights coming from the
  137883. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137884. */
  137885. specularIntensity: number;
  137886. /**
  137887. * Debug Control allowing disabling the bump map on this material.
  137888. */
  137889. disableBumpMap: boolean;
  137890. /**
  137891. * AKA Diffuse Texture in standard nomenclature.
  137892. */
  137893. albedoTexture: BaseTexture;
  137894. /**
  137895. * AKA Occlusion Texture in other nomenclature.
  137896. */
  137897. ambientTexture: BaseTexture;
  137898. /**
  137899. * AKA Occlusion Texture Intensity in other nomenclature.
  137900. */
  137901. ambientTextureStrength: number;
  137902. /**
  137903. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137904. * 1 means it completely occludes it
  137905. * 0 mean it has no impact
  137906. */
  137907. ambientTextureImpactOnAnalyticalLights: number;
  137908. /**
  137909. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137910. */
  137911. opacityTexture: BaseTexture;
  137912. /**
  137913. * Stores the reflection values in a texture.
  137914. */
  137915. reflectionTexture: Nullable<BaseTexture>;
  137916. /**
  137917. * Stores the emissive values in a texture.
  137918. */
  137919. emissiveTexture: BaseTexture;
  137920. /**
  137921. * AKA Specular texture in other nomenclature.
  137922. */
  137923. reflectivityTexture: BaseTexture;
  137924. /**
  137925. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137926. */
  137927. metallicTexture: BaseTexture;
  137928. /**
  137929. * Specifies the metallic scalar of the metallic/roughness workflow.
  137930. * Can also be used to scale the metalness values of the metallic texture.
  137931. */
  137932. metallic: Nullable<number>;
  137933. /**
  137934. * Specifies the roughness scalar of the metallic/roughness workflow.
  137935. * Can also be used to scale the roughness values of the metallic texture.
  137936. */
  137937. roughness: Nullable<number>;
  137938. /**
  137939. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137940. * By default the indexOfrefraction is used to compute F0;
  137941. *
  137942. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137943. *
  137944. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137945. * F90 = metallicReflectanceColor;
  137946. */
  137947. metallicF0Factor: number;
  137948. /**
  137949. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137950. * By default the F90 is always 1;
  137951. *
  137952. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137953. *
  137954. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137955. * F90 = metallicReflectanceColor;
  137956. */
  137957. metallicReflectanceColor: Color3;
  137958. /**
  137959. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137960. * This is multiply against the scalar values defined in the material.
  137961. */
  137962. metallicReflectanceTexture: Nullable<BaseTexture>;
  137963. /**
  137964. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137965. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137966. */
  137967. microSurfaceTexture: BaseTexture;
  137968. /**
  137969. * Stores surface normal data used to displace a mesh in a texture.
  137970. */
  137971. bumpTexture: BaseTexture;
  137972. /**
  137973. * Stores the pre-calculated light information of a mesh in a texture.
  137974. */
  137975. lightmapTexture: BaseTexture;
  137976. /**
  137977. * Stores the refracted light information in a texture.
  137978. */
  137979. get refractionTexture(): Nullable<BaseTexture>;
  137980. set refractionTexture(value: Nullable<BaseTexture>);
  137981. /**
  137982. * The color of a material in ambient lighting.
  137983. */
  137984. ambientColor: Color3;
  137985. /**
  137986. * AKA Diffuse Color in other nomenclature.
  137987. */
  137988. albedoColor: Color3;
  137989. /**
  137990. * AKA Specular Color in other nomenclature.
  137991. */
  137992. reflectivityColor: Color3;
  137993. /**
  137994. * The color reflected from the material.
  137995. */
  137996. reflectionColor: Color3;
  137997. /**
  137998. * The color emitted from the material.
  137999. */
  138000. emissiveColor: Color3;
  138001. /**
  138002. * AKA Glossiness in other nomenclature.
  138003. */
  138004. microSurface: number;
  138005. /**
  138006. * Index of refraction of the material base layer.
  138007. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  138008. *
  138009. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  138010. *
  138011. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  138012. */
  138013. get indexOfRefraction(): number;
  138014. set indexOfRefraction(value: number);
  138015. /**
  138016. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  138017. */
  138018. get invertRefractionY(): boolean;
  138019. set invertRefractionY(value: boolean);
  138020. /**
  138021. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  138022. * Materials half opaque for instance using refraction could benefit from this control.
  138023. */
  138024. get linkRefractionWithTransparency(): boolean;
  138025. set linkRefractionWithTransparency(value: boolean);
  138026. /**
  138027. * If true, the light map contains occlusion information instead of lighting info.
  138028. */
  138029. useLightmapAsShadowmap: boolean;
  138030. /**
  138031. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  138032. */
  138033. useAlphaFromAlbedoTexture: boolean;
  138034. /**
  138035. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  138036. */
  138037. forceAlphaTest: boolean;
  138038. /**
  138039. * Defines the alpha limits in alpha test mode.
  138040. */
  138041. alphaCutOff: number;
  138042. /**
  138043. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  138044. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  138045. */
  138046. useSpecularOverAlpha: boolean;
  138047. /**
  138048. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  138049. */
  138050. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  138051. /**
  138052. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  138053. */
  138054. useRoughnessFromMetallicTextureAlpha: boolean;
  138055. /**
  138056. * Specifies if the metallic texture contains the roughness information in its green channel.
  138057. */
  138058. useRoughnessFromMetallicTextureGreen: boolean;
  138059. /**
  138060. * Specifies if the metallic texture contains the metallness information in its blue channel.
  138061. */
  138062. useMetallnessFromMetallicTextureBlue: boolean;
  138063. /**
  138064. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  138065. */
  138066. useAmbientOcclusionFromMetallicTextureRed: boolean;
  138067. /**
  138068. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  138069. */
  138070. useAmbientInGrayScale: boolean;
  138071. /**
  138072. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  138073. * The material will try to infer what glossiness each pixel should be.
  138074. */
  138075. useAutoMicroSurfaceFromReflectivityMap: boolean;
  138076. /**
  138077. * BJS is using an harcoded light falloff based on a manually sets up range.
  138078. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138079. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138080. */
  138081. get usePhysicalLightFalloff(): boolean;
  138082. /**
  138083. * BJS is using an harcoded light falloff based on a manually sets up range.
  138084. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138085. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138086. */
  138087. set usePhysicalLightFalloff(value: boolean);
  138088. /**
  138089. * In order to support the falloff compatibility with gltf, a special mode has been added
  138090. * to reproduce the gltf light falloff.
  138091. */
  138092. get useGLTFLightFalloff(): boolean;
  138093. /**
  138094. * In order to support the falloff compatibility with gltf, a special mode has been added
  138095. * to reproduce the gltf light falloff.
  138096. */
  138097. set useGLTFLightFalloff(value: boolean);
  138098. /**
  138099. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  138100. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  138101. */
  138102. useRadianceOverAlpha: boolean;
  138103. /**
  138104. * Allows using an object space normal map (instead of tangent space).
  138105. */
  138106. useObjectSpaceNormalMap: boolean;
  138107. /**
  138108. * Allows using the bump map in parallax mode.
  138109. */
  138110. useParallax: boolean;
  138111. /**
  138112. * Allows using the bump map in parallax occlusion mode.
  138113. */
  138114. useParallaxOcclusion: boolean;
  138115. /**
  138116. * Controls the scale bias of the parallax mode.
  138117. */
  138118. parallaxScaleBias: number;
  138119. /**
  138120. * If sets to true, disables all the lights affecting the material.
  138121. */
  138122. disableLighting: boolean;
  138123. /**
  138124. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  138125. */
  138126. forceIrradianceInFragment: boolean;
  138127. /**
  138128. * Number of Simultaneous lights allowed on the material.
  138129. */
  138130. maxSimultaneousLights: number;
  138131. /**
  138132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138133. */
  138134. invertNormalMapX: boolean;
  138135. /**
  138136. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138137. */
  138138. invertNormalMapY: boolean;
  138139. /**
  138140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138141. */
  138142. twoSidedLighting: boolean;
  138143. /**
  138144. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138145. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  138146. */
  138147. useAlphaFresnel: boolean;
  138148. /**
  138149. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138150. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  138151. */
  138152. useLinearAlphaFresnel: boolean;
  138153. /**
  138154. * Let user defines the brdf lookup texture used for IBL.
  138155. * A default 8bit version is embedded but you could point at :
  138156. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  138157. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  138158. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  138159. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  138160. */
  138161. environmentBRDFTexture: Nullable<BaseTexture>;
  138162. /**
  138163. * Force normal to face away from face.
  138164. */
  138165. forceNormalForward: boolean;
  138166. /**
  138167. * Enables specular anti aliasing in the PBR shader.
  138168. * It will both interacts on the Geometry for analytical and IBL lighting.
  138169. * It also prefilter the roughness map based on the bump values.
  138170. */
  138171. enableSpecularAntiAliasing: boolean;
  138172. /**
  138173. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  138174. * makes the reflect vector face the model (under horizon).
  138175. */
  138176. useHorizonOcclusion: boolean;
  138177. /**
  138178. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  138179. * too much the area relying on ambient texture to define their ambient occlusion.
  138180. */
  138181. useRadianceOcclusion: boolean;
  138182. /**
  138183. * If set to true, no lighting calculations will be applied.
  138184. */
  138185. unlit: boolean;
  138186. /**
  138187. * Gets the image processing configuration used either in this material.
  138188. */
  138189. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  138190. /**
  138191. * Sets the Default image processing configuration used either in the this material.
  138192. *
  138193. * If sets to null, the scene one is in use.
  138194. */
  138195. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  138196. /**
  138197. * Gets wether the color curves effect is enabled.
  138198. */
  138199. get cameraColorCurvesEnabled(): boolean;
  138200. /**
  138201. * Sets wether the color curves effect is enabled.
  138202. */
  138203. set cameraColorCurvesEnabled(value: boolean);
  138204. /**
  138205. * Gets wether the color grading effect is enabled.
  138206. */
  138207. get cameraColorGradingEnabled(): boolean;
  138208. /**
  138209. * Gets wether the color grading effect is enabled.
  138210. */
  138211. set cameraColorGradingEnabled(value: boolean);
  138212. /**
  138213. * Gets wether tonemapping is enabled or not.
  138214. */
  138215. get cameraToneMappingEnabled(): boolean;
  138216. /**
  138217. * Sets wether tonemapping is enabled or not
  138218. */
  138219. set cameraToneMappingEnabled(value: boolean);
  138220. /**
  138221. * The camera exposure used on this material.
  138222. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138223. * This corresponds to a photographic exposure.
  138224. */
  138225. get cameraExposure(): number;
  138226. /**
  138227. * The camera exposure used on this material.
  138228. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138229. * This corresponds to a photographic exposure.
  138230. */
  138231. set cameraExposure(value: number);
  138232. /**
  138233. * Gets The camera contrast used on this material.
  138234. */
  138235. get cameraContrast(): number;
  138236. /**
  138237. * Sets The camera contrast used on this material.
  138238. */
  138239. set cameraContrast(value: number);
  138240. /**
  138241. * Gets the Color Grading 2D Lookup Texture.
  138242. */
  138243. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138244. /**
  138245. * Sets the Color Grading 2D Lookup Texture.
  138246. */
  138247. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138248. /**
  138249. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138250. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138251. * 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;
  138252. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138253. */
  138254. get cameraColorCurves(): Nullable<ColorCurves>;
  138255. /**
  138256. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138257. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138258. * 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;
  138259. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138260. */
  138261. set cameraColorCurves(value: Nullable<ColorCurves>);
  138262. /**
  138263. * Instantiates a new PBRMaterial instance.
  138264. *
  138265. * @param name The material name
  138266. * @param scene The scene the material will be use in.
  138267. */
  138268. constructor(name: string, scene: Scene);
  138269. /**
  138270. * Returns the name of this material class.
  138271. */
  138272. getClassName(): string;
  138273. /**
  138274. * Makes a duplicate of the current material.
  138275. * @param name - name to use for the new material.
  138276. */
  138277. clone(name: string): PBRMaterial;
  138278. /**
  138279. * Serializes this PBR Material.
  138280. * @returns - An object with the serialized material.
  138281. */
  138282. serialize(): any;
  138283. /**
  138284. * Parses a PBR Material from a serialized object.
  138285. * @param source - Serialized object.
  138286. * @param scene - BJS scene instance.
  138287. * @param rootUrl - url for the scene object
  138288. * @returns - PBRMaterial
  138289. */
  138290. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  138291. }
  138292. }
  138293. declare module BABYLON {
  138294. /**
  138295. * Direct draw surface info
  138296. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138297. */
  138298. export interface DDSInfo {
  138299. /**
  138300. * Width of the texture
  138301. */
  138302. width: number;
  138303. /**
  138304. * Width of the texture
  138305. */
  138306. height: number;
  138307. /**
  138308. * Number of Mipmaps for the texture
  138309. * @see https://en.wikipedia.org/wiki/Mipmap
  138310. */
  138311. mipmapCount: number;
  138312. /**
  138313. * If the textures format is a known fourCC format
  138314. * @see https://www.fourcc.org/
  138315. */
  138316. isFourCC: boolean;
  138317. /**
  138318. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138319. */
  138320. isRGB: boolean;
  138321. /**
  138322. * If the texture is a lumincance format
  138323. */
  138324. isLuminance: boolean;
  138325. /**
  138326. * If this is a cube texture
  138327. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138328. */
  138329. isCube: boolean;
  138330. /**
  138331. * If the texture is a compressed format eg. FOURCC_DXT1
  138332. */
  138333. isCompressed: boolean;
  138334. /**
  138335. * The dxgiFormat of the texture
  138336. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138337. */
  138338. dxgiFormat: number;
  138339. /**
  138340. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138341. */
  138342. textureType: number;
  138343. /**
  138344. * Sphericle polynomial created for the dds texture
  138345. */
  138346. sphericalPolynomial?: SphericalPolynomial;
  138347. }
  138348. /**
  138349. * Class used to provide DDS decompression tools
  138350. */
  138351. export class DDSTools {
  138352. /**
  138353. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138354. */
  138355. static StoreLODInAlphaChannel: boolean;
  138356. /**
  138357. * Gets DDS information from an array buffer
  138358. * @param data defines the array buffer view to read data from
  138359. * @returns the DDS information
  138360. */
  138361. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138362. private static _FloatView;
  138363. private static _Int32View;
  138364. private static _ToHalfFloat;
  138365. private static _FromHalfFloat;
  138366. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138367. private static _GetHalfFloatRGBAArrayBuffer;
  138368. private static _GetFloatRGBAArrayBuffer;
  138369. private static _GetFloatAsUIntRGBAArrayBuffer;
  138370. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138371. private static _GetRGBAArrayBuffer;
  138372. private static _ExtractLongWordOrder;
  138373. private static _GetRGBArrayBuffer;
  138374. private static _GetLuminanceArrayBuffer;
  138375. /**
  138376. * Uploads DDS Levels to a Babylon Texture
  138377. * @hidden
  138378. */
  138379. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138380. }
  138381. interface ThinEngine {
  138382. /**
  138383. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138384. * @param rootUrl defines the url where the file to load is located
  138385. * @param scene defines the current scene
  138386. * @param lodScale defines scale to apply to the mip map selection
  138387. * @param lodOffset defines offset to apply to the mip map selection
  138388. * @param onLoad defines an optional callback raised when the texture is loaded
  138389. * @param onError defines an optional callback raised if there is an issue to load the texture
  138390. * @param format defines the format of the data
  138391. * @param forcedExtension defines the extension to use to pick the right loader
  138392. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138393. * @returns the cube texture as an InternalTexture
  138394. */
  138395. 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;
  138396. }
  138397. }
  138398. declare module BABYLON {
  138399. /**
  138400. * Implementation of the DDS Texture Loader.
  138401. * @hidden
  138402. */
  138403. export class _DDSTextureLoader implements IInternalTextureLoader {
  138404. /**
  138405. * Defines wether the loader supports cascade loading the different faces.
  138406. */
  138407. readonly supportCascades: boolean;
  138408. /**
  138409. * This returns if the loader support the current file information.
  138410. * @param extension defines the file extension of the file being loaded
  138411. * @returns true if the loader can load the specified file
  138412. */
  138413. canLoad(extension: string): boolean;
  138414. /**
  138415. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138416. * @param data contains the texture data
  138417. * @param texture defines the BabylonJS internal texture
  138418. * @param createPolynomials will be true if polynomials have been requested
  138419. * @param onLoad defines the callback to trigger once the texture is ready
  138420. * @param onError defines the callback to trigger in case of error
  138421. */
  138422. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138423. /**
  138424. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138425. * @param data contains the texture data
  138426. * @param texture defines the BabylonJS internal texture
  138427. * @param callback defines the method to call once ready to upload
  138428. */
  138429. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138430. }
  138431. }
  138432. declare module BABYLON {
  138433. /**
  138434. * Implementation of the ENV Texture Loader.
  138435. * @hidden
  138436. */
  138437. export class _ENVTextureLoader implements IInternalTextureLoader {
  138438. /**
  138439. * Defines wether the loader supports cascade loading the different faces.
  138440. */
  138441. readonly supportCascades: boolean;
  138442. /**
  138443. * This returns if the loader support the current file information.
  138444. * @param extension defines the file extension of the file being loaded
  138445. * @returns true if the loader can load the specified file
  138446. */
  138447. canLoad(extension: string): boolean;
  138448. /**
  138449. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138450. * @param data contains the texture data
  138451. * @param texture defines the BabylonJS internal texture
  138452. * @param createPolynomials will be true if polynomials have been requested
  138453. * @param onLoad defines the callback to trigger once the texture is ready
  138454. * @param onError defines the callback to trigger in case of error
  138455. */
  138456. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138457. /**
  138458. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138459. * @param data contains the texture data
  138460. * @param texture defines the BabylonJS internal texture
  138461. * @param callback defines the method to call once ready to upload
  138462. */
  138463. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138464. }
  138465. }
  138466. declare module BABYLON {
  138467. /**
  138468. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138469. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138470. */
  138471. export class KhronosTextureContainer {
  138472. /** contents of the KTX container file */
  138473. data: ArrayBufferView;
  138474. private static HEADER_LEN;
  138475. private static COMPRESSED_2D;
  138476. private static COMPRESSED_3D;
  138477. private static TEX_2D;
  138478. private static TEX_3D;
  138479. /**
  138480. * Gets the openGL type
  138481. */
  138482. glType: number;
  138483. /**
  138484. * Gets the openGL type size
  138485. */
  138486. glTypeSize: number;
  138487. /**
  138488. * Gets the openGL format
  138489. */
  138490. glFormat: number;
  138491. /**
  138492. * Gets the openGL internal format
  138493. */
  138494. glInternalFormat: number;
  138495. /**
  138496. * Gets the base internal format
  138497. */
  138498. glBaseInternalFormat: number;
  138499. /**
  138500. * Gets image width in pixel
  138501. */
  138502. pixelWidth: number;
  138503. /**
  138504. * Gets image height in pixel
  138505. */
  138506. pixelHeight: number;
  138507. /**
  138508. * Gets image depth in pixels
  138509. */
  138510. pixelDepth: number;
  138511. /**
  138512. * Gets the number of array elements
  138513. */
  138514. numberOfArrayElements: number;
  138515. /**
  138516. * Gets the number of faces
  138517. */
  138518. numberOfFaces: number;
  138519. /**
  138520. * Gets the number of mipmap levels
  138521. */
  138522. numberOfMipmapLevels: number;
  138523. /**
  138524. * Gets the bytes of key value data
  138525. */
  138526. bytesOfKeyValueData: number;
  138527. /**
  138528. * Gets the load type
  138529. */
  138530. loadType: number;
  138531. /**
  138532. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138533. */
  138534. isInvalid: boolean;
  138535. /**
  138536. * Creates a new KhronosTextureContainer
  138537. * @param data contents of the KTX container file
  138538. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138539. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138540. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138541. */
  138542. constructor(
  138543. /** contents of the KTX container file */
  138544. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138545. /**
  138546. * Uploads KTX content to a Babylon Texture.
  138547. * It is assumed that the texture has already been created & is currently bound
  138548. * @hidden
  138549. */
  138550. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138551. private _upload2DCompressedLevels;
  138552. /**
  138553. * Checks if the given data starts with a KTX file identifier.
  138554. * @param data the data to check
  138555. * @returns true if the data is a KTX file or false otherwise
  138556. */
  138557. static IsValid(data: ArrayBufferView): boolean;
  138558. }
  138559. }
  138560. declare module BABYLON {
  138561. /**
  138562. * Helper class to push actions to a pool of workers.
  138563. */
  138564. export class WorkerPool implements IDisposable {
  138565. private _workerInfos;
  138566. private _pendingActions;
  138567. /**
  138568. * Constructor
  138569. * @param workers Array of workers to use for actions
  138570. */
  138571. constructor(workers: Array<Worker>);
  138572. /**
  138573. * Terminates all workers and clears any pending actions.
  138574. */
  138575. dispose(): void;
  138576. /**
  138577. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138578. * pended until a worker has completed its action.
  138579. * @param action The action to perform. Call onComplete when the action is complete.
  138580. */
  138581. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138582. private _execute;
  138583. }
  138584. }
  138585. declare module BABYLON {
  138586. /**
  138587. * Class for loading KTX2 files
  138588. */
  138589. export class KhronosTextureContainer2 {
  138590. private static _WorkerPoolPromise?;
  138591. private static _Initialized;
  138592. private static _Ktx2Decoder;
  138593. /**
  138594. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  138595. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  138596. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  138597. * Urls you can change:
  138598. * URLConfig.jsDecoderModule
  138599. * URLConfig.wasmUASTCToASTC
  138600. * URLConfig.wasmUASTCToBC7
  138601. * URLConfig.jsMSCTranscoder
  138602. * URLConfig.wasmMSCTranscoder
  138603. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  138604. */
  138605. static URLConfig: {
  138606. jsDecoderModule: string;
  138607. wasmUASTCToASTC: null;
  138608. wasmUASTCToBC7: null;
  138609. jsMSCTranscoder: null;
  138610. wasmMSCTranscoder: null;
  138611. };
  138612. /**
  138613. * Default number of workers used to handle data decoding
  138614. */
  138615. static DefaultNumWorkers: number;
  138616. private static GetDefaultNumWorkers;
  138617. private _engine;
  138618. private static _CreateWorkerPool;
  138619. /**
  138620. * Constructor
  138621. * @param engine The engine to use
  138622. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138623. */
  138624. constructor(engine: ThinEngine, numWorkers?: number);
  138625. /** @hidden */
  138626. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138627. /**
  138628. * Stop all async operations and release resources.
  138629. */
  138630. dispose(): void;
  138631. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138632. /**
  138633. * Checks if the given data starts with a KTX2 file identifier.
  138634. * @param data the data to check
  138635. * @returns true if the data is a KTX2 file or false otherwise
  138636. */
  138637. static IsValid(data: ArrayBufferView): boolean;
  138638. }
  138639. }
  138640. declare module BABYLON {
  138641. /**
  138642. * Implementation of the KTX Texture Loader.
  138643. * @hidden
  138644. */
  138645. export class _KTXTextureLoader implements IInternalTextureLoader {
  138646. /**
  138647. * Defines wether the loader supports cascade loading the different faces.
  138648. */
  138649. readonly supportCascades: boolean;
  138650. /**
  138651. * This returns if the loader support the current file information.
  138652. * @param extension defines the file extension of the file being loaded
  138653. * @param mimeType defines the optional mime type of the file being loaded
  138654. * @returns true if the loader can load the specified file
  138655. */
  138656. canLoad(extension: string, mimeType?: string): boolean;
  138657. /**
  138658. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138659. * @param data contains the texture data
  138660. * @param texture defines the BabylonJS internal texture
  138661. * @param createPolynomials will be true if polynomials have been requested
  138662. * @param onLoad defines the callback to trigger once the texture is ready
  138663. * @param onError defines the callback to trigger in case of error
  138664. */
  138665. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138666. /**
  138667. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138668. * @param data contains the texture data
  138669. * @param texture defines the BabylonJS internal texture
  138670. * @param callback defines the method to call once ready to upload
  138671. */
  138672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138673. }
  138674. }
  138675. declare module BABYLON {
  138676. /** @hidden */
  138677. export var _forceSceneHelpersToBundle: boolean;
  138678. interface Scene {
  138679. /**
  138680. * Creates a default light for the scene.
  138681. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138682. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138683. */
  138684. createDefaultLight(replace?: boolean): void;
  138685. /**
  138686. * Creates a default camera for the scene.
  138687. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138688. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138689. * @param replace has default false, when true replaces the active camera in the scene
  138690. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138691. */
  138692. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138693. /**
  138694. * Creates a default camera and a default light.
  138695. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138696. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138697. * @param replace has the default false, when true replaces the active camera/light in the scene
  138698. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138699. */
  138700. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138701. /**
  138702. * Creates a new sky box
  138703. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138704. * @param environmentTexture defines the texture to use as environment texture
  138705. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138706. * @param scale defines the overall scale of the skybox
  138707. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138708. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138709. * @returns a new mesh holding the sky box
  138710. */
  138711. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138712. /**
  138713. * Creates a new environment
  138714. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138715. * @param options defines the options you can use to configure the environment
  138716. * @returns the new EnvironmentHelper
  138717. */
  138718. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138719. /**
  138720. * Creates a new VREXperienceHelper
  138721. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138722. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138723. * @returns a new VREXperienceHelper
  138724. */
  138725. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138726. /**
  138727. * Creates a new WebXRDefaultExperience
  138728. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138729. * @param options experience options
  138730. * @returns a promise for a new WebXRDefaultExperience
  138731. */
  138732. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138733. }
  138734. }
  138735. declare module BABYLON {
  138736. /**
  138737. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138738. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138739. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138740. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138741. */
  138742. export class VideoDome extends TextureDome<VideoTexture> {
  138743. /**
  138744. * Define the video source as a Monoscopic panoramic 360 video.
  138745. */
  138746. static readonly MODE_MONOSCOPIC: number;
  138747. /**
  138748. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138749. */
  138750. static readonly MODE_TOPBOTTOM: number;
  138751. /**
  138752. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138753. */
  138754. static readonly MODE_SIDEBYSIDE: number;
  138755. /**
  138756. * Get the video texture associated with this video dome
  138757. */
  138758. get videoTexture(): VideoTexture;
  138759. /**
  138760. * Get the video mode of this dome
  138761. */
  138762. get videoMode(): number;
  138763. /**
  138764. * Set the video mode of this dome.
  138765. * @see textureMode
  138766. */
  138767. set videoMode(value: number);
  138768. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138769. }
  138770. }
  138771. declare module BABYLON {
  138772. /**
  138773. * This class can be used to get instrumentation data from a Babylon engine
  138774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138775. */
  138776. export class EngineInstrumentation implements IDisposable {
  138777. /**
  138778. * Define the instrumented engine.
  138779. */
  138780. engine: Engine;
  138781. private _captureGPUFrameTime;
  138782. private _gpuFrameTimeToken;
  138783. private _gpuFrameTime;
  138784. private _captureShaderCompilationTime;
  138785. private _shaderCompilationTime;
  138786. private _onBeginFrameObserver;
  138787. private _onEndFrameObserver;
  138788. private _onBeforeShaderCompilationObserver;
  138789. private _onAfterShaderCompilationObserver;
  138790. /**
  138791. * Gets the perf counter used for GPU frame time
  138792. */
  138793. get gpuFrameTimeCounter(): PerfCounter;
  138794. /**
  138795. * Gets the GPU frame time capture status
  138796. */
  138797. get captureGPUFrameTime(): boolean;
  138798. /**
  138799. * Enable or disable the GPU frame time capture
  138800. */
  138801. set captureGPUFrameTime(value: boolean);
  138802. /**
  138803. * Gets the perf counter used for shader compilation time
  138804. */
  138805. get shaderCompilationTimeCounter(): PerfCounter;
  138806. /**
  138807. * Gets the shader compilation time capture status
  138808. */
  138809. get captureShaderCompilationTime(): boolean;
  138810. /**
  138811. * Enable or disable the shader compilation time capture
  138812. */
  138813. set captureShaderCompilationTime(value: boolean);
  138814. /**
  138815. * Instantiates a new engine instrumentation.
  138816. * This class can be used to get instrumentation data from a Babylon engine
  138817. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138818. * @param engine Defines the engine to instrument
  138819. */
  138820. constructor(
  138821. /**
  138822. * Define the instrumented engine.
  138823. */
  138824. engine: Engine);
  138825. /**
  138826. * Dispose and release associated resources.
  138827. */
  138828. dispose(): void;
  138829. }
  138830. }
  138831. declare module BABYLON {
  138832. /**
  138833. * This class can be used to get instrumentation data from a Babylon engine
  138834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138835. */
  138836. export class SceneInstrumentation implements IDisposable {
  138837. /**
  138838. * Defines the scene to instrument
  138839. */
  138840. scene: Scene;
  138841. private _captureActiveMeshesEvaluationTime;
  138842. private _activeMeshesEvaluationTime;
  138843. private _captureRenderTargetsRenderTime;
  138844. private _renderTargetsRenderTime;
  138845. private _captureFrameTime;
  138846. private _frameTime;
  138847. private _captureRenderTime;
  138848. private _renderTime;
  138849. private _captureInterFrameTime;
  138850. private _interFrameTime;
  138851. private _captureParticlesRenderTime;
  138852. private _particlesRenderTime;
  138853. private _captureSpritesRenderTime;
  138854. private _spritesRenderTime;
  138855. private _capturePhysicsTime;
  138856. private _physicsTime;
  138857. private _captureAnimationsTime;
  138858. private _animationsTime;
  138859. private _captureCameraRenderTime;
  138860. private _cameraRenderTime;
  138861. private _onBeforeActiveMeshesEvaluationObserver;
  138862. private _onAfterActiveMeshesEvaluationObserver;
  138863. private _onBeforeRenderTargetsRenderObserver;
  138864. private _onAfterRenderTargetsRenderObserver;
  138865. private _onAfterRenderObserver;
  138866. private _onBeforeDrawPhaseObserver;
  138867. private _onAfterDrawPhaseObserver;
  138868. private _onBeforeAnimationsObserver;
  138869. private _onBeforeParticlesRenderingObserver;
  138870. private _onAfterParticlesRenderingObserver;
  138871. private _onBeforeSpritesRenderingObserver;
  138872. private _onAfterSpritesRenderingObserver;
  138873. private _onBeforePhysicsObserver;
  138874. private _onAfterPhysicsObserver;
  138875. private _onAfterAnimationsObserver;
  138876. private _onBeforeCameraRenderObserver;
  138877. private _onAfterCameraRenderObserver;
  138878. /**
  138879. * Gets the perf counter used for active meshes evaluation time
  138880. */
  138881. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138882. /**
  138883. * Gets the active meshes evaluation time capture status
  138884. */
  138885. get captureActiveMeshesEvaluationTime(): boolean;
  138886. /**
  138887. * Enable or disable the active meshes evaluation time capture
  138888. */
  138889. set captureActiveMeshesEvaluationTime(value: boolean);
  138890. /**
  138891. * Gets the perf counter used for render targets render time
  138892. */
  138893. get renderTargetsRenderTimeCounter(): PerfCounter;
  138894. /**
  138895. * Gets the render targets render time capture status
  138896. */
  138897. get captureRenderTargetsRenderTime(): boolean;
  138898. /**
  138899. * Enable or disable the render targets render time capture
  138900. */
  138901. set captureRenderTargetsRenderTime(value: boolean);
  138902. /**
  138903. * Gets the perf counter used for particles render time
  138904. */
  138905. get particlesRenderTimeCounter(): PerfCounter;
  138906. /**
  138907. * Gets the particles render time capture status
  138908. */
  138909. get captureParticlesRenderTime(): boolean;
  138910. /**
  138911. * Enable or disable the particles render time capture
  138912. */
  138913. set captureParticlesRenderTime(value: boolean);
  138914. /**
  138915. * Gets the perf counter used for sprites render time
  138916. */
  138917. get spritesRenderTimeCounter(): PerfCounter;
  138918. /**
  138919. * Gets the sprites render time capture status
  138920. */
  138921. get captureSpritesRenderTime(): boolean;
  138922. /**
  138923. * Enable or disable the sprites render time capture
  138924. */
  138925. set captureSpritesRenderTime(value: boolean);
  138926. /**
  138927. * Gets the perf counter used for physics time
  138928. */
  138929. get physicsTimeCounter(): PerfCounter;
  138930. /**
  138931. * Gets the physics time capture status
  138932. */
  138933. get capturePhysicsTime(): boolean;
  138934. /**
  138935. * Enable or disable the physics time capture
  138936. */
  138937. set capturePhysicsTime(value: boolean);
  138938. /**
  138939. * Gets the perf counter used for animations time
  138940. */
  138941. get animationsTimeCounter(): PerfCounter;
  138942. /**
  138943. * Gets the animations time capture status
  138944. */
  138945. get captureAnimationsTime(): boolean;
  138946. /**
  138947. * Enable or disable the animations time capture
  138948. */
  138949. set captureAnimationsTime(value: boolean);
  138950. /**
  138951. * Gets the perf counter used for frame time capture
  138952. */
  138953. get frameTimeCounter(): PerfCounter;
  138954. /**
  138955. * Gets the frame time capture status
  138956. */
  138957. get captureFrameTime(): boolean;
  138958. /**
  138959. * Enable or disable the frame time capture
  138960. */
  138961. set captureFrameTime(value: boolean);
  138962. /**
  138963. * Gets the perf counter used for inter-frames time capture
  138964. */
  138965. get interFrameTimeCounter(): PerfCounter;
  138966. /**
  138967. * Gets the inter-frames time capture status
  138968. */
  138969. get captureInterFrameTime(): boolean;
  138970. /**
  138971. * Enable or disable the inter-frames time capture
  138972. */
  138973. set captureInterFrameTime(value: boolean);
  138974. /**
  138975. * Gets the perf counter used for render time capture
  138976. */
  138977. get renderTimeCounter(): PerfCounter;
  138978. /**
  138979. * Gets the render time capture status
  138980. */
  138981. get captureRenderTime(): boolean;
  138982. /**
  138983. * Enable or disable the render time capture
  138984. */
  138985. set captureRenderTime(value: boolean);
  138986. /**
  138987. * Gets the perf counter used for camera render time capture
  138988. */
  138989. get cameraRenderTimeCounter(): PerfCounter;
  138990. /**
  138991. * Gets the camera render time capture status
  138992. */
  138993. get captureCameraRenderTime(): boolean;
  138994. /**
  138995. * Enable or disable the camera render time capture
  138996. */
  138997. set captureCameraRenderTime(value: boolean);
  138998. /**
  138999. * Gets the perf counter used for draw calls
  139000. */
  139001. get drawCallsCounter(): PerfCounter;
  139002. /**
  139003. * Instantiates a new scene instrumentation.
  139004. * This class can be used to get instrumentation data from a Babylon engine
  139005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139006. * @param scene Defines the scene to instrument
  139007. */
  139008. constructor(
  139009. /**
  139010. * Defines the scene to instrument
  139011. */
  139012. scene: Scene);
  139013. /**
  139014. * Dispose and release associated resources.
  139015. */
  139016. dispose(): void;
  139017. }
  139018. }
  139019. declare module BABYLON {
  139020. /** @hidden */
  139021. export var glowMapGenerationPixelShader: {
  139022. name: string;
  139023. shader: string;
  139024. };
  139025. }
  139026. declare module BABYLON {
  139027. /** @hidden */
  139028. export var glowMapGenerationVertexShader: {
  139029. name: string;
  139030. shader: string;
  139031. };
  139032. }
  139033. declare module BABYLON {
  139034. /**
  139035. * Effect layer options. This helps customizing the behaviour
  139036. * of the effect layer.
  139037. */
  139038. export interface IEffectLayerOptions {
  139039. /**
  139040. * Multiplication factor apply to the canvas size to compute the render target size
  139041. * used to generated the objects (the smaller the faster).
  139042. */
  139043. mainTextureRatio: number;
  139044. /**
  139045. * Enforces a fixed size texture to ensure effect stability across devices.
  139046. */
  139047. mainTextureFixedSize?: number;
  139048. /**
  139049. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139050. */
  139051. alphaBlendingMode: number;
  139052. /**
  139053. * The camera attached to the layer.
  139054. */
  139055. camera: Nullable<Camera>;
  139056. /**
  139057. * The rendering group to draw the layer in.
  139058. */
  139059. renderingGroupId: number;
  139060. }
  139061. /**
  139062. * The effect layer Helps adding post process effect blended with the main pass.
  139063. *
  139064. * This can be for instance use to generate glow or higlight effects on the scene.
  139065. *
  139066. * The effect layer class can not be used directly and is intented to inherited from to be
  139067. * customized per effects.
  139068. */
  139069. export abstract class EffectLayer {
  139070. private _vertexBuffers;
  139071. private _indexBuffer;
  139072. private _cachedDefines;
  139073. private _effectLayerMapGenerationEffect;
  139074. private _effectLayerOptions;
  139075. private _mergeEffect;
  139076. protected _scene: Scene;
  139077. protected _engine: Engine;
  139078. protected _maxSize: number;
  139079. protected _mainTextureDesiredSize: ISize;
  139080. protected _mainTexture: RenderTargetTexture;
  139081. protected _shouldRender: boolean;
  139082. protected _postProcesses: PostProcess[];
  139083. protected _textures: BaseTexture[];
  139084. protected _emissiveTextureAndColor: {
  139085. texture: Nullable<BaseTexture>;
  139086. color: Color4;
  139087. };
  139088. /**
  139089. * The name of the layer
  139090. */
  139091. name: string;
  139092. /**
  139093. * The clear color of the texture used to generate the glow map.
  139094. */
  139095. neutralColor: Color4;
  139096. /**
  139097. * Specifies whether the highlight layer is enabled or not.
  139098. */
  139099. isEnabled: boolean;
  139100. /**
  139101. * Gets the camera attached to the layer.
  139102. */
  139103. get camera(): Nullable<Camera>;
  139104. /**
  139105. * Gets the rendering group id the layer should render in.
  139106. */
  139107. get renderingGroupId(): number;
  139108. set renderingGroupId(renderingGroupId: number);
  139109. /**
  139110. * An event triggered when the effect layer has been disposed.
  139111. */
  139112. onDisposeObservable: Observable<EffectLayer>;
  139113. /**
  139114. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139115. */
  139116. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139117. /**
  139118. * An event triggered when the generated texture is being merged in the scene.
  139119. */
  139120. onBeforeComposeObservable: Observable<EffectLayer>;
  139121. /**
  139122. * An event triggered when the mesh is rendered into the effect render target.
  139123. */
  139124. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139125. /**
  139126. * An event triggered after the mesh has been rendered into the effect render target.
  139127. */
  139128. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139129. /**
  139130. * An event triggered when the generated texture has been merged in the scene.
  139131. */
  139132. onAfterComposeObservable: Observable<EffectLayer>;
  139133. /**
  139134. * An event triggered when the efffect layer changes its size.
  139135. */
  139136. onSizeChangedObservable: Observable<EffectLayer>;
  139137. /** @hidden */
  139138. static _SceneComponentInitialization: (scene: Scene) => void;
  139139. /**
  139140. * Instantiates a new effect Layer and references it in the scene.
  139141. * @param name The name of the layer
  139142. * @param scene The scene to use the layer in
  139143. */
  139144. constructor(
  139145. /** The Friendly of the effect in the scene */
  139146. name: string, scene: Scene);
  139147. /**
  139148. * Get the effect name of the layer.
  139149. * @return The effect name
  139150. */
  139151. abstract getEffectName(): string;
  139152. /**
  139153. * Checks for the readiness of the element composing the layer.
  139154. * @param subMesh the mesh to check for
  139155. * @param useInstances specify whether or not to use instances to render the mesh
  139156. * @return true if ready otherwise, false
  139157. */
  139158. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139159. /**
  139160. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139161. * @returns true if the effect requires stencil during the main canvas render pass.
  139162. */
  139163. abstract needStencil(): boolean;
  139164. /**
  139165. * Create the merge effect. This is the shader use to blit the information back
  139166. * to the main canvas at the end of the scene rendering.
  139167. * @returns The effect containing the shader used to merge the effect on the main canvas
  139168. */
  139169. protected abstract _createMergeEffect(): Effect;
  139170. /**
  139171. * Creates the render target textures and post processes used in the effect layer.
  139172. */
  139173. protected abstract _createTextureAndPostProcesses(): void;
  139174. /**
  139175. * Implementation specific of rendering the generating effect on the main canvas.
  139176. * @param effect The effect used to render through
  139177. */
  139178. protected abstract _internalRender(effect: Effect): void;
  139179. /**
  139180. * Sets the required values for both the emissive texture and and the main color.
  139181. */
  139182. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139183. /**
  139184. * Free any resources and references associated to a mesh.
  139185. * Internal use
  139186. * @param mesh The mesh to free.
  139187. */
  139188. abstract _disposeMesh(mesh: Mesh): void;
  139189. /**
  139190. * Serializes this layer (Glow or Highlight for example)
  139191. * @returns a serialized layer object
  139192. */
  139193. abstract serialize?(): any;
  139194. /**
  139195. * Initializes the effect layer with the required options.
  139196. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139197. */
  139198. protected _init(options: Partial<IEffectLayerOptions>): void;
  139199. /**
  139200. * Generates the index buffer of the full screen quad blending to the main canvas.
  139201. */
  139202. private _generateIndexBuffer;
  139203. /**
  139204. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139205. */
  139206. private _generateVertexBuffer;
  139207. /**
  139208. * Sets the main texture desired size which is the closest power of two
  139209. * of the engine canvas size.
  139210. */
  139211. private _setMainTextureSize;
  139212. /**
  139213. * Creates the main texture for the effect layer.
  139214. */
  139215. protected _createMainTexture(): void;
  139216. /**
  139217. * Adds specific effects defines.
  139218. * @param defines The defines to add specifics to.
  139219. */
  139220. protected _addCustomEffectDefines(defines: string[]): void;
  139221. /**
  139222. * Checks for the readiness of the element composing the layer.
  139223. * @param subMesh the mesh to check for
  139224. * @param useInstances specify whether or not to use instances to render the mesh
  139225. * @param emissiveTexture the associated emissive texture used to generate the glow
  139226. * @return true if ready otherwise, false
  139227. */
  139228. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139229. /**
  139230. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139231. */
  139232. render(): void;
  139233. /**
  139234. * Determine if a given mesh will be used in the current effect.
  139235. * @param mesh mesh to test
  139236. * @returns true if the mesh will be used
  139237. */
  139238. hasMesh(mesh: AbstractMesh): boolean;
  139239. /**
  139240. * Returns true if the layer contains information to display, otherwise false.
  139241. * @returns true if the glow layer should be rendered
  139242. */
  139243. shouldRender(): boolean;
  139244. /**
  139245. * Returns true if the mesh should render, otherwise false.
  139246. * @param mesh The mesh to render
  139247. * @returns true if it should render otherwise false
  139248. */
  139249. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139250. /**
  139251. * Returns true if the mesh can be rendered, otherwise false.
  139252. * @param mesh The mesh to render
  139253. * @param material The material used on the mesh
  139254. * @returns true if it can be rendered otherwise false
  139255. */
  139256. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139257. /**
  139258. * Returns true if the mesh should render, otherwise false.
  139259. * @param mesh The mesh to render
  139260. * @returns true if it should render otherwise false
  139261. */
  139262. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139263. /**
  139264. * Renders the submesh passed in parameter to the generation map.
  139265. */
  139266. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139267. /**
  139268. * Defines whether the current material of the mesh should be use to render the effect.
  139269. * @param mesh defines the current mesh to render
  139270. */
  139271. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139272. /**
  139273. * Rebuild the required buffers.
  139274. * @hidden Internal use only.
  139275. */
  139276. _rebuild(): void;
  139277. /**
  139278. * Dispose only the render target textures and post process.
  139279. */
  139280. private _disposeTextureAndPostProcesses;
  139281. /**
  139282. * Dispose the highlight layer and free resources.
  139283. */
  139284. dispose(): void;
  139285. /**
  139286. * Gets the class name of the effect layer
  139287. * @returns the string with the class name of the effect layer
  139288. */
  139289. getClassName(): string;
  139290. /**
  139291. * Creates an effect layer from parsed effect layer data
  139292. * @param parsedEffectLayer defines effect layer data
  139293. * @param scene defines the current scene
  139294. * @param rootUrl defines the root URL containing the effect layer information
  139295. * @returns a parsed effect Layer
  139296. */
  139297. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139298. }
  139299. }
  139300. declare module BABYLON {
  139301. interface AbstractScene {
  139302. /**
  139303. * The list of effect layers (highlights/glow) added to the scene
  139304. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139305. * @see https://doc.babylonjs.com/how_to/glow_layer
  139306. */
  139307. effectLayers: Array<EffectLayer>;
  139308. /**
  139309. * Removes the given effect layer from this scene.
  139310. * @param toRemove defines the effect layer to remove
  139311. * @returns the index of the removed effect layer
  139312. */
  139313. removeEffectLayer(toRemove: EffectLayer): number;
  139314. /**
  139315. * Adds the given effect layer to this scene
  139316. * @param newEffectLayer defines the effect layer to add
  139317. */
  139318. addEffectLayer(newEffectLayer: EffectLayer): void;
  139319. }
  139320. /**
  139321. * Defines the layer scene component responsible to manage any effect layers
  139322. * in a given scene.
  139323. */
  139324. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139325. /**
  139326. * The component name helpfull to identify the component in the list of scene components.
  139327. */
  139328. readonly name: string;
  139329. /**
  139330. * The scene the component belongs to.
  139331. */
  139332. scene: Scene;
  139333. private _engine;
  139334. private _renderEffects;
  139335. private _needStencil;
  139336. private _previousStencilState;
  139337. /**
  139338. * Creates a new instance of the component for the given scene
  139339. * @param scene Defines the scene to register the component in
  139340. */
  139341. constructor(scene: Scene);
  139342. /**
  139343. * Registers the component in a given scene
  139344. */
  139345. register(): void;
  139346. /**
  139347. * Rebuilds the elements related to this component in case of
  139348. * context lost for instance.
  139349. */
  139350. rebuild(): void;
  139351. /**
  139352. * Serializes the component data to the specified json object
  139353. * @param serializationObject The object to serialize to
  139354. */
  139355. serialize(serializationObject: any): void;
  139356. /**
  139357. * Adds all the elements from the container to the scene
  139358. * @param container the container holding the elements
  139359. */
  139360. addFromContainer(container: AbstractScene): void;
  139361. /**
  139362. * Removes all the elements in the container from the scene
  139363. * @param container contains the elements to remove
  139364. * @param dispose if the removed element should be disposed (default: false)
  139365. */
  139366. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139367. /**
  139368. * Disposes the component and the associated ressources.
  139369. */
  139370. dispose(): void;
  139371. private _isReadyForMesh;
  139372. private _renderMainTexture;
  139373. private _setStencil;
  139374. private _setStencilBack;
  139375. private _draw;
  139376. private _drawCamera;
  139377. private _drawRenderingGroup;
  139378. }
  139379. }
  139380. declare module BABYLON {
  139381. /** @hidden */
  139382. export var glowMapMergePixelShader: {
  139383. name: string;
  139384. shader: string;
  139385. };
  139386. }
  139387. declare module BABYLON {
  139388. /** @hidden */
  139389. export var glowMapMergeVertexShader: {
  139390. name: string;
  139391. shader: string;
  139392. };
  139393. }
  139394. declare module BABYLON {
  139395. interface AbstractScene {
  139396. /**
  139397. * Return a the first highlight layer of the scene with a given name.
  139398. * @param name The name of the highlight layer to look for.
  139399. * @return The highlight layer if found otherwise null.
  139400. */
  139401. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139402. }
  139403. /**
  139404. * Glow layer options. This helps customizing the behaviour
  139405. * of the glow layer.
  139406. */
  139407. export interface IGlowLayerOptions {
  139408. /**
  139409. * Multiplication factor apply to the canvas size to compute the render target size
  139410. * used to generated the glowing objects (the smaller the faster).
  139411. */
  139412. mainTextureRatio: number;
  139413. /**
  139414. * Enforces a fixed size texture to ensure resize independant blur.
  139415. */
  139416. mainTextureFixedSize?: number;
  139417. /**
  139418. * How big is the kernel of the blur texture.
  139419. */
  139420. blurKernelSize: number;
  139421. /**
  139422. * The camera attached to the layer.
  139423. */
  139424. camera: Nullable<Camera>;
  139425. /**
  139426. * Enable MSAA by chosing the number of samples.
  139427. */
  139428. mainTextureSamples?: number;
  139429. /**
  139430. * The rendering group to draw the layer in.
  139431. */
  139432. renderingGroupId: number;
  139433. }
  139434. /**
  139435. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139436. *
  139437. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139438. *
  139439. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139440. */
  139441. export class GlowLayer extends EffectLayer {
  139442. /**
  139443. * Effect Name of the layer.
  139444. */
  139445. static readonly EffectName: string;
  139446. /**
  139447. * The default blur kernel size used for the glow.
  139448. */
  139449. static DefaultBlurKernelSize: number;
  139450. /**
  139451. * The default texture size ratio used for the glow.
  139452. */
  139453. static DefaultTextureRatio: number;
  139454. /**
  139455. * Sets the kernel size of the blur.
  139456. */
  139457. set blurKernelSize(value: number);
  139458. /**
  139459. * Gets the kernel size of the blur.
  139460. */
  139461. get blurKernelSize(): number;
  139462. /**
  139463. * Sets the glow intensity.
  139464. */
  139465. set intensity(value: number);
  139466. /**
  139467. * Gets the glow intensity.
  139468. */
  139469. get intensity(): number;
  139470. private _options;
  139471. private _intensity;
  139472. private _horizontalBlurPostprocess1;
  139473. private _verticalBlurPostprocess1;
  139474. private _horizontalBlurPostprocess2;
  139475. private _verticalBlurPostprocess2;
  139476. private _blurTexture1;
  139477. private _blurTexture2;
  139478. private _postProcesses1;
  139479. private _postProcesses2;
  139480. private _includedOnlyMeshes;
  139481. private _excludedMeshes;
  139482. private _meshesUsingTheirOwnMaterials;
  139483. /**
  139484. * Callback used to let the user override the color selection on a per mesh basis
  139485. */
  139486. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139487. /**
  139488. * Callback used to let the user override the texture selection on a per mesh basis
  139489. */
  139490. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139491. /**
  139492. * Instantiates a new glow Layer and references it to the scene.
  139493. * @param name The name of the layer
  139494. * @param scene The scene to use the layer in
  139495. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139496. */
  139497. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139498. /**
  139499. * Get the effect name of the layer.
  139500. * @return The effect name
  139501. */
  139502. getEffectName(): string;
  139503. /**
  139504. * Create the merge effect. This is the shader use to blit the information back
  139505. * to the main canvas at the end of the scene rendering.
  139506. */
  139507. protected _createMergeEffect(): Effect;
  139508. /**
  139509. * Creates the render target textures and post processes used in the glow layer.
  139510. */
  139511. protected _createTextureAndPostProcesses(): void;
  139512. /**
  139513. * Checks for the readiness of the element composing the layer.
  139514. * @param subMesh the mesh to check for
  139515. * @param useInstances specify wether or not to use instances to render the mesh
  139516. * @param emissiveTexture the associated emissive texture used to generate the glow
  139517. * @return true if ready otherwise, false
  139518. */
  139519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139520. /**
  139521. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139522. */
  139523. needStencil(): boolean;
  139524. /**
  139525. * Returns true if the mesh can be rendered, otherwise false.
  139526. * @param mesh The mesh to render
  139527. * @param material The material used on the mesh
  139528. * @returns true if it can be rendered otherwise false
  139529. */
  139530. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139531. /**
  139532. * Implementation specific of rendering the generating effect on the main canvas.
  139533. * @param effect The effect used to render through
  139534. */
  139535. protected _internalRender(effect: Effect): void;
  139536. /**
  139537. * Sets the required values for both the emissive texture and and the main color.
  139538. */
  139539. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139540. /**
  139541. * Returns true if the mesh should render, otherwise false.
  139542. * @param mesh The mesh to render
  139543. * @returns true if it should render otherwise false
  139544. */
  139545. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139546. /**
  139547. * Adds specific effects defines.
  139548. * @param defines The defines to add specifics to.
  139549. */
  139550. protected _addCustomEffectDefines(defines: string[]): void;
  139551. /**
  139552. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139553. * @param mesh The mesh to exclude from the glow layer
  139554. */
  139555. addExcludedMesh(mesh: Mesh): void;
  139556. /**
  139557. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139558. * @param mesh The mesh to remove
  139559. */
  139560. removeExcludedMesh(mesh: Mesh): void;
  139561. /**
  139562. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139563. * @param mesh The mesh to include in the glow layer
  139564. */
  139565. addIncludedOnlyMesh(mesh: Mesh): void;
  139566. /**
  139567. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139568. * @param mesh The mesh to remove
  139569. */
  139570. removeIncludedOnlyMesh(mesh: Mesh): void;
  139571. /**
  139572. * Determine if a given mesh will be used in the glow layer
  139573. * @param mesh The mesh to test
  139574. * @returns true if the mesh will be highlighted by the current glow layer
  139575. */
  139576. hasMesh(mesh: AbstractMesh): boolean;
  139577. /**
  139578. * Defines whether the current material of the mesh should be use to render the effect.
  139579. * @param mesh defines the current mesh to render
  139580. */
  139581. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139582. /**
  139583. * Add a mesh to be rendered through its own material and not with emissive only.
  139584. * @param mesh The mesh for which we need to use its material
  139585. */
  139586. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139587. /**
  139588. * Remove a mesh from being rendered through its own material and not with emissive only.
  139589. * @param mesh The mesh for which we need to not use its material
  139590. */
  139591. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139592. /**
  139593. * Free any resources and references associated to a mesh.
  139594. * Internal use
  139595. * @param mesh The mesh to free.
  139596. * @hidden
  139597. */
  139598. _disposeMesh(mesh: Mesh): void;
  139599. /**
  139600. * Gets the class name of the effect layer
  139601. * @returns the string with the class name of the effect layer
  139602. */
  139603. getClassName(): string;
  139604. /**
  139605. * Serializes this glow layer
  139606. * @returns a serialized glow layer object
  139607. */
  139608. serialize(): any;
  139609. /**
  139610. * Creates a Glow Layer from parsed glow layer data
  139611. * @param parsedGlowLayer defines glow layer data
  139612. * @param scene defines the current scene
  139613. * @param rootUrl defines the root URL containing the glow layer information
  139614. * @returns a parsed Glow Layer
  139615. */
  139616. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139617. }
  139618. }
  139619. declare module BABYLON {
  139620. /** @hidden */
  139621. export var glowBlurPostProcessPixelShader: {
  139622. name: string;
  139623. shader: string;
  139624. };
  139625. }
  139626. declare module BABYLON {
  139627. interface AbstractScene {
  139628. /**
  139629. * Return a the first highlight layer of the scene with a given name.
  139630. * @param name The name of the highlight layer to look for.
  139631. * @return The highlight layer if found otherwise null.
  139632. */
  139633. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139634. }
  139635. /**
  139636. * Highlight layer options. This helps customizing the behaviour
  139637. * of the highlight layer.
  139638. */
  139639. export interface IHighlightLayerOptions {
  139640. /**
  139641. * Multiplication factor apply to the canvas size to compute the render target size
  139642. * used to generated the glowing objects (the smaller the faster).
  139643. */
  139644. mainTextureRatio: number;
  139645. /**
  139646. * Enforces a fixed size texture to ensure resize independant blur.
  139647. */
  139648. mainTextureFixedSize?: number;
  139649. /**
  139650. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139651. * of the picture to blur (the smaller the faster).
  139652. */
  139653. blurTextureSizeRatio: number;
  139654. /**
  139655. * How big in texel of the blur texture is the vertical blur.
  139656. */
  139657. blurVerticalSize: number;
  139658. /**
  139659. * How big in texel of the blur texture is the horizontal blur.
  139660. */
  139661. blurHorizontalSize: number;
  139662. /**
  139663. * Alpha blending mode used to apply the blur. Default is combine.
  139664. */
  139665. alphaBlendingMode: number;
  139666. /**
  139667. * The camera attached to the layer.
  139668. */
  139669. camera: Nullable<Camera>;
  139670. /**
  139671. * Should we display highlight as a solid stroke?
  139672. */
  139673. isStroke?: boolean;
  139674. /**
  139675. * The rendering group to draw the layer in.
  139676. */
  139677. renderingGroupId: number;
  139678. }
  139679. /**
  139680. * The highlight layer Helps adding a glow effect around a mesh.
  139681. *
  139682. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139683. * glowy meshes to your scene.
  139684. *
  139685. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139686. */
  139687. export class HighlightLayer extends EffectLayer {
  139688. name: string;
  139689. /**
  139690. * Effect Name of the highlight layer.
  139691. */
  139692. static readonly EffectName: string;
  139693. /**
  139694. * The neutral color used during the preparation of the glow effect.
  139695. * This is black by default as the blend operation is a blend operation.
  139696. */
  139697. static NeutralColor: Color4;
  139698. /**
  139699. * Stencil value used for glowing meshes.
  139700. */
  139701. static GlowingMeshStencilReference: number;
  139702. /**
  139703. * Stencil value used for the other meshes in the scene.
  139704. */
  139705. static NormalMeshStencilReference: number;
  139706. /**
  139707. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139708. */
  139709. innerGlow: boolean;
  139710. /**
  139711. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139712. */
  139713. outerGlow: boolean;
  139714. /**
  139715. * Specifies the horizontal size of the blur.
  139716. */
  139717. set blurHorizontalSize(value: number);
  139718. /**
  139719. * Specifies the vertical size of the blur.
  139720. */
  139721. set blurVerticalSize(value: number);
  139722. /**
  139723. * Gets the horizontal size of the blur.
  139724. */
  139725. get blurHorizontalSize(): number;
  139726. /**
  139727. * Gets the vertical size of the blur.
  139728. */
  139729. get blurVerticalSize(): number;
  139730. /**
  139731. * An event triggered when the highlight layer is being blurred.
  139732. */
  139733. onBeforeBlurObservable: Observable<HighlightLayer>;
  139734. /**
  139735. * An event triggered when the highlight layer has been blurred.
  139736. */
  139737. onAfterBlurObservable: Observable<HighlightLayer>;
  139738. private _instanceGlowingMeshStencilReference;
  139739. private _options;
  139740. private _downSamplePostprocess;
  139741. private _horizontalBlurPostprocess;
  139742. private _verticalBlurPostprocess;
  139743. private _blurTexture;
  139744. private _meshes;
  139745. private _excludedMeshes;
  139746. /**
  139747. * Instantiates a new highlight Layer and references it to the scene..
  139748. * @param name The name of the layer
  139749. * @param scene The scene to use the layer in
  139750. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139751. */
  139752. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139753. /**
  139754. * Get the effect name of the layer.
  139755. * @return The effect name
  139756. */
  139757. getEffectName(): string;
  139758. /**
  139759. * Create the merge effect. This is the shader use to blit the information back
  139760. * to the main canvas at the end of the scene rendering.
  139761. */
  139762. protected _createMergeEffect(): Effect;
  139763. /**
  139764. * Creates the render target textures and post processes used in the highlight layer.
  139765. */
  139766. protected _createTextureAndPostProcesses(): void;
  139767. /**
  139768. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139769. */
  139770. needStencil(): boolean;
  139771. /**
  139772. * Checks for the readiness of the element composing the layer.
  139773. * @param subMesh the mesh to check for
  139774. * @param useInstances specify wether or not to use instances to render the mesh
  139775. * @param emissiveTexture the associated emissive texture used to generate the glow
  139776. * @return true if ready otherwise, false
  139777. */
  139778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139779. /**
  139780. * Implementation specific of rendering the generating effect on the main canvas.
  139781. * @param effect The effect used to render through
  139782. */
  139783. protected _internalRender(effect: Effect): void;
  139784. /**
  139785. * Returns true if the layer contains information to display, otherwise false.
  139786. */
  139787. shouldRender(): boolean;
  139788. /**
  139789. * Returns true if the mesh should render, otherwise false.
  139790. * @param mesh The mesh to render
  139791. * @returns true if it should render otherwise false
  139792. */
  139793. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139794. /**
  139795. * Returns true if the mesh can be rendered, otherwise false.
  139796. * @param mesh The mesh to render
  139797. * @param material The material used on the mesh
  139798. * @returns true if it can be rendered otherwise false
  139799. */
  139800. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139801. /**
  139802. * Adds specific effects defines.
  139803. * @param defines The defines to add specifics to.
  139804. */
  139805. protected _addCustomEffectDefines(defines: string[]): void;
  139806. /**
  139807. * Sets the required values for both the emissive texture and and the main color.
  139808. */
  139809. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139810. /**
  139811. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139812. * @param mesh The mesh to exclude from the highlight layer
  139813. */
  139814. addExcludedMesh(mesh: Mesh): void;
  139815. /**
  139816. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139817. * @param mesh The mesh to highlight
  139818. */
  139819. removeExcludedMesh(mesh: Mesh): void;
  139820. /**
  139821. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139822. * @param mesh mesh to test
  139823. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139824. */
  139825. hasMesh(mesh: AbstractMesh): boolean;
  139826. /**
  139827. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139828. * @param mesh The mesh to highlight
  139829. * @param color The color of the highlight
  139830. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139831. */
  139832. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139833. /**
  139834. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139835. * @param mesh The mesh to highlight
  139836. */
  139837. removeMesh(mesh: Mesh): void;
  139838. /**
  139839. * Remove all the meshes currently referenced in the highlight layer
  139840. */
  139841. removeAllMeshes(): void;
  139842. /**
  139843. * Force the stencil to the normal expected value for none glowing parts
  139844. */
  139845. private _defaultStencilReference;
  139846. /**
  139847. * Free any resources and references associated to a mesh.
  139848. * Internal use
  139849. * @param mesh The mesh to free.
  139850. * @hidden
  139851. */
  139852. _disposeMesh(mesh: Mesh): void;
  139853. /**
  139854. * Dispose the highlight layer and free resources.
  139855. */
  139856. dispose(): void;
  139857. /**
  139858. * Gets the class name of the effect layer
  139859. * @returns the string with the class name of the effect layer
  139860. */
  139861. getClassName(): string;
  139862. /**
  139863. * Serializes this Highlight layer
  139864. * @returns a serialized Highlight layer object
  139865. */
  139866. serialize(): any;
  139867. /**
  139868. * Creates a Highlight layer from parsed Highlight layer data
  139869. * @param parsedHightlightLayer defines the Highlight layer data
  139870. * @param scene defines the current scene
  139871. * @param rootUrl defines the root URL containing the Highlight layer information
  139872. * @returns a parsed Highlight layer
  139873. */
  139874. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139875. }
  139876. }
  139877. declare module BABYLON {
  139878. interface AbstractScene {
  139879. /**
  139880. * The list of layers (background and foreground) of the scene
  139881. */
  139882. layers: Array<Layer>;
  139883. }
  139884. /**
  139885. * Defines the layer scene component responsible to manage any layers
  139886. * in a given scene.
  139887. */
  139888. export class LayerSceneComponent implements ISceneComponent {
  139889. /**
  139890. * The component name helpfull to identify the component in the list of scene components.
  139891. */
  139892. readonly name: string;
  139893. /**
  139894. * The scene the component belongs to.
  139895. */
  139896. scene: Scene;
  139897. private _engine;
  139898. /**
  139899. * Creates a new instance of the component for the given scene
  139900. * @param scene Defines the scene to register the component in
  139901. */
  139902. constructor(scene: Scene);
  139903. /**
  139904. * Registers the component in a given scene
  139905. */
  139906. register(): void;
  139907. /**
  139908. * Rebuilds the elements related to this component in case of
  139909. * context lost for instance.
  139910. */
  139911. rebuild(): void;
  139912. /**
  139913. * Disposes the component and the associated ressources.
  139914. */
  139915. dispose(): void;
  139916. private _draw;
  139917. private _drawCameraPredicate;
  139918. private _drawCameraBackground;
  139919. private _drawCameraForeground;
  139920. private _drawRenderTargetPredicate;
  139921. private _drawRenderTargetBackground;
  139922. private _drawRenderTargetForeground;
  139923. /**
  139924. * Adds all the elements from the container to the scene
  139925. * @param container the container holding the elements
  139926. */
  139927. addFromContainer(container: AbstractScene): void;
  139928. /**
  139929. * Removes all the elements in the container from the scene
  139930. * @param container contains the elements to remove
  139931. * @param dispose if the removed element should be disposed (default: false)
  139932. */
  139933. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139934. }
  139935. }
  139936. declare module BABYLON {
  139937. /** @hidden */
  139938. export var layerPixelShader: {
  139939. name: string;
  139940. shader: string;
  139941. };
  139942. }
  139943. declare module BABYLON {
  139944. /** @hidden */
  139945. export var layerVertexShader: {
  139946. name: string;
  139947. shader: string;
  139948. };
  139949. }
  139950. declare module BABYLON {
  139951. /**
  139952. * This represents a full screen 2d layer.
  139953. * This can be useful to display a picture in the background of your scene for instance.
  139954. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139955. */
  139956. export class Layer {
  139957. /**
  139958. * Define the name of the layer.
  139959. */
  139960. name: string;
  139961. /**
  139962. * Define the texture the layer should display.
  139963. */
  139964. texture: Nullable<Texture>;
  139965. /**
  139966. * Is the layer in background or foreground.
  139967. */
  139968. isBackground: boolean;
  139969. /**
  139970. * Define the color of the layer (instead of texture).
  139971. */
  139972. color: Color4;
  139973. /**
  139974. * Define the scale of the layer in order to zoom in out of the texture.
  139975. */
  139976. scale: Vector2;
  139977. /**
  139978. * Define an offset for the layer in order to shift the texture.
  139979. */
  139980. offset: Vector2;
  139981. /**
  139982. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139983. */
  139984. alphaBlendingMode: number;
  139985. /**
  139986. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139987. * Alpha test will not mix with the background color in case of transparency.
  139988. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139989. */
  139990. alphaTest: boolean;
  139991. /**
  139992. * Define a mask to restrict the layer to only some of the scene cameras.
  139993. */
  139994. layerMask: number;
  139995. /**
  139996. * Define the list of render target the layer is visible into.
  139997. */
  139998. renderTargetTextures: RenderTargetTexture[];
  139999. /**
  140000. * Define if the layer is only used in renderTarget or if it also
  140001. * renders in the main frame buffer of the canvas.
  140002. */
  140003. renderOnlyInRenderTargetTextures: boolean;
  140004. private _scene;
  140005. private _vertexBuffers;
  140006. private _indexBuffer;
  140007. private _effect;
  140008. private _previousDefines;
  140009. /**
  140010. * An event triggered when the layer is disposed.
  140011. */
  140012. onDisposeObservable: Observable<Layer>;
  140013. private _onDisposeObserver;
  140014. /**
  140015. * Back compatibility with callback before the onDisposeObservable existed.
  140016. * The set callback will be triggered when the layer has been disposed.
  140017. */
  140018. set onDispose(callback: () => void);
  140019. /**
  140020. * An event triggered before rendering the scene
  140021. */
  140022. onBeforeRenderObservable: Observable<Layer>;
  140023. private _onBeforeRenderObserver;
  140024. /**
  140025. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140026. * The set callback will be triggered just before rendering the layer.
  140027. */
  140028. set onBeforeRender(callback: () => void);
  140029. /**
  140030. * An event triggered after rendering the scene
  140031. */
  140032. onAfterRenderObservable: Observable<Layer>;
  140033. private _onAfterRenderObserver;
  140034. /**
  140035. * Back compatibility with callback before the onAfterRenderObservable existed.
  140036. * The set callback will be triggered just after rendering the layer.
  140037. */
  140038. set onAfterRender(callback: () => void);
  140039. /**
  140040. * Instantiates a new layer.
  140041. * This represents a full screen 2d layer.
  140042. * This can be useful to display a picture in the background of your scene for instance.
  140043. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140044. * @param name Define the name of the layer in the scene
  140045. * @param imgUrl Define the url of the texture to display in the layer
  140046. * @param scene Define the scene the layer belongs to
  140047. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140048. * @param color Defines a color for the layer
  140049. */
  140050. constructor(
  140051. /**
  140052. * Define the name of the layer.
  140053. */
  140054. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140055. private _createIndexBuffer;
  140056. /** @hidden */
  140057. _rebuild(): void;
  140058. /**
  140059. * Renders the layer in the scene.
  140060. */
  140061. render(): void;
  140062. /**
  140063. * Disposes and releases the associated ressources.
  140064. */
  140065. dispose(): void;
  140066. }
  140067. }
  140068. declare module BABYLON {
  140069. /** @hidden */
  140070. export var lensFlarePixelShader: {
  140071. name: string;
  140072. shader: string;
  140073. };
  140074. }
  140075. declare module BABYLON {
  140076. /** @hidden */
  140077. export var lensFlareVertexShader: {
  140078. name: string;
  140079. shader: string;
  140080. };
  140081. }
  140082. declare module BABYLON {
  140083. /**
  140084. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140085. * It is usually composed of several `lensFlare`.
  140086. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140087. */
  140088. export class LensFlareSystem {
  140089. /**
  140090. * Define the name of the lens flare system
  140091. */
  140092. name: string;
  140093. /**
  140094. * List of lens flares used in this system.
  140095. */
  140096. lensFlares: LensFlare[];
  140097. /**
  140098. * Define a limit from the border the lens flare can be visible.
  140099. */
  140100. borderLimit: number;
  140101. /**
  140102. * Define a viewport border we do not want to see the lens flare in.
  140103. */
  140104. viewportBorder: number;
  140105. /**
  140106. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140107. */
  140108. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140109. /**
  140110. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140111. */
  140112. layerMask: number;
  140113. /**
  140114. * Define the id of the lens flare system in the scene.
  140115. * (equal to name by default)
  140116. */
  140117. id: string;
  140118. private _scene;
  140119. private _emitter;
  140120. private _vertexBuffers;
  140121. private _indexBuffer;
  140122. private _effect;
  140123. private _positionX;
  140124. private _positionY;
  140125. private _isEnabled;
  140126. /** @hidden */
  140127. static _SceneComponentInitialization: (scene: Scene) => void;
  140128. /**
  140129. * Instantiates a lens flare system.
  140130. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140131. * It is usually composed of several `lensFlare`.
  140132. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140133. * @param name Define the name of the lens flare system in the scene
  140134. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140135. * @param scene Define the scene the lens flare system belongs to
  140136. */
  140137. constructor(
  140138. /**
  140139. * Define the name of the lens flare system
  140140. */
  140141. name: string, emitter: any, scene: Scene);
  140142. /**
  140143. * Define if the lens flare system is enabled.
  140144. */
  140145. get isEnabled(): boolean;
  140146. set isEnabled(value: boolean);
  140147. /**
  140148. * Get the scene the effects belongs to.
  140149. * @returns the scene holding the lens flare system
  140150. */
  140151. getScene(): Scene;
  140152. /**
  140153. * Get the emitter of the lens flare system.
  140154. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140155. * @returns the emitter of the lens flare system
  140156. */
  140157. getEmitter(): any;
  140158. /**
  140159. * Set the emitter of the lens flare system.
  140160. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140161. * @param newEmitter Define the new emitter of the system
  140162. */
  140163. setEmitter(newEmitter: any): void;
  140164. /**
  140165. * Get the lens flare system emitter position.
  140166. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140167. * @returns the position
  140168. */
  140169. getEmitterPosition(): Vector3;
  140170. /**
  140171. * @hidden
  140172. */
  140173. computeEffectivePosition(globalViewport: Viewport): boolean;
  140174. /** @hidden */
  140175. _isVisible(): boolean;
  140176. /**
  140177. * @hidden
  140178. */
  140179. render(): boolean;
  140180. /**
  140181. * Dispose and release the lens flare with its associated resources.
  140182. */
  140183. dispose(): void;
  140184. /**
  140185. * Parse a lens flare system from a JSON repressentation
  140186. * @param parsedLensFlareSystem Define the JSON to parse
  140187. * @param scene Define the scene the parsed system should be instantiated in
  140188. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140189. * @returns the parsed system
  140190. */
  140191. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140192. /**
  140193. * Serialize the current Lens Flare System into a JSON representation.
  140194. * @returns the serialized JSON
  140195. */
  140196. serialize(): any;
  140197. }
  140198. }
  140199. declare module BABYLON {
  140200. /**
  140201. * This represents one of the lens effect in a `lensFlareSystem`.
  140202. * It controls one of the indiviual texture used in the effect.
  140203. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140204. */
  140205. export class LensFlare {
  140206. /**
  140207. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140208. */
  140209. size: number;
  140210. /**
  140211. * 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.
  140212. */
  140213. position: number;
  140214. /**
  140215. * Define the lens color.
  140216. */
  140217. color: Color3;
  140218. /**
  140219. * Define the lens texture.
  140220. */
  140221. texture: Nullable<Texture>;
  140222. /**
  140223. * Define the alpha mode to render this particular lens.
  140224. */
  140225. alphaMode: number;
  140226. private _system;
  140227. /**
  140228. * Creates a new Lens Flare.
  140229. * This represents one of the lens effect in a `lensFlareSystem`.
  140230. * It controls one of the indiviual texture used in the effect.
  140231. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140232. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140233. * @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.
  140234. * @param color Define the lens color
  140235. * @param imgUrl Define the lens texture url
  140236. * @param system Define the `lensFlareSystem` this flare is part of
  140237. * @returns The newly created Lens Flare
  140238. */
  140239. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140240. /**
  140241. * Instantiates a new Lens Flare.
  140242. * This represents one of the lens effect in a `lensFlareSystem`.
  140243. * It controls one of the indiviual texture used in the effect.
  140244. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140245. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140246. * @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.
  140247. * @param color Define the lens color
  140248. * @param imgUrl Define the lens texture url
  140249. * @param system Define the `lensFlareSystem` this flare is part of
  140250. */
  140251. constructor(
  140252. /**
  140253. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140254. */
  140255. size: number,
  140256. /**
  140257. * 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.
  140258. */
  140259. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140260. /**
  140261. * Dispose and release the lens flare with its associated resources.
  140262. */
  140263. dispose(): void;
  140264. }
  140265. }
  140266. declare module BABYLON {
  140267. interface AbstractScene {
  140268. /**
  140269. * The list of lens flare system added to the scene
  140270. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140271. */
  140272. lensFlareSystems: Array<LensFlareSystem>;
  140273. /**
  140274. * Removes the given lens flare system from this scene.
  140275. * @param toRemove The lens flare system to remove
  140276. * @returns The index of the removed lens flare system
  140277. */
  140278. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140279. /**
  140280. * Adds the given lens flare system to this scene
  140281. * @param newLensFlareSystem The lens flare system to add
  140282. */
  140283. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140284. /**
  140285. * Gets a lens flare system using its name
  140286. * @param name defines the name to look for
  140287. * @returns the lens flare system or null if not found
  140288. */
  140289. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140290. /**
  140291. * Gets a lens flare system using its id
  140292. * @param id defines the id to look for
  140293. * @returns the lens flare system or null if not found
  140294. */
  140295. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140296. }
  140297. /**
  140298. * Defines the lens flare scene component responsible to manage any lens flares
  140299. * in a given scene.
  140300. */
  140301. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140302. /**
  140303. * The component name helpfull to identify the component in the list of scene components.
  140304. */
  140305. readonly name: string;
  140306. /**
  140307. * The scene the component belongs to.
  140308. */
  140309. scene: Scene;
  140310. /**
  140311. * Creates a new instance of the component for the given scene
  140312. * @param scene Defines the scene to register the component in
  140313. */
  140314. constructor(scene: Scene);
  140315. /**
  140316. * Registers the component in a given scene
  140317. */
  140318. register(): void;
  140319. /**
  140320. * Rebuilds the elements related to this component in case of
  140321. * context lost for instance.
  140322. */
  140323. rebuild(): void;
  140324. /**
  140325. * Adds all the elements from the container to the scene
  140326. * @param container the container holding the elements
  140327. */
  140328. addFromContainer(container: AbstractScene): void;
  140329. /**
  140330. * Removes all the elements in the container from the scene
  140331. * @param container contains the elements to remove
  140332. * @param dispose if the removed element should be disposed (default: false)
  140333. */
  140334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140335. /**
  140336. * Serializes the component data to the specified json object
  140337. * @param serializationObject The object to serialize to
  140338. */
  140339. serialize(serializationObject: any): void;
  140340. /**
  140341. * Disposes the component and the associated ressources.
  140342. */
  140343. dispose(): void;
  140344. private _draw;
  140345. }
  140346. }
  140347. declare module BABYLON {
  140348. /** @hidden */
  140349. export var depthPixelShader: {
  140350. name: string;
  140351. shader: string;
  140352. };
  140353. }
  140354. declare module BABYLON {
  140355. /** @hidden */
  140356. export var depthVertexShader: {
  140357. name: string;
  140358. shader: string;
  140359. };
  140360. }
  140361. declare module BABYLON {
  140362. /**
  140363. * This represents a depth renderer in Babylon.
  140364. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140365. */
  140366. export class DepthRenderer {
  140367. private _scene;
  140368. private _depthMap;
  140369. private _effect;
  140370. private readonly _storeNonLinearDepth;
  140371. private readonly _clearColor;
  140372. /** Get if the depth renderer is using packed depth or not */
  140373. readonly isPacked: boolean;
  140374. private _cachedDefines;
  140375. private _camera;
  140376. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140377. enabled: boolean;
  140378. /**
  140379. * Specifiess that the depth renderer will only be used within
  140380. * the camera it is created for.
  140381. * This can help forcing its rendering during the camera processing.
  140382. */
  140383. useOnlyInActiveCamera: boolean;
  140384. /** @hidden */
  140385. static _SceneComponentInitialization: (scene: Scene) => void;
  140386. /**
  140387. * Instantiates a depth renderer
  140388. * @param scene The scene the renderer belongs to
  140389. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140390. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140391. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140392. */
  140393. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140394. /**
  140395. * Creates the depth rendering effect and checks if the effect is ready.
  140396. * @param subMesh The submesh to be used to render the depth map of
  140397. * @param useInstances If multiple world instances should be used
  140398. * @returns if the depth renderer is ready to render the depth map
  140399. */
  140400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140401. /**
  140402. * Gets the texture which the depth map will be written to.
  140403. * @returns The depth map texture
  140404. */
  140405. getDepthMap(): RenderTargetTexture;
  140406. /**
  140407. * Disposes of the depth renderer.
  140408. */
  140409. dispose(): void;
  140410. }
  140411. }
  140412. declare module BABYLON {
  140413. /** @hidden */
  140414. export var minmaxReduxPixelShader: {
  140415. name: string;
  140416. shader: string;
  140417. };
  140418. }
  140419. declare module BABYLON {
  140420. /**
  140421. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140422. * and maximum values from all values of the texture.
  140423. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140424. * The source values are read from the red channel of the texture.
  140425. */
  140426. export class MinMaxReducer {
  140427. /**
  140428. * Observable triggered when the computation has been performed
  140429. */
  140430. onAfterReductionPerformed: Observable<{
  140431. min: number;
  140432. max: number;
  140433. }>;
  140434. protected _camera: Camera;
  140435. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140436. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140437. protected _postProcessManager: PostProcessManager;
  140438. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140439. protected _forceFullscreenViewport: boolean;
  140440. /**
  140441. * Creates a min/max reducer
  140442. * @param camera The camera to use for the post processes
  140443. */
  140444. constructor(camera: Camera);
  140445. /**
  140446. * Gets the texture used to read the values from.
  140447. */
  140448. get sourceTexture(): Nullable<RenderTargetTexture>;
  140449. /**
  140450. * Sets the source texture to read the values from.
  140451. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140452. * because in such textures '1' value must not be taken into account to compute the maximum
  140453. * as this value is used to clear the texture.
  140454. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140455. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140456. * @param depthRedux Indicates if the texture is a depth texture or not
  140457. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140458. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140459. */
  140460. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140461. /**
  140462. * Defines the refresh rate of the computation.
  140463. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140464. */
  140465. get refreshRate(): number;
  140466. set refreshRate(value: number);
  140467. protected _activated: boolean;
  140468. /**
  140469. * Gets the activation status of the reducer
  140470. */
  140471. get activated(): boolean;
  140472. /**
  140473. * Activates the reduction computation.
  140474. * When activated, the observers registered in onAfterReductionPerformed are
  140475. * called after the compuation is performed
  140476. */
  140477. activate(): void;
  140478. /**
  140479. * Deactivates the reduction computation.
  140480. */
  140481. deactivate(): void;
  140482. /**
  140483. * Disposes the min/max reducer
  140484. * @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.
  140485. */
  140486. dispose(disposeAll?: boolean): void;
  140487. }
  140488. }
  140489. declare module BABYLON {
  140490. /**
  140491. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140492. */
  140493. export class DepthReducer extends MinMaxReducer {
  140494. private _depthRenderer;
  140495. private _depthRendererId;
  140496. /**
  140497. * Gets the depth renderer used for the computation.
  140498. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140499. */
  140500. get depthRenderer(): Nullable<DepthRenderer>;
  140501. /**
  140502. * Creates a depth reducer
  140503. * @param camera The camera used to render the depth texture
  140504. */
  140505. constructor(camera: Camera);
  140506. /**
  140507. * Sets the depth renderer to use to generate the depth map
  140508. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140509. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140510. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140511. */
  140512. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140513. /** @hidden */
  140514. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140515. /**
  140516. * Activates the reduction computation.
  140517. * When activated, the observers registered in onAfterReductionPerformed are
  140518. * called after the compuation is performed
  140519. */
  140520. activate(): void;
  140521. /**
  140522. * Deactivates the reduction computation.
  140523. */
  140524. deactivate(): void;
  140525. /**
  140526. * Disposes the depth reducer
  140527. * @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.
  140528. */
  140529. dispose(disposeAll?: boolean): void;
  140530. }
  140531. }
  140532. declare module BABYLON {
  140533. /**
  140534. * A CSM implementation allowing casting shadows on large scenes.
  140535. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140536. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140537. */
  140538. export class CascadedShadowGenerator extends ShadowGenerator {
  140539. private static readonly frustumCornersNDCSpace;
  140540. /**
  140541. * Name of the CSM class
  140542. */
  140543. static CLASSNAME: string;
  140544. /**
  140545. * Defines the default number of cascades used by the CSM.
  140546. */
  140547. static readonly DEFAULT_CASCADES_COUNT: number;
  140548. /**
  140549. * Defines the minimum number of cascades used by the CSM.
  140550. */
  140551. static readonly MIN_CASCADES_COUNT: number;
  140552. /**
  140553. * Defines the maximum number of cascades used by the CSM.
  140554. */
  140555. static readonly MAX_CASCADES_COUNT: number;
  140556. protected _validateFilter(filter: number): number;
  140557. /**
  140558. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140559. */
  140560. penumbraDarkness: number;
  140561. private _numCascades;
  140562. /**
  140563. * Gets or set the number of cascades used by the CSM.
  140564. */
  140565. get numCascades(): number;
  140566. set numCascades(value: number);
  140567. /**
  140568. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140569. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140570. */
  140571. stabilizeCascades: boolean;
  140572. private _freezeShadowCastersBoundingInfo;
  140573. private _freezeShadowCastersBoundingInfoObservable;
  140574. /**
  140575. * Enables or disables the shadow casters bounding info computation.
  140576. * If your shadow casters don't move, you can disable this feature.
  140577. * If it is enabled, the bounding box computation is done every frame.
  140578. */
  140579. get freezeShadowCastersBoundingInfo(): boolean;
  140580. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140581. private _scbiMin;
  140582. private _scbiMax;
  140583. protected _computeShadowCastersBoundingInfo(): void;
  140584. protected _shadowCastersBoundingInfo: BoundingInfo;
  140585. /**
  140586. * Gets or sets the shadow casters bounding info.
  140587. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140588. * so that the system won't overwrite the bounds you provide
  140589. */
  140590. get shadowCastersBoundingInfo(): BoundingInfo;
  140591. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140592. protected _breaksAreDirty: boolean;
  140593. protected _minDistance: number;
  140594. protected _maxDistance: number;
  140595. /**
  140596. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140597. *
  140598. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140599. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140600. * @param min minimal distance for the breaks (default to 0.)
  140601. * @param max maximal distance for the breaks (default to 1.)
  140602. */
  140603. setMinMaxDistance(min: number, max: number): void;
  140604. /** Gets the minimal distance used in the cascade break computation */
  140605. get minDistance(): number;
  140606. /** Gets the maximal distance used in the cascade break computation */
  140607. get maxDistance(): number;
  140608. /**
  140609. * Gets the class name of that object
  140610. * @returns "CascadedShadowGenerator"
  140611. */
  140612. getClassName(): string;
  140613. private _cascadeMinExtents;
  140614. private _cascadeMaxExtents;
  140615. /**
  140616. * Gets a cascade minimum extents
  140617. * @param cascadeIndex index of the cascade
  140618. * @returns the minimum cascade extents
  140619. */
  140620. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140621. /**
  140622. * Gets a cascade maximum extents
  140623. * @param cascadeIndex index of the cascade
  140624. * @returns the maximum cascade extents
  140625. */
  140626. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140627. private _cascades;
  140628. private _currentLayer;
  140629. private _viewSpaceFrustumsZ;
  140630. private _viewMatrices;
  140631. private _projectionMatrices;
  140632. private _transformMatrices;
  140633. private _transformMatricesAsArray;
  140634. private _frustumLengths;
  140635. private _lightSizeUVCorrection;
  140636. private _depthCorrection;
  140637. private _frustumCornersWorldSpace;
  140638. private _frustumCenter;
  140639. private _shadowCameraPos;
  140640. private _shadowMaxZ;
  140641. /**
  140642. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140643. * It defaults to camera.maxZ
  140644. */
  140645. get shadowMaxZ(): number;
  140646. /**
  140647. * Sets the shadow max z distance.
  140648. */
  140649. set shadowMaxZ(value: number);
  140650. protected _debug: boolean;
  140651. /**
  140652. * Gets or sets the debug flag.
  140653. * When enabled, the cascades are materialized by different colors on the screen.
  140654. */
  140655. get debug(): boolean;
  140656. set debug(dbg: boolean);
  140657. private _depthClamp;
  140658. /**
  140659. * Gets or sets the depth clamping value.
  140660. *
  140661. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140662. * to account for the shadow casters far away.
  140663. *
  140664. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140665. */
  140666. get depthClamp(): boolean;
  140667. set depthClamp(value: boolean);
  140668. private _cascadeBlendPercentage;
  140669. /**
  140670. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140671. * It defaults to 0.1 (10% blending).
  140672. */
  140673. get cascadeBlendPercentage(): number;
  140674. set cascadeBlendPercentage(value: number);
  140675. private _lambda;
  140676. /**
  140677. * Gets or set the lambda parameter.
  140678. * This parameter is used to split the camera frustum and create the cascades.
  140679. * 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.
  140680. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140681. */
  140682. get lambda(): number;
  140683. set lambda(value: number);
  140684. /**
  140685. * Gets the view matrix corresponding to a given cascade
  140686. * @param cascadeNum cascade to retrieve the view matrix from
  140687. * @returns the cascade view matrix
  140688. */
  140689. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140690. /**
  140691. * Gets the projection matrix corresponding to a given cascade
  140692. * @param cascadeNum cascade to retrieve the projection matrix from
  140693. * @returns the cascade projection matrix
  140694. */
  140695. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140696. /**
  140697. * Gets the transformation matrix corresponding to a given cascade
  140698. * @param cascadeNum cascade to retrieve the transformation matrix from
  140699. * @returns the cascade transformation matrix
  140700. */
  140701. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140702. private _depthRenderer;
  140703. /**
  140704. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140705. *
  140706. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140707. *
  140708. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140709. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140710. * @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
  140711. */
  140712. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140713. private _depthReducer;
  140714. private _autoCalcDepthBounds;
  140715. /**
  140716. * Gets or sets the autoCalcDepthBounds property.
  140717. *
  140718. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140719. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140720. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140721. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140722. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140723. */
  140724. get autoCalcDepthBounds(): boolean;
  140725. set autoCalcDepthBounds(value: boolean);
  140726. /**
  140727. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140728. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140729. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140730. * for setting the refresh rate on the renderer yourself!
  140731. */
  140732. get autoCalcDepthBoundsRefreshRate(): number;
  140733. set autoCalcDepthBoundsRefreshRate(value: number);
  140734. /**
  140735. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140736. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140737. * you change the camera near/far planes!
  140738. */
  140739. splitFrustum(): void;
  140740. private _splitFrustum;
  140741. private _computeMatrices;
  140742. private _computeFrustumInWorldSpace;
  140743. private _computeCascadeFrustum;
  140744. /**
  140745. * Support test.
  140746. */
  140747. static get IsSupported(): boolean;
  140748. /** @hidden */
  140749. static _SceneComponentInitialization: (scene: Scene) => void;
  140750. /**
  140751. * Creates a Cascaded Shadow Generator object.
  140752. * A ShadowGenerator is the required tool to use the shadows.
  140753. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140754. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140755. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140756. * @param light The directional light object generating the shadows.
  140757. * @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.
  140758. */
  140759. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140760. protected _initializeGenerator(): void;
  140761. protected _createTargetRenderTexture(): void;
  140762. protected _initializeShadowMap(): void;
  140763. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140764. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140765. /**
  140766. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140767. * @param defines Defines of the material we want to update
  140768. * @param lightIndex Index of the light in the enabled light list of the material
  140769. */
  140770. prepareDefines(defines: any, lightIndex: number): void;
  140771. /**
  140772. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140773. * defined in the generator but impacting the effect).
  140774. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140775. * @param effect The effect we are binfing the information for
  140776. */
  140777. bindShadowLight(lightIndex: string, effect: Effect): void;
  140778. /**
  140779. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140780. * (eq to view projection * shadow projection matrices)
  140781. * @returns The transform matrix used to create the shadow map
  140782. */
  140783. getTransformMatrix(): Matrix;
  140784. /**
  140785. * Disposes the ShadowGenerator.
  140786. * Returns nothing.
  140787. */
  140788. dispose(): void;
  140789. /**
  140790. * Serializes the shadow generator setup to a json object.
  140791. * @returns The serialized JSON object
  140792. */
  140793. serialize(): any;
  140794. /**
  140795. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140796. * @param parsedShadowGenerator The JSON object to parse
  140797. * @param scene The scene to create the shadow map for
  140798. * @returns The parsed shadow generator
  140799. */
  140800. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140801. }
  140802. }
  140803. declare module BABYLON {
  140804. /**
  140805. * Defines the shadow generator component responsible to manage any shadow generators
  140806. * in a given scene.
  140807. */
  140808. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140809. /**
  140810. * The component name helpfull to identify the component in the list of scene components.
  140811. */
  140812. readonly name: string;
  140813. /**
  140814. * The scene the component belongs to.
  140815. */
  140816. scene: Scene;
  140817. /**
  140818. * Creates a new instance of the component for the given scene
  140819. * @param scene Defines the scene to register the component in
  140820. */
  140821. constructor(scene: Scene);
  140822. /**
  140823. * Registers the component in a given scene
  140824. */
  140825. register(): void;
  140826. /**
  140827. * Rebuilds the elements related to this component in case of
  140828. * context lost for instance.
  140829. */
  140830. rebuild(): void;
  140831. /**
  140832. * Serializes the component data to the specified json object
  140833. * @param serializationObject The object to serialize to
  140834. */
  140835. serialize(serializationObject: any): void;
  140836. /**
  140837. * Adds all the elements from the container to the scene
  140838. * @param container the container holding the elements
  140839. */
  140840. addFromContainer(container: AbstractScene): void;
  140841. /**
  140842. * Removes all the elements in the container from the scene
  140843. * @param container contains the elements to remove
  140844. * @param dispose if the removed element should be disposed (default: false)
  140845. */
  140846. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140847. /**
  140848. * Rebuilds the elements related to this component in case of
  140849. * context lost for instance.
  140850. */
  140851. dispose(): void;
  140852. private _gatherRenderTargets;
  140853. }
  140854. }
  140855. declare module BABYLON {
  140856. /**
  140857. * A point light is a light defined by an unique point in world space.
  140858. * The light is emitted in every direction from this point.
  140859. * A good example of a point light is a standard light bulb.
  140860. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140861. */
  140862. export class PointLight extends ShadowLight {
  140863. private _shadowAngle;
  140864. /**
  140865. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140866. * This specifies what angle the shadow will use to be created.
  140867. *
  140868. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140869. */
  140870. get shadowAngle(): number;
  140871. /**
  140872. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140873. * This specifies what angle the shadow will use to be created.
  140874. *
  140875. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140876. */
  140877. set shadowAngle(value: number);
  140878. /**
  140879. * Gets the direction if it has been set.
  140880. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140881. */
  140882. get direction(): Vector3;
  140883. /**
  140884. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140885. */
  140886. set direction(value: Vector3);
  140887. /**
  140888. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140889. * A PointLight emits the light in every direction.
  140890. * It can cast shadows.
  140891. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140892. * ```javascript
  140893. * var pointLight = new PointLight("pl", camera.position, scene);
  140894. * ```
  140895. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140896. * @param name The light friendly name
  140897. * @param position The position of the point light in the scene
  140898. * @param scene The scene the lights belongs to
  140899. */
  140900. constructor(name: string, position: Vector3, scene: Scene);
  140901. /**
  140902. * Returns the string "PointLight"
  140903. * @returns the class name
  140904. */
  140905. getClassName(): string;
  140906. /**
  140907. * Returns the integer 0.
  140908. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140909. */
  140910. getTypeID(): number;
  140911. /**
  140912. * Specifies wether or not the shadowmap should be a cube texture.
  140913. * @returns true if the shadowmap needs to be a cube texture.
  140914. */
  140915. needCube(): boolean;
  140916. /**
  140917. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140918. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140919. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140920. */
  140921. getShadowDirection(faceIndex?: number): Vector3;
  140922. /**
  140923. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140924. * - fov = PI / 2
  140925. * - aspect ratio : 1.0
  140926. * - z-near and far equal to the active camera minZ and maxZ.
  140927. * Returns the PointLight.
  140928. */
  140929. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140930. protected _buildUniformLayout(): void;
  140931. /**
  140932. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140933. * @param effect The effect to update
  140934. * @param lightIndex The index of the light in the effect to update
  140935. * @returns The point light
  140936. */
  140937. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140938. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140939. /**
  140940. * Prepares the list of defines specific to the light type.
  140941. * @param defines the list of defines
  140942. * @param lightIndex defines the index of the light for the effect
  140943. */
  140944. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140945. }
  140946. }
  140947. declare module BABYLON {
  140948. /**
  140949. * Header information of HDR texture files.
  140950. */
  140951. export interface HDRInfo {
  140952. /**
  140953. * The height of the texture in pixels.
  140954. */
  140955. height: number;
  140956. /**
  140957. * The width of the texture in pixels.
  140958. */
  140959. width: number;
  140960. /**
  140961. * The index of the beginning of the data in the binary file.
  140962. */
  140963. dataPosition: number;
  140964. }
  140965. /**
  140966. * This groups tools to convert HDR texture to native colors array.
  140967. */
  140968. export class HDRTools {
  140969. private static Ldexp;
  140970. private static Rgbe2float;
  140971. private static readStringLine;
  140972. /**
  140973. * Reads header information from an RGBE texture stored in a native array.
  140974. * More information on this format are available here:
  140975. * https://en.wikipedia.org/wiki/RGBE_image_format
  140976. *
  140977. * @param uint8array The binary file stored in native array.
  140978. * @return The header information.
  140979. */
  140980. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140981. /**
  140982. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140983. * This RGBE texture needs to store the information as a panorama.
  140984. *
  140985. * More information on this format are available here:
  140986. * https://en.wikipedia.org/wiki/RGBE_image_format
  140987. *
  140988. * @param buffer The binary file stored in an array buffer.
  140989. * @param size The expected size of the extracted cubemap.
  140990. * @return The Cube Map information.
  140991. */
  140992. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140993. /**
  140994. * Returns the pixels data extracted from an RGBE texture.
  140995. * This pixels will be stored left to right up to down in the R G B order in one array.
  140996. *
  140997. * More information on this format are available here:
  140998. * https://en.wikipedia.org/wiki/RGBE_image_format
  140999. *
  141000. * @param uint8array The binary file stored in an array buffer.
  141001. * @param hdrInfo The header information of the file.
  141002. * @return The pixels data in RGB right to left up to down order.
  141003. */
  141004. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141005. private static RGBE_ReadPixels_RLE;
  141006. private static RGBE_ReadPixels_NOT_RLE;
  141007. }
  141008. }
  141009. declare module BABYLON {
  141010. /**
  141011. * Effect Render Options
  141012. */
  141013. export interface IEffectRendererOptions {
  141014. /**
  141015. * Defines the vertices positions.
  141016. */
  141017. positions?: number[];
  141018. /**
  141019. * Defines the indices.
  141020. */
  141021. indices?: number[];
  141022. }
  141023. /**
  141024. * Helper class to render one or more effects.
  141025. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141026. */
  141027. export class EffectRenderer {
  141028. private engine;
  141029. private static _DefaultOptions;
  141030. private _vertexBuffers;
  141031. private _indexBuffer;
  141032. private _fullscreenViewport;
  141033. /**
  141034. * Creates an effect renderer
  141035. * @param engine the engine to use for rendering
  141036. * @param options defines the options of the effect renderer
  141037. */
  141038. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141039. /**
  141040. * Sets the current viewport in normalized coordinates 0-1
  141041. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141042. */
  141043. setViewport(viewport?: Viewport): void;
  141044. /**
  141045. * Binds the embedded attributes buffer to the effect.
  141046. * @param effect Defines the effect to bind the attributes for
  141047. */
  141048. bindBuffers(effect: Effect): void;
  141049. /**
  141050. * Sets the current effect wrapper to use during draw.
  141051. * The effect needs to be ready before calling this api.
  141052. * This also sets the default full screen position attribute.
  141053. * @param effectWrapper Defines the effect to draw with
  141054. */
  141055. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141056. /**
  141057. * Restores engine states
  141058. */
  141059. restoreStates(): void;
  141060. /**
  141061. * Draws a full screen quad.
  141062. */
  141063. draw(): void;
  141064. private isRenderTargetTexture;
  141065. /**
  141066. * renders one or more effects to a specified texture
  141067. * @param effectWrapper the effect to renderer
  141068. * @param outputTexture texture to draw to, if null it will render to the screen.
  141069. */
  141070. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141071. /**
  141072. * Disposes of the effect renderer
  141073. */
  141074. dispose(): void;
  141075. }
  141076. /**
  141077. * Options to create an EffectWrapper
  141078. */
  141079. interface EffectWrapperCreationOptions {
  141080. /**
  141081. * Engine to use to create the effect
  141082. */
  141083. engine: ThinEngine;
  141084. /**
  141085. * Fragment shader for the effect
  141086. */
  141087. fragmentShader: string;
  141088. /**
  141089. * Use the shader store instead of direct source code
  141090. */
  141091. useShaderStore?: boolean;
  141092. /**
  141093. * Vertex shader for the effect
  141094. */
  141095. vertexShader?: string;
  141096. /**
  141097. * Attributes to use in the shader
  141098. */
  141099. attributeNames?: Array<string>;
  141100. /**
  141101. * Uniforms to use in the shader
  141102. */
  141103. uniformNames?: Array<string>;
  141104. /**
  141105. * Texture sampler names to use in the shader
  141106. */
  141107. samplerNames?: Array<string>;
  141108. /**
  141109. * Defines to use in the shader
  141110. */
  141111. defines?: Array<string>;
  141112. /**
  141113. * Callback when effect is compiled
  141114. */
  141115. onCompiled?: Nullable<(effect: Effect) => void>;
  141116. /**
  141117. * The friendly name of the effect displayed in Spector.
  141118. */
  141119. name?: string;
  141120. }
  141121. /**
  141122. * Wraps an effect to be used for rendering
  141123. */
  141124. export class EffectWrapper {
  141125. /**
  141126. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141127. */
  141128. onApplyObservable: Observable<{}>;
  141129. /**
  141130. * The underlying effect
  141131. */
  141132. effect: Effect;
  141133. /**
  141134. * Creates an effect to be renderer
  141135. * @param creationOptions options to create the effect
  141136. */
  141137. constructor(creationOptions: EffectWrapperCreationOptions);
  141138. /**
  141139. * Disposes of the effect wrapper
  141140. */
  141141. dispose(): void;
  141142. }
  141143. }
  141144. declare module BABYLON {
  141145. /** @hidden */
  141146. export var hdrFilteringVertexShader: {
  141147. name: string;
  141148. shader: string;
  141149. };
  141150. }
  141151. declare module BABYLON {
  141152. /** @hidden */
  141153. export var hdrFilteringPixelShader: {
  141154. name: string;
  141155. shader: string;
  141156. };
  141157. }
  141158. declare module BABYLON {
  141159. /**
  141160. * Options for texture filtering
  141161. */
  141162. interface IHDRFilteringOptions {
  141163. /**
  141164. * Scales pixel intensity for the input HDR map.
  141165. */
  141166. hdrScale?: number;
  141167. /**
  141168. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141169. */
  141170. quality?: number;
  141171. }
  141172. /**
  141173. * Filters HDR maps to get correct renderings of PBR reflections
  141174. */
  141175. export class HDRFiltering {
  141176. private _engine;
  141177. private _effectRenderer;
  141178. private _effectWrapper;
  141179. private _lodGenerationOffset;
  141180. private _lodGenerationScale;
  141181. /**
  141182. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141183. * you care about baking speed.
  141184. */
  141185. quality: number;
  141186. /**
  141187. * Scales pixel intensity for the input HDR map.
  141188. */
  141189. hdrScale: number;
  141190. /**
  141191. * Instantiates HDR filter for reflection maps
  141192. *
  141193. * @param engine Thin engine
  141194. * @param options Options
  141195. */
  141196. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141197. private _createRenderTarget;
  141198. private _prefilterInternal;
  141199. private _createEffect;
  141200. /**
  141201. * Get a value indicating if the filter is ready to be used
  141202. * @param texture Texture to filter
  141203. * @returns true if the filter is ready
  141204. */
  141205. isReady(texture: BaseTexture): boolean;
  141206. /**
  141207. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141208. * Prefiltering will be invoked at the end of next rendering pass.
  141209. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141210. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141211. * @param texture Texture to filter
  141212. * @param onFinished Callback when filtering is done
  141213. * @return Promise called when prefiltering is done
  141214. */
  141215. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141216. }
  141217. }
  141218. declare module BABYLON {
  141219. /**
  141220. * This represents a texture coming from an HDR input.
  141221. *
  141222. * The only supported format is currently panorama picture stored in RGBE format.
  141223. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141224. */
  141225. export class HDRCubeTexture extends BaseTexture {
  141226. private static _facesMapping;
  141227. private _generateHarmonics;
  141228. private _noMipmap;
  141229. private _prefilterOnLoad;
  141230. private _textureMatrix;
  141231. private _size;
  141232. private _onLoad;
  141233. private _onError;
  141234. /**
  141235. * The texture URL.
  141236. */
  141237. url: string;
  141238. protected _isBlocking: boolean;
  141239. /**
  141240. * Sets wether or not the texture is blocking during loading.
  141241. */
  141242. set isBlocking(value: boolean);
  141243. /**
  141244. * Gets wether or not the texture is blocking during loading.
  141245. */
  141246. get isBlocking(): boolean;
  141247. protected _rotationY: number;
  141248. /**
  141249. * Sets texture matrix rotation angle around Y axis in radians.
  141250. */
  141251. set rotationY(value: number);
  141252. /**
  141253. * Gets texture matrix rotation angle around Y axis radians.
  141254. */
  141255. get rotationY(): number;
  141256. /**
  141257. * Gets or sets the center of the bounding box associated with the cube texture
  141258. * It must define where the camera used to render the texture was set
  141259. */
  141260. boundingBoxPosition: Vector3;
  141261. private _boundingBoxSize;
  141262. /**
  141263. * Gets or sets the size of the bounding box associated with the cube texture
  141264. * When defined, the cubemap will switch to local mode
  141265. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141266. * @example https://www.babylonjs-playground.com/#RNASML
  141267. */
  141268. set boundingBoxSize(value: Vector3);
  141269. get boundingBoxSize(): Vector3;
  141270. /**
  141271. * Instantiates an HDRTexture from the following parameters.
  141272. *
  141273. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141274. * @param sceneOrEngine The scene or engine the texture will be used in
  141275. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141276. * @param noMipmap Forces to not generate the mipmap if true
  141277. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141278. * @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)
  141279. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141280. */
  141281. 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>);
  141282. /**
  141283. * Get the current class name of the texture useful for serialization or dynamic coding.
  141284. * @returns "HDRCubeTexture"
  141285. */
  141286. getClassName(): string;
  141287. /**
  141288. * Occurs when the file is raw .hdr file.
  141289. */
  141290. private loadTexture;
  141291. clone(): HDRCubeTexture;
  141292. delayLoad(): void;
  141293. /**
  141294. * Get the texture reflection matrix used to rotate/transform the reflection.
  141295. * @returns the reflection matrix
  141296. */
  141297. getReflectionTextureMatrix(): Matrix;
  141298. /**
  141299. * Set the texture reflection matrix used to rotate/transform the reflection.
  141300. * @param value Define the reflection matrix to set
  141301. */
  141302. setReflectionTextureMatrix(value: Matrix): void;
  141303. /**
  141304. * Parses a JSON representation of an HDR Texture in order to create the texture
  141305. * @param parsedTexture Define the JSON representation
  141306. * @param scene Define the scene the texture should be created in
  141307. * @param rootUrl Define the root url in case we need to load relative dependencies
  141308. * @returns the newly created texture after parsing
  141309. */
  141310. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141311. serialize(): any;
  141312. }
  141313. }
  141314. declare module BABYLON {
  141315. /**
  141316. * Class used to control physics engine
  141317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141318. */
  141319. export class PhysicsEngine implements IPhysicsEngine {
  141320. private _physicsPlugin;
  141321. /**
  141322. * Global value used to control the smallest number supported by the simulation
  141323. */
  141324. static Epsilon: number;
  141325. private _impostors;
  141326. private _joints;
  141327. private _subTimeStep;
  141328. /**
  141329. * Gets the gravity vector used by the simulation
  141330. */
  141331. gravity: Vector3;
  141332. /**
  141333. * Factory used to create the default physics plugin.
  141334. * @returns The default physics plugin
  141335. */
  141336. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141337. /**
  141338. * Creates a new Physics Engine
  141339. * @param gravity defines the gravity vector used by the simulation
  141340. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141341. */
  141342. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141343. /**
  141344. * Sets the gravity vector used by the simulation
  141345. * @param gravity defines the gravity vector to use
  141346. */
  141347. setGravity(gravity: Vector3): void;
  141348. /**
  141349. * Set the time step of the physics engine.
  141350. * Default is 1/60.
  141351. * To slow it down, enter 1/600 for example.
  141352. * To speed it up, 1/30
  141353. * @param newTimeStep defines the new timestep to apply to this world.
  141354. */
  141355. setTimeStep(newTimeStep?: number): void;
  141356. /**
  141357. * Get the time step of the physics engine.
  141358. * @returns the current time step
  141359. */
  141360. getTimeStep(): number;
  141361. /**
  141362. * Set the sub time step of the physics engine.
  141363. * Default is 0 meaning there is no sub steps
  141364. * To increase physics resolution precision, set a small value (like 1 ms)
  141365. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141366. */
  141367. setSubTimeStep(subTimeStep?: number): void;
  141368. /**
  141369. * Get the sub time step of the physics engine.
  141370. * @returns the current sub time step
  141371. */
  141372. getSubTimeStep(): number;
  141373. /**
  141374. * Release all resources
  141375. */
  141376. dispose(): void;
  141377. /**
  141378. * Gets the name of the current physics plugin
  141379. * @returns the name of the plugin
  141380. */
  141381. getPhysicsPluginName(): string;
  141382. /**
  141383. * Adding a new impostor for the impostor tracking.
  141384. * This will be done by the impostor itself.
  141385. * @param impostor the impostor to add
  141386. */
  141387. addImpostor(impostor: PhysicsImpostor): void;
  141388. /**
  141389. * Remove an impostor from the engine.
  141390. * This impostor and its mesh will not longer be updated by the physics engine.
  141391. * @param impostor the impostor to remove
  141392. */
  141393. removeImpostor(impostor: PhysicsImpostor): void;
  141394. /**
  141395. * Add a joint to the physics engine
  141396. * @param mainImpostor defines the main impostor to which the joint is added.
  141397. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141398. * @param joint defines the joint that will connect both impostors.
  141399. */
  141400. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141401. /**
  141402. * Removes a joint from the simulation
  141403. * @param mainImpostor defines the impostor used with the joint
  141404. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141405. * @param joint defines the joint to remove
  141406. */
  141407. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141408. /**
  141409. * Called by the scene. No need to call it.
  141410. * @param delta defines the timespam between frames
  141411. */
  141412. _step(delta: number): void;
  141413. /**
  141414. * Gets the current plugin used to run the simulation
  141415. * @returns current plugin
  141416. */
  141417. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141418. /**
  141419. * Gets the list of physic impostors
  141420. * @returns an array of PhysicsImpostor
  141421. */
  141422. getImpostors(): Array<PhysicsImpostor>;
  141423. /**
  141424. * Gets the impostor for a physics enabled object
  141425. * @param object defines the object impersonated by the impostor
  141426. * @returns the PhysicsImpostor or null if not found
  141427. */
  141428. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141429. /**
  141430. * Gets the impostor for a physics body object
  141431. * @param body defines physics body used by the impostor
  141432. * @returns the PhysicsImpostor or null if not found
  141433. */
  141434. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141435. /**
  141436. * Does a raycast in the physics world
  141437. * @param from when should the ray start?
  141438. * @param to when should the ray end?
  141439. * @returns PhysicsRaycastResult
  141440. */
  141441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141442. }
  141443. }
  141444. declare module BABYLON {
  141445. /** @hidden */
  141446. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141447. private _useDeltaForWorldStep;
  141448. world: any;
  141449. name: string;
  141450. private _physicsMaterials;
  141451. private _fixedTimeStep;
  141452. private _cannonRaycastResult;
  141453. private _raycastResult;
  141454. private _physicsBodysToRemoveAfterStep;
  141455. private _firstFrame;
  141456. BJSCANNON: any;
  141457. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141458. setGravity(gravity: Vector3): void;
  141459. setTimeStep(timeStep: number): void;
  141460. getTimeStep(): number;
  141461. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141462. private _removeMarkedPhysicsBodiesFromWorld;
  141463. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141464. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141465. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141466. private _processChildMeshes;
  141467. removePhysicsBody(impostor: PhysicsImpostor): void;
  141468. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141469. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141470. private _addMaterial;
  141471. private _checkWithEpsilon;
  141472. private _createShape;
  141473. private _createHeightmap;
  141474. private _minus90X;
  141475. private _plus90X;
  141476. private _tmpPosition;
  141477. private _tmpDeltaPosition;
  141478. private _tmpUnityRotation;
  141479. private _updatePhysicsBodyTransformation;
  141480. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141481. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141482. isSupported(): boolean;
  141483. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141484. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141485. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141486. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141487. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141488. getBodyMass(impostor: PhysicsImpostor): number;
  141489. getBodyFriction(impostor: PhysicsImpostor): number;
  141490. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141491. getBodyRestitution(impostor: PhysicsImpostor): number;
  141492. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141493. sleepBody(impostor: PhysicsImpostor): void;
  141494. wakeUpBody(impostor: PhysicsImpostor): void;
  141495. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141496. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141497. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141498. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141499. getRadius(impostor: PhysicsImpostor): number;
  141500. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141501. dispose(): void;
  141502. private _extendNamespace;
  141503. /**
  141504. * Does a raycast in the physics world
  141505. * @param from when should the ray start?
  141506. * @param to when should the ray end?
  141507. * @returns PhysicsRaycastResult
  141508. */
  141509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141510. }
  141511. }
  141512. declare module BABYLON {
  141513. /** @hidden */
  141514. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141515. private _useDeltaForWorldStep;
  141516. world: any;
  141517. name: string;
  141518. BJSOIMO: any;
  141519. private _raycastResult;
  141520. private _fixedTimeStep;
  141521. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141522. setGravity(gravity: Vector3): void;
  141523. setTimeStep(timeStep: number): void;
  141524. getTimeStep(): number;
  141525. private _tmpImpostorsArray;
  141526. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141527. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141529. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141530. private _tmpPositionVector;
  141531. removePhysicsBody(impostor: PhysicsImpostor): void;
  141532. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141533. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141534. isSupported(): boolean;
  141535. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141536. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141540. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141541. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141542. getBodyMass(impostor: PhysicsImpostor): number;
  141543. getBodyFriction(impostor: PhysicsImpostor): number;
  141544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141545. getBodyRestitution(impostor: PhysicsImpostor): number;
  141546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141547. sleepBody(impostor: PhysicsImpostor): void;
  141548. wakeUpBody(impostor: PhysicsImpostor): void;
  141549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141550. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141551. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141553. getRadius(impostor: PhysicsImpostor): number;
  141554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141555. dispose(): void;
  141556. /**
  141557. * Does a raycast in the physics world
  141558. * @param from when should the ray start?
  141559. * @param to when should the ray end?
  141560. * @returns PhysicsRaycastResult
  141561. */
  141562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141563. }
  141564. }
  141565. declare module BABYLON {
  141566. /**
  141567. * AmmoJS Physics plugin
  141568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141569. * @see https://github.com/kripken/ammo.js/
  141570. */
  141571. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141572. private _useDeltaForWorldStep;
  141573. /**
  141574. * Reference to the Ammo library
  141575. */
  141576. bjsAMMO: any;
  141577. /**
  141578. * Created ammoJS world which physics bodies are added to
  141579. */
  141580. world: any;
  141581. /**
  141582. * Name of the plugin
  141583. */
  141584. name: string;
  141585. private _timeStep;
  141586. private _fixedTimeStep;
  141587. private _maxSteps;
  141588. private _tmpQuaternion;
  141589. private _tmpAmmoTransform;
  141590. private _tmpAmmoQuaternion;
  141591. private _tmpAmmoConcreteContactResultCallback;
  141592. private _collisionConfiguration;
  141593. private _dispatcher;
  141594. private _overlappingPairCache;
  141595. private _solver;
  141596. private _softBodySolver;
  141597. private _tmpAmmoVectorA;
  141598. private _tmpAmmoVectorB;
  141599. private _tmpAmmoVectorC;
  141600. private _tmpAmmoVectorD;
  141601. private _tmpContactCallbackResult;
  141602. private _tmpAmmoVectorRCA;
  141603. private _tmpAmmoVectorRCB;
  141604. private _raycastResult;
  141605. private static readonly DISABLE_COLLISION_FLAG;
  141606. private static readonly KINEMATIC_FLAG;
  141607. private static readonly DISABLE_DEACTIVATION_FLAG;
  141608. /**
  141609. * Initializes the ammoJS plugin
  141610. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141611. * @param ammoInjection can be used to inject your own ammo reference
  141612. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141613. */
  141614. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141615. /**
  141616. * Sets the gravity of the physics world (m/(s^2))
  141617. * @param gravity Gravity to set
  141618. */
  141619. setGravity(gravity: Vector3): void;
  141620. /**
  141621. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141622. * @param timeStep timestep to use in seconds
  141623. */
  141624. setTimeStep(timeStep: number): void;
  141625. /**
  141626. * 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)
  141627. * @param fixedTimeStep fixedTimeStep to use in seconds
  141628. */
  141629. setFixedTimeStep(fixedTimeStep: number): void;
  141630. /**
  141631. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141632. * @param maxSteps the maximum number of steps by the physics engine per frame
  141633. */
  141634. setMaxSteps(maxSteps: number): void;
  141635. /**
  141636. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141637. * @returns the current timestep in seconds
  141638. */
  141639. getTimeStep(): number;
  141640. /**
  141641. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141642. */
  141643. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141644. private _isImpostorInContact;
  141645. private _isImpostorPairInContact;
  141646. private _stepSimulation;
  141647. /**
  141648. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141649. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141650. * After the step the babylon meshes are set to the position of the physics imposters
  141651. * @param delta amount of time to step forward
  141652. * @param impostors array of imposters to update before/after the step
  141653. */
  141654. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141655. /**
  141656. * Update babylon mesh to match physics world object
  141657. * @param impostor imposter to match
  141658. */
  141659. private _afterSoftStep;
  141660. /**
  141661. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141662. * @param impostor imposter to match
  141663. */
  141664. private _ropeStep;
  141665. /**
  141666. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141667. * @param impostor imposter to match
  141668. */
  141669. private _softbodyOrClothStep;
  141670. private _tmpMatrix;
  141671. /**
  141672. * Applies an impulse on the imposter
  141673. * @param impostor imposter to apply impulse to
  141674. * @param force amount of force to be applied to the imposter
  141675. * @param contactPoint the location to apply the impulse on the imposter
  141676. */
  141677. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141678. /**
  141679. * Applies a force on the imposter
  141680. * @param impostor imposter to apply force
  141681. * @param force amount of force to be applied to the imposter
  141682. * @param contactPoint the location to apply the force on the imposter
  141683. */
  141684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141685. /**
  141686. * Creates a physics body using the plugin
  141687. * @param impostor the imposter to create the physics body on
  141688. */
  141689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141690. /**
  141691. * Removes the physics body from the imposter and disposes of the body's memory
  141692. * @param impostor imposter to remove the physics body from
  141693. */
  141694. removePhysicsBody(impostor: PhysicsImpostor): void;
  141695. /**
  141696. * Generates a joint
  141697. * @param impostorJoint the imposter joint to create the joint with
  141698. */
  141699. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141700. /**
  141701. * Removes a joint
  141702. * @param impostorJoint the imposter joint to remove the joint from
  141703. */
  141704. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141705. private _addMeshVerts;
  141706. /**
  141707. * Initialise the soft body vertices to match its object's (mesh) vertices
  141708. * Softbody vertices (nodes) are in world space and to match this
  141709. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141710. * @param impostor to create the softbody for
  141711. */
  141712. private _softVertexData;
  141713. /**
  141714. * Create an impostor's soft body
  141715. * @param impostor to create the softbody for
  141716. */
  141717. private _createSoftbody;
  141718. /**
  141719. * Create cloth for an impostor
  141720. * @param impostor to create the softbody for
  141721. */
  141722. private _createCloth;
  141723. /**
  141724. * Create rope for an impostor
  141725. * @param impostor to create the softbody for
  141726. */
  141727. private _createRope;
  141728. /**
  141729. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141730. * @param impostor to create the custom physics shape for
  141731. */
  141732. private _createCustom;
  141733. private _addHullVerts;
  141734. private _createShape;
  141735. /**
  141736. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141737. * @param impostor imposter containing the physics body and babylon object
  141738. */
  141739. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141740. /**
  141741. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141742. * @param impostor imposter containing the physics body and babylon object
  141743. * @param newPosition new position
  141744. * @param newRotation new rotation
  141745. */
  141746. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141747. /**
  141748. * If this plugin is supported
  141749. * @returns true if its supported
  141750. */
  141751. isSupported(): boolean;
  141752. /**
  141753. * Sets the linear velocity of the physics body
  141754. * @param impostor imposter to set the velocity on
  141755. * @param velocity velocity to set
  141756. */
  141757. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141758. /**
  141759. * Sets the angular velocity of the physics body
  141760. * @param impostor imposter to set the velocity on
  141761. * @param velocity velocity to set
  141762. */
  141763. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141764. /**
  141765. * gets the linear velocity
  141766. * @param impostor imposter to get linear velocity from
  141767. * @returns linear velocity
  141768. */
  141769. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141770. /**
  141771. * gets the angular velocity
  141772. * @param impostor imposter to get angular velocity from
  141773. * @returns angular velocity
  141774. */
  141775. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141776. /**
  141777. * Sets the mass of physics body
  141778. * @param impostor imposter to set the mass on
  141779. * @param mass mass to set
  141780. */
  141781. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141782. /**
  141783. * Gets the mass of the physics body
  141784. * @param impostor imposter to get the mass from
  141785. * @returns mass
  141786. */
  141787. getBodyMass(impostor: PhysicsImpostor): number;
  141788. /**
  141789. * Gets friction of the impostor
  141790. * @param impostor impostor to get friction from
  141791. * @returns friction value
  141792. */
  141793. getBodyFriction(impostor: PhysicsImpostor): number;
  141794. /**
  141795. * Sets friction of the impostor
  141796. * @param impostor impostor to set friction on
  141797. * @param friction friction value
  141798. */
  141799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141800. /**
  141801. * Gets restitution of the impostor
  141802. * @param impostor impostor to get restitution from
  141803. * @returns restitution value
  141804. */
  141805. getBodyRestitution(impostor: PhysicsImpostor): number;
  141806. /**
  141807. * Sets resitution of the impostor
  141808. * @param impostor impostor to set resitution on
  141809. * @param restitution resitution value
  141810. */
  141811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141812. /**
  141813. * Gets pressure inside the impostor
  141814. * @param impostor impostor to get pressure from
  141815. * @returns pressure value
  141816. */
  141817. getBodyPressure(impostor: PhysicsImpostor): number;
  141818. /**
  141819. * Sets pressure inside a soft body impostor
  141820. * Cloth and rope must remain 0 pressure
  141821. * @param impostor impostor to set pressure on
  141822. * @param pressure pressure value
  141823. */
  141824. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141825. /**
  141826. * Gets stiffness of the impostor
  141827. * @param impostor impostor to get stiffness from
  141828. * @returns pressure value
  141829. */
  141830. getBodyStiffness(impostor: PhysicsImpostor): number;
  141831. /**
  141832. * Sets stiffness of the impostor
  141833. * @param impostor impostor to set stiffness on
  141834. * @param stiffness stiffness value from 0 to 1
  141835. */
  141836. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141837. /**
  141838. * Gets velocityIterations of the impostor
  141839. * @param impostor impostor to get velocity iterations from
  141840. * @returns velocityIterations value
  141841. */
  141842. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141843. /**
  141844. * Sets velocityIterations of the impostor
  141845. * @param impostor impostor to set velocity iterations on
  141846. * @param velocityIterations velocityIterations value
  141847. */
  141848. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141849. /**
  141850. * Gets positionIterations of the impostor
  141851. * @param impostor impostor to get position iterations from
  141852. * @returns positionIterations value
  141853. */
  141854. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141855. /**
  141856. * Sets positionIterations of the impostor
  141857. * @param impostor impostor to set position on
  141858. * @param positionIterations positionIterations value
  141859. */
  141860. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141861. /**
  141862. * Append an anchor to a cloth object
  141863. * @param impostor is the cloth impostor to add anchor to
  141864. * @param otherImpostor is the rigid impostor to anchor to
  141865. * @param width ratio across width from 0 to 1
  141866. * @param height ratio up height from 0 to 1
  141867. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141868. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141869. */
  141870. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141871. /**
  141872. * Append an hook to a rope object
  141873. * @param impostor is the rope impostor to add hook to
  141874. * @param otherImpostor is the rigid impostor to hook to
  141875. * @param length ratio along the rope from 0 to 1
  141876. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141877. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141878. */
  141879. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141880. /**
  141881. * Sleeps the physics body and stops it from being active
  141882. * @param impostor impostor to sleep
  141883. */
  141884. sleepBody(impostor: PhysicsImpostor): void;
  141885. /**
  141886. * Activates the physics body
  141887. * @param impostor impostor to activate
  141888. */
  141889. wakeUpBody(impostor: PhysicsImpostor): void;
  141890. /**
  141891. * Updates the distance parameters of the joint
  141892. * @param joint joint to update
  141893. * @param maxDistance maximum distance of the joint
  141894. * @param minDistance minimum distance of the joint
  141895. */
  141896. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141897. /**
  141898. * Sets a motor on the joint
  141899. * @param joint joint to set motor on
  141900. * @param speed speed of the motor
  141901. * @param maxForce maximum force of the motor
  141902. * @param motorIndex index of the motor
  141903. */
  141904. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141905. /**
  141906. * Sets the motors limit
  141907. * @param joint joint to set limit on
  141908. * @param upperLimit upper limit
  141909. * @param lowerLimit lower limit
  141910. */
  141911. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141912. /**
  141913. * Syncs the position and rotation of a mesh with the impostor
  141914. * @param mesh mesh to sync
  141915. * @param impostor impostor to update the mesh with
  141916. */
  141917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141918. /**
  141919. * Gets the radius of the impostor
  141920. * @param impostor impostor to get radius from
  141921. * @returns the radius
  141922. */
  141923. getRadius(impostor: PhysicsImpostor): number;
  141924. /**
  141925. * Gets the box size of the impostor
  141926. * @param impostor impostor to get box size from
  141927. * @param result the resulting box size
  141928. */
  141929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141930. /**
  141931. * Disposes of the impostor
  141932. */
  141933. dispose(): void;
  141934. /**
  141935. * Does a raycast in the physics world
  141936. * @param from when should the ray start?
  141937. * @param to when should the ray end?
  141938. * @returns PhysicsRaycastResult
  141939. */
  141940. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141941. }
  141942. }
  141943. declare module BABYLON {
  141944. interface AbstractScene {
  141945. /**
  141946. * The list of reflection probes added to the scene
  141947. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141948. */
  141949. reflectionProbes: Array<ReflectionProbe>;
  141950. /**
  141951. * Removes the given reflection probe from this scene.
  141952. * @param toRemove The reflection probe to remove
  141953. * @returns The index of the removed reflection probe
  141954. */
  141955. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141956. /**
  141957. * Adds the given reflection probe to this scene.
  141958. * @param newReflectionProbe The reflection probe to add
  141959. */
  141960. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141961. }
  141962. /**
  141963. * Class used to generate realtime reflection / refraction cube textures
  141964. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141965. */
  141966. export class ReflectionProbe {
  141967. /** defines the name of the probe */
  141968. name: string;
  141969. private _scene;
  141970. private _renderTargetTexture;
  141971. private _projectionMatrix;
  141972. private _viewMatrix;
  141973. private _target;
  141974. private _add;
  141975. private _attachedMesh;
  141976. private _invertYAxis;
  141977. /** Gets or sets probe position (center of the cube map) */
  141978. position: Vector3;
  141979. /**
  141980. * Creates a new reflection probe
  141981. * @param name defines the name of the probe
  141982. * @param size defines the texture resolution (for each face)
  141983. * @param scene defines the hosting scene
  141984. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141985. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141986. */
  141987. constructor(
  141988. /** defines the name of the probe */
  141989. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141990. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141991. get samples(): number;
  141992. set samples(value: number);
  141993. /** Gets or sets the refresh rate to use (on every frame by default) */
  141994. get refreshRate(): number;
  141995. set refreshRate(value: number);
  141996. /**
  141997. * Gets the hosting scene
  141998. * @returns a Scene
  141999. */
  142000. getScene(): Scene;
  142001. /** Gets the internal CubeTexture used to render to */
  142002. get cubeTexture(): RenderTargetTexture;
  142003. /** Gets the list of meshes to render */
  142004. get renderList(): Nullable<AbstractMesh[]>;
  142005. /**
  142006. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142007. * @param mesh defines the mesh to attach to
  142008. */
  142009. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142010. /**
  142011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142012. * @param renderingGroupId The rendering group id corresponding to its index
  142013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142014. */
  142015. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142016. /**
  142017. * Clean all associated resources
  142018. */
  142019. dispose(): void;
  142020. /**
  142021. * Converts the reflection probe information to a readable string for debug purpose.
  142022. * @param fullDetails Supports for multiple levels of logging within scene loading
  142023. * @returns the human readable reflection probe info
  142024. */
  142025. toString(fullDetails?: boolean): string;
  142026. /**
  142027. * Get the class name of the relfection probe.
  142028. * @returns "ReflectionProbe"
  142029. */
  142030. getClassName(): string;
  142031. /**
  142032. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142033. * @returns The JSON representation of the texture
  142034. */
  142035. serialize(): any;
  142036. /**
  142037. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142038. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142039. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142040. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142041. * @returns The parsed reflection probe if successful
  142042. */
  142043. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142044. }
  142045. }
  142046. declare module BABYLON {
  142047. /** @hidden */
  142048. export var _BabylonLoaderRegistered: boolean;
  142049. /**
  142050. * Helps setting up some configuration for the babylon file loader.
  142051. */
  142052. export class BabylonFileLoaderConfiguration {
  142053. /**
  142054. * The loader does not allow injecting custom physix engine into the plugins.
  142055. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142056. * So you could set this variable to your engine import to make it work.
  142057. */
  142058. static LoaderInjectedPhysicsEngine: any;
  142059. }
  142060. }
  142061. declare module BABYLON {
  142062. /**
  142063. * The Physically based simple base material of BJS.
  142064. *
  142065. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142066. * It is used as the base class for both the specGloss and metalRough conventions.
  142067. */
  142068. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142069. /**
  142070. * Number of Simultaneous lights allowed on the material.
  142071. */
  142072. maxSimultaneousLights: number;
  142073. /**
  142074. * If sets to true, disables all the lights affecting the material.
  142075. */
  142076. disableLighting: boolean;
  142077. /**
  142078. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142079. */
  142080. environmentTexture: BaseTexture;
  142081. /**
  142082. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142083. */
  142084. invertNormalMapX: boolean;
  142085. /**
  142086. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142087. */
  142088. invertNormalMapY: boolean;
  142089. /**
  142090. * Normal map used in the model.
  142091. */
  142092. normalTexture: BaseTexture;
  142093. /**
  142094. * Emissivie color used to self-illuminate the model.
  142095. */
  142096. emissiveColor: Color3;
  142097. /**
  142098. * Emissivie texture used to self-illuminate the model.
  142099. */
  142100. emissiveTexture: BaseTexture;
  142101. /**
  142102. * Occlusion Channel Strenght.
  142103. */
  142104. occlusionStrength: number;
  142105. /**
  142106. * Occlusion Texture of the material (adding extra occlusion effects).
  142107. */
  142108. occlusionTexture: BaseTexture;
  142109. /**
  142110. * Defines the alpha limits in alpha test mode.
  142111. */
  142112. alphaCutOff: number;
  142113. /**
  142114. * Gets the current double sided mode.
  142115. */
  142116. get doubleSided(): boolean;
  142117. /**
  142118. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142119. */
  142120. set doubleSided(value: boolean);
  142121. /**
  142122. * Stores the pre-calculated light information of a mesh in a texture.
  142123. */
  142124. lightmapTexture: BaseTexture;
  142125. /**
  142126. * If true, the light map contains occlusion information instead of lighting info.
  142127. */
  142128. useLightmapAsShadowmap: boolean;
  142129. /**
  142130. * Instantiates a new PBRMaterial instance.
  142131. *
  142132. * @param name The material name
  142133. * @param scene The scene the material will be use in.
  142134. */
  142135. constructor(name: string, scene: Scene);
  142136. getClassName(): string;
  142137. }
  142138. }
  142139. declare module BABYLON {
  142140. /**
  142141. * The PBR material of BJS following the metal roughness convention.
  142142. *
  142143. * This fits to the PBR convention in the GLTF definition:
  142144. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142145. */
  142146. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142147. /**
  142148. * The base color has two different interpretations depending on the value of metalness.
  142149. * When the material is a metal, the base color is the specific measured reflectance value
  142150. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142151. * of the material.
  142152. */
  142153. baseColor: Color3;
  142154. /**
  142155. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142156. * well as opacity information in the alpha channel.
  142157. */
  142158. baseTexture: BaseTexture;
  142159. /**
  142160. * Specifies the metallic scalar value of the material.
  142161. * Can also be used to scale the metalness values of the metallic texture.
  142162. */
  142163. metallic: number;
  142164. /**
  142165. * Specifies the roughness scalar value of the material.
  142166. * Can also be used to scale the roughness values of the metallic texture.
  142167. */
  142168. roughness: number;
  142169. /**
  142170. * Texture containing both the metallic value in the B channel and the
  142171. * roughness value in the G channel to keep better precision.
  142172. */
  142173. metallicRoughnessTexture: BaseTexture;
  142174. /**
  142175. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142176. *
  142177. * @param name The material name
  142178. * @param scene The scene the material will be use in.
  142179. */
  142180. constructor(name: string, scene: Scene);
  142181. /**
  142182. * Return the currrent class name of the material.
  142183. */
  142184. getClassName(): string;
  142185. /**
  142186. * Makes a duplicate of the current material.
  142187. * @param name - name to use for the new material.
  142188. */
  142189. clone(name: string): PBRMetallicRoughnessMaterial;
  142190. /**
  142191. * Serialize the material to a parsable JSON object.
  142192. */
  142193. serialize(): any;
  142194. /**
  142195. * Parses a JSON object correponding to the serialize function.
  142196. */
  142197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142198. }
  142199. }
  142200. declare module BABYLON {
  142201. /**
  142202. * The PBR material of BJS following the specular glossiness convention.
  142203. *
  142204. * This fits to the PBR convention in the GLTF definition:
  142205. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142206. */
  142207. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142208. /**
  142209. * Specifies the diffuse color of the material.
  142210. */
  142211. diffuseColor: Color3;
  142212. /**
  142213. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142214. * channel.
  142215. */
  142216. diffuseTexture: BaseTexture;
  142217. /**
  142218. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142219. */
  142220. specularColor: Color3;
  142221. /**
  142222. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142223. */
  142224. glossiness: number;
  142225. /**
  142226. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142227. */
  142228. specularGlossinessTexture: BaseTexture;
  142229. /**
  142230. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142231. *
  142232. * @param name The material name
  142233. * @param scene The scene the material will be use in.
  142234. */
  142235. constructor(name: string, scene: Scene);
  142236. /**
  142237. * Return the currrent class name of the material.
  142238. */
  142239. getClassName(): string;
  142240. /**
  142241. * Makes a duplicate of the current material.
  142242. * @param name - name to use for the new material.
  142243. */
  142244. clone(name: string): PBRSpecularGlossinessMaterial;
  142245. /**
  142246. * Serialize the material to a parsable JSON object.
  142247. */
  142248. serialize(): any;
  142249. /**
  142250. * Parses a JSON object correponding to the serialize function.
  142251. */
  142252. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142253. }
  142254. }
  142255. declare module BABYLON {
  142256. /**
  142257. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142258. * It can help converting any input color in a desired output one. This can then be used to create effects
  142259. * from sepia, black and white to sixties or futuristic rendering...
  142260. *
  142261. * The only supported format is currently 3dl.
  142262. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142263. */
  142264. export class ColorGradingTexture extends BaseTexture {
  142265. /**
  142266. * The texture URL.
  142267. */
  142268. url: string;
  142269. /**
  142270. * Empty line regex stored for GC.
  142271. */
  142272. private static _noneEmptyLineRegex;
  142273. private _textureMatrix;
  142274. private _onLoad;
  142275. /**
  142276. * Instantiates a ColorGradingTexture from the following parameters.
  142277. *
  142278. * @param url The location of the color gradind data (currently only supporting 3dl)
  142279. * @param sceneOrEngine The scene or engine the texture will be used in
  142280. * @param onLoad defines a callback triggered when the texture has been loaded
  142281. */
  142282. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142283. /**
  142284. * Fires the onload event from the constructor if requested.
  142285. */
  142286. private _triggerOnLoad;
  142287. /**
  142288. * Returns the texture matrix used in most of the material.
  142289. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142290. */
  142291. getTextureMatrix(): Matrix;
  142292. /**
  142293. * Occurs when the file being loaded is a .3dl LUT file.
  142294. */
  142295. private load3dlTexture;
  142296. /**
  142297. * Starts the loading process of the texture.
  142298. */
  142299. private loadTexture;
  142300. /**
  142301. * Clones the color gradind texture.
  142302. */
  142303. clone(): ColorGradingTexture;
  142304. /**
  142305. * Called during delayed load for textures.
  142306. */
  142307. delayLoad(): void;
  142308. /**
  142309. * Parses a color grading texture serialized by Babylon.
  142310. * @param parsedTexture The texture information being parsedTexture
  142311. * @param scene The scene to load the texture in
  142312. * @param rootUrl The root url of the data assets to load
  142313. * @return A color gradind texture
  142314. */
  142315. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142316. /**
  142317. * Serializes the LUT texture to json format.
  142318. */
  142319. serialize(): any;
  142320. }
  142321. }
  142322. declare module BABYLON {
  142323. /**
  142324. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142325. */
  142326. export class EquiRectangularCubeTexture extends BaseTexture {
  142327. /** The six faces of the cube. */
  142328. private static _FacesMapping;
  142329. private _noMipmap;
  142330. private _onLoad;
  142331. private _onError;
  142332. /** The size of the cubemap. */
  142333. private _size;
  142334. /** The buffer of the image. */
  142335. private _buffer;
  142336. /** The width of the input image. */
  142337. private _width;
  142338. /** The height of the input image. */
  142339. private _height;
  142340. /** The URL to the image. */
  142341. url: string;
  142342. /**
  142343. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142344. * @param url The location of the image
  142345. * @param scene The scene the texture will be used in
  142346. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142347. * @param noMipmap Forces to not generate the mipmap if true
  142348. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142349. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142350. * @param onLoad — defines a callback called when texture is loaded
  142351. * @param onError — defines a callback called if there is an error
  142352. */
  142353. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142354. /**
  142355. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142356. */
  142357. private loadImage;
  142358. /**
  142359. * Convert the image buffer into a cubemap and create a CubeTexture.
  142360. */
  142361. private loadTexture;
  142362. /**
  142363. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142364. * @param buffer The ArrayBuffer that should be converted.
  142365. * @returns The buffer as Float32Array.
  142366. */
  142367. private getFloat32ArrayFromArrayBuffer;
  142368. /**
  142369. * Get the current class name of the texture useful for serialization or dynamic coding.
  142370. * @returns "EquiRectangularCubeTexture"
  142371. */
  142372. getClassName(): string;
  142373. /**
  142374. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142375. * @returns A clone of the current EquiRectangularCubeTexture.
  142376. */
  142377. clone(): EquiRectangularCubeTexture;
  142378. }
  142379. }
  142380. declare module BABYLON {
  142381. /**
  142382. * Defines the options related to the creation of an HtmlElementTexture
  142383. */
  142384. export interface IHtmlElementTextureOptions {
  142385. /**
  142386. * Defines wether mip maps should be created or not.
  142387. */
  142388. generateMipMaps?: boolean;
  142389. /**
  142390. * Defines the sampling mode of the texture.
  142391. */
  142392. samplingMode?: number;
  142393. /**
  142394. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142395. */
  142396. engine: Nullable<ThinEngine>;
  142397. /**
  142398. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142399. */
  142400. scene: Nullable<Scene>;
  142401. }
  142402. /**
  142403. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142404. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142405. * is automatically managed.
  142406. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142407. * in your application.
  142408. *
  142409. * As the update is not automatic, you need to call them manually.
  142410. */
  142411. export class HtmlElementTexture extends BaseTexture {
  142412. /**
  142413. * The texture URL.
  142414. */
  142415. element: HTMLVideoElement | HTMLCanvasElement;
  142416. private static readonly DefaultOptions;
  142417. private _textureMatrix;
  142418. private _isVideo;
  142419. private _generateMipMaps;
  142420. private _samplingMode;
  142421. /**
  142422. * Instantiates a HtmlElementTexture from the following parameters.
  142423. *
  142424. * @param name Defines the name of the texture
  142425. * @param element Defines the video or canvas the texture is filled with
  142426. * @param options Defines the other none mandatory texture creation options
  142427. */
  142428. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142429. private _createInternalTexture;
  142430. /**
  142431. * Returns the texture matrix used in most of the material.
  142432. */
  142433. getTextureMatrix(): Matrix;
  142434. /**
  142435. * Updates the content of the texture.
  142436. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142437. */
  142438. update(invertY?: Nullable<boolean>): void;
  142439. }
  142440. }
  142441. declare module BABYLON {
  142442. /**
  142443. * Based on jsTGALoader - Javascript loader for TGA file
  142444. * By Vincent Thibault
  142445. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142446. */
  142447. export class TGATools {
  142448. private static _TYPE_INDEXED;
  142449. private static _TYPE_RGB;
  142450. private static _TYPE_GREY;
  142451. private static _TYPE_RLE_INDEXED;
  142452. private static _TYPE_RLE_RGB;
  142453. private static _TYPE_RLE_GREY;
  142454. private static _ORIGIN_MASK;
  142455. private static _ORIGIN_SHIFT;
  142456. private static _ORIGIN_BL;
  142457. private static _ORIGIN_BR;
  142458. private static _ORIGIN_UL;
  142459. private static _ORIGIN_UR;
  142460. /**
  142461. * Gets the header of a TGA file
  142462. * @param data defines the TGA data
  142463. * @returns the header
  142464. */
  142465. static GetTGAHeader(data: Uint8Array): any;
  142466. /**
  142467. * Uploads TGA content to a Babylon Texture
  142468. * @hidden
  142469. */
  142470. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142471. /** @hidden */
  142472. 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;
  142473. /** @hidden */
  142474. 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;
  142475. /** @hidden */
  142476. 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;
  142477. /** @hidden */
  142478. 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;
  142479. /** @hidden */
  142480. 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;
  142481. /** @hidden */
  142482. 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;
  142483. }
  142484. }
  142485. declare module BABYLON {
  142486. /**
  142487. * Implementation of the TGA Texture Loader.
  142488. * @hidden
  142489. */
  142490. export class _TGATextureLoader implements IInternalTextureLoader {
  142491. /**
  142492. * Defines wether the loader supports cascade loading the different faces.
  142493. */
  142494. readonly supportCascades: boolean;
  142495. /**
  142496. * This returns if the loader support the current file information.
  142497. * @param extension defines the file extension of the file being loaded
  142498. * @returns true if the loader can load the specified file
  142499. */
  142500. canLoad(extension: string): boolean;
  142501. /**
  142502. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142503. * @param data contains the texture data
  142504. * @param texture defines the BabylonJS internal texture
  142505. * @param createPolynomials will be true if polynomials have been requested
  142506. * @param onLoad defines the callback to trigger once the texture is ready
  142507. * @param onError defines the callback to trigger in case of error
  142508. */
  142509. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142510. /**
  142511. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142512. * @param data contains the texture data
  142513. * @param texture defines the BabylonJS internal texture
  142514. * @param callback defines the method to call once ready to upload
  142515. */
  142516. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142517. }
  142518. }
  142519. declare module BABYLON {
  142520. /**
  142521. * Info about the .basis files
  142522. */
  142523. class BasisFileInfo {
  142524. /**
  142525. * If the file has alpha
  142526. */
  142527. hasAlpha: boolean;
  142528. /**
  142529. * Info about each image of the basis file
  142530. */
  142531. images: Array<{
  142532. levels: Array<{
  142533. width: number;
  142534. height: number;
  142535. transcodedPixels: ArrayBufferView;
  142536. }>;
  142537. }>;
  142538. }
  142539. /**
  142540. * Result of transcoding a basis file
  142541. */
  142542. class TranscodeResult {
  142543. /**
  142544. * Info about the .basis file
  142545. */
  142546. fileInfo: BasisFileInfo;
  142547. /**
  142548. * Format to use when loading the file
  142549. */
  142550. format: number;
  142551. }
  142552. /**
  142553. * Configuration options for the Basis transcoder
  142554. */
  142555. export class BasisTranscodeConfiguration {
  142556. /**
  142557. * Supported compression formats used to determine the supported output format of the transcoder
  142558. */
  142559. supportedCompressionFormats?: {
  142560. /**
  142561. * etc1 compression format
  142562. */
  142563. etc1?: boolean;
  142564. /**
  142565. * s3tc compression format
  142566. */
  142567. s3tc?: boolean;
  142568. /**
  142569. * pvrtc compression format
  142570. */
  142571. pvrtc?: boolean;
  142572. /**
  142573. * etc2 compression format
  142574. */
  142575. etc2?: boolean;
  142576. };
  142577. /**
  142578. * If mipmap levels should be loaded for transcoded images (Default: true)
  142579. */
  142580. loadMipmapLevels?: boolean;
  142581. /**
  142582. * Index of a single image to load (Default: all images)
  142583. */
  142584. loadSingleImage?: number;
  142585. }
  142586. /**
  142587. * Used to load .Basis files
  142588. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142589. */
  142590. export class BasisTools {
  142591. private static _IgnoreSupportedFormats;
  142592. /**
  142593. * URL to use when loading the basis transcoder
  142594. */
  142595. static JSModuleURL: string;
  142596. /**
  142597. * URL to use when loading the wasm module for the transcoder
  142598. */
  142599. static WasmModuleURL: string;
  142600. /**
  142601. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142602. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142603. * @returns internal format corresponding to the Basis format
  142604. */
  142605. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142606. private static _WorkerPromise;
  142607. private static _Worker;
  142608. private static _actionId;
  142609. private static _CreateWorkerAsync;
  142610. /**
  142611. * Transcodes a loaded image file to compressed pixel data
  142612. * @param data image data to transcode
  142613. * @param config configuration options for the transcoding
  142614. * @returns a promise resulting in the transcoded image
  142615. */
  142616. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142617. /**
  142618. * Loads a texture from the transcode result
  142619. * @param texture texture load to
  142620. * @param transcodeResult the result of transcoding the basis file to load from
  142621. */
  142622. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142623. }
  142624. }
  142625. declare module BABYLON {
  142626. /**
  142627. * Loader for .basis file format
  142628. */
  142629. export class _BasisTextureLoader implements IInternalTextureLoader {
  142630. /**
  142631. * Defines whether the loader supports cascade loading the different faces.
  142632. */
  142633. readonly supportCascades: boolean;
  142634. /**
  142635. * This returns if the loader support the current file information.
  142636. * @param extension defines the file extension of the file being loaded
  142637. * @returns true if the loader can load the specified file
  142638. */
  142639. canLoad(extension: string): boolean;
  142640. /**
  142641. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142642. * @param data contains the texture data
  142643. * @param texture defines the BabylonJS internal texture
  142644. * @param createPolynomials will be true if polynomials have been requested
  142645. * @param onLoad defines the callback to trigger once the texture is ready
  142646. * @param onError defines the callback to trigger in case of error
  142647. */
  142648. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142649. /**
  142650. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142651. * @param data contains the texture data
  142652. * @param texture defines the BabylonJS internal texture
  142653. * @param callback defines the method to call once ready to upload
  142654. */
  142655. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142656. }
  142657. }
  142658. declare module BABYLON {
  142659. /**
  142660. * Defines the basic options interface of a TexturePacker Frame
  142661. */
  142662. export interface ITexturePackerFrame {
  142663. /**
  142664. * The frame ID
  142665. */
  142666. id: number;
  142667. /**
  142668. * The frames Scale
  142669. */
  142670. scale: Vector2;
  142671. /**
  142672. * The Frames offset
  142673. */
  142674. offset: Vector2;
  142675. }
  142676. /**
  142677. * This is a support class for frame Data on texture packer sets.
  142678. */
  142679. export class TexturePackerFrame implements ITexturePackerFrame {
  142680. /**
  142681. * The frame ID
  142682. */
  142683. id: number;
  142684. /**
  142685. * The frames Scale
  142686. */
  142687. scale: Vector2;
  142688. /**
  142689. * The Frames offset
  142690. */
  142691. offset: Vector2;
  142692. /**
  142693. * Initializes a texture package frame.
  142694. * @param id The numerical frame identifier
  142695. * @param scale Scalar Vector2 for UV frame
  142696. * @param offset Vector2 for the frame position in UV units.
  142697. * @returns TexturePackerFrame
  142698. */
  142699. constructor(id: number, scale: Vector2, offset: Vector2);
  142700. }
  142701. }
  142702. declare module BABYLON {
  142703. /**
  142704. * Defines the basic options interface of a TexturePacker
  142705. */
  142706. export interface ITexturePackerOptions {
  142707. /**
  142708. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142709. */
  142710. map?: string[];
  142711. /**
  142712. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142713. */
  142714. uvsIn?: string;
  142715. /**
  142716. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142717. */
  142718. uvsOut?: string;
  142719. /**
  142720. * number representing the layout style. Defaults to LAYOUT_STRIP
  142721. */
  142722. layout?: number;
  142723. /**
  142724. * number of columns if using custom column count layout(2). This defaults to 4.
  142725. */
  142726. colnum?: number;
  142727. /**
  142728. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142729. */
  142730. updateInputMeshes?: boolean;
  142731. /**
  142732. * boolean flag to dispose all the source textures. Defaults to true.
  142733. */
  142734. disposeSources?: boolean;
  142735. /**
  142736. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142737. */
  142738. fillBlanks?: boolean;
  142739. /**
  142740. * string value representing the context fill style color. Defaults to 'black'.
  142741. */
  142742. customFillColor?: string;
  142743. /**
  142744. * Width and Height Value of each Frame in the TexturePacker Sets
  142745. */
  142746. frameSize?: number;
  142747. /**
  142748. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142749. */
  142750. paddingRatio?: number;
  142751. /**
  142752. * Number that declares the fill method for the padding gutter.
  142753. */
  142754. paddingMode?: number;
  142755. /**
  142756. * If in SUBUV_COLOR padding mode what color to use.
  142757. */
  142758. paddingColor?: Color3 | Color4;
  142759. }
  142760. /**
  142761. * Defines the basic interface of a TexturePacker JSON File
  142762. */
  142763. export interface ITexturePackerJSON {
  142764. /**
  142765. * The frame ID
  142766. */
  142767. name: string;
  142768. /**
  142769. * The base64 channel data
  142770. */
  142771. sets: any;
  142772. /**
  142773. * The options of the Packer
  142774. */
  142775. options: ITexturePackerOptions;
  142776. /**
  142777. * The frame data of the Packer
  142778. */
  142779. frames: Array<number>;
  142780. }
  142781. /**
  142782. * This is a support class that generates a series of packed texture sets.
  142783. * @see https://doc.babylonjs.com/babylon101/materials
  142784. */
  142785. export class TexturePacker {
  142786. /** Packer Layout Constant 0 */
  142787. static readonly LAYOUT_STRIP: number;
  142788. /** Packer Layout Constant 1 */
  142789. static readonly LAYOUT_POWER2: number;
  142790. /** Packer Layout Constant 2 */
  142791. static readonly LAYOUT_COLNUM: number;
  142792. /** Packer Layout Constant 0 */
  142793. static readonly SUBUV_WRAP: number;
  142794. /** Packer Layout Constant 1 */
  142795. static readonly SUBUV_EXTEND: number;
  142796. /** Packer Layout Constant 2 */
  142797. static readonly SUBUV_COLOR: number;
  142798. /** The Name of the Texture Package */
  142799. name: string;
  142800. /** The scene scope of the TexturePacker */
  142801. scene: Scene;
  142802. /** The Meshes to target */
  142803. meshes: AbstractMesh[];
  142804. /** Arguments passed with the Constructor */
  142805. options: ITexturePackerOptions;
  142806. /** The promise that is started upon initialization */
  142807. promise: Nullable<Promise<TexturePacker | string>>;
  142808. /** The Container object for the channel sets that are generated */
  142809. sets: object;
  142810. /** The Container array for the frames that are generated */
  142811. frames: TexturePackerFrame[];
  142812. /** The expected number of textures the system is parsing. */
  142813. private _expecting;
  142814. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142815. private _paddingValue;
  142816. /**
  142817. * Initializes a texture package series from an array of meshes or a single mesh.
  142818. * @param name The name of the package
  142819. * @param meshes The target meshes to compose the package from
  142820. * @param options The arguments that texture packer should follow while building.
  142821. * @param scene The scene which the textures are scoped to.
  142822. * @returns TexturePacker
  142823. */
  142824. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142825. /**
  142826. * Starts the package process
  142827. * @param resolve The promises resolution function
  142828. * @returns TexturePacker
  142829. */
  142830. private _createFrames;
  142831. /**
  142832. * Calculates the Size of the Channel Sets
  142833. * @returns Vector2
  142834. */
  142835. private _calculateSize;
  142836. /**
  142837. * Calculates the UV data for the frames.
  142838. * @param baseSize the base frameSize
  142839. * @param padding the base frame padding
  142840. * @param dtSize size of the Dynamic Texture for that channel
  142841. * @param dtUnits is 1/dtSize
  142842. * @param update flag to update the input meshes
  142843. */
  142844. private _calculateMeshUVFrames;
  142845. /**
  142846. * Calculates the frames Offset.
  142847. * @param index of the frame
  142848. * @returns Vector2
  142849. */
  142850. private _getFrameOffset;
  142851. /**
  142852. * Updates a Mesh to the frame data
  142853. * @param mesh that is the target
  142854. * @param frameID or the frame index
  142855. */
  142856. private _updateMeshUV;
  142857. /**
  142858. * Updates a Meshes materials to use the texture packer channels
  142859. * @param m is the mesh to target
  142860. * @param force all channels on the packer to be set.
  142861. */
  142862. private _updateTextureReferences;
  142863. /**
  142864. * Public method to set a Mesh to a frame
  142865. * @param m that is the target
  142866. * @param frameID or the frame index
  142867. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142868. */
  142869. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142870. /**
  142871. * Starts the async promise to compile the texture packer.
  142872. * @returns Promise<void>
  142873. */
  142874. processAsync(): Promise<void>;
  142875. /**
  142876. * Disposes all textures associated with this packer
  142877. */
  142878. dispose(): void;
  142879. /**
  142880. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142881. * @param imageType is the image type to use.
  142882. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142883. */
  142884. download(imageType?: string, quality?: number): void;
  142885. /**
  142886. * Public method to load a texturePacker JSON file.
  142887. * @param data of the JSON file in string format.
  142888. */
  142889. updateFromJSON(data: string): void;
  142890. }
  142891. }
  142892. declare module BABYLON {
  142893. /**
  142894. * 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.
  142895. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142896. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142897. */
  142898. export class CustomProceduralTexture extends ProceduralTexture {
  142899. private _animate;
  142900. private _time;
  142901. private _config;
  142902. private _texturePath;
  142903. /**
  142904. * Instantiates a new Custom Procedural Texture.
  142905. * 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.
  142906. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142908. * @param name Define the name of the texture
  142909. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142910. * @param size Define the size of the texture to create
  142911. * @param scene Define the scene the texture belongs to
  142912. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142913. * @param generateMipMaps Define if the texture should creates mip maps or not
  142914. */
  142915. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142916. private _loadJson;
  142917. /**
  142918. * Is the texture ready to be used ? (rendered at least once)
  142919. * @returns true if ready, otherwise, false.
  142920. */
  142921. isReady(): boolean;
  142922. /**
  142923. * Render the texture to its associated render target.
  142924. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142925. */
  142926. render(useCameraPostProcess?: boolean): void;
  142927. /**
  142928. * Update the list of dependant textures samplers in the shader.
  142929. */
  142930. updateTextures(): void;
  142931. /**
  142932. * Update the uniform values of the procedural texture in the shader.
  142933. */
  142934. updateShaderUniforms(): void;
  142935. /**
  142936. * Define if the texture animates or not.
  142937. */
  142938. get animate(): boolean;
  142939. set animate(value: boolean);
  142940. }
  142941. }
  142942. declare module BABYLON {
  142943. /** @hidden */
  142944. export var noisePixelShader: {
  142945. name: string;
  142946. shader: string;
  142947. };
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * Class used to generate noise procedural textures
  142952. */
  142953. export class NoiseProceduralTexture extends ProceduralTexture {
  142954. /** Gets or sets the start time (default is 0) */
  142955. time: number;
  142956. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142957. brightness: number;
  142958. /** Defines the number of octaves to process */
  142959. octaves: number;
  142960. /** Defines the level of persistence (0.8 by default) */
  142961. persistence: number;
  142962. /** Gets or sets animation speed factor (default is 1) */
  142963. animationSpeedFactor: number;
  142964. /**
  142965. * Creates a new NoiseProceduralTexture
  142966. * @param name defines the name fo the texture
  142967. * @param size defines the size of the texture (default is 256)
  142968. * @param scene defines the hosting scene
  142969. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142970. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142971. */
  142972. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142973. private _updateShaderUniforms;
  142974. protected _getDefines(): string;
  142975. /** Generate the current state of the procedural texture */
  142976. render(useCameraPostProcess?: boolean): void;
  142977. /**
  142978. * Serializes this noise procedural texture
  142979. * @returns a serialized noise procedural texture object
  142980. */
  142981. serialize(): any;
  142982. /**
  142983. * Clone the texture.
  142984. * @returns the cloned texture
  142985. */
  142986. clone(): NoiseProceduralTexture;
  142987. /**
  142988. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142989. * @param parsedTexture defines parsed texture data
  142990. * @param scene defines the current scene
  142991. * @param rootUrl defines the root URL containing noise procedural texture information
  142992. * @returns a parsed NoiseProceduralTexture
  142993. */
  142994. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142995. }
  142996. }
  142997. declare module BABYLON {
  142998. /**
  142999. * Raw cube texture where the raw buffers are passed in
  143000. */
  143001. export class RawCubeTexture extends CubeTexture {
  143002. /**
  143003. * Creates a cube texture where the raw buffers are passed in.
  143004. * @param scene defines the scene the texture is attached to
  143005. * @param data defines the array of data to use to create each face
  143006. * @param size defines the size of the textures
  143007. * @param format defines the format of the data
  143008. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143009. * @param generateMipMaps defines if the engine should generate the mip levels
  143010. * @param invertY defines if data must be stored with Y axis inverted
  143011. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143012. * @param compression defines the compression used (null by default)
  143013. */
  143014. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143015. /**
  143016. * Updates the raw cube texture.
  143017. * @param data defines the data to store
  143018. * @param format defines the data format
  143019. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143020. * @param invertY defines if data must be stored with Y axis inverted
  143021. * @param compression defines the compression used (null by default)
  143022. * @param level defines which level of the texture to update
  143023. */
  143024. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143025. /**
  143026. * Updates a raw cube texture with RGBD encoded data.
  143027. * @param data defines the array of data [mipmap][face] to use to create each face
  143028. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143029. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143030. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143031. * @returns a promsie that resolves when the operation is complete
  143032. */
  143033. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143034. /**
  143035. * Clones the raw cube texture.
  143036. * @return a new cube texture
  143037. */
  143038. clone(): CubeTexture;
  143039. /** @hidden */
  143040. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143041. }
  143042. }
  143043. declare module BABYLON {
  143044. /**
  143045. * Class used to store 2D array textures containing user data
  143046. */
  143047. export class RawTexture2DArray extends Texture {
  143048. /** Gets or sets the texture format to use */
  143049. format: number;
  143050. /**
  143051. * Create a new RawTexture2DArray
  143052. * @param data defines the data of the texture
  143053. * @param width defines the width of the texture
  143054. * @param height defines the height of the texture
  143055. * @param depth defines the number of layers of the texture
  143056. * @param format defines the texture format to use
  143057. * @param scene defines the hosting scene
  143058. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143059. * @param invertY defines if texture must be stored with Y axis inverted
  143060. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143061. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143062. */
  143063. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143064. /** Gets or sets the texture format to use */
  143065. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143066. /**
  143067. * Update the texture with new data
  143068. * @param data defines the data to store in the texture
  143069. */
  143070. update(data: ArrayBufferView): void;
  143071. }
  143072. }
  143073. declare module BABYLON {
  143074. /**
  143075. * Class used to store 3D textures containing user data
  143076. */
  143077. export class RawTexture3D extends Texture {
  143078. /** Gets or sets the texture format to use */
  143079. format: number;
  143080. /**
  143081. * Create a new RawTexture3D
  143082. * @param data defines the data of the texture
  143083. * @param width defines the width of the texture
  143084. * @param height defines the height of the texture
  143085. * @param depth defines the depth of the texture
  143086. * @param format defines the texture format to use
  143087. * @param scene defines the hosting scene
  143088. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143089. * @param invertY defines if texture must be stored with Y axis inverted
  143090. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143091. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143092. */
  143093. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143094. /** Gets or sets the texture format to use */
  143095. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143096. /**
  143097. * Update the texture with new data
  143098. * @param data defines the data to store in the texture
  143099. */
  143100. update(data: ArrayBufferView): void;
  143101. }
  143102. }
  143103. declare module BABYLON {
  143104. /**
  143105. * Creates a refraction texture used by refraction channel of the standard material.
  143106. * It is like a mirror but to see through a material.
  143107. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143108. */
  143109. export class RefractionTexture extends RenderTargetTexture {
  143110. /**
  143111. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143112. * 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.
  143113. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143114. */
  143115. refractionPlane: Plane;
  143116. /**
  143117. * Define how deep under the surface we should see.
  143118. */
  143119. depth: number;
  143120. /**
  143121. * Creates a refraction texture used by refraction channel of the standard material.
  143122. * It is like a mirror but to see through a material.
  143123. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143124. * @param name Define the texture name
  143125. * @param size Define the size of the underlying texture
  143126. * @param scene Define the scene the refraction belongs to
  143127. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143128. */
  143129. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143130. /**
  143131. * Clone the refraction texture.
  143132. * @returns the cloned texture
  143133. */
  143134. clone(): RefractionTexture;
  143135. /**
  143136. * Serialize the texture to a JSON representation you could use in Parse later on
  143137. * @returns the serialized JSON representation
  143138. */
  143139. serialize(): any;
  143140. }
  143141. }
  143142. declare module BABYLON {
  143143. /**
  143144. * Block used to add support for vertex skinning (bones)
  143145. */
  143146. export class BonesBlock extends NodeMaterialBlock {
  143147. /**
  143148. * Creates a new BonesBlock
  143149. * @param name defines the block name
  143150. */
  143151. constructor(name: string);
  143152. /**
  143153. * Initialize the block and prepare the context for build
  143154. * @param state defines the state that will be used for the build
  143155. */
  143156. initialize(state: NodeMaterialBuildState): void;
  143157. /**
  143158. * Gets the current class name
  143159. * @returns the class name
  143160. */
  143161. getClassName(): string;
  143162. /**
  143163. * Gets the matrix indices input component
  143164. */
  143165. get matricesIndices(): NodeMaterialConnectionPoint;
  143166. /**
  143167. * Gets the matrix weights input component
  143168. */
  143169. get matricesWeights(): NodeMaterialConnectionPoint;
  143170. /**
  143171. * Gets the extra matrix indices input component
  143172. */
  143173. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143174. /**
  143175. * Gets the extra matrix weights input component
  143176. */
  143177. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143178. /**
  143179. * Gets the world input component
  143180. */
  143181. get world(): NodeMaterialConnectionPoint;
  143182. /**
  143183. * Gets the output component
  143184. */
  143185. get output(): NodeMaterialConnectionPoint;
  143186. autoConfigure(material: NodeMaterial): void;
  143187. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143190. protected _buildBlock(state: NodeMaterialBuildState): this;
  143191. }
  143192. }
  143193. declare module BABYLON {
  143194. /**
  143195. * Block used to add support for instances
  143196. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143197. */
  143198. export class InstancesBlock extends NodeMaterialBlock {
  143199. /**
  143200. * Creates a new InstancesBlock
  143201. * @param name defines the block name
  143202. */
  143203. constructor(name: string);
  143204. /**
  143205. * Gets the current class name
  143206. * @returns the class name
  143207. */
  143208. getClassName(): string;
  143209. /**
  143210. * Gets the first world row input component
  143211. */
  143212. get world0(): NodeMaterialConnectionPoint;
  143213. /**
  143214. * Gets the second world row input component
  143215. */
  143216. get world1(): NodeMaterialConnectionPoint;
  143217. /**
  143218. * Gets the third world row input component
  143219. */
  143220. get world2(): NodeMaterialConnectionPoint;
  143221. /**
  143222. * Gets the forth world row input component
  143223. */
  143224. get world3(): NodeMaterialConnectionPoint;
  143225. /**
  143226. * Gets the world input component
  143227. */
  143228. get world(): NodeMaterialConnectionPoint;
  143229. /**
  143230. * Gets the output component
  143231. */
  143232. get output(): NodeMaterialConnectionPoint;
  143233. /**
  143234. * Gets the isntanceID component
  143235. */
  143236. get instanceID(): NodeMaterialConnectionPoint;
  143237. autoConfigure(material: NodeMaterial): void;
  143238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143239. protected _buildBlock(state: NodeMaterialBuildState): this;
  143240. }
  143241. }
  143242. declare module BABYLON {
  143243. /**
  143244. * Block used to add morph targets support to vertex shader
  143245. */
  143246. export class MorphTargetsBlock extends NodeMaterialBlock {
  143247. private _repeatableContentAnchor;
  143248. /**
  143249. * Create a new MorphTargetsBlock
  143250. * @param name defines the block name
  143251. */
  143252. constructor(name: string);
  143253. /**
  143254. * Gets the current class name
  143255. * @returns the class name
  143256. */
  143257. getClassName(): string;
  143258. /**
  143259. * Gets the position input component
  143260. */
  143261. get position(): NodeMaterialConnectionPoint;
  143262. /**
  143263. * Gets the normal input component
  143264. */
  143265. get normal(): NodeMaterialConnectionPoint;
  143266. /**
  143267. * Gets the tangent input component
  143268. */
  143269. get tangent(): NodeMaterialConnectionPoint;
  143270. /**
  143271. * Gets the tangent input component
  143272. */
  143273. get uv(): NodeMaterialConnectionPoint;
  143274. /**
  143275. * Gets the position output component
  143276. */
  143277. get positionOutput(): NodeMaterialConnectionPoint;
  143278. /**
  143279. * Gets the normal output component
  143280. */
  143281. get normalOutput(): NodeMaterialConnectionPoint;
  143282. /**
  143283. * Gets the tangent output component
  143284. */
  143285. get tangentOutput(): NodeMaterialConnectionPoint;
  143286. /**
  143287. * Gets the tangent output component
  143288. */
  143289. get uvOutput(): NodeMaterialConnectionPoint;
  143290. initialize(state: NodeMaterialBuildState): void;
  143291. autoConfigure(material: NodeMaterial): void;
  143292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143294. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143295. protected _buildBlock(state: NodeMaterialBuildState): this;
  143296. }
  143297. }
  143298. declare module BABYLON {
  143299. /**
  143300. * Block used to get data information from a light
  143301. */
  143302. export class LightInformationBlock extends NodeMaterialBlock {
  143303. private _lightDataUniformName;
  143304. private _lightColorUniformName;
  143305. private _lightTypeDefineName;
  143306. /**
  143307. * Gets or sets the light associated with this block
  143308. */
  143309. light: Nullable<Light>;
  143310. /**
  143311. * Creates a new LightInformationBlock
  143312. * @param name defines the block name
  143313. */
  143314. constructor(name: string);
  143315. /**
  143316. * Gets the current class name
  143317. * @returns the class name
  143318. */
  143319. getClassName(): string;
  143320. /**
  143321. * Gets the world position input component
  143322. */
  143323. get worldPosition(): NodeMaterialConnectionPoint;
  143324. /**
  143325. * Gets the direction output component
  143326. */
  143327. get direction(): NodeMaterialConnectionPoint;
  143328. /**
  143329. * Gets the direction output component
  143330. */
  143331. get color(): NodeMaterialConnectionPoint;
  143332. /**
  143333. * Gets the direction output component
  143334. */
  143335. get intensity(): NodeMaterialConnectionPoint;
  143336. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143338. protected _buildBlock(state: NodeMaterialBuildState): this;
  143339. serialize(): any;
  143340. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143341. }
  143342. }
  143343. declare module BABYLON {
  143344. /**
  143345. * Block used to add image processing support to fragment shader
  143346. */
  143347. export class ImageProcessingBlock extends NodeMaterialBlock {
  143348. /**
  143349. * Create a new ImageProcessingBlock
  143350. * @param name defines the block name
  143351. */
  143352. constructor(name: string);
  143353. /**
  143354. * Gets the current class name
  143355. * @returns the class name
  143356. */
  143357. getClassName(): string;
  143358. /**
  143359. * Gets the color input component
  143360. */
  143361. get color(): NodeMaterialConnectionPoint;
  143362. /**
  143363. * Gets the output component
  143364. */
  143365. get output(): NodeMaterialConnectionPoint;
  143366. /**
  143367. * Initialize the block and prepare the context for build
  143368. * @param state defines the state that will be used for the build
  143369. */
  143370. initialize(state: NodeMaterialBuildState): void;
  143371. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143374. protected _buildBlock(state: NodeMaterialBuildState): this;
  143375. }
  143376. }
  143377. declare module BABYLON {
  143378. /**
  143379. * Block used to pertub normals based on a normal map
  143380. */
  143381. export class PerturbNormalBlock extends NodeMaterialBlock {
  143382. private _tangentSpaceParameterName;
  143383. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143384. invertX: boolean;
  143385. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143386. invertY: boolean;
  143387. /**
  143388. * Create a new PerturbNormalBlock
  143389. * @param name defines the block name
  143390. */
  143391. constructor(name: string);
  143392. /**
  143393. * Gets the current class name
  143394. * @returns the class name
  143395. */
  143396. getClassName(): string;
  143397. /**
  143398. * Gets the world position input component
  143399. */
  143400. get worldPosition(): NodeMaterialConnectionPoint;
  143401. /**
  143402. * Gets the world normal input component
  143403. */
  143404. get worldNormal(): NodeMaterialConnectionPoint;
  143405. /**
  143406. * Gets the world tangent input component
  143407. */
  143408. get worldTangent(): NodeMaterialConnectionPoint;
  143409. /**
  143410. * Gets the uv input component
  143411. */
  143412. get uv(): NodeMaterialConnectionPoint;
  143413. /**
  143414. * Gets the normal map color input component
  143415. */
  143416. get normalMapColor(): NodeMaterialConnectionPoint;
  143417. /**
  143418. * Gets the strength input component
  143419. */
  143420. get strength(): NodeMaterialConnectionPoint;
  143421. /**
  143422. * Gets the output component
  143423. */
  143424. get output(): NodeMaterialConnectionPoint;
  143425. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143427. autoConfigure(material: NodeMaterial): void;
  143428. protected _buildBlock(state: NodeMaterialBuildState): this;
  143429. protected _dumpPropertiesCode(): string;
  143430. serialize(): any;
  143431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143432. }
  143433. }
  143434. declare module BABYLON {
  143435. /**
  143436. * Block used to discard a pixel if a value is smaller than a cutoff
  143437. */
  143438. export class DiscardBlock extends NodeMaterialBlock {
  143439. /**
  143440. * Create a new DiscardBlock
  143441. * @param name defines the block name
  143442. */
  143443. constructor(name: string);
  143444. /**
  143445. * Gets the current class name
  143446. * @returns the class name
  143447. */
  143448. getClassName(): string;
  143449. /**
  143450. * Gets the color input component
  143451. */
  143452. get value(): NodeMaterialConnectionPoint;
  143453. /**
  143454. * Gets the cutoff input component
  143455. */
  143456. get cutoff(): NodeMaterialConnectionPoint;
  143457. protected _buildBlock(state: NodeMaterialBuildState): this;
  143458. }
  143459. }
  143460. declare module BABYLON {
  143461. /**
  143462. * Block used to test if the fragment shader is front facing
  143463. */
  143464. export class FrontFacingBlock extends NodeMaterialBlock {
  143465. /**
  143466. * Creates a new FrontFacingBlock
  143467. * @param name defines the block name
  143468. */
  143469. constructor(name: string);
  143470. /**
  143471. * Gets the current class name
  143472. * @returns the class name
  143473. */
  143474. getClassName(): string;
  143475. /**
  143476. * Gets the output component
  143477. */
  143478. get output(): NodeMaterialConnectionPoint;
  143479. protected _buildBlock(state: NodeMaterialBuildState): this;
  143480. }
  143481. }
  143482. declare module BABYLON {
  143483. /**
  143484. * Block used to get the derivative value on x and y of a given input
  143485. */
  143486. export class DerivativeBlock extends NodeMaterialBlock {
  143487. /**
  143488. * Create a new DerivativeBlock
  143489. * @param name defines the block name
  143490. */
  143491. constructor(name: string);
  143492. /**
  143493. * Gets the current class name
  143494. * @returns the class name
  143495. */
  143496. getClassName(): string;
  143497. /**
  143498. * Gets the input component
  143499. */
  143500. get input(): NodeMaterialConnectionPoint;
  143501. /**
  143502. * Gets the derivative output on x
  143503. */
  143504. get dx(): NodeMaterialConnectionPoint;
  143505. /**
  143506. * Gets the derivative output on y
  143507. */
  143508. get dy(): NodeMaterialConnectionPoint;
  143509. protected _buildBlock(state: NodeMaterialBuildState): this;
  143510. }
  143511. }
  143512. declare module BABYLON {
  143513. /**
  143514. * Block used to make gl_FragCoord available
  143515. */
  143516. export class FragCoordBlock extends NodeMaterialBlock {
  143517. /**
  143518. * Creates a new FragCoordBlock
  143519. * @param name defines the block name
  143520. */
  143521. constructor(name: string);
  143522. /**
  143523. * Gets the current class name
  143524. * @returns the class name
  143525. */
  143526. getClassName(): string;
  143527. /**
  143528. * Gets the xy component
  143529. */
  143530. get xy(): NodeMaterialConnectionPoint;
  143531. /**
  143532. * Gets the xyz component
  143533. */
  143534. get xyz(): NodeMaterialConnectionPoint;
  143535. /**
  143536. * Gets the xyzw component
  143537. */
  143538. get xyzw(): NodeMaterialConnectionPoint;
  143539. /**
  143540. * Gets the x component
  143541. */
  143542. get x(): NodeMaterialConnectionPoint;
  143543. /**
  143544. * Gets the y component
  143545. */
  143546. get y(): NodeMaterialConnectionPoint;
  143547. /**
  143548. * Gets the z component
  143549. */
  143550. get z(): NodeMaterialConnectionPoint;
  143551. /**
  143552. * Gets the w component
  143553. */
  143554. get output(): NodeMaterialConnectionPoint;
  143555. protected writeOutputs(state: NodeMaterialBuildState): string;
  143556. protected _buildBlock(state: NodeMaterialBuildState): this;
  143557. }
  143558. }
  143559. declare module BABYLON {
  143560. /**
  143561. * Block used to get the screen sizes
  143562. */
  143563. export class ScreenSizeBlock extends NodeMaterialBlock {
  143564. private _varName;
  143565. private _scene;
  143566. /**
  143567. * Creates a new ScreenSizeBlock
  143568. * @param name defines the block name
  143569. */
  143570. constructor(name: string);
  143571. /**
  143572. * Gets the current class name
  143573. * @returns the class name
  143574. */
  143575. getClassName(): string;
  143576. /**
  143577. * Gets the xy component
  143578. */
  143579. get xy(): NodeMaterialConnectionPoint;
  143580. /**
  143581. * Gets the x component
  143582. */
  143583. get x(): NodeMaterialConnectionPoint;
  143584. /**
  143585. * Gets the y component
  143586. */
  143587. get y(): NodeMaterialConnectionPoint;
  143588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143589. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143590. protected _buildBlock(state: NodeMaterialBuildState): this;
  143591. }
  143592. }
  143593. declare module BABYLON {
  143594. /**
  143595. * Block used to add support for scene fog
  143596. */
  143597. export class FogBlock extends NodeMaterialBlock {
  143598. private _fogDistanceName;
  143599. private _fogParameters;
  143600. /**
  143601. * Create a new FogBlock
  143602. * @param name defines the block name
  143603. */
  143604. constructor(name: string);
  143605. /**
  143606. * Gets the current class name
  143607. * @returns the class name
  143608. */
  143609. getClassName(): string;
  143610. /**
  143611. * Gets the world position input component
  143612. */
  143613. get worldPosition(): NodeMaterialConnectionPoint;
  143614. /**
  143615. * Gets the view input component
  143616. */
  143617. get view(): NodeMaterialConnectionPoint;
  143618. /**
  143619. * Gets the color input component
  143620. */
  143621. get input(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the fog color input component
  143624. */
  143625. get fogColor(): NodeMaterialConnectionPoint;
  143626. /**
  143627. * Gets the output component
  143628. */
  143629. get output(): NodeMaterialConnectionPoint;
  143630. autoConfigure(material: NodeMaterial): void;
  143631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143633. protected _buildBlock(state: NodeMaterialBuildState): this;
  143634. }
  143635. }
  143636. declare module BABYLON {
  143637. /**
  143638. * Block used to add light in the fragment shader
  143639. */
  143640. export class LightBlock extends NodeMaterialBlock {
  143641. private _lightId;
  143642. /**
  143643. * Gets or sets the light associated with this block
  143644. */
  143645. light: Nullable<Light>;
  143646. /**
  143647. * Create a new LightBlock
  143648. * @param name defines the block name
  143649. */
  143650. constructor(name: string);
  143651. /**
  143652. * Gets the current class name
  143653. * @returns the class name
  143654. */
  143655. getClassName(): string;
  143656. /**
  143657. * Gets the world position input component
  143658. */
  143659. get worldPosition(): NodeMaterialConnectionPoint;
  143660. /**
  143661. * Gets the world normal input component
  143662. */
  143663. get worldNormal(): NodeMaterialConnectionPoint;
  143664. /**
  143665. * Gets the camera (or eye) position component
  143666. */
  143667. get cameraPosition(): NodeMaterialConnectionPoint;
  143668. /**
  143669. * Gets the glossiness component
  143670. */
  143671. get glossiness(): NodeMaterialConnectionPoint;
  143672. /**
  143673. * Gets the glossinness power component
  143674. */
  143675. get glossPower(): NodeMaterialConnectionPoint;
  143676. /**
  143677. * Gets the diffuse color component
  143678. */
  143679. get diffuseColor(): NodeMaterialConnectionPoint;
  143680. /**
  143681. * Gets the specular color component
  143682. */
  143683. get specularColor(): NodeMaterialConnectionPoint;
  143684. /**
  143685. * Gets the diffuse output component
  143686. */
  143687. get diffuseOutput(): NodeMaterialConnectionPoint;
  143688. /**
  143689. * Gets the specular output component
  143690. */
  143691. get specularOutput(): NodeMaterialConnectionPoint;
  143692. /**
  143693. * Gets the shadow output component
  143694. */
  143695. get shadow(): NodeMaterialConnectionPoint;
  143696. autoConfigure(material: NodeMaterial): void;
  143697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143698. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143700. private _injectVertexCode;
  143701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143702. serialize(): any;
  143703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143704. }
  143705. }
  143706. declare module BABYLON {
  143707. /**
  143708. * Block used to read a reflection texture from a sampler
  143709. */
  143710. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143711. /**
  143712. * Create a new ReflectionTextureBlock
  143713. * @param name defines the block name
  143714. */
  143715. constructor(name: string);
  143716. /**
  143717. * Gets the current class name
  143718. * @returns the class name
  143719. */
  143720. getClassName(): string;
  143721. /**
  143722. * Gets the world position input component
  143723. */
  143724. get position(): NodeMaterialConnectionPoint;
  143725. /**
  143726. * Gets the world position input component
  143727. */
  143728. get worldPosition(): NodeMaterialConnectionPoint;
  143729. /**
  143730. * Gets the world normal input component
  143731. */
  143732. get worldNormal(): NodeMaterialConnectionPoint;
  143733. /**
  143734. * Gets the world input component
  143735. */
  143736. get world(): NodeMaterialConnectionPoint;
  143737. /**
  143738. * Gets the camera (or eye) position component
  143739. */
  143740. get cameraPosition(): NodeMaterialConnectionPoint;
  143741. /**
  143742. * Gets the view input component
  143743. */
  143744. get view(): NodeMaterialConnectionPoint;
  143745. /**
  143746. * Gets the rgb output component
  143747. */
  143748. get rgb(): NodeMaterialConnectionPoint;
  143749. /**
  143750. * Gets the rgba output component
  143751. */
  143752. get rgba(): NodeMaterialConnectionPoint;
  143753. /**
  143754. * Gets the r output component
  143755. */
  143756. get r(): NodeMaterialConnectionPoint;
  143757. /**
  143758. * Gets the g output component
  143759. */
  143760. get g(): NodeMaterialConnectionPoint;
  143761. /**
  143762. * Gets the b output component
  143763. */
  143764. get b(): NodeMaterialConnectionPoint;
  143765. /**
  143766. * Gets the a output component
  143767. */
  143768. get a(): NodeMaterialConnectionPoint;
  143769. autoConfigure(material: NodeMaterial): void;
  143770. protected _buildBlock(state: NodeMaterialBuildState): this;
  143771. }
  143772. }
  143773. declare module BABYLON {
  143774. /**
  143775. * Block used to add 2 vectors
  143776. */
  143777. export class AddBlock extends NodeMaterialBlock {
  143778. /**
  143779. * Creates a new AddBlock
  143780. * @param name defines the block name
  143781. */
  143782. constructor(name: string);
  143783. /**
  143784. * Gets the current class name
  143785. * @returns the class name
  143786. */
  143787. getClassName(): string;
  143788. /**
  143789. * Gets the left operand input component
  143790. */
  143791. get left(): NodeMaterialConnectionPoint;
  143792. /**
  143793. * Gets the right operand input component
  143794. */
  143795. get right(): NodeMaterialConnectionPoint;
  143796. /**
  143797. * Gets the output component
  143798. */
  143799. get output(): NodeMaterialConnectionPoint;
  143800. protected _buildBlock(state: NodeMaterialBuildState): this;
  143801. }
  143802. }
  143803. declare module BABYLON {
  143804. /**
  143805. * Block used to scale a vector by a float
  143806. */
  143807. export class ScaleBlock extends NodeMaterialBlock {
  143808. /**
  143809. * Creates a new ScaleBlock
  143810. * @param name defines the block name
  143811. */
  143812. constructor(name: string);
  143813. /**
  143814. * Gets the current class name
  143815. * @returns the class name
  143816. */
  143817. getClassName(): string;
  143818. /**
  143819. * Gets the input component
  143820. */
  143821. get input(): NodeMaterialConnectionPoint;
  143822. /**
  143823. * Gets the factor input component
  143824. */
  143825. get factor(): NodeMaterialConnectionPoint;
  143826. /**
  143827. * Gets the output component
  143828. */
  143829. get output(): NodeMaterialConnectionPoint;
  143830. protected _buildBlock(state: NodeMaterialBuildState): this;
  143831. }
  143832. }
  143833. declare module BABYLON {
  143834. /**
  143835. * Block used to clamp a float
  143836. */
  143837. export class ClampBlock extends NodeMaterialBlock {
  143838. /** Gets or sets the minimum range */
  143839. minimum: number;
  143840. /** Gets or sets the maximum range */
  143841. maximum: number;
  143842. /**
  143843. * Creates a new ClampBlock
  143844. * @param name defines the block name
  143845. */
  143846. constructor(name: string);
  143847. /**
  143848. * Gets the current class name
  143849. * @returns the class name
  143850. */
  143851. getClassName(): string;
  143852. /**
  143853. * Gets the value input component
  143854. */
  143855. get value(): NodeMaterialConnectionPoint;
  143856. /**
  143857. * Gets the output component
  143858. */
  143859. get output(): NodeMaterialConnectionPoint;
  143860. protected _buildBlock(state: NodeMaterialBuildState): this;
  143861. protected _dumpPropertiesCode(): string;
  143862. serialize(): any;
  143863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143864. }
  143865. }
  143866. declare module BABYLON {
  143867. /**
  143868. * Block used to apply a cross product between 2 vectors
  143869. */
  143870. export class CrossBlock extends NodeMaterialBlock {
  143871. /**
  143872. * Creates a new CrossBlock
  143873. * @param name defines the block name
  143874. */
  143875. constructor(name: string);
  143876. /**
  143877. * Gets the current class name
  143878. * @returns the class name
  143879. */
  143880. getClassName(): string;
  143881. /**
  143882. * Gets the left operand input component
  143883. */
  143884. get left(): NodeMaterialConnectionPoint;
  143885. /**
  143886. * Gets the right operand input component
  143887. */
  143888. get right(): NodeMaterialConnectionPoint;
  143889. /**
  143890. * Gets the output component
  143891. */
  143892. get output(): NodeMaterialConnectionPoint;
  143893. protected _buildBlock(state: NodeMaterialBuildState): this;
  143894. }
  143895. }
  143896. declare module BABYLON {
  143897. /**
  143898. * Block used to apply a dot product between 2 vectors
  143899. */
  143900. export class DotBlock extends NodeMaterialBlock {
  143901. /**
  143902. * Creates a new DotBlock
  143903. * @param name defines the block name
  143904. */
  143905. constructor(name: string);
  143906. /**
  143907. * Gets the current class name
  143908. * @returns the class name
  143909. */
  143910. getClassName(): string;
  143911. /**
  143912. * Gets the left operand input component
  143913. */
  143914. get left(): NodeMaterialConnectionPoint;
  143915. /**
  143916. * Gets the right operand input component
  143917. */
  143918. get right(): NodeMaterialConnectionPoint;
  143919. /**
  143920. * Gets the output component
  143921. */
  143922. get output(): NodeMaterialConnectionPoint;
  143923. protected _buildBlock(state: NodeMaterialBuildState): this;
  143924. }
  143925. }
  143926. declare module BABYLON {
  143927. /**
  143928. * Block used to normalize a vector
  143929. */
  143930. export class NormalizeBlock extends NodeMaterialBlock {
  143931. /**
  143932. * Creates a new NormalizeBlock
  143933. * @param name defines the block name
  143934. */
  143935. constructor(name: string);
  143936. /**
  143937. * Gets the current class name
  143938. * @returns the class name
  143939. */
  143940. getClassName(): string;
  143941. /**
  143942. * Gets the input component
  143943. */
  143944. get input(): NodeMaterialConnectionPoint;
  143945. /**
  143946. * Gets the output component
  143947. */
  143948. get output(): NodeMaterialConnectionPoint;
  143949. protected _buildBlock(state: NodeMaterialBuildState): this;
  143950. }
  143951. }
  143952. declare module BABYLON {
  143953. /**
  143954. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143955. */
  143956. export class ColorMergerBlock extends NodeMaterialBlock {
  143957. /**
  143958. * Create a new ColorMergerBlock
  143959. * @param name defines the block name
  143960. */
  143961. constructor(name: string);
  143962. /**
  143963. * Gets the current class name
  143964. * @returns the class name
  143965. */
  143966. getClassName(): string;
  143967. /**
  143968. * Gets the rgb component (input)
  143969. */
  143970. get rgbIn(): NodeMaterialConnectionPoint;
  143971. /**
  143972. * Gets the r component (input)
  143973. */
  143974. get r(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the g component (input)
  143977. */
  143978. get g(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the b component (input)
  143981. */
  143982. get b(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the a component (input)
  143985. */
  143986. get a(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the rgba component (output)
  143989. */
  143990. get rgba(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the rgb component (output)
  143993. */
  143994. get rgbOut(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the rgb component (output)
  143997. * @deprecated Please use rgbOut instead.
  143998. */
  143999. get rgb(): NodeMaterialConnectionPoint;
  144000. protected _buildBlock(state: NodeMaterialBuildState): this;
  144001. }
  144002. }
  144003. declare module BABYLON {
  144004. /**
  144005. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144006. */
  144007. export class VectorSplitterBlock extends NodeMaterialBlock {
  144008. /**
  144009. * Create a new VectorSplitterBlock
  144010. * @param name defines the block name
  144011. */
  144012. constructor(name: string);
  144013. /**
  144014. * Gets the current class name
  144015. * @returns the class name
  144016. */
  144017. getClassName(): string;
  144018. /**
  144019. * Gets the xyzw component (input)
  144020. */
  144021. get xyzw(): NodeMaterialConnectionPoint;
  144022. /**
  144023. * Gets the xyz component (input)
  144024. */
  144025. get xyzIn(): NodeMaterialConnectionPoint;
  144026. /**
  144027. * Gets the xy component (input)
  144028. */
  144029. get xyIn(): NodeMaterialConnectionPoint;
  144030. /**
  144031. * Gets the xyz component (output)
  144032. */
  144033. get xyzOut(): NodeMaterialConnectionPoint;
  144034. /**
  144035. * Gets the xy component (output)
  144036. */
  144037. get xyOut(): NodeMaterialConnectionPoint;
  144038. /**
  144039. * Gets the x component (output)
  144040. */
  144041. get x(): NodeMaterialConnectionPoint;
  144042. /**
  144043. * Gets the y component (output)
  144044. */
  144045. get y(): NodeMaterialConnectionPoint;
  144046. /**
  144047. * Gets the z component (output)
  144048. */
  144049. get z(): NodeMaterialConnectionPoint;
  144050. /**
  144051. * Gets the w component (output)
  144052. */
  144053. get w(): NodeMaterialConnectionPoint;
  144054. protected _inputRename(name: string): string;
  144055. protected _outputRename(name: string): string;
  144056. protected _buildBlock(state: NodeMaterialBuildState): this;
  144057. }
  144058. }
  144059. declare module BABYLON {
  144060. /**
  144061. * Block used to lerp between 2 values
  144062. */
  144063. export class LerpBlock extends NodeMaterialBlock {
  144064. /**
  144065. * Creates a new LerpBlock
  144066. * @param name defines the block name
  144067. */
  144068. constructor(name: string);
  144069. /**
  144070. * Gets the current class name
  144071. * @returns the class name
  144072. */
  144073. getClassName(): string;
  144074. /**
  144075. * Gets the left operand input component
  144076. */
  144077. get left(): NodeMaterialConnectionPoint;
  144078. /**
  144079. * Gets the right operand input component
  144080. */
  144081. get right(): NodeMaterialConnectionPoint;
  144082. /**
  144083. * Gets the gradient operand input component
  144084. */
  144085. get gradient(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the output component
  144088. */
  144089. get output(): NodeMaterialConnectionPoint;
  144090. protected _buildBlock(state: NodeMaterialBuildState): this;
  144091. }
  144092. }
  144093. declare module BABYLON {
  144094. /**
  144095. * Block used to divide 2 vectors
  144096. */
  144097. export class DivideBlock extends NodeMaterialBlock {
  144098. /**
  144099. * Creates a new DivideBlock
  144100. * @param name defines the block name
  144101. */
  144102. constructor(name: string);
  144103. /**
  144104. * Gets the current class name
  144105. * @returns the class name
  144106. */
  144107. getClassName(): string;
  144108. /**
  144109. * Gets the left operand input component
  144110. */
  144111. get left(): NodeMaterialConnectionPoint;
  144112. /**
  144113. * Gets the right operand input component
  144114. */
  144115. get right(): NodeMaterialConnectionPoint;
  144116. /**
  144117. * Gets the output component
  144118. */
  144119. get output(): NodeMaterialConnectionPoint;
  144120. protected _buildBlock(state: NodeMaterialBuildState): this;
  144121. }
  144122. }
  144123. declare module BABYLON {
  144124. /**
  144125. * Block used to subtract 2 vectors
  144126. */
  144127. export class SubtractBlock extends NodeMaterialBlock {
  144128. /**
  144129. * Creates a new SubtractBlock
  144130. * @param name defines the block name
  144131. */
  144132. constructor(name: string);
  144133. /**
  144134. * Gets the current class name
  144135. * @returns the class name
  144136. */
  144137. getClassName(): string;
  144138. /**
  144139. * Gets the left operand input component
  144140. */
  144141. get left(): NodeMaterialConnectionPoint;
  144142. /**
  144143. * Gets the right operand input component
  144144. */
  144145. get right(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the output component
  144148. */
  144149. get output(): NodeMaterialConnectionPoint;
  144150. protected _buildBlock(state: NodeMaterialBuildState): this;
  144151. }
  144152. }
  144153. declare module BABYLON {
  144154. /**
  144155. * Block used to step a value
  144156. */
  144157. export class StepBlock extends NodeMaterialBlock {
  144158. /**
  144159. * Creates a new StepBlock
  144160. * @param name defines the block name
  144161. */
  144162. constructor(name: string);
  144163. /**
  144164. * Gets the current class name
  144165. * @returns the class name
  144166. */
  144167. getClassName(): string;
  144168. /**
  144169. * Gets the value operand input component
  144170. */
  144171. get value(): NodeMaterialConnectionPoint;
  144172. /**
  144173. * Gets the edge operand input component
  144174. */
  144175. get edge(): NodeMaterialConnectionPoint;
  144176. /**
  144177. * Gets the output component
  144178. */
  144179. get output(): NodeMaterialConnectionPoint;
  144180. protected _buildBlock(state: NodeMaterialBuildState): this;
  144181. }
  144182. }
  144183. declare module BABYLON {
  144184. /**
  144185. * Block used to get the opposite (1 - x) of a value
  144186. */
  144187. export class OneMinusBlock extends NodeMaterialBlock {
  144188. /**
  144189. * Creates a new OneMinusBlock
  144190. * @param name defines the block name
  144191. */
  144192. constructor(name: string);
  144193. /**
  144194. * Gets the current class name
  144195. * @returns the class name
  144196. */
  144197. getClassName(): string;
  144198. /**
  144199. * Gets the input component
  144200. */
  144201. get input(): NodeMaterialConnectionPoint;
  144202. /**
  144203. * Gets the output component
  144204. */
  144205. get output(): NodeMaterialConnectionPoint;
  144206. protected _buildBlock(state: NodeMaterialBuildState): this;
  144207. }
  144208. }
  144209. declare module BABYLON {
  144210. /**
  144211. * Block used to get the view direction
  144212. */
  144213. export class ViewDirectionBlock extends NodeMaterialBlock {
  144214. /**
  144215. * Creates a new ViewDirectionBlock
  144216. * @param name defines the block name
  144217. */
  144218. constructor(name: string);
  144219. /**
  144220. * Gets the current class name
  144221. * @returns the class name
  144222. */
  144223. getClassName(): string;
  144224. /**
  144225. * Gets the world position component
  144226. */
  144227. get worldPosition(): NodeMaterialConnectionPoint;
  144228. /**
  144229. * Gets the camera position component
  144230. */
  144231. get cameraPosition(): NodeMaterialConnectionPoint;
  144232. /**
  144233. * Gets the output component
  144234. */
  144235. get output(): NodeMaterialConnectionPoint;
  144236. autoConfigure(material: NodeMaterial): void;
  144237. protected _buildBlock(state: NodeMaterialBuildState): this;
  144238. }
  144239. }
  144240. declare module BABYLON {
  144241. /**
  144242. * Block used to compute fresnel value
  144243. */
  144244. export class FresnelBlock extends NodeMaterialBlock {
  144245. /**
  144246. * Create a new FresnelBlock
  144247. * @param name defines the block name
  144248. */
  144249. constructor(name: string);
  144250. /**
  144251. * Gets the current class name
  144252. * @returns the class name
  144253. */
  144254. getClassName(): string;
  144255. /**
  144256. * Gets the world normal input component
  144257. */
  144258. get worldNormal(): NodeMaterialConnectionPoint;
  144259. /**
  144260. * Gets the view direction input component
  144261. */
  144262. get viewDirection(): NodeMaterialConnectionPoint;
  144263. /**
  144264. * Gets the bias input component
  144265. */
  144266. get bias(): NodeMaterialConnectionPoint;
  144267. /**
  144268. * Gets the camera (or eye) position component
  144269. */
  144270. get power(): NodeMaterialConnectionPoint;
  144271. /**
  144272. * Gets the fresnel output component
  144273. */
  144274. get fresnel(): NodeMaterialConnectionPoint;
  144275. autoConfigure(material: NodeMaterial): void;
  144276. protected _buildBlock(state: NodeMaterialBuildState): this;
  144277. }
  144278. }
  144279. declare module BABYLON {
  144280. /**
  144281. * Block used to get the max of 2 values
  144282. */
  144283. export class MaxBlock extends NodeMaterialBlock {
  144284. /**
  144285. * Creates a new MaxBlock
  144286. * @param name defines the block name
  144287. */
  144288. constructor(name: string);
  144289. /**
  144290. * Gets the current class name
  144291. * @returns the class name
  144292. */
  144293. getClassName(): string;
  144294. /**
  144295. * Gets the left operand input component
  144296. */
  144297. get left(): NodeMaterialConnectionPoint;
  144298. /**
  144299. * Gets the right operand input component
  144300. */
  144301. get right(): NodeMaterialConnectionPoint;
  144302. /**
  144303. * Gets the output component
  144304. */
  144305. get output(): NodeMaterialConnectionPoint;
  144306. protected _buildBlock(state: NodeMaterialBuildState): this;
  144307. }
  144308. }
  144309. declare module BABYLON {
  144310. /**
  144311. * Block used to get the min of 2 values
  144312. */
  144313. export class MinBlock extends NodeMaterialBlock {
  144314. /**
  144315. * Creates a new MinBlock
  144316. * @param name defines the block name
  144317. */
  144318. constructor(name: string);
  144319. /**
  144320. * Gets the current class name
  144321. * @returns the class name
  144322. */
  144323. getClassName(): string;
  144324. /**
  144325. * Gets the left operand input component
  144326. */
  144327. get left(): NodeMaterialConnectionPoint;
  144328. /**
  144329. * Gets the right operand input component
  144330. */
  144331. get right(): NodeMaterialConnectionPoint;
  144332. /**
  144333. * Gets the output component
  144334. */
  144335. get output(): NodeMaterialConnectionPoint;
  144336. protected _buildBlock(state: NodeMaterialBuildState): this;
  144337. }
  144338. }
  144339. declare module BABYLON {
  144340. /**
  144341. * Block used to get the distance between 2 values
  144342. */
  144343. export class DistanceBlock extends NodeMaterialBlock {
  144344. /**
  144345. * Creates a new DistanceBlock
  144346. * @param name defines the block name
  144347. */
  144348. constructor(name: string);
  144349. /**
  144350. * Gets the current class name
  144351. * @returns the class name
  144352. */
  144353. getClassName(): string;
  144354. /**
  144355. * Gets the left operand input component
  144356. */
  144357. get left(): NodeMaterialConnectionPoint;
  144358. /**
  144359. * Gets the right operand input component
  144360. */
  144361. get right(): NodeMaterialConnectionPoint;
  144362. /**
  144363. * Gets the output component
  144364. */
  144365. get output(): NodeMaterialConnectionPoint;
  144366. protected _buildBlock(state: NodeMaterialBuildState): this;
  144367. }
  144368. }
  144369. declare module BABYLON {
  144370. /**
  144371. * Block used to get the length of a vector
  144372. */
  144373. export class LengthBlock extends NodeMaterialBlock {
  144374. /**
  144375. * Creates a new LengthBlock
  144376. * @param name defines the block name
  144377. */
  144378. constructor(name: string);
  144379. /**
  144380. * Gets the current class name
  144381. * @returns the class name
  144382. */
  144383. getClassName(): string;
  144384. /**
  144385. * Gets the value input component
  144386. */
  144387. get value(): NodeMaterialConnectionPoint;
  144388. /**
  144389. * Gets the output component
  144390. */
  144391. get output(): NodeMaterialConnectionPoint;
  144392. protected _buildBlock(state: NodeMaterialBuildState): this;
  144393. }
  144394. }
  144395. declare module BABYLON {
  144396. /**
  144397. * Block used to get negative version of a value (i.e. x * -1)
  144398. */
  144399. export class NegateBlock extends NodeMaterialBlock {
  144400. /**
  144401. * Creates a new NegateBlock
  144402. * @param name defines the block name
  144403. */
  144404. constructor(name: string);
  144405. /**
  144406. * Gets the current class name
  144407. * @returns the class name
  144408. */
  144409. getClassName(): string;
  144410. /**
  144411. * Gets the value input component
  144412. */
  144413. get value(): NodeMaterialConnectionPoint;
  144414. /**
  144415. * Gets the output component
  144416. */
  144417. get output(): NodeMaterialConnectionPoint;
  144418. protected _buildBlock(state: NodeMaterialBuildState): this;
  144419. }
  144420. }
  144421. declare module BABYLON {
  144422. /**
  144423. * Block used to get the value of the first parameter raised to the power of the second
  144424. */
  144425. export class PowBlock extends NodeMaterialBlock {
  144426. /**
  144427. * Creates a new PowBlock
  144428. * @param name defines the block name
  144429. */
  144430. constructor(name: string);
  144431. /**
  144432. * Gets the current class name
  144433. * @returns the class name
  144434. */
  144435. getClassName(): string;
  144436. /**
  144437. * Gets the value operand input component
  144438. */
  144439. get value(): NodeMaterialConnectionPoint;
  144440. /**
  144441. * Gets the power operand input component
  144442. */
  144443. get power(): NodeMaterialConnectionPoint;
  144444. /**
  144445. * Gets the output component
  144446. */
  144447. get output(): NodeMaterialConnectionPoint;
  144448. protected _buildBlock(state: NodeMaterialBuildState): this;
  144449. }
  144450. }
  144451. declare module BABYLON {
  144452. /**
  144453. * Block used to get a random number
  144454. */
  144455. export class RandomNumberBlock extends NodeMaterialBlock {
  144456. /**
  144457. * Creates a new RandomNumberBlock
  144458. * @param name defines the block name
  144459. */
  144460. constructor(name: string);
  144461. /**
  144462. * Gets the current class name
  144463. * @returns the class name
  144464. */
  144465. getClassName(): string;
  144466. /**
  144467. * Gets the seed input component
  144468. */
  144469. get seed(): NodeMaterialConnectionPoint;
  144470. /**
  144471. * Gets the output component
  144472. */
  144473. get output(): NodeMaterialConnectionPoint;
  144474. protected _buildBlock(state: NodeMaterialBuildState): this;
  144475. }
  144476. }
  144477. declare module BABYLON {
  144478. /**
  144479. * Block used to compute arc tangent of 2 values
  144480. */
  144481. export class ArcTan2Block extends NodeMaterialBlock {
  144482. /**
  144483. * Creates a new ArcTan2Block
  144484. * @param name defines the block name
  144485. */
  144486. constructor(name: string);
  144487. /**
  144488. * Gets the current class name
  144489. * @returns the class name
  144490. */
  144491. getClassName(): string;
  144492. /**
  144493. * Gets the x operand input component
  144494. */
  144495. get x(): NodeMaterialConnectionPoint;
  144496. /**
  144497. * Gets the y operand input component
  144498. */
  144499. get y(): NodeMaterialConnectionPoint;
  144500. /**
  144501. * Gets the output component
  144502. */
  144503. get output(): NodeMaterialConnectionPoint;
  144504. protected _buildBlock(state: NodeMaterialBuildState): this;
  144505. }
  144506. }
  144507. declare module BABYLON {
  144508. /**
  144509. * Block used to smooth step a value
  144510. */
  144511. export class SmoothStepBlock extends NodeMaterialBlock {
  144512. /**
  144513. * Creates a new SmoothStepBlock
  144514. * @param name defines the block name
  144515. */
  144516. constructor(name: string);
  144517. /**
  144518. * Gets the current class name
  144519. * @returns the class name
  144520. */
  144521. getClassName(): string;
  144522. /**
  144523. * Gets the value operand input component
  144524. */
  144525. get value(): NodeMaterialConnectionPoint;
  144526. /**
  144527. * Gets the first edge operand input component
  144528. */
  144529. get edge0(): NodeMaterialConnectionPoint;
  144530. /**
  144531. * Gets the second edge operand input component
  144532. */
  144533. get edge1(): NodeMaterialConnectionPoint;
  144534. /**
  144535. * Gets the output component
  144536. */
  144537. get output(): NodeMaterialConnectionPoint;
  144538. protected _buildBlock(state: NodeMaterialBuildState): this;
  144539. }
  144540. }
  144541. declare module BABYLON {
  144542. /**
  144543. * Block used to get the reciprocal (1 / x) of a value
  144544. */
  144545. export class ReciprocalBlock extends NodeMaterialBlock {
  144546. /**
  144547. * Creates a new ReciprocalBlock
  144548. * @param name defines the block name
  144549. */
  144550. constructor(name: string);
  144551. /**
  144552. * Gets the current class name
  144553. * @returns the class name
  144554. */
  144555. getClassName(): string;
  144556. /**
  144557. * Gets the input component
  144558. */
  144559. get input(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the output component
  144562. */
  144563. get output(): NodeMaterialConnectionPoint;
  144564. protected _buildBlock(state: NodeMaterialBuildState): this;
  144565. }
  144566. }
  144567. declare module BABYLON {
  144568. /**
  144569. * Block used to replace a color by another one
  144570. */
  144571. export class ReplaceColorBlock extends NodeMaterialBlock {
  144572. /**
  144573. * Creates a new ReplaceColorBlock
  144574. * @param name defines the block name
  144575. */
  144576. constructor(name: string);
  144577. /**
  144578. * Gets the current class name
  144579. * @returns the class name
  144580. */
  144581. getClassName(): string;
  144582. /**
  144583. * Gets the value input component
  144584. */
  144585. get value(): NodeMaterialConnectionPoint;
  144586. /**
  144587. * Gets the reference input component
  144588. */
  144589. get reference(): NodeMaterialConnectionPoint;
  144590. /**
  144591. * Gets the distance input component
  144592. */
  144593. get distance(): NodeMaterialConnectionPoint;
  144594. /**
  144595. * Gets the replacement input component
  144596. */
  144597. get replacement(): NodeMaterialConnectionPoint;
  144598. /**
  144599. * Gets the output component
  144600. */
  144601. get output(): NodeMaterialConnectionPoint;
  144602. protected _buildBlock(state: NodeMaterialBuildState): this;
  144603. }
  144604. }
  144605. declare module BABYLON {
  144606. /**
  144607. * Block used to posterize a value
  144608. * @see https://en.wikipedia.org/wiki/Posterization
  144609. */
  144610. export class PosterizeBlock extends NodeMaterialBlock {
  144611. /**
  144612. * Creates a new PosterizeBlock
  144613. * @param name defines the block name
  144614. */
  144615. constructor(name: string);
  144616. /**
  144617. * Gets the current class name
  144618. * @returns the class name
  144619. */
  144620. getClassName(): string;
  144621. /**
  144622. * Gets the value input component
  144623. */
  144624. get value(): NodeMaterialConnectionPoint;
  144625. /**
  144626. * Gets the steps input component
  144627. */
  144628. get steps(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the output component
  144631. */
  144632. get output(): NodeMaterialConnectionPoint;
  144633. protected _buildBlock(state: NodeMaterialBuildState): this;
  144634. }
  144635. }
  144636. declare module BABYLON {
  144637. /**
  144638. * Operations supported by the Wave block
  144639. */
  144640. export enum WaveBlockKind {
  144641. /** SawTooth */
  144642. SawTooth = 0,
  144643. /** Square */
  144644. Square = 1,
  144645. /** Triangle */
  144646. Triangle = 2
  144647. }
  144648. /**
  144649. * Block used to apply wave operation to floats
  144650. */
  144651. export class WaveBlock extends NodeMaterialBlock {
  144652. /**
  144653. * Gets or sets the kibnd of wave to be applied by the block
  144654. */
  144655. kind: WaveBlockKind;
  144656. /**
  144657. * Creates a new WaveBlock
  144658. * @param name defines the block name
  144659. */
  144660. constructor(name: string);
  144661. /**
  144662. * Gets the current class name
  144663. * @returns the class name
  144664. */
  144665. getClassName(): string;
  144666. /**
  144667. * Gets the input component
  144668. */
  144669. get input(): NodeMaterialConnectionPoint;
  144670. /**
  144671. * Gets the output component
  144672. */
  144673. get output(): NodeMaterialConnectionPoint;
  144674. protected _buildBlock(state: NodeMaterialBuildState): this;
  144675. serialize(): any;
  144676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144677. }
  144678. }
  144679. declare module BABYLON {
  144680. /**
  144681. * Class used to store a color step for the GradientBlock
  144682. */
  144683. export class GradientBlockColorStep {
  144684. private _step;
  144685. /**
  144686. * Gets value indicating which step this color is associated with (between 0 and 1)
  144687. */
  144688. get step(): number;
  144689. /**
  144690. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144691. */
  144692. set step(val: number);
  144693. private _color;
  144694. /**
  144695. * Gets the color associated with this step
  144696. */
  144697. get color(): Color3;
  144698. /**
  144699. * Sets the color associated with this step
  144700. */
  144701. set color(val: Color3);
  144702. /**
  144703. * Creates a new GradientBlockColorStep
  144704. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144705. * @param color defines the color associated with this step
  144706. */
  144707. constructor(step: number, color: Color3);
  144708. }
  144709. /**
  144710. * Block used to return a color from a gradient based on an input value between 0 and 1
  144711. */
  144712. export class GradientBlock extends NodeMaterialBlock {
  144713. /**
  144714. * Gets or sets the list of color steps
  144715. */
  144716. colorSteps: GradientBlockColorStep[];
  144717. /** Gets an observable raised when the value is changed */
  144718. onValueChangedObservable: Observable<GradientBlock>;
  144719. /** calls observable when the value is changed*/
  144720. colorStepsUpdated(): void;
  144721. /**
  144722. * Creates a new GradientBlock
  144723. * @param name defines the block name
  144724. */
  144725. constructor(name: string);
  144726. /**
  144727. * Gets the current class name
  144728. * @returns the class name
  144729. */
  144730. getClassName(): string;
  144731. /**
  144732. * Gets the gradient input component
  144733. */
  144734. get gradient(): NodeMaterialConnectionPoint;
  144735. /**
  144736. * Gets the output component
  144737. */
  144738. get output(): NodeMaterialConnectionPoint;
  144739. private _writeColorConstant;
  144740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144741. serialize(): any;
  144742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144743. protected _dumpPropertiesCode(): string;
  144744. }
  144745. }
  144746. declare module BABYLON {
  144747. /**
  144748. * Block used to normalize lerp between 2 values
  144749. */
  144750. export class NLerpBlock extends NodeMaterialBlock {
  144751. /**
  144752. * Creates a new NLerpBlock
  144753. * @param name defines the block name
  144754. */
  144755. constructor(name: string);
  144756. /**
  144757. * Gets the current class name
  144758. * @returns the class name
  144759. */
  144760. getClassName(): string;
  144761. /**
  144762. * Gets the left operand input component
  144763. */
  144764. get left(): NodeMaterialConnectionPoint;
  144765. /**
  144766. * Gets the right operand input component
  144767. */
  144768. get right(): NodeMaterialConnectionPoint;
  144769. /**
  144770. * Gets the gradient operand input component
  144771. */
  144772. get gradient(): NodeMaterialConnectionPoint;
  144773. /**
  144774. * Gets the output component
  144775. */
  144776. get output(): NodeMaterialConnectionPoint;
  144777. protected _buildBlock(state: NodeMaterialBuildState): this;
  144778. }
  144779. }
  144780. declare module BABYLON {
  144781. /**
  144782. * block used to Generate a Worley Noise 3D Noise Pattern
  144783. */
  144784. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144785. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144786. manhattanDistance: boolean;
  144787. /**
  144788. * Creates a new WorleyNoise3DBlock
  144789. * @param name defines the block name
  144790. */
  144791. constructor(name: string);
  144792. /**
  144793. * Gets the current class name
  144794. * @returns the class name
  144795. */
  144796. getClassName(): string;
  144797. /**
  144798. * Gets the seed input component
  144799. */
  144800. get seed(): NodeMaterialConnectionPoint;
  144801. /**
  144802. * Gets the jitter input component
  144803. */
  144804. get jitter(): NodeMaterialConnectionPoint;
  144805. /**
  144806. * Gets the output component
  144807. */
  144808. get output(): NodeMaterialConnectionPoint;
  144809. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144810. /**
  144811. * Exposes the properties to the UI?
  144812. */
  144813. protected _dumpPropertiesCode(): string;
  144814. /**
  144815. * Exposes the properties to the Seralize?
  144816. */
  144817. serialize(): any;
  144818. /**
  144819. * Exposes the properties to the deseralize?
  144820. */
  144821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144822. }
  144823. }
  144824. declare module BABYLON {
  144825. /**
  144826. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144827. */
  144828. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144829. /**
  144830. * Creates a new SimplexPerlin3DBlock
  144831. * @param name defines the block name
  144832. */
  144833. constructor(name: string);
  144834. /**
  144835. * Gets the current class name
  144836. * @returns the class name
  144837. */
  144838. getClassName(): string;
  144839. /**
  144840. * Gets the seed operand input component
  144841. */
  144842. get seed(): NodeMaterialConnectionPoint;
  144843. /**
  144844. * Gets the output component
  144845. */
  144846. get output(): NodeMaterialConnectionPoint;
  144847. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144848. }
  144849. }
  144850. declare module BABYLON {
  144851. /**
  144852. * Block used to blend normals
  144853. */
  144854. export class NormalBlendBlock extends NodeMaterialBlock {
  144855. /**
  144856. * Creates a new NormalBlendBlock
  144857. * @param name defines the block name
  144858. */
  144859. constructor(name: string);
  144860. /**
  144861. * Gets the current class name
  144862. * @returns the class name
  144863. */
  144864. getClassName(): string;
  144865. /**
  144866. * Gets the first input component
  144867. */
  144868. get normalMap0(): NodeMaterialConnectionPoint;
  144869. /**
  144870. * Gets the second input component
  144871. */
  144872. get normalMap1(): NodeMaterialConnectionPoint;
  144873. /**
  144874. * Gets the output component
  144875. */
  144876. get output(): NodeMaterialConnectionPoint;
  144877. protected _buildBlock(state: NodeMaterialBuildState): this;
  144878. }
  144879. }
  144880. declare module BABYLON {
  144881. /**
  144882. * Block used to rotate a 2d vector by a given angle
  144883. */
  144884. export class Rotate2dBlock extends NodeMaterialBlock {
  144885. /**
  144886. * Creates a new Rotate2dBlock
  144887. * @param name defines the block name
  144888. */
  144889. constructor(name: string);
  144890. /**
  144891. * Gets the current class name
  144892. * @returns the class name
  144893. */
  144894. getClassName(): string;
  144895. /**
  144896. * Gets the input vector
  144897. */
  144898. get input(): NodeMaterialConnectionPoint;
  144899. /**
  144900. * Gets the input angle
  144901. */
  144902. get angle(): NodeMaterialConnectionPoint;
  144903. /**
  144904. * Gets the output component
  144905. */
  144906. get output(): NodeMaterialConnectionPoint;
  144907. autoConfigure(material: NodeMaterial): void;
  144908. protected _buildBlock(state: NodeMaterialBuildState): this;
  144909. }
  144910. }
  144911. declare module BABYLON {
  144912. /**
  144913. * Block used to get the reflected vector from a direction and a normal
  144914. */
  144915. export class ReflectBlock extends NodeMaterialBlock {
  144916. /**
  144917. * Creates a new ReflectBlock
  144918. * @param name defines the block name
  144919. */
  144920. constructor(name: string);
  144921. /**
  144922. * Gets the current class name
  144923. * @returns the class name
  144924. */
  144925. getClassName(): string;
  144926. /**
  144927. * Gets the incident component
  144928. */
  144929. get incident(): NodeMaterialConnectionPoint;
  144930. /**
  144931. * Gets the normal component
  144932. */
  144933. get normal(): NodeMaterialConnectionPoint;
  144934. /**
  144935. * Gets the output component
  144936. */
  144937. get output(): NodeMaterialConnectionPoint;
  144938. protected _buildBlock(state: NodeMaterialBuildState): this;
  144939. }
  144940. }
  144941. declare module BABYLON {
  144942. /**
  144943. * Block used to get the refracted vector from a direction and a normal
  144944. */
  144945. export class RefractBlock extends NodeMaterialBlock {
  144946. /**
  144947. * Creates a new RefractBlock
  144948. * @param name defines the block name
  144949. */
  144950. constructor(name: string);
  144951. /**
  144952. * Gets the current class name
  144953. * @returns the class name
  144954. */
  144955. getClassName(): string;
  144956. /**
  144957. * Gets the incident component
  144958. */
  144959. get incident(): NodeMaterialConnectionPoint;
  144960. /**
  144961. * Gets the normal component
  144962. */
  144963. get normal(): NodeMaterialConnectionPoint;
  144964. /**
  144965. * Gets the index of refraction component
  144966. */
  144967. get ior(): NodeMaterialConnectionPoint;
  144968. /**
  144969. * Gets the output component
  144970. */
  144971. get output(): NodeMaterialConnectionPoint;
  144972. protected _buildBlock(state: NodeMaterialBuildState): this;
  144973. }
  144974. }
  144975. declare module BABYLON {
  144976. /**
  144977. * Block used to desaturate a color
  144978. */
  144979. export class DesaturateBlock extends NodeMaterialBlock {
  144980. /**
  144981. * Creates a new DesaturateBlock
  144982. * @param name defines the block name
  144983. */
  144984. constructor(name: string);
  144985. /**
  144986. * Gets the current class name
  144987. * @returns the class name
  144988. */
  144989. getClassName(): string;
  144990. /**
  144991. * Gets the color operand input component
  144992. */
  144993. get color(): NodeMaterialConnectionPoint;
  144994. /**
  144995. * Gets the level operand input component
  144996. */
  144997. get level(): NodeMaterialConnectionPoint;
  144998. /**
  144999. * Gets the output component
  145000. */
  145001. get output(): NodeMaterialConnectionPoint;
  145002. protected _buildBlock(state: NodeMaterialBuildState): this;
  145003. }
  145004. }
  145005. declare module BABYLON {
  145006. /**
  145007. * Block used to implement the ambient occlusion module of the PBR material
  145008. */
  145009. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145010. /**
  145011. * Create a new AmbientOcclusionBlock
  145012. * @param name defines the block name
  145013. */
  145014. constructor(name: string);
  145015. /**
  145016. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145017. */
  145018. useAmbientInGrayScale: boolean;
  145019. /**
  145020. * Initialize the block and prepare the context for build
  145021. * @param state defines the state that will be used for the build
  145022. */
  145023. initialize(state: NodeMaterialBuildState): void;
  145024. /**
  145025. * Gets the current class name
  145026. * @returns the class name
  145027. */
  145028. getClassName(): string;
  145029. /**
  145030. * Gets the texture input component
  145031. */
  145032. get texture(): NodeMaterialConnectionPoint;
  145033. /**
  145034. * Gets the texture intensity component
  145035. */
  145036. get intensity(): NodeMaterialConnectionPoint;
  145037. /**
  145038. * Gets the direct light intensity input component
  145039. */
  145040. get directLightIntensity(): NodeMaterialConnectionPoint;
  145041. /**
  145042. * Gets the ambient occlusion object output component
  145043. */
  145044. get ambientOcc(): NodeMaterialConnectionPoint;
  145045. /**
  145046. * Gets the main code of the block (fragment side)
  145047. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145048. * @returns the shader code
  145049. */
  145050. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145052. protected _buildBlock(state: NodeMaterialBuildState): this;
  145053. protected _dumpPropertiesCode(): string;
  145054. serialize(): any;
  145055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145056. }
  145057. }
  145058. declare module BABYLON {
  145059. /**
  145060. * Block used to implement the reflection module of the PBR material
  145061. */
  145062. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145063. /** @hidden */
  145064. _defineLODReflectionAlpha: string;
  145065. /** @hidden */
  145066. _defineLinearSpecularReflection: string;
  145067. private _vEnvironmentIrradianceName;
  145068. /** @hidden */
  145069. _vReflectionMicrosurfaceInfosName: string;
  145070. /** @hidden */
  145071. _vReflectionInfosName: string;
  145072. /** @hidden */
  145073. _vReflectionFilteringInfoName: string;
  145074. private _scene;
  145075. /**
  145076. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145077. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145078. * It's less burden on the user side in the editor part.
  145079. */
  145080. /** @hidden */
  145081. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145082. /** @hidden */
  145083. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145084. /** @hidden */
  145085. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145086. /**
  145087. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145088. * diffuse part of the IBL.
  145089. */
  145090. useSphericalHarmonics: boolean;
  145091. /**
  145092. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145093. */
  145094. forceIrradianceInFragment: boolean;
  145095. /**
  145096. * Create a new ReflectionBlock
  145097. * @param name defines the block name
  145098. */
  145099. constructor(name: string);
  145100. /**
  145101. * Gets the current class name
  145102. * @returns the class name
  145103. */
  145104. getClassName(): string;
  145105. /**
  145106. * Gets the position input component
  145107. */
  145108. get position(): NodeMaterialConnectionPoint;
  145109. /**
  145110. * Gets the world position input component
  145111. */
  145112. get worldPosition(): NodeMaterialConnectionPoint;
  145113. /**
  145114. * Gets the world normal input component
  145115. */
  145116. get worldNormal(): NodeMaterialConnectionPoint;
  145117. /**
  145118. * Gets the world input component
  145119. */
  145120. get world(): NodeMaterialConnectionPoint;
  145121. /**
  145122. * Gets the camera (or eye) position component
  145123. */
  145124. get cameraPosition(): NodeMaterialConnectionPoint;
  145125. /**
  145126. * Gets the view input component
  145127. */
  145128. get view(): NodeMaterialConnectionPoint;
  145129. /**
  145130. * Gets the color input component
  145131. */
  145132. get color(): NodeMaterialConnectionPoint;
  145133. /**
  145134. * Gets the reflection object output component
  145135. */
  145136. get reflection(): NodeMaterialConnectionPoint;
  145137. /**
  145138. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145139. */
  145140. get hasTexture(): boolean;
  145141. /**
  145142. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145143. */
  145144. get reflectionColor(): string;
  145145. protected _getTexture(): Nullable<BaseTexture>;
  145146. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145148. /**
  145149. * Gets the code to inject in the vertex shader
  145150. * @param state current state of the node material building
  145151. * @returns the shader code
  145152. */
  145153. handleVertexSide(state: NodeMaterialBuildState): string;
  145154. /**
  145155. * Gets the main code of the block (fragment side)
  145156. * @param state current state of the node material building
  145157. * @param normalVarName name of the existing variable corresponding to the normal
  145158. * @returns the shader code
  145159. */
  145160. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145161. protected _buildBlock(state: NodeMaterialBuildState): this;
  145162. protected _dumpPropertiesCode(): string;
  145163. serialize(): any;
  145164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145165. }
  145166. }
  145167. declare module BABYLON {
  145168. /**
  145169. * Block used to implement the sheen module of the PBR material
  145170. */
  145171. export class SheenBlock extends NodeMaterialBlock {
  145172. /**
  145173. * Create a new SheenBlock
  145174. * @param name defines the block name
  145175. */
  145176. constructor(name: string);
  145177. /**
  145178. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145179. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145180. * making it easier to setup and tweak the effect
  145181. */
  145182. albedoScaling: boolean;
  145183. /**
  145184. * Defines if the sheen is linked to the sheen color.
  145185. */
  145186. linkSheenWithAlbedo: boolean;
  145187. /**
  145188. * Initialize the block and prepare the context for build
  145189. * @param state defines the state that will be used for the build
  145190. */
  145191. initialize(state: NodeMaterialBuildState): void;
  145192. /**
  145193. * Gets the current class name
  145194. * @returns the class name
  145195. */
  145196. getClassName(): string;
  145197. /**
  145198. * Gets the intensity input component
  145199. */
  145200. get intensity(): NodeMaterialConnectionPoint;
  145201. /**
  145202. * Gets the color input component
  145203. */
  145204. get color(): NodeMaterialConnectionPoint;
  145205. /**
  145206. * Gets the roughness input component
  145207. */
  145208. get roughness(): NodeMaterialConnectionPoint;
  145209. /**
  145210. * Gets the sheen object output component
  145211. */
  145212. get sheen(): NodeMaterialConnectionPoint;
  145213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145214. /**
  145215. * Gets the main code of the block (fragment side)
  145216. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145217. * @returns the shader code
  145218. */
  145219. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145220. protected _buildBlock(state: NodeMaterialBuildState): this;
  145221. protected _dumpPropertiesCode(): string;
  145222. serialize(): any;
  145223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145224. }
  145225. }
  145226. declare module BABYLON {
  145227. /**
  145228. * Block used to implement the reflectivity module of the PBR material
  145229. */
  145230. export class ReflectivityBlock extends NodeMaterialBlock {
  145231. private _metallicReflectanceColor;
  145232. private _metallicF0Factor;
  145233. /** @hidden */
  145234. _vMetallicReflectanceFactorsName: string;
  145235. /**
  145236. * The property below is set by the main PBR block prior to calling methods of this class.
  145237. */
  145238. /** @hidden */
  145239. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145240. /**
  145241. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145242. */
  145243. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145244. /**
  145245. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145246. */
  145247. useMetallnessFromMetallicTextureBlue: boolean;
  145248. /**
  145249. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145250. */
  145251. useRoughnessFromMetallicTextureAlpha: boolean;
  145252. /**
  145253. * Specifies if the metallic texture contains the roughness information in its green channel.
  145254. */
  145255. useRoughnessFromMetallicTextureGreen: boolean;
  145256. /**
  145257. * Create a new ReflectivityBlock
  145258. * @param name defines the block name
  145259. */
  145260. constructor(name: string);
  145261. /**
  145262. * Initialize the block and prepare the context for build
  145263. * @param state defines the state that will be used for the build
  145264. */
  145265. initialize(state: NodeMaterialBuildState): void;
  145266. /**
  145267. * Gets the current class name
  145268. * @returns the class name
  145269. */
  145270. getClassName(): string;
  145271. /**
  145272. * Gets the metallic input component
  145273. */
  145274. get metallic(): NodeMaterialConnectionPoint;
  145275. /**
  145276. * Gets the roughness input component
  145277. */
  145278. get roughness(): NodeMaterialConnectionPoint;
  145279. /**
  145280. * Gets the texture input component
  145281. */
  145282. get texture(): NodeMaterialConnectionPoint;
  145283. /**
  145284. * Gets the reflectivity object output component
  145285. */
  145286. get reflectivity(): NodeMaterialConnectionPoint;
  145287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145288. /**
  145289. * Gets the main code of the block (fragment side)
  145290. * @param state current state of the node material building
  145291. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145292. * @returns the shader code
  145293. */
  145294. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145296. protected _buildBlock(state: NodeMaterialBuildState): this;
  145297. protected _dumpPropertiesCode(): string;
  145298. serialize(): any;
  145299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145300. }
  145301. }
  145302. declare module BABYLON {
  145303. /**
  145304. * Block used to implement the anisotropy module of the PBR material
  145305. */
  145306. export class AnisotropyBlock extends NodeMaterialBlock {
  145307. /**
  145308. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145309. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145310. * It's less burden on the user side in the editor part.
  145311. */
  145312. /** @hidden */
  145313. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145314. /** @hidden */
  145315. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145316. /**
  145317. * Create a new AnisotropyBlock
  145318. * @param name defines the block name
  145319. */
  145320. constructor(name: string);
  145321. /**
  145322. * Initialize the block and prepare the context for build
  145323. * @param state defines the state that will be used for the build
  145324. */
  145325. initialize(state: NodeMaterialBuildState): void;
  145326. /**
  145327. * Gets the current class name
  145328. * @returns the class name
  145329. */
  145330. getClassName(): string;
  145331. /**
  145332. * Gets the intensity input component
  145333. */
  145334. get intensity(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the direction input component
  145337. */
  145338. get direction(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the texture input component
  145341. */
  145342. get texture(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the uv input component
  145345. */
  145346. get uv(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the worldTangent input component
  145349. */
  145350. get worldTangent(): NodeMaterialConnectionPoint;
  145351. /**
  145352. * Gets the anisotropy object output component
  145353. */
  145354. get anisotropy(): NodeMaterialConnectionPoint;
  145355. private _generateTBNSpace;
  145356. /**
  145357. * Gets the main code of the block (fragment side)
  145358. * @param state current state of the node material building
  145359. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145360. * @returns the shader code
  145361. */
  145362. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145364. protected _buildBlock(state: NodeMaterialBuildState): this;
  145365. }
  145366. }
  145367. declare module BABYLON {
  145368. /**
  145369. * Block used to implement the clear coat module of the PBR material
  145370. */
  145371. export class ClearCoatBlock extends NodeMaterialBlock {
  145372. private _scene;
  145373. /**
  145374. * Create a new ClearCoatBlock
  145375. * @param name defines the block name
  145376. */
  145377. constructor(name: string);
  145378. /**
  145379. * Initialize the block and prepare the context for build
  145380. * @param state defines the state that will be used for the build
  145381. */
  145382. initialize(state: NodeMaterialBuildState): void;
  145383. /**
  145384. * Gets the current class name
  145385. * @returns the class name
  145386. */
  145387. getClassName(): string;
  145388. /**
  145389. * Gets the intensity input component
  145390. */
  145391. get intensity(): NodeMaterialConnectionPoint;
  145392. /**
  145393. * Gets the roughness input component
  145394. */
  145395. get roughness(): NodeMaterialConnectionPoint;
  145396. /**
  145397. * Gets the ior input component
  145398. */
  145399. get ior(): NodeMaterialConnectionPoint;
  145400. /**
  145401. * Gets the texture input component
  145402. */
  145403. get texture(): NodeMaterialConnectionPoint;
  145404. /**
  145405. * Gets the bump texture input component
  145406. */
  145407. get bumpTexture(): NodeMaterialConnectionPoint;
  145408. /**
  145409. * Gets the uv input component
  145410. */
  145411. get uv(): NodeMaterialConnectionPoint;
  145412. /**
  145413. * Gets the tint color input component
  145414. */
  145415. get tintColor(): NodeMaterialConnectionPoint;
  145416. /**
  145417. * Gets the tint "at distance" input component
  145418. */
  145419. get tintAtDistance(): NodeMaterialConnectionPoint;
  145420. /**
  145421. * Gets the tint thickness input component
  145422. */
  145423. get tintThickness(): NodeMaterialConnectionPoint;
  145424. /**
  145425. * Gets the world tangent input component
  145426. */
  145427. get worldTangent(): NodeMaterialConnectionPoint;
  145428. /**
  145429. * Gets the clear coat object output component
  145430. */
  145431. get clearcoat(): NodeMaterialConnectionPoint;
  145432. autoConfigure(material: NodeMaterial): void;
  145433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145435. private _generateTBNSpace;
  145436. /**
  145437. * Gets the main code of the block (fragment side)
  145438. * @param state current state of the node material building
  145439. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145440. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145441. * @param worldPosVarName name of the variable holding the world position
  145442. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145443. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145444. * @param worldNormalVarName name of the variable holding the world normal
  145445. * @returns the shader code
  145446. */
  145447. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145448. protected _buildBlock(state: NodeMaterialBuildState): this;
  145449. }
  145450. }
  145451. declare module BABYLON {
  145452. /**
  145453. * Block used to implement the sub surface module of the PBR material
  145454. */
  145455. export class SubSurfaceBlock extends NodeMaterialBlock {
  145456. /**
  145457. * Create a new SubSurfaceBlock
  145458. * @param name defines the block name
  145459. */
  145460. constructor(name: string);
  145461. /**
  145462. * Stores the intensity of the different subsurface effects in the thickness texture.
  145463. * * the green channel is the translucency intensity.
  145464. * * the blue channel is the scattering intensity.
  145465. * * the alpha channel is the refraction intensity.
  145466. */
  145467. useMaskFromThicknessTexture: boolean;
  145468. /**
  145469. * Initialize the block and prepare the context for build
  145470. * @param state defines the state that will be used for the build
  145471. */
  145472. initialize(state: NodeMaterialBuildState): void;
  145473. /**
  145474. * Gets the current class name
  145475. * @returns the class name
  145476. */
  145477. getClassName(): string;
  145478. /**
  145479. * Gets the min thickness input component
  145480. */
  145481. get minThickness(): NodeMaterialConnectionPoint;
  145482. /**
  145483. * Gets the max thickness input component
  145484. */
  145485. get maxThickness(): NodeMaterialConnectionPoint;
  145486. /**
  145487. * Gets the thickness texture component
  145488. */
  145489. get thicknessTexture(): NodeMaterialConnectionPoint;
  145490. /**
  145491. * Gets the tint color input component
  145492. */
  145493. get tintColor(): NodeMaterialConnectionPoint;
  145494. /**
  145495. * Gets the translucency intensity input component
  145496. */
  145497. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145498. /**
  145499. * Gets the translucency diffusion distance input component
  145500. */
  145501. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145502. /**
  145503. * Gets the refraction object parameters
  145504. */
  145505. get refraction(): NodeMaterialConnectionPoint;
  145506. /**
  145507. * Gets the sub surface object output component
  145508. */
  145509. get subsurface(): NodeMaterialConnectionPoint;
  145510. autoConfigure(material: NodeMaterial): void;
  145511. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145512. /**
  145513. * Gets the main code of the block (fragment side)
  145514. * @param state current state of the node material building
  145515. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145516. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145517. * @param worldPosVarName name of the variable holding the world position
  145518. * @returns the shader code
  145519. */
  145520. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145521. protected _buildBlock(state: NodeMaterialBuildState): this;
  145522. }
  145523. }
  145524. declare module BABYLON {
  145525. /**
  145526. * Block used to implement the PBR metallic/roughness model
  145527. */
  145528. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145529. /**
  145530. * Gets or sets the light associated with this block
  145531. */
  145532. light: Nullable<Light>;
  145533. private _lightId;
  145534. private _scene;
  145535. private _environmentBRDFTexture;
  145536. private _environmentBrdfSamplerName;
  145537. private _vNormalWName;
  145538. private _invertNormalName;
  145539. /**
  145540. * Create a new ReflectionBlock
  145541. * @param name defines the block name
  145542. */
  145543. constructor(name: string);
  145544. /**
  145545. * Intensity of the direct lights e.g. the four lights available in your scene.
  145546. * This impacts both the direct diffuse and specular highlights.
  145547. */
  145548. directIntensity: number;
  145549. /**
  145550. * Intensity of the environment e.g. how much the environment will light the object
  145551. * either through harmonics for rough material or through the refelction for shiny ones.
  145552. */
  145553. environmentIntensity: number;
  145554. /**
  145555. * This is a special control allowing the reduction of the specular highlights coming from the
  145556. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145557. */
  145558. specularIntensity: number;
  145559. /**
  145560. * Defines the falloff type used in this material.
  145561. * It by default is Physical.
  145562. */
  145563. lightFalloff: number;
  145564. /**
  145565. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145566. */
  145567. useAlphaFromAlbedoTexture: boolean;
  145568. /**
  145569. * Specifies that alpha test should be used
  145570. */
  145571. useAlphaTest: boolean;
  145572. /**
  145573. * Defines the alpha limits in alpha test mode.
  145574. */
  145575. alphaTestCutoff: number;
  145576. /**
  145577. * Specifies that alpha blending should be used
  145578. */
  145579. useAlphaBlending: boolean;
  145580. /**
  145581. * Defines if the alpha value should be determined via the rgb values.
  145582. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145583. */
  145584. opacityRGB: boolean;
  145585. /**
  145586. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145587. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145588. */
  145589. useRadianceOverAlpha: boolean;
  145590. /**
  145591. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145592. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145593. */
  145594. useSpecularOverAlpha: boolean;
  145595. /**
  145596. * Enables specular anti aliasing in the PBR shader.
  145597. * It will both interacts on the Geometry for analytical and IBL lighting.
  145598. * It also prefilter the roughness map based on the bump values.
  145599. */
  145600. enableSpecularAntiAliasing: boolean;
  145601. /**
  145602. * Enables realtime filtering on the texture.
  145603. */
  145604. realTimeFiltering: boolean;
  145605. /**
  145606. * Quality switch for realtime filtering
  145607. */
  145608. realTimeFilteringQuality: number;
  145609. /**
  145610. * Defines if the material uses energy conservation.
  145611. */
  145612. useEnergyConservation: boolean;
  145613. /**
  145614. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145615. * too much the area relying on ambient texture to define their ambient occlusion.
  145616. */
  145617. useRadianceOcclusion: boolean;
  145618. /**
  145619. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145620. * makes the reflect vector face the model (under horizon).
  145621. */
  145622. useHorizonOcclusion: boolean;
  145623. /**
  145624. * If set to true, no lighting calculations will be applied.
  145625. */
  145626. unlit: boolean;
  145627. /**
  145628. * Force normal to face away from face.
  145629. */
  145630. forceNormalForward: boolean;
  145631. /**
  145632. * Defines the material debug mode.
  145633. * It helps seeing only some components of the material while troubleshooting.
  145634. */
  145635. debugMode: number;
  145636. /**
  145637. * Specify from where on screen the debug mode should start.
  145638. * The value goes from -1 (full screen) to 1 (not visible)
  145639. * It helps with side by side comparison against the final render
  145640. * This defaults to 0
  145641. */
  145642. debugLimit: number;
  145643. /**
  145644. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145645. * You can use the factor to better multiply the final value.
  145646. */
  145647. debugFactor: number;
  145648. /**
  145649. * Initialize the block and prepare the context for build
  145650. * @param state defines the state that will be used for the build
  145651. */
  145652. initialize(state: NodeMaterialBuildState): void;
  145653. /**
  145654. * Gets the current class name
  145655. * @returns the class name
  145656. */
  145657. getClassName(): string;
  145658. /**
  145659. * Gets the world position input component
  145660. */
  145661. get worldPosition(): NodeMaterialConnectionPoint;
  145662. /**
  145663. * Gets the world normal input component
  145664. */
  145665. get worldNormal(): NodeMaterialConnectionPoint;
  145666. /**
  145667. * Gets the perturbed normal input component
  145668. */
  145669. get perturbedNormal(): NodeMaterialConnectionPoint;
  145670. /**
  145671. * Gets the camera position input component
  145672. */
  145673. get cameraPosition(): NodeMaterialConnectionPoint;
  145674. /**
  145675. * Gets the base color input component
  145676. */
  145677. get baseColor(): NodeMaterialConnectionPoint;
  145678. /**
  145679. * Gets the opacity texture input component
  145680. */
  145681. get opacityTexture(): NodeMaterialConnectionPoint;
  145682. /**
  145683. * Gets the ambient color input component
  145684. */
  145685. get ambientColor(): NodeMaterialConnectionPoint;
  145686. /**
  145687. * Gets the reflectivity object parameters
  145688. */
  145689. get reflectivity(): NodeMaterialConnectionPoint;
  145690. /**
  145691. * Gets the ambient occlusion object parameters
  145692. */
  145693. get ambientOcc(): NodeMaterialConnectionPoint;
  145694. /**
  145695. * Gets the reflection object parameters
  145696. */
  145697. get reflection(): NodeMaterialConnectionPoint;
  145698. /**
  145699. * Gets the sheen object parameters
  145700. */
  145701. get sheen(): NodeMaterialConnectionPoint;
  145702. /**
  145703. * Gets the clear coat object parameters
  145704. */
  145705. get clearcoat(): NodeMaterialConnectionPoint;
  145706. /**
  145707. * Gets the sub surface object parameters
  145708. */
  145709. get subsurface(): NodeMaterialConnectionPoint;
  145710. /**
  145711. * Gets the anisotropy object parameters
  145712. */
  145713. get anisotropy(): NodeMaterialConnectionPoint;
  145714. /**
  145715. * Gets the ambient output component
  145716. */
  145717. get ambient(): NodeMaterialConnectionPoint;
  145718. /**
  145719. * Gets the diffuse output component
  145720. */
  145721. get diffuse(): NodeMaterialConnectionPoint;
  145722. /**
  145723. * Gets the specular output component
  145724. */
  145725. get specular(): NodeMaterialConnectionPoint;
  145726. /**
  145727. * Gets the sheen output component
  145728. */
  145729. get sheenDir(): NodeMaterialConnectionPoint;
  145730. /**
  145731. * Gets the clear coat output component
  145732. */
  145733. get clearcoatDir(): NodeMaterialConnectionPoint;
  145734. /**
  145735. * Gets the indirect diffuse output component
  145736. */
  145737. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145738. /**
  145739. * Gets the indirect specular output component
  145740. */
  145741. get specularIndirect(): NodeMaterialConnectionPoint;
  145742. /**
  145743. * Gets the indirect sheen output component
  145744. */
  145745. get sheenIndirect(): NodeMaterialConnectionPoint;
  145746. /**
  145747. * Gets the indirect clear coat output component
  145748. */
  145749. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145750. /**
  145751. * Gets the refraction output component
  145752. */
  145753. get refraction(): NodeMaterialConnectionPoint;
  145754. /**
  145755. * Gets the global lighting output component
  145756. */
  145757. get lighting(): NodeMaterialConnectionPoint;
  145758. /**
  145759. * Gets the shadow output component
  145760. */
  145761. get shadow(): NodeMaterialConnectionPoint;
  145762. /**
  145763. * Gets the alpha output component
  145764. */
  145765. get alpha(): NodeMaterialConnectionPoint;
  145766. autoConfigure(material: NodeMaterial): void;
  145767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145768. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145770. private _injectVertexCode;
  145771. /**
  145772. * Gets the code corresponding to the albedo/opacity module
  145773. * @returns the shader code
  145774. */
  145775. getAlbedoOpacityCode(): string;
  145776. protected _buildBlock(state: NodeMaterialBuildState): this;
  145777. protected _dumpPropertiesCode(): string;
  145778. serialize(): any;
  145779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145780. }
  145781. }
  145782. declare module BABYLON {
  145783. /**
  145784. * Block used to compute value of one parameter modulo another
  145785. */
  145786. export class ModBlock extends NodeMaterialBlock {
  145787. /**
  145788. * Creates a new ModBlock
  145789. * @param name defines the block name
  145790. */
  145791. constructor(name: string);
  145792. /**
  145793. * Gets the current class name
  145794. * @returns the class name
  145795. */
  145796. getClassName(): string;
  145797. /**
  145798. * Gets the left operand input component
  145799. */
  145800. get left(): NodeMaterialConnectionPoint;
  145801. /**
  145802. * Gets the right operand input component
  145803. */
  145804. get right(): NodeMaterialConnectionPoint;
  145805. /**
  145806. * Gets the output component
  145807. */
  145808. get output(): NodeMaterialConnectionPoint;
  145809. protected _buildBlock(state: NodeMaterialBuildState): this;
  145810. }
  145811. }
  145812. declare module BABYLON {
  145813. /**
  145814. * Configuration for Draco compression
  145815. */
  145816. export interface IDracoCompressionConfiguration {
  145817. /**
  145818. * Configuration for the decoder.
  145819. */
  145820. decoder: {
  145821. /**
  145822. * The url to the WebAssembly module.
  145823. */
  145824. wasmUrl?: string;
  145825. /**
  145826. * The url to the WebAssembly binary.
  145827. */
  145828. wasmBinaryUrl?: string;
  145829. /**
  145830. * The url to the fallback JavaScript module.
  145831. */
  145832. fallbackUrl?: string;
  145833. };
  145834. }
  145835. /**
  145836. * Draco compression (https://google.github.io/draco/)
  145837. *
  145838. * This class wraps the Draco module.
  145839. *
  145840. * **Encoder**
  145841. *
  145842. * The encoder is not currently implemented.
  145843. *
  145844. * **Decoder**
  145845. *
  145846. * 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.
  145847. *
  145848. * To update the configuration, use the following code:
  145849. * ```javascript
  145850. * DracoCompression.Configuration = {
  145851. * decoder: {
  145852. * wasmUrl: "<url to the WebAssembly library>",
  145853. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145854. * fallbackUrl: "<url to the fallback JavaScript library>",
  145855. * }
  145856. * };
  145857. * ```
  145858. *
  145859. * 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.
  145860. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145861. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145862. *
  145863. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145864. * ```javascript
  145865. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145866. * ```
  145867. *
  145868. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145869. */
  145870. export class DracoCompression implements IDisposable {
  145871. private _workerPoolPromise?;
  145872. private _decoderModulePromise?;
  145873. /**
  145874. * The configuration. Defaults to the following urls:
  145875. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145876. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145877. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145878. */
  145879. static Configuration: IDracoCompressionConfiguration;
  145880. /**
  145881. * Returns true if the decoder configuration is available.
  145882. */
  145883. static get DecoderAvailable(): boolean;
  145884. /**
  145885. * Default number of workers to create when creating the draco compression object.
  145886. */
  145887. static DefaultNumWorkers: number;
  145888. private static GetDefaultNumWorkers;
  145889. private static _Default;
  145890. /**
  145891. * Default instance for the draco compression object.
  145892. */
  145893. static get Default(): DracoCompression;
  145894. /**
  145895. * Constructor
  145896. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145897. */
  145898. constructor(numWorkers?: number);
  145899. /**
  145900. * Stop all async operations and release resources.
  145901. */
  145902. dispose(): void;
  145903. /**
  145904. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145905. * @returns a promise that resolves when ready
  145906. */
  145907. whenReadyAsync(): Promise<void>;
  145908. /**
  145909. * Decode Draco compressed mesh data to vertex data.
  145910. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145911. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145912. * @returns A promise that resolves with the decoded vertex data
  145913. */
  145914. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145915. [kind: string]: number;
  145916. }): Promise<VertexData>;
  145917. }
  145918. }
  145919. declare module BABYLON {
  145920. /**
  145921. * Class for building Constructive Solid Geometry
  145922. */
  145923. export class CSG {
  145924. private polygons;
  145925. /**
  145926. * The world matrix
  145927. */
  145928. matrix: Matrix;
  145929. /**
  145930. * Stores the position
  145931. */
  145932. position: Vector3;
  145933. /**
  145934. * Stores the rotation
  145935. */
  145936. rotation: Vector3;
  145937. /**
  145938. * Stores the rotation quaternion
  145939. */
  145940. rotationQuaternion: Nullable<Quaternion>;
  145941. /**
  145942. * Stores the scaling vector
  145943. */
  145944. scaling: Vector3;
  145945. /**
  145946. * Convert the Mesh to CSG
  145947. * @param mesh The Mesh to convert to CSG
  145948. * @returns A new CSG from the Mesh
  145949. */
  145950. static FromMesh(mesh: Mesh): CSG;
  145951. /**
  145952. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145953. * @param polygons Polygons used to construct a CSG solid
  145954. */
  145955. private static FromPolygons;
  145956. /**
  145957. * Clones, or makes a deep copy, of the CSG
  145958. * @returns A new CSG
  145959. */
  145960. clone(): CSG;
  145961. /**
  145962. * Unions this CSG with another CSG
  145963. * @param csg The CSG to union against this CSG
  145964. * @returns The unioned CSG
  145965. */
  145966. union(csg: CSG): CSG;
  145967. /**
  145968. * Unions this CSG with another CSG in place
  145969. * @param csg The CSG to union against this CSG
  145970. */
  145971. unionInPlace(csg: CSG): void;
  145972. /**
  145973. * Subtracts this CSG with another CSG
  145974. * @param csg The CSG to subtract against this CSG
  145975. * @returns A new CSG
  145976. */
  145977. subtract(csg: CSG): CSG;
  145978. /**
  145979. * Subtracts this CSG with another CSG in place
  145980. * @param csg The CSG to subtact against this CSG
  145981. */
  145982. subtractInPlace(csg: CSG): void;
  145983. /**
  145984. * Intersect this CSG with another CSG
  145985. * @param csg The CSG to intersect against this CSG
  145986. * @returns A new CSG
  145987. */
  145988. intersect(csg: CSG): CSG;
  145989. /**
  145990. * Intersects this CSG with another CSG in place
  145991. * @param csg The CSG to intersect against this CSG
  145992. */
  145993. intersectInPlace(csg: CSG): void;
  145994. /**
  145995. * Return a new CSG solid with solid and empty space switched. This solid is
  145996. * not modified.
  145997. * @returns A new CSG solid with solid and empty space switched
  145998. */
  145999. inverse(): CSG;
  146000. /**
  146001. * Inverses the CSG in place
  146002. */
  146003. inverseInPlace(): void;
  146004. /**
  146005. * This is used to keep meshes transformations so they can be restored
  146006. * when we build back a Babylon Mesh
  146007. * NB : All CSG operations are performed in world coordinates
  146008. * @param csg The CSG to copy the transform attributes from
  146009. * @returns This CSG
  146010. */
  146011. copyTransformAttributes(csg: CSG): CSG;
  146012. /**
  146013. * Build Raw mesh from CSG
  146014. * Coordinates here are in world space
  146015. * @param name The name of the mesh geometry
  146016. * @param scene The Scene
  146017. * @param keepSubMeshes Specifies if the submeshes should be kept
  146018. * @returns A new Mesh
  146019. */
  146020. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146021. /**
  146022. * Build Mesh from CSG taking material and transforms into account
  146023. * @param name The name of the Mesh
  146024. * @param material The material of the Mesh
  146025. * @param scene The Scene
  146026. * @param keepSubMeshes Specifies if submeshes should be kept
  146027. * @returns The new Mesh
  146028. */
  146029. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146030. }
  146031. }
  146032. declare module BABYLON {
  146033. /**
  146034. * Class used to create a trail following a mesh
  146035. */
  146036. export class TrailMesh extends Mesh {
  146037. private _generator;
  146038. private _autoStart;
  146039. private _running;
  146040. private _diameter;
  146041. private _length;
  146042. private _sectionPolygonPointsCount;
  146043. private _sectionVectors;
  146044. private _sectionNormalVectors;
  146045. private _beforeRenderObserver;
  146046. /**
  146047. * @constructor
  146048. * @param name The value used by scene.getMeshByName() to do a lookup.
  146049. * @param generator The mesh or transform node to generate a trail.
  146050. * @param scene The scene to add this mesh to.
  146051. * @param diameter Diameter of trailing mesh. Default is 1.
  146052. * @param length Length of trailing mesh. Default is 60.
  146053. * @param autoStart Automatically start trailing mesh. Default true.
  146054. */
  146055. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146056. /**
  146057. * "TrailMesh"
  146058. * @returns "TrailMesh"
  146059. */
  146060. getClassName(): string;
  146061. private _createMesh;
  146062. /**
  146063. * Start trailing mesh.
  146064. */
  146065. start(): void;
  146066. /**
  146067. * Stop trailing mesh.
  146068. */
  146069. stop(): void;
  146070. /**
  146071. * Update trailing mesh geometry.
  146072. */
  146073. update(): void;
  146074. /**
  146075. * Returns a new TrailMesh object.
  146076. * @param name is a string, the name given to the new mesh
  146077. * @param newGenerator use new generator object for cloned trail mesh
  146078. * @returns a new mesh
  146079. */
  146080. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146081. /**
  146082. * Serializes this trail mesh
  146083. * @param serializationObject object to write serialization to
  146084. */
  146085. serialize(serializationObject: any): void;
  146086. /**
  146087. * Parses a serialized trail mesh
  146088. * @param parsedMesh the serialized mesh
  146089. * @param scene the scene to create the trail mesh in
  146090. * @returns the created trail mesh
  146091. */
  146092. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146093. }
  146094. }
  146095. declare module BABYLON {
  146096. /**
  146097. * Class containing static functions to help procedurally build meshes
  146098. */
  146099. export class TiledBoxBuilder {
  146100. /**
  146101. * Creates a box mesh
  146102. * 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)
  146103. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146107. * @param name defines the name of the mesh
  146108. * @param options defines the options used to create the mesh
  146109. * @param scene defines the hosting scene
  146110. * @returns the box mesh
  146111. */
  146112. static CreateTiledBox(name: string, options: {
  146113. pattern?: number;
  146114. width?: number;
  146115. height?: number;
  146116. depth?: number;
  146117. tileSize?: number;
  146118. tileWidth?: number;
  146119. tileHeight?: number;
  146120. alignHorizontal?: number;
  146121. alignVertical?: number;
  146122. faceUV?: Vector4[];
  146123. faceColors?: Color4[];
  146124. sideOrientation?: number;
  146125. updatable?: boolean;
  146126. }, scene?: Nullable<Scene>): Mesh;
  146127. }
  146128. }
  146129. declare module BABYLON {
  146130. /**
  146131. * Class containing static functions to help procedurally build meshes
  146132. */
  146133. export class TorusKnotBuilder {
  146134. /**
  146135. * Creates a torus knot mesh
  146136. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146137. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146138. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146139. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146143. * @param name defines the name of the mesh
  146144. * @param options defines the options used to create the mesh
  146145. * @param scene defines the hosting scene
  146146. * @returns the torus knot mesh
  146147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146148. */
  146149. static CreateTorusKnot(name: string, options: {
  146150. radius?: number;
  146151. tube?: number;
  146152. radialSegments?: number;
  146153. tubularSegments?: number;
  146154. p?: number;
  146155. q?: number;
  146156. updatable?: boolean;
  146157. sideOrientation?: number;
  146158. frontUVs?: Vector4;
  146159. backUVs?: Vector4;
  146160. }, scene: any): Mesh;
  146161. }
  146162. }
  146163. declare module BABYLON {
  146164. /**
  146165. * Polygon
  146166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146167. */
  146168. export class Polygon {
  146169. /**
  146170. * Creates a rectangle
  146171. * @param xmin bottom X coord
  146172. * @param ymin bottom Y coord
  146173. * @param xmax top X coord
  146174. * @param ymax top Y coord
  146175. * @returns points that make the resulting rectation
  146176. */
  146177. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146178. /**
  146179. * Creates a circle
  146180. * @param radius radius of circle
  146181. * @param cx scale in x
  146182. * @param cy scale in y
  146183. * @param numberOfSides number of sides that make up the circle
  146184. * @returns points that make the resulting circle
  146185. */
  146186. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146187. /**
  146188. * Creates a polygon from input string
  146189. * @param input Input polygon data
  146190. * @returns the parsed points
  146191. */
  146192. static Parse(input: string): Vector2[];
  146193. /**
  146194. * Starts building a polygon from x and y coordinates
  146195. * @param x x coordinate
  146196. * @param y y coordinate
  146197. * @returns the started path2
  146198. */
  146199. static StartingAt(x: number, y: number): Path2;
  146200. }
  146201. /**
  146202. * Builds a polygon
  146203. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146204. */
  146205. export class PolygonMeshBuilder {
  146206. private _points;
  146207. private _outlinepoints;
  146208. private _holes;
  146209. private _name;
  146210. private _scene;
  146211. private _epoints;
  146212. private _eholes;
  146213. private _addToepoint;
  146214. /**
  146215. * Babylon reference to the earcut plugin.
  146216. */
  146217. bjsEarcut: any;
  146218. /**
  146219. * Creates a PolygonMeshBuilder
  146220. * @param name name of the builder
  146221. * @param contours Path of the polygon
  146222. * @param scene scene to add to when creating the mesh
  146223. * @param earcutInjection can be used to inject your own earcut reference
  146224. */
  146225. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146226. /**
  146227. * Adds a whole within the polygon
  146228. * @param hole Array of points defining the hole
  146229. * @returns this
  146230. */
  146231. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146232. /**
  146233. * Creates the polygon
  146234. * @param updatable If the mesh should be updatable
  146235. * @param depth The depth of the mesh created
  146236. * @returns the created mesh
  146237. */
  146238. build(updatable?: boolean, depth?: number): Mesh;
  146239. /**
  146240. * Creates the polygon
  146241. * @param depth The depth of the mesh created
  146242. * @returns the created VertexData
  146243. */
  146244. buildVertexData(depth?: number): VertexData;
  146245. /**
  146246. * Adds a side to the polygon
  146247. * @param positions points that make the polygon
  146248. * @param normals normals of the polygon
  146249. * @param uvs uvs of the polygon
  146250. * @param indices indices of the polygon
  146251. * @param bounds bounds of the polygon
  146252. * @param points points of the polygon
  146253. * @param depth depth of the polygon
  146254. * @param flip flip of the polygon
  146255. */
  146256. private addSide;
  146257. }
  146258. }
  146259. declare module BABYLON {
  146260. /**
  146261. * Class containing static functions to help procedurally build meshes
  146262. */
  146263. export class PolygonBuilder {
  146264. /**
  146265. * Creates a polygon mesh
  146266. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146267. * * 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
  146268. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146271. * * Remember you can only change the shape positions, not their number when updating a polygon
  146272. * @param name defines the name of the mesh
  146273. * @param options defines the options used to create the mesh
  146274. * @param scene defines the hosting scene
  146275. * @param earcutInjection can be used to inject your own earcut reference
  146276. * @returns the polygon mesh
  146277. */
  146278. static CreatePolygon(name: string, options: {
  146279. shape: Vector3[];
  146280. holes?: Vector3[][];
  146281. depth?: number;
  146282. faceUV?: Vector4[];
  146283. faceColors?: Color4[];
  146284. updatable?: boolean;
  146285. sideOrientation?: number;
  146286. frontUVs?: Vector4;
  146287. backUVs?: Vector4;
  146288. wrap?: boolean;
  146289. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146290. /**
  146291. * Creates an extruded polygon mesh, with depth in the Y direction.
  146292. * * 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)
  146293. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146294. * @param name defines the name of the mesh
  146295. * @param options defines the options used to create the mesh
  146296. * @param scene defines the hosting scene
  146297. * @param earcutInjection can be used to inject your own earcut reference
  146298. * @returns the polygon mesh
  146299. */
  146300. static ExtrudePolygon(name: string, options: {
  146301. shape: Vector3[];
  146302. holes?: Vector3[][];
  146303. depth?: number;
  146304. faceUV?: Vector4[];
  146305. faceColors?: Color4[];
  146306. updatable?: boolean;
  146307. sideOrientation?: number;
  146308. frontUVs?: Vector4;
  146309. backUVs?: Vector4;
  146310. wrap?: boolean;
  146311. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146312. }
  146313. }
  146314. declare module BABYLON {
  146315. /**
  146316. * Class containing static functions to help procedurally build meshes
  146317. */
  146318. export class LatheBuilder {
  146319. /**
  146320. * Creates lathe mesh.
  146321. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146322. * * 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
  146323. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146324. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146325. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146326. * * 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
  146327. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146328. * * 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
  146329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146333. * @param name defines the name of the mesh
  146334. * @param options defines the options used to create the mesh
  146335. * @param scene defines the hosting scene
  146336. * @returns the lathe mesh
  146337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146338. */
  146339. static CreateLathe(name: string, options: {
  146340. shape: Vector3[];
  146341. radius?: number;
  146342. tessellation?: number;
  146343. clip?: number;
  146344. arc?: number;
  146345. closed?: boolean;
  146346. updatable?: boolean;
  146347. sideOrientation?: number;
  146348. frontUVs?: Vector4;
  146349. backUVs?: Vector4;
  146350. cap?: number;
  146351. invertUV?: boolean;
  146352. }, scene?: Nullable<Scene>): Mesh;
  146353. }
  146354. }
  146355. declare module BABYLON {
  146356. /**
  146357. * Class containing static functions to help procedurally build meshes
  146358. */
  146359. export class TiledPlaneBuilder {
  146360. /**
  146361. * Creates a tiled plane mesh
  146362. * * The parameter `pattern` will, depending on value, do nothing or
  146363. * * * flip (reflect about central vertical) alternate tiles across and up
  146364. * * * flip every tile on alternate rows
  146365. * * * rotate (180 degs) alternate tiles across and up
  146366. * * * rotate every tile on alternate rows
  146367. * * * flip and rotate alternate tiles across and up
  146368. * * * flip and rotate every tile on alternate rows
  146369. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146370. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146373. * * 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)
  146374. * * 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)
  146375. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146376. * @param name defines the name of the mesh
  146377. * @param options defines the options used to create the mesh
  146378. * @param scene defines the hosting scene
  146379. * @returns the box mesh
  146380. */
  146381. static CreateTiledPlane(name: string, options: {
  146382. pattern?: number;
  146383. tileSize?: number;
  146384. tileWidth?: number;
  146385. tileHeight?: number;
  146386. size?: number;
  146387. width?: number;
  146388. height?: number;
  146389. alignHorizontal?: number;
  146390. alignVertical?: number;
  146391. sideOrientation?: number;
  146392. frontUVs?: Vector4;
  146393. backUVs?: Vector4;
  146394. updatable?: boolean;
  146395. }, scene?: Nullable<Scene>): Mesh;
  146396. }
  146397. }
  146398. declare module BABYLON {
  146399. /**
  146400. * Class containing static functions to help procedurally build meshes
  146401. */
  146402. export class TubeBuilder {
  146403. /**
  146404. * Creates a tube mesh.
  146405. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146406. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146407. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146408. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146409. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146410. * * 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)
  146411. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146412. * * 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
  146413. * * 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
  146414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146418. * @param name defines the name of the mesh
  146419. * @param options defines the options used to create the mesh
  146420. * @param scene defines the hosting scene
  146421. * @returns the tube mesh
  146422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146423. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146424. */
  146425. static CreateTube(name: string, options: {
  146426. path: Vector3[];
  146427. radius?: number;
  146428. tessellation?: number;
  146429. radiusFunction?: {
  146430. (i: number, distance: number): number;
  146431. };
  146432. cap?: number;
  146433. arc?: number;
  146434. updatable?: boolean;
  146435. sideOrientation?: number;
  146436. frontUVs?: Vector4;
  146437. backUVs?: Vector4;
  146438. instance?: Mesh;
  146439. invertUV?: boolean;
  146440. }, scene?: Nullable<Scene>): Mesh;
  146441. }
  146442. }
  146443. declare module BABYLON {
  146444. /**
  146445. * Class containing static functions to help procedurally build meshes
  146446. */
  146447. export class IcoSphereBuilder {
  146448. /**
  146449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146451. * * 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`)
  146452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146453. * * 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
  146454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146457. * @param name defines the name of the mesh
  146458. * @param options defines the options used to create the mesh
  146459. * @param scene defines the hosting scene
  146460. * @returns the icosahedron mesh
  146461. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146462. */
  146463. static CreateIcoSphere(name: string, options: {
  146464. radius?: number;
  146465. radiusX?: number;
  146466. radiusY?: number;
  146467. radiusZ?: number;
  146468. flat?: boolean;
  146469. subdivisions?: number;
  146470. sideOrientation?: number;
  146471. frontUVs?: Vector4;
  146472. backUVs?: Vector4;
  146473. updatable?: boolean;
  146474. }, scene?: Nullable<Scene>): Mesh;
  146475. }
  146476. }
  146477. declare module BABYLON {
  146478. /**
  146479. * Class containing static functions to help procedurally build meshes
  146480. */
  146481. export class DecalBuilder {
  146482. /**
  146483. * Creates a decal mesh.
  146484. * 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
  146485. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146486. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146487. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146488. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146489. * @param name defines the name of the mesh
  146490. * @param sourceMesh defines the mesh where the decal must be applied
  146491. * @param options defines the options used to create the mesh
  146492. * @param scene defines the hosting scene
  146493. * @returns the decal mesh
  146494. * @see https://doc.babylonjs.com/how_to/decals
  146495. */
  146496. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146497. position?: Vector3;
  146498. normal?: Vector3;
  146499. size?: Vector3;
  146500. angle?: number;
  146501. }): Mesh;
  146502. }
  146503. }
  146504. declare module BABYLON {
  146505. /**
  146506. * Class containing static functions to help procedurally build meshes
  146507. */
  146508. export class MeshBuilder {
  146509. /**
  146510. * Creates a box mesh
  146511. * * The parameter `size` sets the size (float) of each box side (default 1)
  146512. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146513. * * 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)
  146514. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146518. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146519. * @param name defines the name of the mesh
  146520. * @param options defines the options used to create the mesh
  146521. * @param scene defines the hosting scene
  146522. * @returns the box mesh
  146523. */
  146524. static CreateBox(name: string, options: {
  146525. size?: number;
  146526. width?: number;
  146527. height?: number;
  146528. depth?: number;
  146529. faceUV?: Vector4[];
  146530. faceColors?: Color4[];
  146531. sideOrientation?: number;
  146532. frontUVs?: Vector4;
  146533. backUVs?: Vector4;
  146534. wrap?: boolean;
  146535. topBaseAt?: number;
  146536. bottomBaseAt?: number;
  146537. updatable?: boolean;
  146538. }, scene?: Nullable<Scene>): Mesh;
  146539. /**
  146540. * Creates a tiled box mesh
  146541. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146543. * @param name defines the name of the mesh
  146544. * @param options defines the options used to create the mesh
  146545. * @param scene defines the hosting scene
  146546. * @returns the tiled box mesh
  146547. */
  146548. static CreateTiledBox(name: string, options: {
  146549. pattern?: number;
  146550. size?: number;
  146551. width?: number;
  146552. height?: number;
  146553. depth: number;
  146554. tileSize?: number;
  146555. tileWidth?: number;
  146556. tileHeight?: number;
  146557. faceUV?: Vector4[];
  146558. faceColors?: Color4[];
  146559. alignHorizontal?: number;
  146560. alignVertical?: number;
  146561. sideOrientation?: number;
  146562. updatable?: boolean;
  146563. }, scene?: Nullable<Scene>): Mesh;
  146564. /**
  146565. * Creates a sphere mesh
  146566. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146567. * * 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`)
  146568. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146569. * * 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
  146570. * * 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)
  146571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146574. * @param name defines the name of the mesh
  146575. * @param options defines the options used to create the mesh
  146576. * @param scene defines the hosting scene
  146577. * @returns the sphere mesh
  146578. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146579. */
  146580. static CreateSphere(name: string, options: {
  146581. segments?: number;
  146582. diameter?: number;
  146583. diameterX?: number;
  146584. diameterY?: number;
  146585. diameterZ?: number;
  146586. arc?: number;
  146587. slice?: number;
  146588. sideOrientation?: number;
  146589. frontUVs?: Vector4;
  146590. backUVs?: Vector4;
  146591. updatable?: boolean;
  146592. }, scene?: Nullable<Scene>): Mesh;
  146593. /**
  146594. * Creates a plane polygonal mesh. By default, this is a disc
  146595. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146596. * * 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
  146597. * * 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
  146598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146601. * @param name defines the name of the mesh
  146602. * @param options defines the options used to create the mesh
  146603. * @param scene defines the hosting scene
  146604. * @returns the plane polygonal mesh
  146605. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146606. */
  146607. static CreateDisc(name: string, options: {
  146608. radius?: number;
  146609. tessellation?: number;
  146610. arc?: number;
  146611. updatable?: boolean;
  146612. sideOrientation?: number;
  146613. frontUVs?: Vector4;
  146614. backUVs?: Vector4;
  146615. }, scene?: Nullable<Scene>): Mesh;
  146616. /**
  146617. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146618. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146619. * * 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`)
  146620. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146621. * * 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
  146622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146625. * @param name defines the name of the mesh
  146626. * @param options defines the options used to create the mesh
  146627. * @param scene defines the hosting scene
  146628. * @returns the icosahedron mesh
  146629. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146630. */
  146631. static CreateIcoSphere(name: string, options: {
  146632. radius?: number;
  146633. radiusX?: number;
  146634. radiusY?: number;
  146635. radiusZ?: number;
  146636. flat?: boolean;
  146637. subdivisions?: number;
  146638. sideOrientation?: number;
  146639. frontUVs?: Vector4;
  146640. backUVs?: Vector4;
  146641. updatable?: boolean;
  146642. }, scene?: Nullable<Scene>): Mesh;
  146643. /**
  146644. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146645. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146646. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146647. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146648. * * 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
  146649. * * 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
  146650. * * 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
  146651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146654. * * 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
  146655. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146656. * * 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
  146657. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146659. * @param name defines the name of the mesh
  146660. * @param options defines the options used to create the mesh
  146661. * @param scene defines the hosting scene
  146662. * @returns the ribbon mesh
  146663. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146665. */
  146666. static CreateRibbon(name: string, options: {
  146667. pathArray: Vector3[][];
  146668. closeArray?: boolean;
  146669. closePath?: boolean;
  146670. offset?: number;
  146671. updatable?: boolean;
  146672. sideOrientation?: number;
  146673. frontUVs?: Vector4;
  146674. backUVs?: Vector4;
  146675. instance?: Mesh;
  146676. invertUV?: boolean;
  146677. uvs?: Vector2[];
  146678. colors?: Color4[];
  146679. }, scene?: Nullable<Scene>): Mesh;
  146680. /**
  146681. * Creates a cylinder or a cone mesh
  146682. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146683. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146684. * * 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.
  146685. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146686. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146687. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146688. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146689. * * 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).
  146690. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146691. * * 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).
  146692. * * 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
  146693. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146694. * * 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
  146695. * * 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.
  146696. * * If `enclose` is false, a ring surface is one element.
  146697. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146698. * * 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
  146699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146702. * @param name defines the name of the mesh
  146703. * @param options defines the options used to create the mesh
  146704. * @param scene defines the hosting scene
  146705. * @returns the cylinder mesh
  146706. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146707. */
  146708. static CreateCylinder(name: string, options: {
  146709. height?: number;
  146710. diameterTop?: number;
  146711. diameterBottom?: number;
  146712. diameter?: number;
  146713. tessellation?: number;
  146714. subdivisions?: number;
  146715. arc?: number;
  146716. faceColors?: Color4[];
  146717. faceUV?: Vector4[];
  146718. updatable?: boolean;
  146719. hasRings?: boolean;
  146720. enclose?: boolean;
  146721. cap?: number;
  146722. sideOrientation?: number;
  146723. frontUVs?: Vector4;
  146724. backUVs?: Vector4;
  146725. }, scene?: Nullable<Scene>): Mesh;
  146726. /**
  146727. * Creates a torus mesh
  146728. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146729. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146730. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146734. * @param name defines the name of the mesh
  146735. * @param options defines the options used to create the mesh
  146736. * @param scene defines the hosting scene
  146737. * @returns the torus mesh
  146738. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146739. */
  146740. static CreateTorus(name: string, options: {
  146741. diameter?: number;
  146742. thickness?: number;
  146743. tessellation?: number;
  146744. updatable?: boolean;
  146745. sideOrientation?: number;
  146746. frontUVs?: Vector4;
  146747. backUVs?: Vector4;
  146748. }, scene?: Nullable<Scene>): Mesh;
  146749. /**
  146750. * Creates a torus knot mesh
  146751. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146752. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146753. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146754. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146758. * @param name defines the name of the mesh
  146759. * @param options defines the options used to create the mesh
  146760. * @param scene defines the hosting scene
  146761. * @returns the torus knot mesh
  146762. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146763. */
  146764. static CreateTorusKnot(name: string, options: {
  146765. radius?: number;
  146766. tube?: number;
  146767. radialSegments?: number;
  146768. tubularSegments?: number;
  146769. p?: number;
  146770. q?: number;
  146771. updatable?: boolean;
  146772. sideOrientation?: number;
  146773. frontUVs?: Vector4;
  146774. backUVs?: Vector4;
  146775. }, scene?: Nullable<Scene>): Mesh;
  146776. /**
  146777. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146778. * * 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
  146779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146780. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146781. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146782. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146784. * * 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
  146785. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146788. * @param name defines the name of the new line system
  146789. * @param options defines the options used to create the line system
  146790. * @param scene defines the hosting scene
  146791. * @returns a new line system mesh
  146792. */
  146793. static CreateLineSystem(name: string, options: {
  146794. lines: Vector3[][];
  146795. updatable?: boolean;
  146796. instance?: Nullable<LinesMesh>;
  146797. colors?: Nullable<Color4[][]>;
  146798. useVertexAlpha?: boolean;
  146799. }, scene: Nullable<Scene>): LinesMesh;
  146800. /**
  146801. * Creates a line mesh
  146802. * 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
  146803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146804. * * The parameter `points` is an array successive Vector3
  146805. * * 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
  146806. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146808. * * When updating an instance, remember that only point positions can change, not the number of points
  146809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146811. * @param name defines the name of the new line system
  146812. * @param options defines the options used to create the line system
  146813. * @param scene defines the hosting scene
  146814. * @returns a new line mesh
  146815. */
  146816. static CreateLines(name: string, options: {
  146817. points: Vector3[];
  146818. updatable?: boolean;
  146819. instance?: Nullable<LinesMesh>;
  146820. colors?: Color4[];
  146821. useVertexAlpha?: boolean;
  146822. }, scene?: Nullable<Scene>): LinesMesh;
  146823. /**
  146824. * Creates a dashed line mesh
  146825. * * 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
  146826. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146827. * * The parameter `points` is an array successive Vector3
  146828. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146829. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146830. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146831. * * 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
  146832. * * When updating an instance, remember that only point positions can change, not the number of points
  146833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146834. * @param name defines the name of the mesh
  146835. * @param options defines the options used to create the mesh
  146836. * @param scene defines the hosting scene
  146837. * @returns the dashed line mesh
  146838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146839. */
  146840. static CreateDashedLines(name: string, options: {
  146841. points: Vector3[];
  146842. dashSize?: number;
  146843. gapSize?: number;
  146844. dashNb?: number;
  146845. updatable?: boolean;
  146846. instance?: LinesMesh;
  146847. }, scene?: Nullable<Scene>): LinesMesh;
  146848. /**
  146849. * 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.
  146850. * * 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.
  146851. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146852. * * 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.
  146853. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146854. * * 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
  146855. * * 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
  146856. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146861. * @param name defines the name of the mesh
  146862. * @param options defines the options used to create the mesh
  146863. * @param scene defines the hosting scene
  146864. * @returns the extruded shape mesh
  146865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146867. */
  146868. static ExtrudeShape(name: string, options: {
  146869. shape: Vector3[];
  146870. path: Vector3[];
  146871. scale?: number;
  146872. rotation?: number;
  146873. cap?: number;
  146874. updatable?: boolean;
  146875. sideOrientation?: number;
  146876. frontUVs?: Vector4;
  146877. backUVs?: Vector4;
  146878. instance?: Mesh;
  146879. invertUV?: boolean;
  146880. }, scene?: Nullable<Scene>): Mesh;
  146881. /**
  146882. * Creates an custom extruded shape mesh.
  146883. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146884. * * 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.
  146885. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146886. * * 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
  146887. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146888. * * 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
  146889. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146890. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146891. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146892. * * 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
  146893. * * 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
  146894. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146899. * @param name defines the name of the mesh
  146900. * @param options defines the options used to create the mesh
  146901. * @param scene defines the hosting scene
  146902. * @returns the custom extruded shape mesh
  146903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146906. */
  146907. static ExtrudeShapeCustom(name: string, options: {
  146908. shape: Vector3[];
  146909. path: Vector3[];
  146910. scaleFunction?: any;
  146911. rotationFunction?: any;
  146912. ribbonCloseArray?: boolean;
  146913. ribbonClosePath?: boolean;
  146914. cap?: number;
  146915. updatable?: boolean;
  146916. sideOrientation?: number;
  146917. frontUVs?: Vector4;
  146918. backUVs?: Vector4;
  146919. instance?: Mesh;
  146920. invertUV?: boolean;
  146921. }, scene?: Nullable<Scene>): Mesh;
  146922. /**
  146923. * Creates lathe mesh.
  146924. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146925. * * 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
  146926. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146927. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146928. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146929. * * 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
  146930. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146931. * * 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
  146932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146936. * @param name defines the name of the mesh
  146937. * @param options defines the options used to create the mesh
  146938. * @param scene defines the hosting scene
  146939. * @returns the lathe mesh
  146940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146941. */
  146942. static CreateLathe(name: string, options: {
  146943. shape: Vector3[];
  146944. radius?: number;
  146945. tessellation?: number;
  146946. clip?: number;
  146947. arc?: number;
  146948. closed?: boolean;
  146949. updatable?: boolean;
  146950. sideOrientation?: number;
  146951. frontUVs?: Vector4;
  146952. backUVs?: Vector4;
  146953. cap?: number;
  146954. invertUV?: boolean;
  146955. }, scene?: Nullable<Scene>): Mesh;
  146956. /**
  146957. * Creates a tiled plane mesh
  146958. * * You can set a limited pattern arrangement with the tiles
  146959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146962. * @param name defines the name of the mesh
  146963. * @param options defines the options used to create the mesh
  146964. * @param scene defines the hosting scene
  146965. * @returns the plane mesh
  146966. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146967. */
  146968. static CreateTiledPlane(name: string, options: {
  146969. pattern?: number;
  146970. tileSize?: number;
  146971. tileWidth?: number;
  146972. tileHeight?: number;
  146973. size?: number;
  146974. width?: number;
  146975. height?: number;
  146976. alignHorizontal?: number;
  146977. alignVertical?: number;
  146978. sideOrientation?: number;
  146979. frontUVs?: Vector4;
  146980. backUVs?: Vector4;
  146981. updatable?: boolean;
  146982. }, scene?: Nullable<Scene>): Mesh;
  146983. /**
  146984. * Creates a plane mesh
  146985. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146986. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146987. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146991. * @param name defines the name of the mesh
  146992. * @param options defines the options used to create the mesh
  146993. * @param scene defines the hosting scene
  146994. * @returns the plane mesh
  146995. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146996. */
  146997. static CreatePlane(name: string, options: {
  146998. size?: number;
  146999. width?: number;
  147000. height?: number;
  147001. sideOrientation?: number;
  147002. frontUVs?: Vector4;
  147003. backUVs?: Vector4;
  147004. updatable?: boolean;
  147005. sourcePlane?: Plane;
  147006. }, scene?: Nullable<Scene>): Mesh;
  147007. /**
  147008. * Creates a ground mesh
  147009. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147010. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147012. * @param name defines the name of the mesh
  147013. * @param options defines the options used to create the mesh
  147014. * @param scene defines the hosting scene
  147015. * @returns the ground mesh
  147016. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147017. */
  147018. static CreateGround(name: string, options: {
  147019. width?: number;
  147020. height?: number;
  147021. subdivisions?: number;
  147022. subdivisionsX?: number;
  147023. subdivisionsY?: number;
  147024. updatable?: boolean;
  147025. }, scene?: Nullable<Scene>): Mesh;
  147026. /**
  147027. * Creates a tiled ground mesh
  147028. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147029. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147030. * * 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
  147031. * * 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
  147032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147033. * @param name defines the name of the mesh
  147034. * @param options defines the options used to create the mesh
  147035. * @param scene defines the hosting scene
  147036. * @returns the tiled ground mesh
  147037. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147038. */
  147039. static CreateTiledGround(name: string, options: {
  147040. xmin: number;
  147041. zmin: number;
  147042. xmax: number;
  147043. zmax: number;
  147044. subdivisions?: {
  147045. w: number;
  147046. h: number;
  147047. };
  147048. precision?: {
  147049. w: number;
  147050. h: number;
  147051. };
  147052. updatable?: boolean;
  147053. }, scene?: Nullable<Scene>): Mesh;
  147054. /**
  147055. * Creates a ground mesh from a height map
  147056. * * The parameter `url` sets the URL of the height map image resource.
  147057. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147058. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147059. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147060. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147061. * * 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.
  147062. * * 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).
  147063. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147065. * @param name defines the name of the mesh
  147066. * @param url defines the url to the height map
  147067. * @param options defines the options used to create the mesh
  147068. * @param scene defines the hosting scene
  147069. * @returns the ground mesh
  147070. * @see https://doc.babylonjs.com/babylon101/height_map
  147071. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147072. */
  147073. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147074. width?: number;
  147075. height?: number;
  147076. subdivisions?: number;
  147077. minHeight?: number;
  147078. maxHeight?: number;
  147079. colorFilter?: Color3;
  147080. alphaFilter?: number;
  147081. updatable?: boolean;
  147082. onReady?: (mesh: GroundMesh) => void;
  147083. }, scene?: Nullable<Scene>): GroundMesh;
  147084. /**
  147085. * Creates a polygon mesh
  147086. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147087. * * 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
  147088. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147091. * * Remember you can only change the shape positions, not their number when updating a polygon
  147092. * @param name defines the name of the mesh
  147093. * @param options defines the options used to create the mesh
  147094. * @param scene defines the hosting scene
  147095. * @param earcutInjection can be used to inject your own earcut reference
  147096. * @returns the polygon mesh
  147097. */
  147098. static CreatePolygon(name: string, options: {
  147099. shape: Vector3[];
  147100. holes?: Vector3[][];
  147101. depth?: number;
  147102. faceUV?: Vector4[];
  147103. faceColors?: Color4[];
  147104. updatable?: boolean;
  147105. sideOrientation?: number;
  147106. frontUVs?: Vector4;
  147107. backUVs?: Vector4;
  147108. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147109. /**
  147110. * Creates an extruded polygon mesh, with depth in the Y direction.
  147111. * * 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)
  147112. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147113. * @param name defines the name of the mesh
  147114. * @param options defines the options used to create the mesh
  147115. * @param scene defines the hosting scene
  147116. * @param earcutInjection can be used to inject your own earcut reference
  147117. * @returns the polygon mesh
  147118. */
  147119. static ExtrudePolygon(name: string, options: {
  147120. shape: Vector3[];
  147121. holes?: Vector3[][];
  147122. depth?: number;
  147123. faceUV?: Vector4[];
  147124. faceColors?: Color4[];
  147125. updatable?: boolean;
  147126. sideOrientation?: number;
  147127. frontUVs?: Vector4;
  147128. backUVs?: Vector4;
  147129. wrap?: boolean;
  147130. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147131. /**
  147132. * Creates a tube mesh.
  147133. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147134. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147135. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147136. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147137. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147138. * * 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)
  147139. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147140. * * 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
  147141. * * 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
  147142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147146. * @param name defines the name of the mesh
  147147. * @param options defines the options used to create the mesh
  147148. * @param scene defines the hosting scene
  147149. * @returns the tube mesh
  147150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147151. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147152. */
  147153. static CreateTube(name: string, options: {
  147154. path: Vector3[];
  147155. radius?: number;
  147156. tessellation?: number;
  147157. radiusFunction?: {
  147158. (i: number, distance: number): number;
  147159. };
  147160. cap?: number;
  147161. arc?: number;
  147162. updatable?: boolean;
  147163. sideOrientation?: number;
  147164. frontUVs?: Vector4;
  147165. backUVs?: Vector4;
  147166. instance?: Mesh;
  147167. invertUV?: boolean;
  147168. }, scene?: Nullable<Scene>): Mesh;
  147169. /**
  147170. * Creates a polyhedron mesh
  147171. * * 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
  147172. * * The parameter `size` (positive float, default 1) sets the polygon size
  147173. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147174. * * 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`
  147175. * * 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
  147176. * * 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)`)
  147177. * * 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
  147178. * * 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
  147179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147182. * @param name defines the name of the mesh
  147183. * @param options defines the options used to create the mesh
  147184. * @param scene defines the hosting scene
  147185. * @returns the polyhedron mesh
  147186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147187. */
  147188. static CreatePolyhedron(name: string, options: {
  147189. type?: number;
  147190. size?: number;
  147191. sizeX?: number;
  147192. sizeY?: number;
  147193. sizeZ?: number;
  147194. custom?: any;
  147195. faceUV?: Vector4[];
  147196. faceColors?: Color4[];
  147197. flat?: boolean;
  147198. updatable?: boolean;
  147199. sideOrientation?: number;
  147200. frontUVs?: Vector4;
  147201. backUVs?: Vector4;
  147202. }, scene?: Nullable<Scene>): Mesh;
  147203. /**
  147204. * Creates a decal mesh.
  147205. * 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
  147206. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147207. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147208. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147209. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147210. * @param name defines the name of the mesh
  147211. * @param sourceMesh defines the mesh where the decal must be applied
  147212. * @param options defines the options used to create the mesh
  147213. * @param scene defines the hosting scene
  147214. * @returns the decal mesh
  147215. * @see https://doc.babylonjs.com/how_to/decals
  147216. */
  147217. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147218. position?: Vector3;
  147219. normal?: Vector3;
  147220. size?: Vector3;
  147221. angle?: number;
  147222. }): Mesh;
  147223. /**
  147224. * Creates a Capsule Mesh
  147225. * @param name defines the name of the mesh.
  147226. * @param options the constructors options used to shape the mesh.
  147227. * @param scene defines the scene the mesh is scoped to.
  147228. * @returns the capsule mesh
  147229. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147230. */
  147231. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147232. }
  147233. }
  147234. declare module BABYLON {
  147235. /**
  147236. * A simplifier interface for future simplification implementations
  147237. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147238. */
  147239. export interface ISimplifier {
  147240. /**
  147241. * Simplification of a given mesh according to the given settings.
  147242. * Since this requires computation, it is assumed that the function runs async.
  147243. * @param settings The settings of the simplification, including quality and distance
  147244. * @param successCallback A callback that will be called after the mesh was simplified.
  147245. * @param errorCallback in case of an error, this callback will be called. optional.
  147246. */
  147247. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147248. }
  147249. /**
  147250. * Expected simplification settings.
  147251. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147252. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147253. */
  147254. export interface ISimplificationSettings {
  147255. /**
  147256. * Gets or sets the expected quality
  147257. */
  147258. quality: number;
  147259. /**
  147260. * Gets or sets the distance when this optimized version should be used
  147261. */
  147262. distance: number;
  147263. /**
  147264. * Gets an already optimized mesh
  147265. */
  147266. optimizeMesh?: boolean;
  147267. }
  147268. /**
  147269. * Class used to specify simplification options
  147270. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147271. */
  147272. export class SimplificationSettings implements ISimplificationSettings {
  147273. /** expected quality */
  147274. quality: number;
  147275. /** distance when this optimized version should be used */
  147276. distance: number;
  147277. /** already optimized mesh */
  147278. optimizeMesh?: boolean | undefined;
  147279. /**
  147280. * Creates a SimplificationSettings
  147281. * @param quality expected quality
  147282. * @param distance distance when this optimized version should be used
  147283. * @param optimizeMesh already optimized mesh
  147284. */
  147285. constructor(
  147286. /** expected quality */
  147287. quality: number,
  147288. /** distance when this optimized version should be used */
  147289. distance: number,
  147290. /** already optimized mesh */
  147291. optimizeMesh?: boolean | undefined);
  147292. }
  147293. /**
  147294. * Interface used to define a simplification task
  147295. */
  147296. export interface ISimplificationTask {
  147297. /**
  147298. * Array of settings
  147299. */
  147300. settings: Array<ISimplificationSettings>;
  147301. /**
  147302. * Simplification type
  147303. */
  147304. simplificationType: SimplificationType;
  147305. /**
  147306. * Mesh to simplify
  147307. */
  147308. mesh: Mesh;
  147309. /**
  147310. * Callback called on success
  147311. */
  147312. successCallback?: () => void;
  147313. /**
  147314. * Defines if parallel processing can be used
  147315. */
  147316. parallelProcessing: boolean;
  147317. }
  147318. /**
  147319. * Queue used to order the simplification tasks
  147320. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147321. */
  147322. export class SimplificationQueue {
  147323. private _simplificationArray;
  147324. /**
  147325. * Gets a boolean indicating that the process is still running
  147326. */
  147327. running: boolean;
  147328. /**
  147329. * Creates a new queue
  147330. */
  147331. constructor();
  147332. /**
  147333. * Adds a new simplification task
  147334. * @param task defines a task to add
  147335. */
  147336. addTask(task: ISimplificationTask): void;
  147337. /**
  147338. * Execute next task
  147339. */
  147340. executeNext(): void;
  147341. /**
  147342. * Execute a simplification task
  147343. * @param task defines the task to run
  147344. */
  147345. runSimplification(task: ISimplificationTask): void;
  147346. private getSimplifier;
  147347. }
  147348. /**
  147349. * The implemented types of simplification
  147350. * At the moment only Quadratic Error Decimation is implemented
  147351. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147352. */
  147353. export enum SimplificationType {
  147354. /** Quadratic error decimation */
  147355. QUADRATIC = 0
  147356. }
  147357. /**
  147358. * An implementation of the Quadratic Error simplification algorithm.
  147359. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147360. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147361. * @author RaananW
  147362. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147363. */
  147364. export class QuadraticErrorSimplification implements ISimplifier {
  147365. private _mesh;
  147366. private triangles;
  147367. private vertices;
  147368. private references;
  147369. private _reconstructedMesh;
  147370. /** Gets or sets the number pf sync interations */
  147371. syncIterations: number;
  147372. /** Gets or sets the aggressiveness of the simplifier */
  147373. aggressiveness: number;
  147374. /** Gets or sets the number of allowed iterations for decimation */
  147375. decimationIterations: number;
  147376. /** Gets or sets the espilon to use for bounding box computation */
  147377. boundingBoxEpsilon: number;
  147378. /**
  147379. * Creates a new QuadraticErrorSimplification
  147380. * @param _mesh defines the target mesh
  147381. */
  147382. constructor(_mesh: Mesh);
  147383. /**
  147384. * Simplification of a given mesh according to the given settings.
  147385. * Since this requires computation, it is assumed that the function runs async.
  147386. * @param settings The settings of the simplification, including quality and distance
  147387. * @param successCallback A callback that will be called after the mesh was simplified.
  147388. */
  147389. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147390. private runDecimation;
  147391. private initWithMesh;
  147392. private init;
  147393. private reconstructMesh;
  147394. private initDecimatedMesh;
  147395. private isFlipped;
  147396. private updateTriangles;
  147397. private identifyBorder;
  147398. private updateMesh;
  147399. private vertexError;
  147400. private calculateError;
  147401. }
  147402. }
  147403. declare module BABYLON {
  147404. interface Scene {
  147405. /** @hidden (Backing field) */
  147406. _simplificationQueue: SimplificationQueue;
  147407. /**
  147408. * Gets or sets the simplification queue attached to the scene
  147409. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147410. */
  147411. simplificationQueue: SimplificationQueue;
  147412. }
  147413. interface Mesh {
  147414. /**
  147415. * Simplify the mesh according to the given array of settings.
  147416. * Function will return immediately and will simplify async
  147417. * @param settings a collection of simplification settings
  147418. * @param parallelProcessing should all levels calculate parallel or one after the other
  147419. * @param simplificationType the type of simplification to run
  147420. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147421. * @returns the current mesh
  147422. */
  147423. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147424. }
  147425. /**
  147426. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147427. * created in a scene
  147428. */
  147429. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147430. /**
  147431. * The component name helpfull to identify the component in the list of scene components.
  147432. */
  147433. readonly name: string;
  147434. /**
  147435. * The scene the component belongs to.
  147436. */
  147437. scene: Scene;
  147438. /**
  147439. * Creates a new instance of the component for the given scene
  147440. * @param scene Defines the scene to register the component in
  147441. */
  147442. constructor(scene: Scene);
  147443. /**
  147444. * Registers the component in a given scene
  147445. */
  147446. register(): void;
  147447. /**
  147448. * Rebuilds the elements related to this component in case of
  147449. * context lost for instance.
  147450. */
  147451. rebuild(): void;
  147452. /**
  147453. * Disposes the component and the associated ressources
  147454. */
  147455. dispose(): void;
  147456. private _beforeCameraUpdate;
  147457. }
  147458. }
  147459. declare module BABYLON {
  147460. interface Mesh {
  147461. /**
  147462. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147463. */
  147464. thinInstanceEnablePicking: boolean;
  147465. /**
  147466. * Creates a new thin instance
  147467. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147468. * @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
  147469. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147470. */
  147471. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147472. /**
  147473. * Adds the transformation (matrix) of the current mesh as a thin instance
  147474. * @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
  147475. * @returns the thin instance index number
  147476. */
  147477. thinInstanceAddSelf(refresh: boolean): number;
  147478. /**
  147479. * Registers a custom attribute to be used with thin instances
  147480. * @param kind name of the attribute
  147481. * @param stride size in floats of the attribute
  147482. */
  147483. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147484. /**
  147485. * Sets the matrix of a thin instance
  147486. * @param index index of the thin instance
  147487. * @param matrix matrix to set
  147488. * @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
  147489. */
  147490. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147491. /**
  147492. * Sets the value of a custom attribute for a thin instance
  147493. * @param kind name of the attribute
  147494. * @param index index of the thin instance
  147495. * @param value value to set
  147496. * @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
  147497. */
  147498. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147499. /**
  147500. * 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.
  147501. */
  147502. thinInstanceCount: number;
  147503. /**
  147504. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147505. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147506. * @param buffer buffer to set
  147507. * @param stride size in floats of each value of the buffer
  147508. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147509. */
  147510. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147511. /**
  147512. * Gets the list of world matrices
  147513. * @return an array containing all the world matrices from the thin instances
  147514. */
  147515. thinInstanceGetWorldMatrices(): Matrix[];
  147516. /**
  147517. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147518. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147519. */
  147520. thinInstanceBufferUpdated(kind: string): void;
  147521. /**
  147522. * Applies a partial update to a buffer directly on the GPU
  147523. * 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
  147524. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147525. * @param data the data to set in the GPU buffer
  147526. * @param offset the offset in the GPU buffer where to update the data
  147527. */
  147528. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147529. /**
  147530. * Refreshes the bounding info, taking into account all the thin instances defined
  147531. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147532. */
  147533. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147534. /** @hidden */
  147535. _thinInstanceInitializeUserStorage(): void;
  147536. /** @hidden */
  147537. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147538. /** @hidden */
  147539. _userThinInstanceBuffersStorage: {
  147540. data: {
  147541. [key: string]: Float32Array;
  147542. };
  147543. sizes: {
  147544. [key: string]: number;
  147545. };
  147546. vertexBuffers: {
  147547. [key: string]: Nullable<VertexBuffer>;
  147548. };
  147549. strides: {
  147550. [key: string]: number;
  147551. };
  147552. };
  147553. }
  147554. }
  147555. declare module BABYLON {
  147556. /**
  147557. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147558. */
  147559. export interface INavigationEnginePlugin {
  147560. /**
  147561. * plugin name
  147562. */
  147563. name: string;
  147564. /**
  147565. * Creates a navigation mesh
  147566. * @param meshes array of all the geometry used to compute the navigatio mesh
  147567. * @param parameters bunch of parameters used to filter geometry
  147568. */
  147569. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147570. /**
  147571. * Create a navigation mesh debug mesh
  147572. * @param scene is where the mesh will be added
  147573. * @returns debug display mesh
  147574. */
  147575. createDebugNavMesh(scene: Scene): Mesh;
  147576. /**
  147577. * Get a navigation mesh constrained position, closest to the parameter position
  147578. * @param position world position
  147579. * @returns the closest point to position constrained by the navigation mesh
  147580. */
  147581. getClosestPoint(position: Vector3): Vector3;
  147582. /**
  147583. * Get a navigation mesh constrained position, closest to the parameter position
  147584. * @param position world position
  147585. * @param result output the closest point to position constrained by the navigation mesh
  147586. */
  147587. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147588. /**
  147589. * Get a navigation mesh constrained position, within a particular radius
  147590. * @param position world position
  147591. * @param maxRadius the maximum distance to the constrained world position
  147592. * @returns the closest point to position constrained by the navigation mesh
  147593. */
  147594. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147595. /**
  147596. * Get a navigation mesh constrained position, within a particular radius
  147597. * @param position world position
  147598. * @param maxRadius the maximum distance to the constrained world position
  147599. * @param result output the closest point to position constrained by the navigation mesh
  147600. */
  147601. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147602. /**
  147603. * Compute the final position from a segment made of destination-position
  147604. * @param position world position
  147605. * @param destination world position
  147606. * @returns the resulting point along the navmesh
  147607. */
  147608. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147609. /**
  147610. * Compute the final position from a segment made of destination-position
  147611. * @param position world position
  147612. * @param destination world position
  147613. * @param result output the resulting point along the navmesh
  147614. */
  147615. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147616. /**
  147617. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147618. * @param start world position
  147619. * @param end world position
  147620. * @returns array containing world position composing the path
  147621. */
  147622. computePath(start: Vector3, end: Vector3): Vector3[];
  147623. /**
  147624. * If this plugin is supported
  147625. * @returns true if plugin is supported
  147626. */
  147627. isSupported(): boolean;
  147628. /**
  147629. * Create a new Crowd so you can add agents
  147630. * @param maxAgents the maximum agent count in the crowd
  147631. * @param maxAgentRadius the maximum radius an agent can have
  147632. * @param scene to attach the crowd to
  147633. * @returns the crowd you can add agents to
  147634. */
  147635. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147636. /**
  147637. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147638. * The queries will try to find a solution within those bounds
  147639. * default is (1,1,1)
  147640. * @param extent x,y,z value that define the extent around the queries point of reference
  147641. */
  147642. setDefaultQueryExtent(extent: Vector3): void;
  147643. /**
  147644. * Get the Bounding box extent specified by setDefaultQueryExtent
  147645. * @returns the box extent values
  147646. */
  147647. getDefaultQueryExtent(): Vector3;
  147648. /**
  147649. * build the navmesh from a previously saved state using getNavmeshData
  147650. * @param data the Uint8Array returned by getNavmeshData
  147651. */
  147652. buildFromNavmeshData(data: Uint8Array): void;
  147653. /**
  147654. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147655. * @returns data the Uint8Array that can be saved and reused
  147656. */
  147657. getNavmeshData(): Uint8Array;
  147658. /**
  147659. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147660. * @param result output the box extent values
  147661. */
  147662. getDefaultQueryExtentToRef(result: Vector3): void;
  147663. /**
  147664. * Release all resources
  147665. */
  147666. dispose(): void;
  147667. }
  147668. /**
  147669. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147670. */
  147671. export interface ICrowd {
  147672. /**
  147673. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147674. * You can attach anything to that node. The node position is updated in the scene update tick.
  147675. * @param pos world position that will be constrained by the navigation mesh
  147676. * @param parameters agent parameters
  147677. * @param transform hooked to the agent that will be update by the scene
  147678. * @returns agent index
  147679. */
  147680. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147681. /**
  147682. * Returns the agent position in world space
  147683. * @param index agent index returned by addAgent
  147684. * @returns world space position
  147685. */
  147686. getAgentPosition(index: number): Vector3;
  147687. /**
  147688. * Gets the agent position result in world space
  147689. * @param index agent index returned by addAgent
  147690. * @param result output world space position
  147691. */
  147692. getAgentPositionToRef(index: number, result: Vector3): void;
  147693. /**
  147694. * Gets the agent velocity in world space
  147695. * @param index agent index returned by addAgent
  147696. * @returns world space velocity
  147697. */
  147698. getAgentVelocity(index: number): Vector3;
  147699. /**
  147700. * Gets the agent velocity result in world space
  147701. * @param index agent index returned by addAgent
  147702. * @param result output world space velocity
  147703. */
  147704. getAgentVelocityToRef(index: number, result: Vector3): void;
  147705. /**
  147706. * remove a particular agent previously created
  147707. * @param index agent index returned by addAgent
  147708. */
  147709. removeAgent(index: number): void;
  147710. /**
  147711. * get the list of all agents attached to this crowd
  147712. * @returns list of agent indices
  147713. */
  147714. getAgents(): number[];
  147715. /**
  147716. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147717. * @param deltaTime in seconds
  147718. */
  147719. update(deltaTime: number): void;
  147720. /**
  147721. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147722. * @param index agent index returned by addAgent
  147723. * @param destination targeted world position
  147724. */
  147725. agentGoto(index: number, destination: Vector3): void;
  147726. /**
  147727. * Teleport the agent to a new position
  147728. * @param index agent index returned by addAgent
  147729. * @param destination targeted world position
  147730. */
  147731. agentTeleport(index: number, destination: Vector3): void;
  147732. /**
  147733. * Update agent parameters
  147734. * @param index agent index returned by addAgent
  147735. * @param parameters agent parameters
  147736. */
  147737. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147738. /**
  147739. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147740. * The queries will try to find a solution within those bounds
  147741. * default is (1,1,1)
  147742. * @param extent x,y,z value that define the extent around the queries point of reference
  147743. */
  147744. setDefaultQueryExtent(extent: Vector3): void;
  147745. /**
  147746. * Get the Bounding box extent specified by setDefaultQueryExtent
  147747. * @returns the box extent values
  147748. */
  147749. getDefaultQueryExtent(): Vector3;
  147750. /**
  147751. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147752. * @param result output the box extent values
  147753. */
  147754. getDefaultQueryExtentToRef(result: Vector3): void;
  147755. /**
  147756. * Release all resources
  147757. */
  147758. dispose(): void;
  147759. }
  147760. /**
  147761. * Configures an agent
  147762. */
  147763. export interface IAgentParameters {
  147764. /**
  147765. * Agent radius. [Limit: >= 0]
  147766. */
  147767. radius: number;
  147768. /**
  147769. * Agent height. [Limit: > 0]
  147770. */
  147771. height: number;
  147772. /**
  147773. * Maximum allowed acceleration. [Limit: >= 0]
  147774. */
  147775. maxAcceleration: number;
  147776. /**
  147777. * Maximum allowed speed. [Limit: >= 0]
  147778. */
  147779. maxSpeed: number;
  147780. /**
  147781. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147782. */
  147783. collisionQueryRange: number;
  147784. /**
  147785. * The path visibility optimization range. [Limit: > 0]
  147786. */
  147787. pathOptimizationRange: number;
  147788. /**
  147789. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147790. */
  147791. separationWeight: number;
  147792. }
  147793. /**
  147794. * Configures the navigation mesh creation
  147795. */
  147796. export interface INavMeshParameters {
  147797. /**
  147798. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147799. */
  147800. cs: number;
  147801. /**
  147802. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147803. */
  147804. ch: number;
  147805. /**
  147806. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147807. */
  147808. walkableSlopeAngle: number;
  147809. /**
  147810. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147811. * be considered walkable. [Limit: >= 3] [Units: vx]
  147812. */
  147813. walkableHeight: number;
  147814. /**
  147815. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147816. */
  147817. walkableClimb: number;
  147818. /**
  147819. * The distance to erode/shrink the walkable area of the heightfield away from
  147820. * obstructions. [Limit: >=0] [Units: vx]
  147821. */
  147822. walkableRadius: number;
  147823. /**
  147824. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147825. */
  147826. maxEdgeLen: number;
  147827. /**
  147828. * The maximum distance a simplfied contour's border edges should deviate
  147829. * the original raw contour. [Limit: >=0] [Units: vx]
  147830. */
  147831. maxSimplificationError: number;
  147832. /**
  147833. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147834. */
  147835. minRegionArea: number;
  147836. /**
  147837. * Any regions with a span count smaller than this value will, if possible,
  147838. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147839. */
  147840. mergeRegionArea: number;
  147841. /**
  147842. * The maximum number of vertices allowed for polygons generated during the
  147843. * contour to polygon conversion process. [Limit: >= 3]
  147844. */
  147845. maxVertsPerPoly: number;
  147846. /**
  147847. * Sets the sampling distance to use when generating the detail mesh.
  147848. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147849. */
  147850. detailSampleDist: number;
  147851. /**
  147852. * The maximum distance the detail mesh surface should deviate from heightfield
  147853. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147854. */
  147855. detailSampleMaxError: number;
  147856. }
  147857. }
  147858. declare module BABYLON {
  147859. /**
  147860. * RecastJS navigation plugin
  147861. */
  147862. export class RecastJSPlugin implements INavigationEnginePlugin {
  147863. /**
  147864. * Reference to the Recast library
  147865. */
  147866. bjsRECAST: any;
  147867. /**
  147868. * plugin name
  147869. */
  147870. name: string;
  147871. /**
  147872. * the first navmesh created. We might extend this to support multiple navmeshes
  147873. */
  147874. navMesh: any;
  147875. /**
  147876. * Initializes the recastJS plugin
  147877. * @param recastInjection can be used to inject your own recast reference
  147878. */
  147879. constructor(recastInjection?: any);
  147880. /**
  147881. * Creates a navigation mesh
  147882. * @param meshes array of all the geometry used to compute the navigatio mesh
  147883. * @param parameters bunch of parameters used to filter geometry
  147884. */
  147885. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147886. /**
  147887. * Create a navigation mesh debug mesh
  147888. * @param scene is where the mesh will be added
  147889. * @returns debug display mesh
  147890. */
  147891. createDebugNavMesh(scene: Scene): Mesh;
  147892. /**
  147893. * Get a navigation mesh constrained position, closest to the parameter position
  147894. * @param position world position
  147895. * @returns the closest point to position constrained by the navigation mesh
  147896. */
  147897. getClosestPoint(position: Vector3): Vector3;
  147898. /**
  147899. * Get a navigation mesh constrained position, closest to the parameter position
  147900. * @param position world position
  147901. * @param result output the closest point to position constrained by the navigation mesh
  147902. */
  147903. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147904. /**
  147905. * Get a navigation mesh constrained position, within a particular radius
  147906. * @param position world position
  147907. * @param maxRadius the maximum distance to the constrained world position
  147908. * @returns the closest point to position constrained by the navigation mesh
  147909. */
  147910. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147911. /**
  147912. * Get a navigation mesh constrained position, within a particular radius
  147913. * @param position world position
  147914. * @param maxRadius the maximum distance to the constrained world position
  147915. * @param result output the closest point to position constrained by the navigation mesh
  147916. */
  147917. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147918. /**
  147919. * Compute the final position from a segment made of destination-position
  147920. * @param position world position
  147921. * @param destination world position
  147922. * @returns the resulting point along the navmesh
  147923. */
  147924. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147925. /**
  147926. * Compute the final position from a segment made of destination-position
  147927. * @param position world position
  147928. * @param destination world position
  147929. * @param result output the resulting point along the navmesh
  147930. */
  147931. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147932. /**
  147933. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147934. * @param start world position
  147935. * @param end world position
  147936. * @returns array containing world position composing the path
  147937. */
  147938. computePath(start: Vector3, end: Vector3): Vector3[];
  147939. /**
  147940. * Create a new Crowd so you can add agents
  147941. * @param maxAgents the maximum agent count in the crowd
  147942. * @param maxAgentRadius the maximum radius an agent can have
  147943. * @param scene to attach the crowd to
  147944. * @returns the crowd you can add agents to
  147945. */
  147946. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147947. /**
  147948. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147949. * The queries will try to find a solution within those bounds
  147950. * default is (1,1,1)
  147951. * @param extent x,y,z value that define the extent around the queries point of reference
  147952. */
  147953. setDefaultQueryExtent(extent: Vector3): void;
  147954. /**
  147955. * Get the Bounding box extent specified by setDefaultQueryExtent
  147956. * @returns the box extent values
  147957. */
  147958. getDefaultQueryExtent(): Vector3;
  147959. /**
  147960. * build the navmesh from a previously saved state using getNavmeshData
  147961. * @param data the Uint8Array returned by getNavmeshData
  147962. */
  147963. buildFromNavmeshData(data: Uint8Array): void;
  147964. /**
  147965. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147966. * @returns data the Uint8Array that can be saved and reused
  147967. */
  147968. getNavmeshData(): Uint8Array;
  147969. /**
  147970. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147971. * @param result output the box extent values
  147972. */
  147973. getDefaultQueryExtentToRef(result: Vector3): void;
  147974. /**
  147975. * Disposes
  147976. */
  147977. dispose(): void;
  147978. /**
  147979. * If this plugin is supported
  147980. * @returns true if plugin is supported
  147981. */
  147982. isSupported(): boolean;
  147983. }
  147984. /**
  147985. * Recast detour crowd implementation
  147986. */
  147987. export class RecastJSCrowd implements ICrowd {
  147988. /**
  147989. * Recast/detour plugin
  147990. */
  147991. bjsRECASTPlugin: RecastJSPlugin;
  147992. /**
  147993. * Link to the detour crowd
  147994. */
  147995. recastCrowd: any;
  147996. /**
  147997. * One transform per agent
  147998. */
  147999. transforms: TransformNode[];
  148000. /**
  148001. * All agents created
  148002. */
  148003. agents: number[];
  148004. /**
  148005. * Link to the scene is kept to unregister the crowd from the scene
  148006. */
  148007. private _scene;
  148008. /**
  148009. * Observer for crowd updates
  148010. */
  148011. private _onBeforeAnimationsObserver;
  148012. /**
  148013. * Constructor
  148014. * @param plugin recastJS plugin
  148015. * @param maxAgents the maximum agent count in the crowd
  148016. * @param maxAgentRadius the maximum radius an agent can have
  148017. * @param scene to attach the crowd to
  148018. * @returns the crowd you can add agents to
  148019. */
  148020. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148021. /**
  148022. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148023. * You can attach anything to that node. The node position is updated in the scene update tick.
  148024. * @param pos world position that will be constrained by the navigation mesh
  148025. * @param parameters agent parameters
  148026. * @param transform hooked to the agent that will be update by the scene
  148027. * @returns agent index
  148028. */
  148029. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148030. /**
  148031. * Returns the agent position in world space
  148032. * @param index agent index returned by addAgent
  148033. * @returns world space position
  148034. */
  148035. getAgentPosition(index: number): Vector3;
  148036. /**
  148037. * Returns the agent position result in world space
  148038. * @param index agent index returned by addAgent
  148039. * @param result output world space position
  148040. */
  148041. getAgentPositionToRef(index: number, result: Vector3): void;
  148042. /**
  148043. * Returns the agent velocity in world space
  148044. * @param index agent index returned by addAgent
  148045. * @returns world space velocity
  148046. */
  148047. getAgentVelocity(index: number): Vector3;
  148048. /**
  148049. * Returns the agent velocity result in world space
  148050. * @param index agent index returned by addAgent
  148051. * @param result output world space velocity
  148052. */
  148053. getAgentVelocityToRef(index: number, result: Vector3): void;
  148054. /**
  148055. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148056. * @param index agent index returned by addAgent
  148057. * @param destination targeted world position
  148058. */
  148059. agentGoto(index: number, destination: Vector3): void;
  148060. /**
  148061. * Teleport the agent to a new position
  148062. * @param index agent index returned by addAgent
  148063. * @param destination targeted world position
  148064. */
  148065. agentTeleport(index: number, destination: Vector3): void;
  148066. /**
  148067. * Update agent parameters
  148068. * @param index agent index returned by addAgent
  148069. * @param parameters agent parameters
  148070. */
  148071. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148072. /**
  148073. * remove a particular agent previously created
  148074. * @param index agent index returned by addAgent
  148075. */
  148076. removeAgent(index: number): void;
  148077. /**
  148078. * get the list of all agents attached to this crowd
  148079. * @returns list of agent indices
  148080. */
  148081. getAgents(): number[];
  148082. /**
  148083. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148084. * @param deltaTime in seconds
  148085. */
  148086. update(deltaTime: number): void;
  148087. /**
  148088. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148089. * The queries will try to find a solution within those bounds
  148090. * default is (1,1,1)
  148091. * @param extent x,y,z value that define the extent around the queries point of reference
  148092. */
  148093. setDefaultQueryExtent(extent: Vector3): void;
  148094. /**
  148095. * Get the Bounding box extent specified by setDefaultQueryExtent
  148096. * @returns the box extent values
  148097. */
  148098. getDefaultQueryExtent(): Vector3;
  148099. /**
  148100. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148101. * @param result output the box extent values
  148102. */
  148103. getDefaultQueryExtentToRef(result: Vector3): void;
  148104. /**
  148105. * Release all resources
  148106. */
  148107. dispose(): void;
  148108. }
  148109. }
  148110. declare module BABYLON {
  148111. /**
  148112. * Class used to enable access to IndexedDB
  148113. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148114. */
  148115. export class Database implements IOfflineProvider {
  148116. private _callbackManifestChecked;
  148117. private _currentSceneUrl;
  148118. private _db;
  148119. private _enableSceneOffline;
  148120. private _enableTexturesOffline;
  148121. private _manifestVersionFound;
  148122. private _mustUpdateRessources;
  148123. private _hasReachedQuota;
  148124. private _isSupported;
  148125. private _idbFactory;
  148126. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148127. private static IsUASupportingBlobStorage;
  148128. /**
  148129. * Gets a boolean indicating if Database storate is enabled (off by default)
  148130. */
  148131. static IDBStorageEnabled: boolean;
  148132. /**
  148133. * Gets a boolean indicating if scene must be saved in the database
  148134. */
  148135. get enableSceneOffline(): boolean;
  148136. /**
  148137. * Gets a boolean indicating if textures must be saved in the database
  148138. */
  148139. get enableTexturesOffline(): boolean;
  148140. /**
  148141. * Creates a new Database
  148142. * @param urlToScene defines the url to load the scene
  148143. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148144. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148145. */
  148146. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148147. private static _ParseURL;
  148148. private static _ReturnFullUrlLocation;
  148149. private _checkManifestFile;
  148150. /**
  148151. * Open the database and make it available
  148152. * @param successCallback defines the callback to call on success
  148153. * @param errorCallback defines the callback to call on error
  148154. */
  148155. open(successCallback: () => void, errorCallback: () => void): void;
  148156. /**
  148157. * Loads an image from the database
  148158. * @param url defines the url to load from
  148159. * @param image defines the target DOM image
  148160. */
  148161. loadImage(url: string, image: HTMLImageElement): void;
  148162. private _loadImageFromDBAsync;
  148163. private _saveImageIntoDBAsync;
  148164. private _checkVersionFromDB;
  148165. private _loadVersionFromDBAsync;
  148166. private _saveVersionIntoDBAsync;
  148167. /**
  148168. * Loads a file from database
  148169. * @param url defines the URL to load from
  148170. * @param sceneLoaded defines a callback to call on success
  148171. * @param progressCallBack defines a callback to call when progress changed
  148172. * @param errorCallback defines a callback to call on error
  148173. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148174. */
  148175. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148176. private _loadFileAsync;
  148177. private _saveFileAsync;
  148178. /**
  148179. * Validates if xhr data is correct
  148180. * @param xhr defines the request to validate
  148181. * @param dataType defines the expected data type
  148182. * @returns true if data is correct
  148183. */
  148184. private static _ValidateXHRData;
  148185. }
  148186. }
  148187. declare module BABYLON {
  148188. /** @hidden */
  148189. export var gpuUpdateParticlesPixelShader: {
  148190. name: string;
  148191. shader: string;
  148192. };
  148193. }
  148194. declare module BABYLON {
  148195. /** @hidden */
  148196. export var gpuUpdateParticlesVertexShader: {
  148197. name: string;
  148198. shader: string;
  148199. };
  148200. }
  148201. declare module BABYLON {
  148202. /** @hidden */
  148203. export var clipPlaneFragmentDeclaration2: {
  148204. name: string;
  148205. shader: string;
  148206. };
  148207. }
  148208. declare module BABYLON {
  148209. /** @hidden */
  148210. export var gpuRenderParticlesPixelShader: {
  148211. name: string;
  148212. shader: string;
  148213. };
  148214. }
  148215. declare module BABYLON {
  148216. /** @hidden */
  148217. export var clipPlaneVertexDeclaration2: {
  148218. name: string;
  148219. shader: string;
  148220. };
  148221. }
  148222. declare module BABYLON {
  148223. /** @hidden */
  148224. export var gpuRenderParticlesVertexShader: {
  148225. name: string;
  148226. shader: string;
  148227. };
  148228. }
  148229. declare module BABYLON {
  148230. /**
  148231. * This represents a GPU particle system in Babylon
  148232. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148233. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148234. */
  148235. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148236. /**
  148237. * The layer mask we are rendering the particles through.
  148238. */
  148239. layerMask: number;
  148240. private _capacity;
  148241. private _activeCount;
  148242. private _currentActiveCount;
  148243. private _accumulatedCount;
  148244. private _renderEffect;
  148245. private _updateEffect;
  148246. private _buffer0;
  148247. private _buffer1;
  148248. private _spriteBuffer;
  148249. private _updateVAO;
  148250. private _renderVAO;
  148251. private _targetIndex;
  148252. private _sourceBuffer;
  148253. private _targetBuffer;
  148254. private _currentRenderId;
  148255. private _started;
  148256. private _stopped;
  148257. private _timeDelta;
  148258. private _randomTexture;
  148259. private _randomTexture2;
  148260. private _attributesStrideSize;
  148261. private _updateEffectOptions;
  148262. private _randomTextureSize;
  148263. private _actualFrame;
  148264. private _customEffect;
  148265. private readonly _rawTextureWidth;
  148266. /**
  148267. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148268. */
  148269. static get IsSupported(): boolean;
  148270. /**
  148271. * An event triggered when the system is disposed.
  148272. */
  148273. onDisposeObservable: Observable<IParticleSystem>;
  148274. /**
  148275. * Gets the maximum number of particles active at the same time.
  148276. * @returns The max number of active particles.
  148277. */
  148278. getCapacity(): number;
  148279. /**
  148280. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148281. * to override the particles.
  148282. */
  148283. forceDepthWrite: boolean;
  148284. /**
  148285. * Gets or set the number of active particles
  148286. */
  148287. get activeParticleCount(): number;
  148288. set activeParticleCount(value: number);
  148289. private _preWarmDone;
  148290. /**
  148291. * Specifies if the particles are updated in emitter local space or world space.
  148292. */
  148293. isLocal: boolean;
  148294. /** Gets or sets a matrix to use to compute projection */
  148295. defaultProjectionMatrix: Matrix;
  148296. /**
  148297. * Is this system ready to be used/rendered
  148298. * @return true if the system is ready
  148299. */
  148300. isReady(): boolean;
  148301. /**
  148302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148303. * @returns True if it has been started, otherwise false.
  148304. */
  148305. isStarted(): boolean;
  148306. /**
  148307. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148308. * @returns True if it has been stopped, otherwise false.
  148309. */
  148310. isStopped(): boolean;
  148311. /**
  148312. * Gets a boolean indicating that the system is stopping
  148313. * @returns true if the system is currently stopping
  148314. */
  148315. isStopping(): boolean;
  148316. /**
  148317. * Gets the number of particles active at the same time.
  148318. * @returns The number of active particles.
  148319. */
  148320. getActiveCount(): number;
  148321. /**
  148322. * Starts the particle system and begins to emit
  148323. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148324. */
  148325. start(delay?: number): void;
  148326. /**
  148327. * Stops the particle system.
  148328. */
  148329. stop(): void;
  148330. /**
  148331. * Remove all active particles
  148332. */
  148333. reset(): void;
  148334. /**
  148335. * Returns the string "GPUParticleSystem"
  148336. * @returns a string containing the class name
  148337. */
  148338. getClassName(): string;
  148339. /**
  148340. * Gets the custom effect used to render the particles
  148341. * @param blendMode Blend mode for which the effect should be retrieved
  148342. * @returns The effect
  148343. */
  148344. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148345. /**
  148346. * Sets the custom effect used to render the particles
  148347. * @param effect The effect to set
  148348. * @param blendMode Blend mode for which the effect should be set
  148349. */
  148350. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148351. /** @hidden */
  148352. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148353. /**
  148354. * Observable that will be called just before the particles are drawn
  148355. */
  148356. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148357. /**
  148358. * Gets the name of the particle vertex shader
  148359. */
  148360. get vertexShaderName(): string;
  148361. private _colorGradientsTexture;
  148362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148363. /**
  148364. * Adds a new color gradient
  148365. * @param gradient defines the gradient to use (between 0 and 1)
  148366. * @param color1 defines the color to affect to the specified gradient
  148367. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148368. * @returns the current particle system
  148369. */
  148370. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148371. private _refreshColorGradient;
  148372. /** Force the system to rebuild all gradients that need to be resync */
  148373. forceRefreshGradients(): void;
  148374. /**
  148375. * Remove a specific color gradient
  148376. * @param gradient defines the gradient to remove
  148377. * @returns the current particle system
  148378. */
  148379. removeColorGradient(gradient: number): GPUParticleSystem;
  148380. private _angularSpeedGradientsTexture;
  148381. private _sizeGradientsTexture;
  148382. private _velocityGradientsTexture;
  148383. private _limitVelocityGradientsTexture;
  148384. private _dragGradientsTexture;
  148385. private _addFactorGradient;
  148386. /**
  148387. * Adds a new size gradient
  148388. * @param gradient defines the gradient to use (between 0 and 1)
  148389. * @param factor defines the size factor to affect to the specified gradient
  148390. * @returns the current particle system
  148391. */
  148392. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148393. /**
  148394. * Remove a specific size gradient
  148395. * @param gradient defines the gradient to remove
  148396. * @returns the current particle system
  148397. */
  148398. removeSizeGradient(gradient: number): GPUParticleSystem;
  148399. private _refreshFactorGradient;
  148400. /**
  148401. * Adds a new angular speed gradient
  148402. * @param gradient defines the gradient to use (between 0 and 1)
  148403. * @param factor defines the angular speed to affect to the specified gradient
  148404. * @returns the current particle system
  148405. */
  148406. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148407. /**
  148408. * Remove a specific angular speed gradient
  148409. * @param gradient defines the gradient to remove
  148410. * @returns the current particle system
  148411. */
  148412. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148413. /**
  148414. * Adds a new velocity gradient
  148415. * @param gradient defines the gradient to use (between 0 and 1)
  148416. * @param factor defines the velocity to affect to the specified gradient
  148417. * @returns the current particle system
  148418. */
  148419. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148420. /**
  148421. * Remove a specific velocity gradient
  148422. * @param gradient defines the gradient to remove
  148423. * @returns the current particle system
  148424. */
  148425. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148426. /**
  148427. * Adds a new limit velocity gradient
  148428. * @param gradient defines the gradient to use (between 0 and 1)
  148429. * @param factor defines the limit velocity value to affect to the specified gradient
  148430. * @returns the current particle system
  148431. */
  148432. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148433. /**
  148434. * Remove a specific limit velocity gradient
  148435. * @param gradient defines the gradient to remove
  148436. * @returns the current particle system
  148437. */
  148438. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148439. /**
  148440. * Adds a new drag gradient
  148441. * @param gradient defines the gradient to use (between 0 and 1)
  148442. * @param factor defines the drag value to affect to the specified gradient
  148443. * @returns the current particle system
  148444. */
  148445. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148446. /**
  148447. * Remove a specific drag gradient
  148448. * @param gradient defines the gradient to remove
  148449. * @returns the current particle system
  148450. */
  148451. removeDragGradient(gradient: number): GPUParticleSystem;
  148452. /**
  148453. * Not supported by GPUParticleSystem
  148454. * @param gradient defines the gradient to use (between 0 and 1)
  148455. * @param factor defines the emit rate value to affect to the specified gradient
  148456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148457. * @returns the current particle system
  148458. */
  148459. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148460. /**
  148461. * Not supported by GPUParticleSystem
  148462. * @param gradient defines the gradient to remove
  148463. * @returns the current particle system
  148464. */
  148465. removeEmitRateGradient(gradient: number): IParticleSystem;
  148466. /**
  148467. * Not supported by GPUParticleSystem
  148468. * @param gradient defines the gradient to use (between 0 and 1)
  148469. * @param factor defines the start size value to affect to the specified gradient
  148470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148471. * @returns the current particle system
  148472. */
  148473. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148474. /**
  148475. * Not supported by GPUParticleSystem
  148476. * @param gradient defines the gradient to remove
  148477. * @returns the current particle system
  148478. */
  148479. removeStartSizeGradient(gradient: number): IParticleSystem;
  148480. /**
  148481. * Not supported by GPUParticleSystem
  148482. * @param gradient defines the gradient to use (between 0 and 1)
  148483. * @param min defines the color remap minimal range
  148484. * @param max defines the color remap maximal range
  148485. * @returns the current particle system
  148486. */
  148487. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148488. /**
  148489. * Not supported by GPUParticleSystem
  148490. * @param gradient defines the gradient to remove
  148491. * @returns the current particle system
  148492. */
  148493. removeColorRemapGradient(): IParticleSystem;
  148494. /**
  148495. * Not supported by GPUParticleSystem
  148496. * @param gradient defines the gradient to use (between 0 and 1)
  148497. * @param min defines the alpha remap minimal range
  148498. * @param max defines the alpha remap maximal range
  148499. * @returns the current particle system
  148500. */
  148501. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148502. /**
  148503. * Not supported by GPUParticleSystem
  148504. * @param gradient defines the gradient to remove
  148505. * @returns the current particle system
  148506. */
  148507. removeAlphaRemapGradient(): IParticleSystem;
  148508. /**
  148509. * Not supported by GPUParticleSystem
  148510. * @param gradient defines the gradient to use (between 0 and 1)
  148511. * @param color defines the color to affect to the specified gradient
  148512. * @returns the current particle system
  148513. */
  148514. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148515. /**
  148516. * Not supported by GPUParticleSystem
  148517. * @param gradient defines the gradient to remove
  148518. * @returns the current particle system
  148519. */
  148520. removeRampGradient(): IParticleSystem;
  148521. /**
  148522. * Not supported by GPUParticleSystem
  148523. * @returns the list of ramp gradients
  148524. */
  148525. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148526. /**
  148527. * Not supported by GPUParticleSystem
  148528. * Gets or sets a boolean indicating that ramp gradients must be used
  148529. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148530. */
  148531. get useRampGradients(): boolean;
  148532. set useRampGradients(value: boolean);
  148533. /**
  148534. * Not supported by GPUParticleSystem
  148535. * @param gradient defines the gradient to use (between 0 and 1)
  148536. * @param factor defines the life time factor to affect to the specified gradient
  148537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148538. * @returns the current particle system
  148539. */
  148540. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148541. /**
  148542. * Not supported by GPUParticleSystem
  148543. * @param gradient defines the gradient to remove
  148544. * @returns the current particle system
  148545. */
  148546. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148547. /**
  148548. * Instantiates a GPU particle system.
  148549. * 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.
  148550. * @param name The name of the particle system
  148551. * @param options The options used to create the system
  148552. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148553. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148554. * @param customEffect a custom effect used to change the way particles are rendered by default
  148555. */
  148556. constructor(name: string, options: Partial<{
  148557. capacity: number;
  148558. randomTextureSize: number;
  148559. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148560. protected _reset(): void;
  148561. private _createUpdateVAO;
  148562. private _createRenderVAO;
  148563. private _initialize;
  148564. /** @hidden */
  148565. _recreateUpdateEffect(): void;
  148566. private _getEffect;
  148567. /**
  148568. * Fill the defines array according to the current settings of the particle system
  148569. * @param defines Array to be updated
  148570. * @param blendMode blend mode to take into account when updating the array
  148571. */
  148572. fillDefines(defines: Array<string>, blendMode?: number): void;
  148573. /**
  148574. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148575. * @param uniforms Uniforms array to fill
  148576. * @param attributes Attributes array to fill
  148577. * @param samplers Samplers array to fill
  148578. */
  148579. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148580. /** @hidden */
  148581. _recreateRenderEffect(): Effect;
  148582. /**
  148583. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148584. * @param preWarm defines if we are in the pre-warmimg phase
  148585. */
  148586. animate(preWarm?: boolean): void;
  148587. private _createFactorGradientTexture;
  148588. private _createSizeGradientTexture;
  148589. private _createAngularSpeedGradientTexture;
  148590. private _createVelocityGradientTexture;
  148591. private _createLimitVelocityGradientTexture;
  148592. private _createDragGradientTexture;
  148593. private _createColorGradientTexture;
  148594. /**
  148595. * Renders the particle system in its current state
  148596. * @param preWarm defines if the system should only update the particles but not render them
  148597. * @returns the current number of particles
  148598. */
  148599. render(preWarm?: boolean): number;
  148600. /**
  148601. * Rebuilds the particle system
  148602. */
  148603. rebuild(): void;
  148604. private _releaseBuffers;
  148605. private _releaseVAOs;
  148606. /**
  148607. * Disposes the particle system and free the associated resources
  148608. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148609. */
  148610. dispose(disposeTexture?: boolean): void;
  148611. /**
  148612. * Clones the particle system.
  148613. * @param name The name of the cloned object
  148614. * @param newEmitter The new emitter to use
  148615. * @returns the cloned particle system
  148616. */
  148617. clone(name: string, newEmitter: any): GPUParticleSystem;
  148618. /**
  148619. * Serializes the particle system to a JSON object
  148620. * @param serializeTexture defines if the texture must be serialized as well
  148621. * @returns the JSON object
  148622. */
  148623. serialize(serializeTexture?: boolean): any;
  148624. /**
  148625. * Parses a JSON object to create a GPU particle system.
  148626. * @param parsedParticleSystem The JSON object to parse
  148627. * @param sceneOrEngine The scene or the engine to create the particle system in
  148628. * @param rootUrl The root url to use to load external dependencies like texture
  148629. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148630. * @returns the parsed GPU particle system
  148631. */
  148632. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148633. }
  148634. }
  148635. declare module BABYLON {
  148636. /**
  148637. * Represents a set of particle systems working together to create a specific effect
  148638. */
  148639. export class ParticleSystemSet implements IDisposable {
  148640. /**
  148641. * Gets or sets base Assets URL
  148642. */
  148643. static BaseAssetsUrl: string;
  148644. private _emitterCreationOptions;
  148645. private _emitterNode;
  148646. /**
  148647. * Gets the particle system list
  148648. */
  148649. systems: IParticleSystem[];
  148650. /**
  148651. * Gets the emitter node used with this set
  148652. */
  148653. get emitterNode(): Nullable<TransformNode>;
  148654. /**
  148655. * Creates a new emitter mesh as a sphere
  148656. * @param options defines the options used to create the sphere
  148657. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148658. * @param scene defines the hosting scene
  148659. */
  148660. setEmitterAsSphere(options: {
  148661. diameter: number;
  148662. segments: number;
  148663. color: Color3;
  148664. }, renderingGroupId: number, scene: Scene): void;
  148665. /**
  148666. * Starts all particle systems of the set
  148667. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148668. */
  148669. start(emitter?: AbstractMesh): void;
  148670. /**
  148671. * Release all associated resources
  148672. */
  148673. dispose(): void;
  148674. /**
  148675. * Serialize the set into a JSON compatible object
  148676. * @param serializeTexture defines if the texture must be serialized as well
  148677. * @returns a JSON compatible representation of the set
  148678. */
  148679. serialize(serializeTexture?: boolean): any;
  148680. /**
  148681. * Parse a new ParticleSystemSet from a serialized source
  148682. * @param data defines a JSON compatible representation of the set
  148683. * @param scene defines the hosting scene
  148684. * @param gpu defines if we want GPU particles or CPU particles
  148685. * @returns a new ParticleSystemSet
  148686. */
  148687. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148688. }
  148689. }
  148690. declare module BABYLON {
  148691. /**
  148692. * This class is made for on one-liner static method to help creating particle system set.
  148693. */
  148694. export class ParticleHelper {
  148695. /**
  148696. * Gets or sets base Assets URL
  148697. */
  148698. static BaseAssetsUrl: string;
  148699. /** Define the Url to load snippets */
  148700. static SnippetUrl: string;
  148701. /**
  148702. * Create a default particle system that you can tweak
  148703. * @param emitter defines the emitter to use
  148704. * @param capacity defines the system capacity (default is 500 particles)
  148705. * @param scene defines the hosting scene
  148706. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148707. * @returns the new Particle system
  148708. */
  148709. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148710. /**
  148711. * This is the main static method (one-liner) of this helper to create different particle systems
  148712. * @param type This string represents the type to the particle system to create
  148713. * @param scene The scene where the particle system should live
  148714. * @param gpu If the system will use gpu
  148715. * @returns the ParticleSystemSet created
  148716. */
  148717. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148718. /**
  148719. * Static function used to export a particle system to a ParticleSystemSet variable.
  148720. * Please note that the emitter shape is not exported
  148721. * @param systems defines the particle systems to export
  148722. * @returns the created particle system set
  148723. */
  148724. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148725. /**
  148726. * Creates a particle system from a snippet saved in a remote file
  148727. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148728. * @param url defines the url to load from
  148729. * @param scene defines the hosting scene
  148730. * @param gpu If the system will use gpu
  148731. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148732. * @returns a promise that will resolve to the new particle system
  148733. */
  148734. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148735. /**
  148736. * Creates a particle system from a snippet saved by the particle system editor
  148737. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148738. * @param scene defines the hosting scene
  148739. * @param gpu If the system will use gpu
  148740. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148741. * @returns a promise that will resolve to the new particle system
  148742. */
  148743. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148744. }
  148745. }
  148746. declare module BABYLON {
  148747. interface Engine {
  148748. /**
  148749. * Create an effect to use with particle systems.
  148750. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148751. * the particle system for which you want to create a custom effect in the last parameter
  148752. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148753. * @param uniformsNames defines a list of attribute names
  148754. * @param samplers defines an array of string used to represent textures
  148755. * @param defines defines the string containing the defines to use to compile the shaders
  148756. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148757. * @param onCompiled defines a function to call when the effect creation is successful
  148758. * @param onError defines a function to call when the effect creation has failed
  148759. * @param particleSystem the particle system you want to create the effect for
  148760. * @returns the new Effect
  148761. */
  148762. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148763. }
  148764. interface Mesh {
  148765. /**
  148766. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148767. * @returns an array of IParticleSystem
  148768. */
  148769. getEmittedParticleSystems(): IParticleSystem[];
  148770. /**
  148771. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148772. * @returns an array of IParticleSystem
  148773. */
  148774. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148775. }
  148776. }
  148777. declare module BABYLON {
  148778. /** Defines the 4 color options */
  148779. export enum PointColor {
  148780. /** color value */
  148781. Color = 2,
  148782. /** uv value */
  148783. UV = 1,
  148784. /** random value */
  148785. Random = 0,
  148786. /** stated value */
  148787. Stated = 3
  148788. }
  148789. /**
  148790. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148791. * 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.
  148792. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148793. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148794. *
  148795. * Full documentation here : TO BE ENTERED
  148796. */
  148797. export class PointsCloudSystem implements IDisposable {
  148798. /**
  148799. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148800. * Example : var p = SPS.particles[i];
  148801. */
  148802. particles: CloudPoint[];
  148803. /**
  148804. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148805. */
  148806. nbParticles: number;
  148807. /**
  148808. * This a counter for your own usage. It's not set by any SPS functions.
  148809. */
  148810. counter: number;
  148811. /**
  148812. * The PCS name. This name is also given to the underlying mesh.
  148813. */
  148814. name: string;
  148815. /**
  148816. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148817. */
  148818. mesh: Mesh;
  148819. /**
  148820. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148821. * Please read :
  148822. */
  148823. vars: any;
  148824. /**
  148825. * @hidden
  148826. */
  148827. _size: number;
  148828. private _scene;
  148829. private _promises;
  148830. private _positions;
  148831. private _indices;
  148832. private _normals;
  148833. private _colors;
  148834. private _uvs;
  148835. private _indices32;
  148836. private _positions32;
  148837. private _colors32;
  148838. private _uvs32;
  148839. private _updatable;
  148840. private _isVisibilityBoxLocked;
  148841. private _alwaysVisible;
  148842. private _groups;
  148843. private _groupCounter;
  148844. private _computeParticleColor;
  148845. private _computeParticleTexture;
  148846. private _computeParticleRotation;
  148847. private _computeBoundingBox;
  148848. private _isReady;
  148849. /**
  148850. * Creates a PCS (Points Cloud System) object
  148851. * @param name (String) is the PCS name, this will be the underlying mesh name
  148852. * @param pointSize (number) is the size for each point
  148853. * @param scene (Scene) is the scene in which the PCS is added
  148854. * @param options defines the options of the PCS e.g.
  148855. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148856. */
  148857. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148858. updatable?: boolean;
  148859. });
  148860. /**
  148861. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148862. * If no points were added to the PCS, the returned mesh is just a single point.
  148863. * @returns a promise for the created mesh
  148864. */
  148865. buildMeshAsync(): Promise<Mesh>;
  148866. /**
  148867. * @hidden
  148868. */
  148869. private _buildMesh;
  148870. private _addParticle;
  148871. private _randomUnitVector;
  148872. private _getColorIndicesForCoord;
  148873. private _setPointsColorOrUV;
  148874. private _colorFromTexture;
  148875. private _calculateDensity;
  148876. /**
  148877. * Adds points to the PCS in random positions within a unit sphere
  148878. * @param nb (positive integer) the number of particles to be created from this model
  148879. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148880. * @returns the number of groups in the system
  148881. */
  148882. addPoints(nb: number, pointFunction?: any): number;
  148883. /**
  148884. * Adds points to the PCS from the surface of the model shape
  148885. * @param mesh is any Mesh object that will be used as a surface model for the points
  148886. * @param nb (positive integer) the number of particles to be created from this model
  148887. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148888. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148889. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148890. * @returns the number of groups in the system
  148891. */
  148892. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148893. /**
  148894. * Adds points to the PCS inside the model shape
  148895. * @param mesh is any Mesh object that will be used as a surface model for the points
  148896. * @param nb (positive integer) the number of particles to be created from this model
  148897. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148898. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148899. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148900. * @returns the number of groups in the system
  148901. */
  148902. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148903. /**
  148904. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148905. * This method calls `updateParticle()` for each particle of the SPS.
  148906. * For an animated SPS, it is usually called within the render loop.
  148907. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148908. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148909. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148910. * @returns the PCS.
  148911. */
  148912. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148913. /**
  148914. * Disposes the PCS.
  148915. */
  148916. dispose(): void;
  148917. /**
  148918. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148919. * doc :
  148920. * @returns the PCS.
  148921. */
  148922. refreshVisibleSize(): PointsCloudSystem;
  148923. /**
  148924. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148925. * @param size the size (float) of the visibility box
  148926. * note : this doesn't lock the PCS mesh bounding box.
  148927. * doc :
  148928. */
  148929. setVisibilityBox(size: number): void;
  148930. /**
  148931. * Gets whether the PCS is always visible or not
  148932. * doc :
  148933. */
  148934. get isAlwaysVisible(): boolean;
  148935. /**
  148936. * Sets the PCS as always visible or not
  148937. * doc :
  148938. */
  148939. set isAlwaysVisible(val: boolean);
  148940. /**
  148941. * Tells to `setParticles()` to compute the particle rotations or not
  148942. * Default value : false. The PCS is faster when it's set to false
  148943. * Note : particle rotations are only applied to parent particles
  148944. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148945. */
  148946. set computeParticleRotation(val: boolean);
  148947. /**
  148948. * Tells to `setParticles()` to compute the particle colors or not.
  148949. * Default value : true. The PCS is faster when it's set to false.
  148950. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148951. */
  148952. set computeParticleColor(val: boolean);
  148953. set computeParticleTexture(val: boolean);
  148954. /**
  148955. * Gets if `setParticles()` computes the particle colors or not.
  148956. * Default value : false. The PCS is faster when it's set to false.
  148957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148958. */
  148959. get computeParticleColor(): boolean;
  148960. /**
  148961. * Gets if `setParticles()` computes the particle textures or not.
  148962. * Default value : false. The PCS is faster when it's set to false.
  148963. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148964. */
  148965. get computeParticleTexture(): boolean;
  148966. /**
  148967. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148968. */
  148969. set computeBoundingBox(val: boolean);
  148970. /**
  148971. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148972. */
  148973. get computeBoundingBox(): boolean;
  148974. /**
  148975. * This function does nothing. It may be overwritten to set all the particle first values.
  148976. * The PCS doesn't call this function, you may have to call it by your own.
  148977. * doc :
  148978. */
  148979. initParticles(): void;
  148980. /**
  148981. * This function does nothing. It may be overwritten to recycle a particle
  148982. * The PCS doesn't call this function, you can to call it
  148983. * doc :
  148984. * @param particle The particle to recycle
  148985. * @returns the recycled particle
  148986. */
  148987. recycleParticle(particle: CloudPoint): CloudPoint;
  148988. /**
  148989. * Updates a particle : this function should be overwritten by the user.
  148990. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148991. * doc :
  148992. * @example : just set a particle position or velocity and recycle conditions
  148993. * @param particle The particle to update
  148994. * @returns the updated particle
  148995. */
  148996. updateParticle(particle: CloudPoint): CloudPoint;
  148997. /**
  148998. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148999. * This does nothing and may be overwritten by the user.
  149000. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149001. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149002. * @param update the boolean update value actually passed to setParticles()
  149003. */
  149004. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149005. /**
  149006. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149007. * This will be passed three parameters.
  149008. * This does nothing and may be overwritten by the user.
  149009. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149010. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149011. * @param update the boolean update value actually passed to setParticles()
  149012. */
  149013. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149014. }
  149015. }
  149016. declare module BABYLON {
  149017. /**
  149018. * Represents one particle of a points cloud system.
  149019. */
  149020. export class CloudPoint {
  149021. /**
  149022. * particle global index
  149023. */
  149024. idx: number;
  149025. /**
  149026. * The color of the particle
  149027. */
  149028. color: Nullable<Color4>;
  149029. /**
  149030. * The world space position of the particle.
  149031. */
  149032. position: Vector3;
  149033. /**
  149034. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149035. */
  149036. rotation: Vector3;
  149037. /**
  149038. * The world space rotation quaternion of the particle.
  149039. */
  149040. rotationQuaternion: Nullable<Quaternion>;
  149041. /**
  149042. * The uv of the particle.
  149043. */
  149044. uv: Nullable<Vector2>;
  149045. /**
  149046. * The current speed of the particle.
  149047. */
  149048. velocity: Vector3;
  149049. /**
  149050. * The pivot point in the particle local space.
  149051. */
  149052. pivot: Vector3;
  149053. /**
  149054. * Must the particle be translated from its pivot point in its local space ?
  149055. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149056. * Default : false
  149057. */
  149058. translateFromPivot: boolean;
  149059. /**
  149060. * Index of this particle in the global "positions" array (Internal use)
  149061. * @hidden
  149062. */
  149063. _pos: number;
  149064. /**
  149065. * @hidden Index of this particle in the global "indices" array (Internal use)
  149066. */
  149067. _ind: number;
  149068. /**
  149069. * Group this particle belongs to
  149070. */
  149071. _group: PointsGroup;
  149072. /**
  149073. * Group id of this particle
  149074. */
  149075. groupId: number;
  149076. /**
  149077. * Index of the particle in its group id (Internal use)
  149078. */
  149079. idxInGroup: number;
  149080. /**
  149081. * @hidden Particle BoundingInfo object (Internal use)
  149082. */
  149083. _boundingInfo: BoundingInfo;
  149084. /**
  149085. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149086. */
  149087. _pcs: PointsCloudSystem;
  149088. /**
  149089. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149090. */
  149091. _stillInvisible: boolean;
  149092. /**
  149093. * @hidden Last computed particle rotation matrix
  149094. */
  149095. _rotationMatrix: number[];
  149096. /**
  149097. * Parent particle Id, if any.
  149098. * Default null.
  149099. */
  149100. parentId: Nullable<number>;
  149101. /**
  149102. * @hidden Internal global position in the PCS.
  149103. */
  149104. _globalPosition: Vector3;
  149105. /**
  149106. * Creates a Point Cloud object.
  149107. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149108. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149109. * @param group (PointsGroup) is the group the particle belongs to
  149110. * @param groupId (integer) is the group identifier in the PCS.
  149111. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149112. * @param pcs defines the PCS it is associated to
  149113. */
  149114. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149115. /**
  149116. * get point size
  149117. */
  149118. get size(): Vector3;
  149119. /**
  149120. * Set point size
  149121. */
  149122. set size(scale: Vector3);
  149123. /**
  149124. * Legacy support, changed quaternion to rotationQuaternion
  149125. */
  149126. get quaternion(): Nullable<Quaternion>;
  149127. /**
  149128. * Legacy support, changed quaternion to rotationQuaternion
  149129. */
  149130. set quaternion(q: Nullable<Quaternion>);
  149131. /**
  149132. * Returns a boolean. True if the particle intersects a mesh, else false
  149133. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149134. * @param target is the object (point or mesh) what the intersection is computed against
  149135. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149136. * @returns true if it intersects
  149137. */
  149138. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149139. /**
  149140. * get the rotation matrix of the particle
  149141. * @hidden
  149142. */
  149143. getRotationMatrix(m: Matrix): void;
  149144. }
  149145. /**
  149146. * Represents a group of points in a points cloud system
  149147. * * PCS internal tool, don't use it manually.
  149148. */
  149149. export class PointsGroup {
  149150. /**
  149151. * The group id
  149152. * @hidden
  149153. */
  149154. groupID: number;
  149155. /**
  149156. * image data for group (internal use)
  149157. * @hidden
  149158. */
  149159. _groupImageData: Nullable<ArrayBufferView>;
  149160. /**
  149161. * Image Width (internal use)
  149162. * @hidden
  149163. */
  149164. _groupImgWidth: number;
  149165. /**
  149166. * Image Height (internal use)
  149167. * @hidden
  149168. */
  149169. _groupImgHeight: number;
  149170. /**
  149171. * Custom position function (internal use)
  149172. * @hidden
  149173. */
  149174. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149175. /**
  149176. * density per facet for surface points
  149177. * @hidden
  149178. */
  149179. _groupDensity: number[];
  149180. /**
  149181. * Only when points are colored by texture carries pointer to texture list array
  149182. * @hidden
  149183. */
  149184. _textureNb: number;
  149185. /**
  149186. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149187. * PCS internal tool, don't use it manually.
  149188. * @hidden
  149189. */
  149190. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149191. }
  149192. }
  149193. declare module BABYLON {
  149194. interface Scene {
  149195. /** @hidden (Backing field) */
  149196. _physicsEngine: Nullable<IPhysicsEngine>;
  149197. /** @hidden */
  149198. _physicsTimeAccumulator: number;
  149199. /**
  149200. * Gets the current physics engine
  149201. * @returns a IPhysicsEngine or null if none attached
  149202. */
  149203. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149204. /**
  149205. * Enables physics to the current scene
  149206. * @param gravity defines the scene's gravity for the physics engine
  149207. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149208. * @return a boolean indicating if the physics engine was initialized
  149209. */
  149210. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149211. /**
  149212. * Disables and disposes the physics engine associated with the scene
  149213. */
  149214. disablePhysicsEngine(): void;
  149215. /**
  149216. * Gets a boolean indicating if there is an active physics engine
  149217. * @returns a boolean indicating if there is an active physics engine
  149218. */
  149219. isPhysicsEnabled(): boolean;
  149220. /**
  149221. * Deletes a physics compound impostor
  149222. * @param compound defines the compound to delete
  149223. */
  149224. deleteCompoundImpostor(compound: any): void;
  149225. /**
  149226. * An event triggered when physic simulation is about to be run
  149227. */
  149228. onBeforePhysicsObservable: Observable<Scene>;
  149229. /**
  149230. * An event triggered when physic simulation has been done
  149231. */
  149232. onAfterPhysicsObservable: Observable<Scene>;
  149233. }
  149234. interface AbstractMesh {
  149235. /** @hidden */
  149236. _physicsImpostor: Nullable<PhysicsImpostor>;
  149237. /**
  149238. * Gets or sets impostor used for physic simulation
  149239. * @see https://doc.babylonjs.com/features/physics_engine
  149240. */
  149241. physicsImpostor: Nullable<PhysicsImpostor>;
  149242. /**
  149243. * Gets the current physics impostor
  149244. * @see https://doc.babylonjs.com/features/physics_engine
  149245. * @returns a physics impostor or null
  149246. */
  149247. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149248. /** Apply a physic impulse to the mesh
  149249. * @param force defines the force to apply
  149250. * @param contactPoint defines where to apply the force
  149251. * @returns the current mesh
  149252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149253. */
  149254. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149255. /**
  149256. * Creates a physic joint between two meshes
  149257. * @param otherMesh defines the other mesh to use
  149258. * @param pivot1 defines the pivot to use on this mesh
  149259. * @param pivot2 defines the pivot to use on the other mesh
  149260. * @param options defines additional options (can be plugin dependent)
  149261. * @returns the current mesh
  149262. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149263. */
  149264. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149265. /** @hidden */
  149266. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149267. }
  149268. /**
  149269. * Defines the physics engine scene component responsible to manage a physics engine
  149270. */
  149271. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149272. /**
  149273. * The component name helpful to identify the component in the list of scene components.
  149274. */
  149275. readonly name: string;
  149276. /**
  149277. * The scene the component belongs to.
  149278. */
  149279. scene: Scene;
  149280. /**
  149281. * Creates a new instance of the component for the given scene
  149282. * @param scene Defines the scene to register the component in
  149283. */
  149284. constructor(scene: Scene);
  149285. /**
  149286. * Registers the component in a given scene
  149287. */
  149288. register(): void;
  149289. /**
  149290. * Rebuilds the elements related to this component in case of
  149291. * context lost for instance.
  149292. */
  149293. rebuild(): void;
  149294. /**
  149295. * Disposes the component and the associated ressources
  149296. */
  149297. dispose(): void;
  149298. }
  149299. }
  149300. declare module BABYLON {
  149301. /**
  149302. * A helper for physics simulations
  149303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149304. */
  149305. export class PhysicsHelper {
  149306. private _scene;
  149307. private _physicsEngine;
  149308. /**
  149309. * Initializes the Physics helper
  149310. * @param scene Babylon.js scene
  149311. */
  149312. constructor(scene: Scene);
  149313. /**
  149314. * Applies a radial explosion impulse
  149315. * @param origin the origin of the explosion
  149316. * @param radiusOrEventOptions the radius or the options of radial explosion
  149317. * @param strength the explosion strength
  149318. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149319. * @returns A physics radial explosion event, or null
  149320. */
  149321. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149322. /**
  149323. * Applies a radial explosion force
  149324. * @param origin the origin of the explosion
  149325. * @param radiusOrEventOptions the radius or the options of radial explosion
  149326. * @param strength the explosion strength
  149327. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149328. * @returns A physics radial explosion event, or null
  149329. */
  149330. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149331. /**
  149332. * Creates a gravitational field
  149333. * @param origin the origin of the explosion
  149334. * @param radiusOrEventOptions the radius or the options of radial explosion
  149335. * @param strength the explosion strength
  149336. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149337. * @returns A physics gravitational field event, or null
  149338. */
  149339. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149340. /**
  149341. * Creates a physics updraft event
  149342. * @param origin the origin of the updraft
  149343. * @param radiusOrEventOptions the radius or the options of the updraft
  149344. * @param strength the strength of the updraft
  149345. * @param height the height of the updraft
  149346. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149347. * @returns A physics updraft event, or null
  149348. */
  149349. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149350. /**
  149351. * Creates a physics vortex event
  149352. * @param origin the of the vortex
  149353. * @param radiusOrEventOptions the radius or the options of the vortex
  149354. * @param strength the strength of the vortex
  149355. * @param height the height of the vortex
  149356. * @returns a Physics vortex event, or null
  149357. * A physics vortex event or null
  149358. */
  149359. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149360. }
  149361. /**
  149362. * Represents a physics radial explosion event
  149363. */
  149364. class PhysicsRadialExplosionEvent {
  149365. private _scene;
  149366. private _options;
  149367. private _sphere;
  149368. private _dataFetched;
  149369. /**
  149370. * Initializes a radial explosioin event
  149371. * @param _scene BabylonJS scene
  149372. * @param _options The options for the vortex event
  149373. */
  149374. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149375. /**
  149376. * Returns the data related to the radial explosion event (sphere).
  149377. * @returns The radial explosion event data
  149378. */
  149379. getData(): PhysicsRadialExplosionEventData;
  149380. /**
  149381. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149382. * @param impostor A physics imposter
  149383. * @param origin the origin of the explosion
  149384. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149385. */
  149386. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149387. /**
  149388. * Triggers affecterd impostors callbacks
  149389. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149390. */
  149391. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149392. /**
  149393. * Disposes the sphere.
  149394. * @param force Specifies if the sphere should be disposed by force
  149395. */
  149396. dispose(force?: boolean): void;
  149397. /*** Helpers ***/
  149398. private _prepareSphere;
  149399. private _intersectsWithSphere;
  149400. }
  149401. /**
  149402. * Represents a gravitational field event
  149403. */
  149404. class PhysicsGravitationalFieldEvent {
  149405. private _physicsHelper;
  149406. private _scene;
  149407. private _origin;
  149408. private _options;
  149409. private _tickCallback;
  149410. private _sphere;
  149411. private _dataFetched;
  149412. /**
  149413. * Initializes the physics gravitational field event
  149414. * @param _physicsHelper A physics helper
  149415. * @param _scene BabylonJS scene
  149416. * @param _origin The origin position of the gravitational field event
  149417. * @param _options The options for the vortex event
  149418. */
  149419. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149420. /**
  149421. * Returns the data related to the gravitational field event (sphere).
  149422. * @returns A gravitational field event
  149423. */
  149424. getData(): PhysicsGravitationalFieldEventData;
  149425. /**
  149426. * Enables the gravitational field.
  149427. */
  149428. enable(): void;
  149429. /**
  149430. * Disables the gravitational field.
  149431. */
  149432. disable(): void;
  149433. /**
  149434. * Disposes the sphere.
  149435. * @param force The force to dispose from the gravitational field event
  149436. */
  149437. dispose(force?: boolean): void;
  149438. private _tick;
  149439. }
  149440. /**
  149441. * Represents a physics updraft event
  149442. */
  149443. class PhysicsUpdraftEvent {
  149444. private _scene;
  149445. private _origin;
  149446. private _options;
  149447. private _physicsEngine;
  149448. private _originTop;
  149449. private _originDirection;
  149450. private _tickCallback;
  149451. private _cylinder;
  149452. private _cylinderPosition;
  149453. private _dataFetched;
  149454. /**
  149455. * Initializes the physics updraft event
  149456. * @param _scene BabylonJS scene
  149457. * @param _origin The origin position of the updraft
  149458. * @param _options The options for the updraft event
  149459. */
  149460. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149461. /**
  149462. * Returns the data related to the updraft event (cylinder).
  149463. * @returns A physics updraft event
  149464. */
  149465. getData(): PhysicsUpdraftEventData;
  149466. /**
  149467. * Enables the updraft.
  149468. */
  149469. enable(): void;
  149470. /**
  149471. * Disables the updraft.
  149472. */
  149473. disable(): void;
  149474. /**
  149475. * Disposes the cylinder.
  149476. * @param force Specifies if the updraft should be disposed by force
  149477. */
  149478. dispose(force?: boolean): void;
  149479. private getImpostorHitData;
  149480. private _tick;
  149481. /*** Helpers ***/
  149482. private _prepareCylinder;
  149483. private _intersectsWithCylinder;
  149484. }
  149485. /**
  149486. * Represents a physics vortex event
  149487. */
  149488. class PhysicsVortexEvent {
  149489. private _scene;
  149490. private _origin;
  149491. private _options;
  149492. private _physicsEngine;
  149493. private _originTop;
  149494. private _tickCallback;
  149495. private _cylinder;
  149496. private _cylinderPosition;
  149497. private _dataFetched;
  149498. /**
  149499. * Initializes the physics vortex event
  149500. * @param _scene The BabylonJS scene
  149501. * @param _origin The origin position of the vortex
  149502. * @param _options The options for the vortex event
  149503. */
  149504. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149505. /**
  149506. * Returns the data related to the vortex event (cylinder).
  149507. * @returns The physics vortex event data
  149508. */
  149509. getData(): PhysicsVortexEventData;
  149510. /**
  149511. * Enables the vortex.
  149512. */
  149513. enable(): void;
  149514. /**
  149515. * Disables the cortex.
  149516. */
  149517. disable(): void;
  149518. /**
  149519. * Disposes the sphere.
  149520. * @param force
  149521. */
  149522. dispose(force?: boolean): void;
  149523. private getImpostorHitData;
  149524. private _tick;
  149525. /*** Helpers ***/
  149526. private _prepareCylinder;
  149527. private _intersectsWithCylinder;
  149528. }
  149529. /**
  149530. * Options fot the radial explosion event
  149531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149532. */
  149533. export class PhysicsRadialExplosionEventOptions {
  149534. /**
  149535. * The radius of the sphere for the radial explosion.
  149536. */
  149537. radius: number;
  149538. /**
  149539. * The strenth of the explosion.
  149540. */
  149541. strength: number;
  149542. /**
  149543. * The strenght of the force in correspondence to the distance of the affected object
  149544. */
  149545. falloff: PhysicsRadialImpulseFalloff;
  149546. /**
  149547. * Sphere options for the radial explosion.
  149548. */
  149549. sphere: {
  149550. segments: number;
  149551. diameter: number;
  149552. };
  149553. /**
  149554. * Sphere options for the radial explosion.
  149555. */
  149556. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149557. }
  149558. /**
  149559. * Options fot the updraft event
  149560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149561. */
  149562. export class PhysicsUpdraftEventOptions {
  149563. /**
  149564. * The radius of the cylinder for the vortex
  149565. */
  149566. radius: number;
  149567. /**
  149568. * The strenth of the updraft.
  149569. */
  149570. strength: number;
  149571. /**
  149572. * The height of the cylinder for the updraft.
  149573. */
  149574. height: number;
  149575. /**
  149576. * The mode for the the updraft.
  149577. */
  149578. updraftMode: PhysicsUpdraftMode;
  149579. }
  149580. /**
  149581. * Options fot the vortex event
  149582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149583. */
  149584. export class PhysicsVortexEventOptions {
  149585. /**
  149586. * The radius of the cylinder for the vortex
  149587. */
  149588. radius: number;
  149589. /**
  149590. * The strenth of the vortex.
  149591. */
  149592. strength: number;
  149593. /**
  149594. * The height of the cylinder for the vortex.
  149595. */
  149596. height: number;
  149597. /**
  149598. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149599. */
  149600. centripetalForceThreshold: number;
  149601. /**
  149602. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149603. */
  149604. centripetalForceMultiplier: number;
  149605. /**
  149606. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149607. */
  149608. centrifugalForceMultiplier: number;
  149609. /**
  149610. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149611. */
  149612. updraftForceMultiplier: number;
  149613. }
  149614. /**
  149615. * The strenght of the force in correspondence to the distance of the affected object
  149616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149617. */
  149618. export enum PhysicsRadialImpulseFalloff {
  149619. /** Defines that impulse is constant in strength across it's whole radius */
  149620. Constant = 0,
  149621. /** Defines that impulse gets weaker if it's further from the origin */
  149622. Linear = 1
  149623. }
  149624. /**
  149625. * The strength of the force in correspondence to the distance of the affected object
  149626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149627. */
  149628. export enum PhysicsUpdraftMode {
  149629. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149630. Center = 0,
  149631. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149632. Perpendicular = 1
  149633. }
  149634. /**
  149635. * Interface for a physics hit data
  149636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149637. */
  149638. export interface PhysicsHitData {
  149639. /**
  149640. * The force applied at the contact point
  149641. */
  149642. force: Vector3;
  149643. /**
  149644. * The contact point
  149645. */
  149646. contactPoint: Vector3;
  149647. /**
  149648. * The distance from the origin to the contact point
  149649. */
  149650. distanceFromOrigin: number;
  149651. }
  149652. /**
  149653. * Interface for radial explosion event data
  149654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149655. */
  149656. export interface PhysicsRadialExplosionEventData {
  149657. /**
  149658. * A sphere used for the radial explosion event
  149659. */
  149660. sphere: Mesh;
  149661. }
  149662. /**
  149663. * Interface for gravitational field event data
  149664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149665. */
  149666. export interface PhysicsGravitationalFieldEventData {
  149667. /**
  149668. * A sphere mesh used for the gravitational field event
  149669. */
  149670. sphere: Mesh;
  149671. }
  149672. /**
  149673. * Interface for updraft event data
  149674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149675. */
  149676. export interface PhysicsUpdraftEventData {
  149677. /**
  149678. * A cylinder used for the updraft event
  149679. */
  149680. cylinder: Mesh;
  149681. }
  149682. /**
  149683. * Interface for vortex event data
  149684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149685. */
  149686. export interface PhysicsVortexEventData {
  149687. /**
  149688. * A cylinder used for the vortex event
  149689. */
  149690. cylinder: Mesh;
  149691. }
  149692. /**
  149693. * Interface for an affected physics impostor
  149694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149695. */
  149696. export interface PhysicsAffectedImpostorWithData {
  149697. /**
  149698. * The impostor affected by the effect
  149699. */
  149700. impostor: PhysicsImpostor;
  149701. /**
  149702. * The data about the hit/horce from the explosion
  149703. */
  149704. hitData: PhysicsHitData;
  149705. }
  149706. }
  149707. declare module BABYLON {
  149708. /** @hidden */
  149709. export var blackAndWhitePixelShader: {
  149710. name: string;
  149711. shader: string;
  149712. };
  149713. }
  149714. declare module BABYLON {
  149715. /**
  149716. * Post process used to render in black and white
  149717. */
  149718. export class BlackAndWhitePostProcess extends PostProcess {
  149719. /**
  149720. * Linear about to convert he result to black and white (default: 1)
  149721. */
  149722. degree: number;
  149723. /**
  149724. * Gets a string identifying the name of the class
  149725. * @returns "BlackAndWhitePostProcess" string
  149726. */
  149727. getClassName(): string;
  149728. /**
  149729. * Creates a black and white post process
  149730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149731. * @param name The name of the effect.
  149732. * @param options The required width/height ratio to downsize to before computing the render pass.
  149733. * @param camera The camera to apply the render pass to.
  149734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149735. * @param engine The engine which the post process will be applied. (default: current engine)
  149736. * @param reusable If the post process can be reused on the same frame. (default: false)
  149737. */
  149738. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149739. /** @hidden */
  149740. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149741. }
  149742. }
  149743. declare module BABYLON {
  149744. /**
  149745. * This represents a set of one or more post processes in Babylon.
  149746. * A post process can be used to apply a shader to a texture after it is rendered.
  149747. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149748. */
  149749. export class PostProcessRenderEffect {
  149750. private _postProcesses;
  149751. private _getPostProcesses;
  149752. private _singleInstance;
  149753. private _cameras;
  149754. private _indicesForCamera;
  149755. /**
  149756. * Name of the effect
  149757. * @hidden
  149758. */
  149759. _name: string;
  149760. /**
  149761. * Instantiates a post process render effect.
  149762. * A post process can be used to apply a shader to a texture after it is rendered.
  149763. * @param engine The engine the effect is tied to
  149764. * @param name The name of the effect
  149765. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149766. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149767. */
  149768. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149769. /**
  149770. * Checks if all the post processes in the effect are supported.
  149771. */
  149772. get isSupported(): boolean;
  149773. /**
  149774. * Updates the current state of the effect
  149775. * @hidden
  149776. */
  149777. _update(): void;
  149778. /**
  149779. * Attaches the effect on cameras
  149780. * @param cameras The camera to attach to.
  149781. * @hidden
  149782. */
  149783. _attachCameras(cameras: Camera): void;
  149784. /**
  149785. * Attaches the effect on cameras
  149786. * @param cameras The camera to attach to.
  149787. * @hidden
  149788. */
  149789. _attachCameras(cameras: Camera[]): void;
  149790. /**
  149791. * Detaches the effect on cameras
  149792. * @param cameras The camera to detatch from.
  149793. * @hidden
  149794. */
  149795. _detachCameras(cameras: Camera): void;
  149796. /**
  149797. * Detatches the effect on cameras
  149798. * @param cameras The camera to detatch from.
  149799. * @hidden
  149800. */
  149801. _detachCameras(cameras: Camera[]): void;
  149802. /**
  149803. * Enables the effect on given cameras
  149804. * @param cameras The camera to enable.
  149805. * @hidden
  149806. */
  149807. _enable(cameras: Camera): void;
  149808. /**
  149809. * Enables the effect on given cameras
  149810. * @param cameras The camera to enable.
  149811. * @hidden
  149812. */
  149813. _enable(cameras: Nullable<Camera[]>): void;
  149814. /**
  149815. * Disables the effect on the given cameras
  149816. * @param cameras The camera to disable.
  149817. * @hidden
  149818. */
  149819. _disable(cameras: Camera): void;
  149820. /**
  149821. * Disables the effect on the given cameras
  149822. * @param cameras The camera to disable.
  149823. * @hidden
  149824. */
  149825. _disable(cameras: Nullable<Camera[]>): void;
  149826. /**
  149827. * Gets a list of the post processes contained in the effect.
  149828. * @param camera The camera to get the post processes on.
  149829. * @returns The list of the post processes in the effect.
  149830. */
  149831. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149832. }
  149833. }
  149834. declare module BABYLON {
  149835. /** @hidden */
  149836. export var extractHighlightsPixelShader: {
  149837. name: string;
  149838. shader: string;
  149839. };
  149840. }
  149841. declare module BABYLON {
  149842. /**
  149843. * 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.
  149844. */
  149845. export class ExtractHighlightsPostProcess extends PostProcess {
  149846. /**
  149847. * The luminance threshold, pixels below this value will be set to black.
  149848. */
  149849. threshold: number;
  149850. /** @hidden */
  149851. _exposure: number;
  149852. /**
  149853. * Post process which has the input texture to be used when performing highlight extraction
  149854. * @hidden
  149855. */
  149856. _inputPostProcess: Nullable<PostProcess>;
  149857. /**
  149858. * Gets a string identifying the name of the class
  149859. * @returns "ExtractHighlightsPostProcess" string
  149860. */
  149861. getClassName(): string;
  149862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149863. }
  149864. }
  149865. declare module BABYLON {
  149866. /** @hidden */
  149867. export var bloomMergePixelShader: {
  149868. name: string;
  149869. shader: string;
  149870. };
  149871. }
  149872. declare module BABYLON {
  149873. /**
  149874. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149875. */
  149876. export class BloomMergePostProcess extends PostProcess {
  149877. /** Weight of the bloom to be added to the original input. */
  149878. weight: number;
  149879. /**
  149880. * Gets a string identifying the name of the class
  149881. * @returns "BloomMergePostProcess" string
  149882. */
  149883. getClassName(): string;
  149884. /**
  149885. * Creates a new instance of @see BloomMergePostProcess
  149886. * @param name The name of the effect.
  149887. * @param originalFromInput Post process which's input will be used for the merge.
  149888. * @param blurred Blurred highlights post process which's output will be used.
  149889. * @param weight Weight of the bloom to be added to the original input.
  149890. * @param options The required width/height ratio to downsize to before computing the render pass.
  149891. * @param camera The camera to apply the render pass to.
  149892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149893. * @param engine The engine which the post process will be applied. (default: current engine)
  149894. * @param reusable If the post process can be reused on the same frame. (default: false)
  149895. * @param textureType Type of textures used when performing the post process. (default: 0)
  149896. * @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)
  149897. */
  149898. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149899. /** Weight of the bloom to be added to the original input. */
  149900. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149901. }
  149902. }
  149903. declare module BABYLON {
  149904. /**
  149905. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149906. */
  149907. export class BloomEffect extends PostProcessRenderEffect {
  149908. private bloomScale;
  149909. /**
  149910. * @hidden Internal
  149911. */
  149912. _effects: Array<PostProcess>;
  149913. /**
  149914. * @hidden Internal
  149915. */
  149916. _downscale: ExtractHighlightsPostProcess;
  149917. private _blurX;
  149918. private _blurY;
  149919. private _merge;
  149920. /**
  149921. * The luminance threshold to find bright areas of the image to bloom.
  149922. */
  149923. get threshold(): number;
  149924. set threshold(value: number);
  149925. /**
  149926. * The strength of the bloom.
  149927. */
  149928. get weight(): number;
  149929. set weight(value: number);
  149930. /**
  149931. * Specifies the size of the bloom blur kernel, relative to the final output size
  149932. */
  149933. get kernel(): number;
  149934. set kernel(value: number);
  149935. /**
  149936. * Creates a new instance of @see BloomEffect
  149937. * @param scene The scene the effect belongs to.
  149938. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149939. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149940. * @param bloomWeight The the strength of bloom.
  149941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149942. * @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)
  149943. */
  149944. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149945. /**
  149946. * Disposes each of the internal effects for a given camera.
  149947. * @param camera The camera to dispose the effect on.
  149948. */
  149949. disposeEffects(camera: Camera): void;
  149950. /**
  149951. * @hidden Internal
  149952. */
  149953. _updateEffects(): void;
  149954. /**
  149955. * Internal
  149956. * @returns if all the contained post processes are ready.
  149957. * @hidden
  149958. */
  149959. _isReady(): boolean;
  149960. }
  149961. }
  149962. declare module BABYLON {
  149963. /** @hidden */
  149964. export var chromaticAberrationPixelShader: {
  149965. name: string;
  149966. shader: string;
  149967. };
  149968. }
  149969. declare module BABYLON {
  149970. /**
  149971. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149972. */
  149973. export class ChromaticAberrationPostProcess extends PostProcess {
  149974. /**
  149975. * The amount of seperation of rgb channels (default: 30)
  149976. */
  149977. aberrationAmount: number;
  149978. /**
  149979. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149980. */
  149981. radialIntensity: number;
  149982. /**
  149983. * 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))
  149984. */
  149985. direction: Vector2;
  149986. /**
  149987. * 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))
  149988. */
  149989. centerPosition: Vector2;
  149990. /** The width of the screen to apply the effect on */
  149991. screenWidth: number;
  149992. /** The height of the screen to apply the effect on */
  149993. screenHeight: number;
  149994. /**
  149995. * Gets a string identifying the name of the class
  149996. * @returns "ChromaticAberrationPostProcess" string
  149997. */
  149998. getClassName(): string;
  149999. /**
  150000. * Creates a new instance ChromaticAberrationPostProcess
  150001. * @param name The name of the effect.
  150002. * @param screenWidth The width of the screen to apply the effect on.
  150003. * @param screenHeight The height of the screen to apply the effect on.
  150004. * @param options The required width/height ratio to downsize to before computing the render pass.
  150005. * @param camera The camera to apply the render pass to.
  150006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150007. * @param engine The engine which the post process will be applied. (default: current engine)
  150008. * @param reusable If the post process can be reused on the same frame. (default: false)
  150009. * @param textureType Type of textures used when performing the post process. (default: 0)
  150010. * @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)
  150011. */
  150012. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150013. /** @hidden */
  150014. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150015. }
  150016. }
  150017. declare module BABYLON {
  150018. /** @hidden */
  150019. export var circleOfConfusionPixelShader: {
  150020. name: string;
  150021. shader: string;
  150022. };
  150023. }
  150024. declare module BABYLON {
  150025. /**
  150026. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150027. */
  150028. export class CircleOfConfusionPostProcess extends PostProcess {
  150029. /**
  150030. * 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.
  150031. */
  150032. lensSize: number;
  150033. /**
  150034. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150035. */
  150036. fStop: number;
  150037. /**
  150038. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150039. */
  150040. focusDistance: number;
  150041. /**
  150042. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150043. */
  150044. focalLength: number;
  150045. /**
  150046. * Gets a string identifying the name of the class
  150047. * @returns "CircleOfConfusionPostProcess" string
  150048. */
  150049. getClassName(): string;
  150050. private _depthTexture;
  150051. /**
  150052. * Creates a new instance CircleOfConfusionPostProcess
  150053. * @param name The name of the effect.
  150054. * @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.
  150055. * @param options The required width/height ratio to downsize to before computing the render pass.
  150056. * @param camera The camera to apply the render pass to.
  150057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150058. * @param engine The engine which the post process will be applied. (default: current engine)
  150059. * @param reusable If the post process can be reused on the same frame. (default: false)
  150060. * @param textureType Type of textures used when performing the post process. (default: 0)
  150061. * @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)
  150062. */
  150063. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150064. /**
  150065. * 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.
  150066. */
  150067. set depthTexture(value: RenderTargetTexture);
  150068. }
  150069. }
  150070. declare module BABYLON {
  150071. /** @hidden */
  150072. export var colorCorrectionPixelShader: {
  150073. name: string;
  150074. shader: string;
  150075. };
  150076. }
  150077. declare module BABYLON {
  150078. /**
  150079. *
  150080. * This post-process allows the modification of rendered colors by using
  150081. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150082. *
  150083. * The object needs to be provided an url to a texture containing the color
  150084. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150085. * Use an image editing software to tweak the LUT to match your needs.
  150086. *
  150087. * For an example of a color LUT, see here:
  150088. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150089. * For explanations on color grading, see here:
  150090. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150091. *
  150092. */
  150093. export class ColorCorrectionPostProcess extends PostProcess {
  150094. private _colorTableTexture;
  150095. /**
  150096. * Gets the color table url used to create the LUT texture
  150097. */
  150098. colorTableUrl: string;
  150099. /**
  150100. * Gets a string identifying the name of the class
  150101. * @returns "ColorCorrectionPostProcess" string
  150102. */
  150103. getClassName(): string;
  150104. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150105. /** @hidden */
  150106. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150107. }
  150108. }
  150109. declare module BABYLON {
  150110. /** @hidden */
  150111. export var convolutionPixelShader: {
  150112. name: string;
  150113. shader: string;
  150114. };
  150115. }
  150116. declare module BABYLON {
  150117. /**
  150118. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150119. * input texture to perform effects such as edge detection or sharpening
  150120. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150121. */
  150122. export class ConvolutionPostProcess extends PostProcess {
  150123. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150124. kernel: number[];
  150125. /**
  150126. * Gets a string identifying the name of the class
  150127. * @returns "ConvolutionPostProcess" string
  150128. */
  150129. getClassName(): string;
  150130. /**
  150131. * Creates a new instance ConvolutionPostProcess
  150132. * @param name The name of the effect.
  150133. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150134. * @param options The required width/height ratio to downsize to before computing the render pass.
  150135. * @param camera The camera to apply the render pass to.
  150136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150137. * @param engine The engine which the post process will be applied. (default: current engine)
  150138. * @param reusable If the post process can be reused on the same frame. (default: false)
  150139. * @param textureType Type of textures used when performing the post process. (default: 0)
  150140. */
  150141. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150142. /** @hidden */
  150143. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150144. /**
  150145. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150146. */
  150147. static EdgeDetect0Kernel: number[];
  150148. /**
  150149. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150150. */
  150151. static EdgeDetect1Kernel: number[];
  150152. /**
  150153. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150154. */
  150155. static EdgeDetect2Kernel: number[];
  150156. /**
  150157. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150158. */
  150159. static SharpenKernel: number[];
  150160. /**
  150161. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150162. */
  150163. static EmbossKernel: number[];
  150164. /**
  150165. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150166. */
  150167. static GaussianKernel: number[];
  150168. }
  150169. }
  150170. declare module BABYLON {
  150171. /**
  150172. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150173. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150174. * based on samples that have a large difference in distance than the center pixel.
  150175. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150176. */
  150177. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150178. /**
  150179. * The direction the blur should be applied
  150180. */
  150181. direction: Vector2;
  150182. /**
  150183. * Gets a string identifying the name of the class
  150184. * @returns "DepthOfFieldBlurPostProcess" string
  150185. */
  150186. getClassName(): string;
  150187. /**
  150188. * Creates a new instance CircleOfConfusionPostProcess
  150189. * @param name The name of the effect.
  150190. * @param scene The scene the effect belongs to.
  150191. * @param direction The direction the blur should be applied.
  150192. * @param kernel The size of the kernel used to blur.
  150193. * @param options The required width/height ratio to downsize to before computing the render pass.
  150194. * @param camera The camera to apply the render pass to.
  150195. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150196. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150198. * @param engine The engine which the post process will be applied. (default: current engine)
  150199. * @param reusable If the post process can be reused on the same frame. (default: false)
  150200. * @param textureType Type of textures used when performing the post process. (default: 0)
  150201. * @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)
  150202. */
  150203. 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);
  150204. }
  150205. }
  150206. declare module BABYLON {
  150207. /** @hidden */
  150208. export var depthOfFieldMergePixelShader: {
  150209. name: string;
  150210. shader: string;
  150211. };
  150212. }
  150213. declare module BABYLON {
  150214. /**
  150215. * Options to be set when merging outputs from the default pipeline.
  150216. */
  150217. export class DepthOfFieldMergePostProcessOptions {
  150218. /**
  150219. * The original image to merge on top of
  150220. */
  150221. originalFromInput: PostProcess;
  150222. /**
  150223. * Parameters to perform the merge of the depth of field effect
  150224. */
  150225. depthOfField?: {
  150226. circleOfConfusion: PostProcess;
  150227. blurSteps: Array<PostProcess>;
  150228. };
  150229. /**
  150230. * Parameters to perform the merge of bloom effect
  150231. */
  150232. bloom?: {
  150233. blurred: PostProcess;
  150234. weight: number;
  150235. };
  150236. }
  150237. /**
  150238. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150239. */
  150240. export class DepthOfFieldMergePostProcess extends PostProcess {
  150241. private blurSteps;
  150242. /**
  150243. * Gets a string identifying the name of the class
  150244. * @returns "DepthOfFieldMergePostProcess" string
  150245. */
  150246. getClassName(): string;
  150247. /**
  150248. * Creates a new instance of DepthOfFieldMergePostProcess
  150249. * @param name The name of the effect.
  150250. * @param originalFromInput Post process which's input will be used for the merge.
  150251. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150252. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150253. * @param options The required width/height ratio to downsize to before computing the render pass.
  150254. * @param camera The camera to apply the render pass to.
  150255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150256. * @param engine The engine which the post process will be applied. (default: current engine)
  150257. * @param reusable If the post process can be reused on the same frame. (default: false)
  150258. * @param textureType Type of textures used when performing the post process. (default: 0)
  150259. * @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)
  150260. */
  150261. 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);
  150262. /**
  150263. * Updates the effect with the current post process compile time values and recompiles the shader.
  150264. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150265. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150266. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150267. * @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
  150268. * @param onCompiled Called when the shader has been compiled.
  150269. * @param onError Called if there is an error when compiling a shader.
  150270. */
  150271. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150272. }
  150273. }
  150274. declare module BABYLON {
  150275. /**
  150276. * Specifies the level of max blur that should be applied when using the depth of field effect
  150277. */
  150278. export enum DepthOfFieldEffectBlurLevel {
  150279. /**
  150280. * Subtle blur
  150281. */
  150282. Low = 0,
  150283. /**
  150284. * Medium blur
  150285. */
  150286. Medium = 1,
  150287. /**
  150288. * Large blur
  150289. */
  150290. High = 2
  150291. }
  150292. /**
  150293. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150294. */
  150295. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150296. private _circleOfConfusion;
  150297. /**
  150298. * @hidden Internal, blurs from high to low
  150299. */
  150300. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150301. private _depthOfFieldBlurY;
  150302. private _dofMerge;
  150303. /**
  150304. * @hidden Internal post processes in depth of field effect
  150305. */
  150306. _effects: Array<PostProcess>;
  150307. /**
  150308. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150309. */
  150310. set focalLength(value: number);
  150311. get focalLength(): number;
  150312. /**
  150313. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150314. */
  150315. set fStop(value: number);
  150316. get fStop(): number;
  150317. /**
  150318. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150319. */
  150320. set focusDistance(value: number);
  150321. get focusDistance(): number;
  150322. /**
  150323. * 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.
  150324. */
  150325. set lensSize(value: number);
  150326. get lensSize(): number;
  150327. /**
  150328. * Creates a new instance DepthOfFieldEffect
  150329. * @param scene The scene the effect belongs to.
  150330. * @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.
  150331. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150332. * @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)
  150333. */
  150334. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150335. /**
  150336. * Get the current class name of the current effet
  150337. * @returns "DepthOfFieldEffect"
  150338. */
  150339. getClassName(): string;
  150340. /**
  150341. * 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.
  150342. */
  150343. set depthTexture(value: RenderTargetTexture);
  150344. /**
  150345. * Disposes each of the internal effects for a given camera.
  150346. * @param camera The camera to dispose the effect on.
  150347. */
  150348. disposeEffects(camera: Camera): void;
  150349. /**
  150350. * @hidden Internal
  150351. */
  150352. _updateEffects(): void;
  150353. /**
  150354. * Internal
  150355. * @returns if all the contained post processes are ready.
  150356. * @hidden
  150357. */
  150358. _isReady(): boolean;
  150359. }
  150360. }
  150361. declare module BABYLON {
  150362. /** @hidden */
  150363. export var displayPassPixelShader: {
  150364. name: string;
  150365. shader: string;
  150366. };
  150367. }
  150368. declare module BABYLON {
  150369. /**
  150370. * DisplayPassPostProcess which produces an output the same as it's input
  150371. */
  150372. export class DisplayPassPostProcess extends PostProcess {
  150373. /**
  150374. * Gets a string identifying the name of the class
  150375. * @returns "DisplayPassPostProcess" string
  150376. */
  150377. getClassName(): string;
  150378. /**
  150379. * Creates the DisplayPassPostProcess
  150380. * @param name The name of the effect.
  150381. * @param options The required width/height ratio to downsize to before computing the render pass.
  150382. * @param camera The camera to apply the render pass to.
  150383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150384. * @param engine The engine which the post process will be applied. (default: current engine)
  150385. * @param reusable If the post process can be reused on the same frame. (default: false)
  150386. */
  150387. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150388. /** @hidden */
  150389. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150390. }
  150391. }
  150392. declare module BABYLON {
  150393. /** @hidden */
  150394. export var filterPixelShader: {
  150395. name: string;
  150396. shader: string;
  150397. };
  150398. }
  150399. declare module BABYLON {
  150400. /**
  150401. * Applies a kernel filter to the image
  150402. */
  150403. export class FilterPostProcess extends PostProcess {
  150404. /** The matrix to be applied to the image */
  150405. kernelMatrix: Matrix;
  150406. /**
  150407. * Gets a string identifying the name of the class
  150408. * @returns "FilterPostProcess" string
  150409. */
  150410. getClassName(): string;
  150411. /**
  150412. *
  150413. * @param name The name of the effect.
  150414. * @param kernelMatrix The matrix to be applied to the image
  150415. * @param options The required width/height ratio to downsize to before computing the render pass.
  150416. * @param camera The camera to apply the render pass to.
  150417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150418. * @param engine The engine which the post process will be applied. (default: current engine)
  150419. * @param reusable If the post process can be reused on the same frame. (default: false)
  150420. */
  150421. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150422. /** @hidden */
  150423. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150424. }
  150425. }
  150426. declare module BABYLON {
  150427. /** @hidden */
  150428. export var fxaaPixelShader: {
  150429. name: string;
  150430. shader: string;
  150431. };
  150432. }
  150433. declare module BABYLON {
  150434. /** @hidden */
  150435. export var fxaaVertexShader: {
  150436. name: string;
  150437. shader: string;
  150438. };
  150439. }
  150440. declare module BABYLON {
  150441. /**
  150442. * Fxaa post process
  150443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150444. */
  150445. export class FxaaPostProcess extends PostProcess {
  150446. /**
  150447. * Gets a string identifying the name of the class
  150448. * @returns "FxaaPostProcess" string
  150449. */
  150450. getClassName(): string;
  150451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150452. private _getDefines;
  150453. /** @hidden */
  150454. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150455. }
  150456. }
  150457. declare module BABYLON {
  150458. /** @hidden */
  150459. export var grainPixelShader: {
  150460. name: string;
  150461. shader: string;
  150462. };
  150463. }
  150464. declare module BABYLON {
  150465. /**
  150466. * The GrainPostProcess adds noise to the image at mid luminance levels
  150467. */
  150468. export class GrainPostProcess extends PostProcess {
  150469. /**
  150470. * The intensity of the grain added (default: 30)
  150471. */
  150472. intensity: number;
  150473. /**
  150474. * If the grain should be randomized on every frame
  150475. */
  150476. animated: boolean;
  150477. /**
  150478. * Gets a string identifying the name of the class
  150479. * @returns "GrainPostProcess" string
  150480. */
  150481. getClassName(): string;
  150482. /**
  150483. * Creates a new instance of @see GrainPostProcess
  150484. * @param name The name of the effect.
  150485. * @param options The required width/height ratio to downsize to before computing the render pass.
  150486. * @param camera The camera to apply the render pass to.
  150487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150488. * @param engine The engine which the post process will be applied. (default: current engine)
  150489. * @param reusable If the post process can be reused on the same frame. (default: false)
  150490. * @param textureType Type of textures used when performing the post process. (default: 0)
  150491. * @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)
  150492. */
  150493. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150494. /** @hidden */
  150495. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150496. }
  150497. }
  150498. declare module BABYLON {
  150499. /** @hidden */
  150500. export var highlightsPixelShader: {
  150501. name: string;
  150502. shader: string;
  150503. };
  150504. }
  150505. declare module BABYLON {
  150506. /**
  150507. * Extracts highlights from the image
  150508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150509. */
  150510. export class HighlightsPostProcess extends PostProcess {
  150511. /**
  150512. * Gets a string identifying the name of the class
  150513. * @returns "HighlightsPostProcess" string
  150514. */
  150515. getClassName(): string;
  150516. /**
  150517. * Extracts highlights from the image
  150518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150519. * @param name The name of the effect.
  150520. * @param options The required width/height ratio to downsize to before computing the render pass.
  150521. * @param camera The camera to apply the render pass to.
  150522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150523. * @param engine The engine which the post process will be applied. (default: current engine)
  150524. * @param reusable If the post process can be reused on the same frame. (default: false)
  150525. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150526. */
  150527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150528. }
  150529. }
  150530. declare module BABYLON {
  150531. /** @hidden */
  150532. export var mrtFragmentDeclaration: {
  150533. name: string;
  150534. shader: string;
  150535. };
  150536. }
  150537. declare module BABYLON {
  150538. /** @hidden */
  150539. export var geometryPixelShader: {
  150540. name: string;
  150541. shader: string;
  150542. };
  150543. }
  150544. declare module BABYLON {
  150545. /** @hidden */
  150546. export var geometryVertexShader: {
  150547. name: string;
  150548. shader: string;
  150549. };
  150550. }
  150551. declare module BABYLON {
  150552. /** @hidden */
  150553. interface ISavedTransformationMatrix {
  150554. world: Matrix;
  150555. viewProjection: Matrix;
  150556. }
  150557. /**
  150558. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150559. */
  150560. export class GeometryBufferRenderer {
  150561. /**
  150562. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150563. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150564. */
  150565. static readonly POSITION_TEXTURE_TYPE: number;
  150566. /**
  150567. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150568. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150569. */
  150570. static readonly VELOCITY_TEXTURE_TYPE: number;
  150571. /**
  150572. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150573. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150574. */
  150575. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150576. /**
  150577. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150578. * in order to compute objects velocities when enableVelocity is set to "true"
  150579. * @hidden
  150580. */
  150581. _previousTransformationMatrices: {
  150582. [index: number]: ISavedTransformationMatrix;
  150583. };
  150584. /**
  150585. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150586. * in order to compute objects velocities when enableVelocity is set to "true"
  150587. * @hidden
  150588. */
  150589. _previousBonesTransformationMatrices: {
  150590. [index: number]: Float32Array;
  150591. };
  150592. /**
  150593. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150594. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150595. */
  150596. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150597. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150598. renderTransparentMeshes: boolean;
  150599. private _scene;
  150600. private _resizeObserver;
  150601. private _multiRenderTarget;
  150602. private _ratio;
  150603. private _enablePosition;
  150604. private _enableVelocity;
  150605. private _enableReflectivity;
  150606. private _positionIndex;
  150607. private _velocityIndex;
  150608. private _reflectivityIndex;
  150609. protected _effect: Effect;
  150610. protected _cachedDefines: string;
  150611. /**
  150612. * Set the render list (meshes to be rendered) used in the G buffer.
  150613. */
  150614. set renderList(meshes: Mesh[]);
  150615. /**
  150616. * Gets wether or not G buffer are supported by the running hardware.
  150617. * This requires draw buffer supports
  150618. */
  150619. get isSupported(): boolean;
  150620. /**
  150621. * Returns the index of the given texture type in the G-Buffer textures array
  150622. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150623. * @returns the index of the given texture type in the G-Buffer textures array
  150624. */
  150625. getTextureIndex(textureType: number): number;
  150626. /**
  150627. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150628. */
  150629. get enablePosition(): boolean;
  150630. /**
  150631. * Sets whether or not objects positions are enabled for the G buffer.
  150632. */
  150633. set enablePosition(enable: boolean);
  150634. /**
  150635. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150636. */
  150637. get enableVelocity(): boolean;
  150638. /**
  150639. * Sets wether or not objects velocities are enabled for the G buffer.
  150640. */
  150641. set enableVelocity(enable: boolean);
  150642. /**
  150643. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150644. */
  150645. get enableReflectivity(): boolean;
  150646. /**
  150647. * Sets wether or not objects roughness are enabled for the G buffer.
  150648. */
  150649. set enableReflectivity(enable: boolean);
  150650. /**
  150651. * Gets the scene associated with the buffer.
  150652. */
  150653. get scene(): Scene;
  150654. /**
  150655. * Gets the ratio used by the buffer during its creation.
  150656. * How big is the buffer related to the main canvas.
  150657. */
  150658. get ratio(): number;
  150659. /** @hidden */
  150660. static _SceneComponentInitialization: (scene: Scene) => void;
  150661. /**
  150662. * Creates a new G Buffer for the scene
  150663. * @param scene The scene the buffer belongs to
  150664. * @param ratio How big is the buffer related to the main canvas.
  150665. */
  150666. constructor(scene: Scene, ratio?: number);
  150667. /**
  150668. * Checks wether everything is ready to render a submesh to the G buffer.
  150669. * @param subMesh the submesh to check readiness for
  150670. * @param useInstances is the mesh drawn using instance or not
  150671. * @returns true if ready otherwise false
  150672. */
  150673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150674. /**
  150675. * Gets the current underlying G Buffer.
  150676. * @returns the buffer
  150677. */
  150678. getGBuffer(): MultiRenderTarget;
  150679. /**
  150680. * Gets the number of samples used to render the buffer (anti aliasing).
  150681. */
  150682. get samples(): number;
  150683. /**
  150684. * Sets the number of samples used to render the buffer (anti aliasing).
  150685. */
  150686. set samples(value: number);
  150687. /**
  150688. * Disposes the renderer and frees up associated resources.
  150689. */
  150690. dispose(): void;
  150691. protected _createRenderTargets(): void;
  150692. private _copyBonesTransformationMatrices;
  150693. }
  150694. }
  150695. declare module BABYLON {
  150696. /**
  150697. * Contains all parameters needed for the prepass to perform
  150698. * motion blur
  150699. */
  150700. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  150701. /**
  150702. * Is motion blur enabled
  150703. */
  150704. enabled: boolean;
  150705. /**
  150706. * Name of the configuration
  150707. */
  150708. name: string;
  150709. /**
  150710. * Textures that should be present in the MRT for this effect to work
  150711. */
  150712. readonly texturesRequired: number[];
  150713. }
  150714. }
  150715. declare module BABYLON {
  150716. interface Scene {
  150717. /** @hidden (Backing field) */
  150718. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150719. /**
  150720. * Gets or Sets the current geometry buffer associated to the scene.
  150721. */
  150722. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150723. /**
  150724. * Enables a GeometryBufferRender and associates it with the scene
  150725. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150726. * @returns the GeometryBufferRenderer
  150727. */
  150728. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150729. /**
  150730. * Disables the GeometryBufferRender associated with the scene
  150731. */
  150732. disableGeometryBufferRenderer(): void;
  150733. }
  150734. /**
  150735. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150736. * in several rendering techniques.
  150737. */
  150738. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150739. /**
  150740. * The component name helpful to identify the component in the list of scene components.
  150741. */
  150742. readonly name: string;
  150743. /**
  150744. * The scene the component belongs to.
  150745. */
  150746. scene: Scene;
  150747. /**
  150748. * Creates a new instance of the component for the given scene
  150749. * @param scene Defines the scene to register the component in
  150750. */
  150751. constructor(scene: Scene);
  150752. /**
  150753. * Registers the component in a given scene
  150754. */
  150755. register(): void;
  150756. /**
  150757. * Rebuilds the elements related to this component in case of
  150758. * context lost for instance.
  150759. */
  150760. rebuild(): void;
  150761. /**
  150762. * Disposes the component and the associated ressources
  150763. */
  150764. dispose(): void;
  150765. private _gatherRenderTargets;
  150766. }
  150767. }
  150768. declare module BABYLON {
  150769. /** @hidden */
  150770. export var motionBlurPixelShader: {
  150771. name: string;
  150772. shader: string;
  150773. };
  150774. }
  150775. declare module BABYLON {
  150776. /**
  150777. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150778. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150779. * As an example, all you have to do is to create the post-process:
  150780. * var mb = new BABYLON.MotionBlurPostProcess(
  150781. * 'mb', // The name of the effect.
  150782. * scene, // The scene containing the objects to blur according to their velocity.
  150783. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150784. * camera // The camera to apply the render pass to.
  150785. * );
  150786. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150787. */
  150788. export class MotionBlurPostProcess extends PostProcess {
  150789. /**
  150790. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150791. */
  150792. motionStrength: number;
  150793. /**
  150794. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150795. */
  150796. get motionBlurSamples(): number;
  150797. /**
  150798. * Sets the number of iterations to be used for motion blur quality
  150799. */
  150800. set motionBlurSamples(samples: number);
  150801. private _motionBlurSamples;
  150802. private _forceGeometryBuffer;
  150803. private _geometryBufferRenderer;
  150804. private _prePassRenderer;
  150805. /**
  150806. * Gets a string identifying the name of the class
  150807. * @returns "MotionBlurPostProcess" string
  150808. */
  150809. getClassName(): string;
  150810. /**
  150811. * Creates a new instance MotionBlurPostProcess
  150812. * @param name The name of the effect.
  150813. * @param scene The scene containing the objects to blur according to their velocity.
  150814. * @param options The required width/height ratio to downsize to before computing the render pass.
  150815. * @param camera The camera to apply the render pass to.
  150816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150817. * @param engine The engine which the post process will be applied. (default: current engine)
  150818. * @param reusable If the post process can be reused on the same frame. (default: false)
  150819. * @param textureType Type of textures used when performing the post process. (default: 0)
  150820. * @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)
  150821. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  150822. */
  150823. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  150824. /**
  150825. * Excludes the given skinned mesh from computing bones velocities.
  150826. * 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.
  150827. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150828. */
  150829. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150830. /**
  150831. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150832. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150833. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150834. */
  150835. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150836. /**
  150837. * Disposes the post process.
  150838. * @param camera The camera to dispose the post process on.
  150839. */
  150840. dispose(camera?: Camera): void;
  150841. /** @hidden */
  150842. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150843. }
  150844. }
  150845. declare module BABYLON {
  150846. /** @hidden */
  150847. export var refractionPixelShader: {
  150848. name: string;
  150849. shader: string;
  150850. };
  150851. }
  150852. declare module BABYLON {
  150853. /**
  150854. * Post process which applies a refractin texture
  150855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150856. */
  150857. export class RefractionPostProcess extends PostProcess {
  150858. private _refTexture;
  150859. private _ownRefractionTexture;
  150860. /** the base color of the refraction (used to taint the rendering) */
  150861. color: Color3;
  150862. /** simulated refraction depth */
  150863. depth: number;
  150864. /** the coefficient of the base color (0 to remove base color tainting) */
  150865. colorLevel: number;
  150866. /** Gets the url used to load the refraction texture */
  150867. refractionTextureUrl: string;
  150868. /**
  150869. * Gets or sets the refraction texture
  150870. * Please note that you are responsible for disposing the texture if you set it manually
  150871. */
  150872. get refractionTexture(): Texture;
  150873. set refractionTexture(value: Texture);
  150874. /**
  150875. * Gets a string identifying the name of the class
  150876. * @returns "RefractionPostProcess" string
  150877. */
  150878. getClassName(): string;
  150879. /**
  150880. * Initializes the RefractionPostProcess
  150881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150882. * @param name The name of the effect.
  150883. * @param refractionTextureUrl Url of the refraction texture to use
  150884. * @param color the base color of the refraction (used to taint the rendering)
  150885. * @param depth simulated refraction depth
  150886. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150887. * @param camera The camera to apply the render pass to.
  150888. * @param options The required width/height ratio to downsize to before computing the render pass.
  150889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150890. * @param engine The engine which the post process will be applied. (default: current engine)
  150891. * @param reusable If the post process can be reused on the same frame. (default: false)
  150892. */
  150893. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150894. /**
  150895. * Disposes of the post process
  150896. * @param camera Camera to dispose post process on
  150897. */
  150898. dispose(camera: Camera): void;
  150899. /** @hidden */
  150900. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150901. }
  150902. }
  150903. declare module BABYLON {
  150904. /** @hidden */
  150905. export var sharpenPixelShader: {
  150906. name: string;
  150907. shader: string;
  150908. };
  150909. }
  150910. declare module BABYLON {
  150911. /**
  150912. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150913. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150914. */
  150915. export class SharpenPostProcess extends PostProcess {
  150916. /**
  150917. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150918. */
  150919. colorAmount: number;
  150920. /**
  150921. * How much sharpness should be applied (default: 0.3)
  150922. */
  150923. edgeAmount: number;
  150924. /**
  150925. * Gets a string identifying the name of the class
  150926. * @returns "SharpenPostProcess" string
  150927. */
  150928. getClassName(): string;
  150929. /**
  150930. * Creates a new instance ConvolutionPostProcess
  150931. * @param name The name of the effect.
  150932. * @param options The required width/height ratio to downsize to before computing the render pass.
  150933. * @param camera The camera to apply the render pass to.
  150934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150935. * @param engine The engine which the post process will be applied. (default: current engine)
  150936. * @param reusable If the post process can be reused on the same frame. (default: false)
  150937. * @param textureType Type of textures used when performing the post process. (default: 0)
  150938. * @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)
  150939. */
  150940. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150941. /** @hidden */
  150942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150943. }
  150944. }
  150945. declare module BABYLON {
  150946. /**
  150947. * PostProcessRenderPipeline
  150948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150949. */
  150950. export class PostProcessRenderPipeline {
  150951. private engine;
  150952. private _renderEffects;
  150953. private _renderEffectsForIsolatedPass;
  150954. /**
  150955. * List of inspectable custom properties (used by the Inspector)
  150956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150957. */
  150958. inspectableCustomProperties: IInspectable[];
  150959. /**
  150960. * @hidden
  150961. */
  150962. protected _cameras: Camera[];
  150963. /** @hidden */
  150964. _name: string;
  150965. /**
  150966. * Gets pipeline name
  150967. */
  150968. get name(): string;
  150969. /** Gets the list of attached cameras */
  150970. get cameras(): Camera[];
  150971. /**
  150972. * Initializes a PostProcessRenderPipeline
  150973. * @param engine engine to add the pipeline to
  150974. * @param name name of the pipeline
  150975. */
  150976. constructor(engine: Engine, name: string);
  150977. /**
  150978. * Gets the class name
  150979. * @returns "PostProcessRenderPipeline"
  150980. */
  150981. getClassName(): string;
  150982. /**
  150983. * If all the render effects in the pipeline are supported
  150984. */
  150985. get isSupported(): boolean;
  150986. /**
  150987. * Adds an effect to the pipeline
  150988. * @param renderEffect the effect to add
  150989. */
  150990. addEffect(renderEffect: PostProcessRenderEffect): void;
  150991. /** @hidden */
  150992. _rebuild(): void;
  150993. /** @hidden */
  150994. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150995. /** @hidden */
  150996. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150997. /** @hidden */
  150998. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150999. /** @hidden */
  151000. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151001. /** @hidden */
  151002. _attachCameras(cameras: Camera, unique: boolean): void;
  151003. /** @hidden */
  151004. _attachCameras(cameras: Camera[], unique: boolean): void;
  151005. /** @hidden */
  151006. _detachCameras(cameras: Camera): void;
  151007. /** @hidden */
  151008. _detachCameras(cameras: Nullable<Camera[]>): void;
  151009. /** @hidden */
  151010. _update(): void;
  151011. /** @hidden */
  151012. _reset(): void;
  151013. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151014. /**
  151015. * Sets the required values to the prepass renderer.
  151016. * @param prePassRenderer defines the prepass renderer to setup.
  151017. * @returns true if the pre pass is needed.
  151018. */
  151019. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151020. /**
  151021. * Disposes of the pipeline
  151022. */
  151023. dispose(): void;
  151024. }
  151025. }
  151026. declare module BABYLON {
  151027. /**
  151028. * PostProcessRenderPipelineManager class
  151029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151030. */
  151031. export class PostProcessRenderPipelineManager {
  151032. private _renderPipelines;
  151033. /**
  151034. * Initializes a PostProcessRenderPipelineManager
  151035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151036. */
  151037. constructor();
  151038. /**
  151039. * Gets the list of supported render pipelines
  151040. */
  151041. get supportedPipelines(): PostProcessRenderPipeline[];
  151042. /**
  151043. * Adds a pipeline to the manager
  151044. * @param renderPipeline The pipeline to add
  151045. */
  151046. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151047. /**
  151048. * Attaches a camera to the pipeline
  151049. * @param renderPipelineName The name of the pipeline to attach to
  151050. * @param cameras the camera to attach
  151051. * @param unique if the camera can be attached multiple times to the pipeline
  151052. */
  151053. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151054. /**
  151055. * Detaches a camera from the pipeline
  151056. * @param renderPipelineName The name of the pipeline to detach from
  151057. * @param cameras the camera to detach
  151058. */
  151059. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151060. /**
  151061. * Enables an effect by name on a pipeline
  151062. * @param renderPipelineName the name of the pipeline to enable the effect in
  151063. * @param renderEffectName the name of the effect to enable
  151064. * @param cameras the cameras that the effect should be enabled on
  151065. */
  151066. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151067. /**
  151068. * Disables an effect by name on a pipeline
  151069. * @param renderPipelineName the name of the pipeline to disable the effect in
  151070. * @param renderEffectName the name of the effect to disable
  151071. * @param cameras the cameras that the effect should be disabled on
  151072. */
  151073. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151074. /**
  151075. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151076. */
  151077. update(): void;
  151078. /** @hidden */
  151079. _rebuild(): void;
  151080. /**
  151081. * Disposes of the manager and pipelines
  151082. */
  151083. dispose(): void;
  151084. }
  151085. }
  151086. declare module BABYLON {
  151087. interface Scene {
  151088. /** @hidden (Backing field) */
  151089. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151090. /**
  151091. * Gets the postprocess render pipeline manager
  151092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151093. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151094. */
  151095. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151096. }
  151097. /**
  151098. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151099. */
  151100. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151101. /**
  151102. * The component name helpfull to identify the component in the list of scene components.
  151103. */
  151104. readonly name: string;
  151105. /**
  151106. * The scene the component belongs to.
  151107. */
  151108. scene: Scene;
  151109. /**
  151110. * Creates a new instance of the component for the given scene
  151111. * @param scene Defines the scene to register the component in
  151112. */
  151113. constructor(scene: Scene);
  151114. /**
  151115. * Registers the component in a given scene
  151116. */
  151117. register(): void;
  151118. /**
  151119. * Rebuilds the elements related to this component in case of
  151120. * context lost for instance.
  151121. */
  151122. rebuild(): void;
  151123. /**
  151124. * Disposes the component and the associated ressources
  151125. */
  151126. dispose(): void;
  151127. private _gatherRenderTargets;
  151128. }
  151129. }
  151130. declare module BABYLON {
  151131. /**
  151132. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151133. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151134. */
  151135. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151136. private _scene;
  151137. private _camerasToBeAttached;
  151138. /**
  151139. * ID of the sharpen post process,
  151140. */
  151141. private readonly SharpenPostProcessId;
  151142. /**
  151143. * @ignore
  151144. * ID of the image processing post process;
  151145. */
  151146. readonly ImageProcessingPostProcessId: string;
  151147. /**
  151148. * @ignore
  151149. * ID of the Fast Approximate Anti-Aliasing post process;
  151150. */
  151151. readonly FxaaPostProcessId: string;
  151152. /**
  151153. * ID of the chromatic aberration post process,
  151154. */
  151155. private readonly ChromaticAberrationPostProcessId;
  151156. /**
  151157. * ID of the grain post process
  151158. */
  151159. private readonly GrainPostProcessId;
  151160. /**
  151161. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151162. */
  151163. sharpen: SharpenPostProcess;
  151164. private _sharpenEffect;
  151165. private bloom;
  151166. /**
  151167. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151168. */
  151169. depthOfField: DepthOfFieldEffect;
  151170. /**
  151171. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151172. */
  151173. fxaa: FxaaPostProcess;
  151174. /**
  151175. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151176. */
  151177. imageProcessing: ImageProcessingPostProcess;
  151178. /**
  151179. * Chromatic aberration post process which will shift rgb colors in the image
  151180. */
  151181. chromaticAberration: ChromaticAberrationPostProcess;
  151182. private _chromaticAberrationEffect;
  151183. /**
  151184. * Grain post process which add noise to the image
  151185. */
  151186. grain: GrainPostProcess;
  151187. private _grainEffect;
  151188. /**
  151189. * Glow post process which adds a glow to emissive areas of the image
  151190. */
  151191. private _glowLayer;
  151192. /**
  151193. * Animations which can be used to tweak settings over a period of time
  151194. */
  151195. animations: Animation[];
  151196. private _imageProcessingConfigurationObserver;
  151197. private _sharpenEnabled;
  151198. private _bloomEnabled;
  151199. private _depthOfFieldEnabled;
  151200. private _depthOfFieldBlurLevel;
  151201. private _fxaaEnabled;
  151202. private _imageProcessingEnabled;
  151203. private _defaultPipelineTextureType;
  151204. private _bloomScale;
  151205. private _chromaticAberrationEnabled;
  151206. private _grainEnabled;
  151207. private _buildAllowed;
  151208. /**
  151209. * Gets active scene
  151210. */
  151211. get scene(): Scene;
  151212. /**
  151213. * Enable or disable the sharpen process from the pipeline
  151214. */
  151215. set sharpenEnabled(enabled: boolean);
  151216. get sharpenEnabled(): boolean;
  151217. private _resizeObserver;
  151218. private _hardwareScaleLevel;
  151219. private _bloomKernel;
  151220. /**
  151221. * Specifies the size of the bloom blur kernel, relative to the final output size
  151222. */
  151223. get bloomKernel(): number;
  151224. set bloomKernel(value: number);
  151225. /**
  151226. * Specifies the weight of the bloom in the final rendering
  151227. */
  151228. private _bloomWeight;
  151229. /**
  151230. * Specifies the luma threshold for the area that will be blurred by the bloom
  151231. */
  151232. private _bloomThreshold;
  151233. private _hdr;
  151234. /**
  151235. * The strength of the bloom.
  151236. */
  151237. set bloomWeight(value: number);
  151238. get bloomWeight(): number;
  151239. /**
  151240. * The strength of the bloom.
  151241. */
  151242. set bloomThreshold(value: number);
  151243. get bloomThreshold(): number;
  151244. /**
  151245. * The scale of the bloom, lower value will provide better performance.
  151246. */
  151247. set bloomScale(value: number);
  151248. get bloomScale(): number;
  151249. /**
  151250. * Enable or disable the bloom from the pipeline
  151251. */
  151252. set bloomEnabled(enabled: boolean);
  151253. get bloomEnabled(): boolean;
  151254. private _rebuildBloom;
  151255. /**
  151256. * If the depth of field is enabled.
  151257. */
  151258. get depthOfFieldEnabled(): boolean;
  151259. set depthOfFieldEnabled(enabled: boolean);
  151260. /**
  151261. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151262. */
  151263. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151264. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151265. /**
  151266. * If the anti aliasing is enabled.
  151267. */
  151268. set fxaaEnabled(enabled: boolean);
  151269. get fxaaEnabled(): boolean;
  151270. private _samples;
  151271. /**
  151272. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151273. */
  151274. set samples(sampleCount: number);
  151275. get samples(): number;
  151276. /**
  151277. * If image processing is enabled.
  151278. */
  151279. set imageProcessingEnabled(enabled: boolean);
  151280. get imageProcessingEnabled(): boolean;
  151281. /**
  151282. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151283. */
  151284. set glowLayerEnabled(enabled: boolean);
  151285. get glowLayerEnabled(): boolean;
  151286. /**
  151287. * Gets the glow layer (or null if not defined)
  151288. */
  151289. get glowLayer(): Nullable<GlowLayer>;
  151290. /**
  151291. * Enable or disable the chromaticAberration process from the pipeline
  151292. */
  151293. set chromaticAberrationEnabled(enabled: boolean);
  151294. get chromaticAberrationEnabled(): boolean;
  151295. /**
  151296. * Enable or disable the grain process from the pipeline
  151297. */
  151298. set grainEnabled(enabled: boolean);
  151299. get grainEnabled(): boolean;
  151300. /**
  151301. * @constructor
  151302. * @param name - The rendering pipeline name (default: "")
  151303. * @param hdr - If high dynamic range textures should be used (default: true)
  151304. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151305. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151306. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151307. */
  151308. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151309. /**
  151310. * Get the class name
  151311. * @returns "DefaultRenderingPipeline"
  151312. */
  151313. getClassName(): string;
  151314. /**
  151315. * Force the compilation of the entire pipeline.
  151316. */
  151317. prepare(): void;
  151318. private _hasCleared;
  151319. private _prevPostProcess;
  151320. private _prevPrevPostProcess;
  151321. private _setAutoClearAndTextureSharing;
  151322. private _depthOfFieldSceneObserver;
  151323. private _buildPipeline;
  151324. private _disposePostProcesses;
  151325. /**
  151326. * Adds a camera to the pipeline
  151327. * @param camera the camera to be added
  151328. */
  151329. addCamera(camera: Camera): void;
  151330. /**
  151331. * Removes a camera from the pipeline
  151332. * @param camera the camera to remove
  151333. */
  151334. removeCamera(camera: Camera): void;
  151335. /**
  151336. * Dispose of the pipeline and stop all post processes
  151337. */
  151338. dispose(): void;
  151339. /**
  151340. * Serialize the rendering pipeline (Used when exporting)
  151341. * @returns the serialized object
  151342. */
  151343. serialize(): any;
  151344. /**
  151345. * Parse the serialized pipeline
  151346. * @param source Source pipeline.
  151347. * @param scene The scene to load the pipeline to.
  151348. * @param rootUrl The URL of the serialized pipeline.
  151349. * @returns An instantiated pipeline from the serialized object.
  151350. */
  151351. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151352. }
  151353. }
  151354. declare module BABYLON {
  151355. /** @hidden */
  151356. export var lensHighlightsPixelShader: {
  151357. name: string;
  151358. shader: string;
  151359. };
  151360. }
  151361. declare module BABYLON {
  151362. /** @hidden */
  151363. export var depthOfFieldPixelShader: {
  151364. name: string;
  151365. shader: string;
  151366. };
  151367. }
  151368. declare module BABYLON {
  151369. /**
  151370. * BABYLON.JS Chromatic Aberration GLSL Shader
  151371. * Author: Olivier Guyot
  151372. * Separates very slightly R, G and B colors on the edges of the screen
  151373. * Inspired by Francois Tarlier & Martins Upitis
  151374. */
  151375. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151376. /**
  151377. * @ignore
  151378. * The chromatic aberration PostProcess id in the pipeline
  151379. */
  151380. LensChromaticAberrationEffect: string;
  151381. /**
  151382. * @ignore
  151383. * The highlights enhancing PostProcess id in the pipeline
  151384. */
  151385. HighlightsEnhancingEffect: string;
  151386. /**
  151387. * @ignore
  151388. * The depth-of-field PostProcess id in the pipeline
  151389. */
  151390. LensDepthOfFieldEffect: string;
  151391. private _scene;
  151392. private _depthTexture;
  151393. private _grainTexture;
  151394. private _chromaticAberrationPostProcess;
  151395. private _highlightsPostProcess;
  151396. private _depthOfFieldPostProcess;
  151397. private _edgeBlur;
  151398. private _grainAmount;
  151399. private _chromaticAberration;
  151400. private _distortion;
  151401. private _highlightsGain;
  151402. private _highlightsThreshold;
  151403. private _dofDistance;
  151404. private _dofAperture;
  151405. private _dofDarken;
  151406. private _dofPentagon;
  151407. private _blurNoise;
  151408. /**
  151409. * @constructor
  151410. *
  151411. * Effect parameters are as follow:
  151412. * {
  151413. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151414. * edge_blur: number; // from 0 to x (1 for realism)
  151415. * distortion: number; // from 0 to x (1 for realism)
  151416. * grain_amount: number; // from 0 to 1
  151417. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151418. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151419. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151420. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151421. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151422. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151423. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151424. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151425. * }
  151426. * Note: if an effect parameter is unset, effect is disabled
  151427. *
  151428. * @param name The rendering pipeline name
  151429. * @param parameters - An object containing all parameters (see above)
  151430. * @param scene The scene linked to this pipeline
  151431. * @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)
  151432. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151433. */
  151434. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151435. /**
  151436. * Get the class name
  151437. * @returns "LensRenderingPipeline"
  151438. */
  151439. getClassName(): string;
  151440. /**
  151441. * Gets associated scene
  151442. */
  151443. get scene(): Scene;
  151444. /**
  151445. * Gets or sets the edge blur
  151446. */
  151447. get edgeBlur(): number;
  151448. set edgeBlur(value: number);
  151449. /**
  151450. * Gets or sets the grain amount
  151451. */
  151452. get grainAmount(): number;
  151453. set grainAmount(value: number);
  151454. /**
  151455. * Gets or sets the chromatic aberration amount
  151456. */
  151457. get chromaticAberration(): number;
  151458. set chromaticAberration(value: number);
  151459. /**
  151460. * Gets or sets the depth of field aperture
  151461. */
  151462. get dofAperture(): number;
  151463. set dofAperture(value: number);
  151464. /**
  151465. * Gets or sets the edge distortion
  151466. */
  151467. get edgeDistortion(): number;
  151468. set edgeDistortion(value: number);
  151469. /**
  151470. * Gets or sets the depth of field distortion
  151471. */
  151472. get dofDistortion(): number;
  151473. set dofDistortion(value: number);
  151474. /**
  151475. * Gets or sets the darken out of focus amount
  151476. */
  151477. get darkenOutOfFocus(): number;
  151478. set darkenOutOfFocus(value: number);
  151479. /**
  151480. * Gets or sets a boolean indicating if blur noise is enabled
  151481. */
  151482. get blurNoise(): boolean;
  151483. set blurNoise(value: boolean);
  151484. /**
  151485. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151486. */
  151487. get pentagonBokeh(): boolean;
  151488. set pentagonBokeh(value: boolean);
  151489. /**
  151490. * Gets or sets the highlight grain amount
  151491. */
  151492. get highlightsGain(): number;
  151493. set highlightsGain(value: number);
  151494. /**
  151495. * Gets or sets the highlight threshold
  151496. */
  151497. get highlightsThreshold(): number;
  151498. set highlightsThreshold(value: number);
  151499. /**
  151500. * Sets the amount of blur at the edges
  151501. * @param amount blur amount
  151502. */
  151503. setEdgeBlur(amount: number): void;
  151504. /**
  151505. * Sets edge blur to 0
  151506. */
  151507. disableEdgeBlur(): void;
  151508. /**
  151509. * Sets the amout of grain
  151510. * @param amount Amount of grain
  151511. */
  151512. setGrainAmount(amount: number): void;
  151513. /**
  151514. * Set grain amount to 0
  151515. */
  151516. disableGrain(): void;
  151517. /**
  151518. * Sets the chromatic aberration amount
  151519. * @param amount amount of chromatic aberration
  151520. */
  151521. setChromaticAberration(amount: number): void;
  151522. /**
  151523. * Sets chromatic aberration amount to 0
  151524. */
  151525. disableChromaticAberration(): void;
  151526. /**
  151527. * Sets the EdgeDistortion amount
  151528. * @param amount amount of EdgeDistortion
  151529. */
  151530. setEdgeDistortion(amount: number): void;
  151531. /**
  151532. * Sets edge distortion to 0
  151533. */
  151534. disableEdgeDistortion(): void;
  151535. /**
  151536. * Sets the FocusDistance amount
  151537. * @param amount amount of FocusDistance
  151538. */
  151539. setFocusDistance(amount: number): void;
  151540. /**
  151541. * Disables depth of field
  151542. */
  151543. disableDepthOfField(): void;
  151544. /**
  151545. * Sets the Aperture amount
  151546. * @param amount amount of Aperture
  151547. */
  151548. setAperture(amount: number): void;
  151549. /**
  151550. * Sets the DarkenOutOfFocus amount
  151551. * @param amount amount of DarkenOutOfFocus
  151552. */
  151553. setDarkenOutOfFocus(amount: number): void;
  151554. private _pentagonBokehIsEnabled;
  151555. /**
  151556. * Creates a pentagon bokeh effect
  151557. */
  151558. enablePentagonBokeh(): void;
  151559. /**
  151560. * Disables the pentagon bokeh effect
  151561. */
  151562. disablePentagonBokeh(): void;
  151563. /**
  151564. * Enables noise blur
  151565. */
  151566. enableNoiseBlur(): void;
  151567. /**
  151568. * Disables noise blur
  151569. */
  151570. disableNoiseBlur(): void;
  151571. /**
  151572. * Sets the HighlightsGain amount
  151573. * @param amount amount of HighlightsGain
  151574. */
  151575. setHighlightsGain(amount: number): void;
  151576. /**
  151577. * Sets the HighlightsThreshold amount
  151578. * @param amount amount of HighlightsThreshold
  151579. */
  151580. setHighlightsThreshold(amount: number): void;
  151581. /**
  151582. * Disables highlights
  151583. */
  151584. disableHighlights(): void;
  151585. /**
  151586. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151587. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151588. */
  151589. dispose(disableDepthRender?: boolean): void;
  151590. private _createChromaticAberrationPostProcess;
  151591. private _createHighlightsPostProcess;
  151592. private _createDepthOfFieldPostProcess;
  151593. private _createGrainTexture;
  151594. }
  151595. }
  151596. declare module BABYLON {
  151597. /**
  151598. * Contains all parameters needed for the prepass to perform
  151599. * screen space subsurface scattering
  151600. */
  151601. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151602. /**
  151603. * Is subsurface enabled
  151604. */
  151605. enabled: boolean;
  151606. /**
  151607. * Name of the configuration
  151608. */
  151609. name: string;
  151610. /**
  151611. * Textures that should be present in the MRT for this effect to work
  151612. */
  151613. readonly texturesRequired: number[];
  151614. }
  151615. }
  151616. declare module BABYLON {
  151617. /** @hidden */
  151618. export var ssao2PixelShader: {
  151619. name: string;
  151620. shader: string;
  151621. };
  151622. }
  151623. declare module BABYLON {
  151624. /** @hidden */
  151625. export var ssaoCombinePixelShader: {
  151626. name: string;
  151627. shader: string;
  151628. };
  151629. }
  151630. declare module BABYLON {
  151631. /**
  151632. * Render pipeline to produce ssao effect
  151633. */
  151634. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151635. /**
  151636. * @ignore
  151637. * The PassPostProcess id in the pipeline that contains the original scene color
  151638. */
  151639. SSAOOriginalSceneColorEffect: string;
  151640. /**
  151641. * @ignore
  151642. * The SSAO PostProcess id in the pipeline
  151643. */
  151644. SSAORenderEffect: string;
  151645. /**
  151646. * @ignore
  151647. * The horizontal blur PostProcess id in the pipeline
  151648. */
  151649. SSAOBlurHRenderEffect: string;
  151650. /**
  151651. * @ignore
  151652. * The vertical blur PostProcess id in the pipeline
  151653. */
  151654. SSAOBlurVRenderEffect: string;
  151655. /**
  151656. * @ignore
  151657. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151658. */
  151659. SSAOCombineRenderEffect: string;
  151660. /**
  151661. * The output strength of the SSAO post-process. Default value is 1.0.
  151662. */
  151663. totalStrength: number;
  151664. /**
  151665. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151666. */
  151667. maxZ: number;
  151668. /**
  151669. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151670. */
  151671. minZAspect: number;
  151672. private _samples;
  151673. /**
  151674. * Number of samples used for the SSAO calculations. Default value is 8
  151675. */
  151676. set samples(n: number);
  151677. get samples(): number;
  151678. private _textureSamples;
  151679. /**
  151680. * Number of samples to use for antialiasing
  151681. */
  151682. set textureSamples(n: number);
  151683. get textureSamples(): number;
  151684. /**
  151685. * Force rendering the geometry through geometry buffer
  151686. */
  151687. private _forceGeometryBuffer;
  151688. /**
  151689. * Ratio object used for SSAO ratio and blur ratio
  151690. */
  151691. private _ratio;
  151692. /**
  151693. * Dynamically generated sphere sampler.
  151694. */
  151695. private _sampleSphere;
  151696. /**
  151697. * Blur filter offsets
  151698. */
  151699. private _samplerOffsets;
  151700. private _expensiveBlur;
  151701. /**
  151702. * If bilateral blur should be used
  151703. */
  151704. set expensiveBlur(b: boolean);
  151705. get expensiveBlur(): boolean;
  151706. /**
  151707. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151708. */
  151709. radius: number;
  151710. /**
  151711. * The base color of the SSAO post-process
  151712. * The final result is "base + ssao" between [0, 1]
  151713. */
  151714. base: number;
  151715. /**
  151716. * Support test.
  151717. */
  151718. static get IsSupported(): boolean;
  151719. private _scene;
  151720. private _randomTexture;
  151721. private _originalColorPostProcess;
  151722. private _ssaoPostProcess;
  151723. private _blurHPostProcess;
  151724. private _blurVPostProcess;
  151725. private _ssaoCombinePostProcess;
  151726. private _prePassRenderer;
  151727. /**
  151728. * Gets active scene
  151729. */
  151730. get scene(): Scene;
  151731. /**
  151732. * @constructor
  151733. * @param name The rendering pipeline name
  151734. * @param scene The scene linked to this pipeline
  151735. * @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 }
  151736. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151737. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151738. */
  151739. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151740. /**
  151741. * Get the class name
  151742. * @returns "SSAO2RenderingPipeline"
  151743. */
  151744. getClassName(): string;
  151745. /**
  151746. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151747. */
  151748. dispose(disableGeometryBufferRenderer?: boolean): void;
  151749. private _createBlurPostProcess;
  151750. /** @hidden */
  151751. _rebuild(): void;
  151752. private _bits;
  151753. private _radicalInverse_VdC;
  151754. private _hammersley;
  151755. private _hemisphereSample_uniform;
  151756. private _generateHemisphere;
  151757. private _getDefinesForSSAO;
  151758. private _createSSAOPostProcess;
  151759. private _createSSAOCombinePostProcess;
  151760. private _createRandomTexture;
  151761. /**
  151762. * Serialize the rendering pipeline (Used when exporting)
  151763. * @returns the serialized object
  151764. */
  151765. serialize(): any;
  151766. /**
  151767. * Parse the serialized pipeline
  151768. * @param source Source pipeline.
  151769. * @param scene The scene to load the pipeline to.
  151770. * @param rootUrl The URL of the serialized pipeline.
  151771. * @returns An instantiated pipeline from the serialized object.
  151772. */
  151773. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151774. }
  151775. }
  151776. declare module BABYLON {
  151777. /** @hidden */
  151778. export var ssaoPixelShader: {
  151779. name: string;
  151780. shader: string;
  151781. };
  151782. }
  151783. declare module BABYLON {
  151784. /**
  151785. * Render pipeline to produce ssao effect
  151786. */
  151787. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151788. /**
  151789. * @ignore
  151790. * The PassPostProcess id in the pipeline that contains the original scene color
  151791. */
  151792. SSAOOriginalSceneColorEffect: string;
  151793. /**
  151794. * @ignore
  151795. * The SSAO PostProcess id in the pipeline
  151796. */
  151797. SSAORenderEffect: string;
  151798. /**
  151799. * @ignore
  151800. * The horizontal blur PostProcess id in the pipeline
  151801. */
  151802. SSAOBlurHRenderEffect: string;
  151803. /**
  151804. * @ignore
  151805. * The vertical blur PostProcess id in the pipeline
  151806. */
  151807. SSAOBlurVRenderEffect: string;
  151808. /**
  151809. * @ignore
  151810. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151811. */
  151812. SSAOCombineRenderEffect: string;
  151813. /**
  151814. * The output strength of the SSAO post-process. Default value is 1.0.
  151815. */
  151816. totalStrength: number;
  151817. /**
  151818. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151819. */
  151820. radius: number;
  151821. /**
  151822. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151823. * Must not be equal to fallOff and superior to fallOff.
  151824. * Default value is 0.0075
  151825. */
  151826. area: number;
  151827. /**
  151828. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151829. * Must not be equal to area and inferior to area.
  151830. * Default value is 0.000001
  151831. */
  151832. fallOff: number;
  151833. /**
  151834. * The base color of the SSAO post-process
  151835. * The final result is "base + ssao" between [0, 1]
  151836. */
  151837. base: number;
  151838. private _scene;
  151839. private _depthTexture;
  151840. private _randomTexture;
  151841. private _originalColorPostProcess;
  151842. private _ssaoPostProcess;
  151843. private _blurHPostProcess;
  151844. private _blurVPostProcess;
  151845. private _ssaoCombinePostProcess;
  151846. private _firstUpdate;
  151847. /**
  151848. * Gets active scene
  151849. */
  151850. get scene(): Scene;
  151851. /**
  151852. * @constructor
  151853. * @param name - The rendering pipeline name
  151854. * @param scene - The scene linked to this pipeline
  151855. * @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 }
  151856. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151857. */
  151858. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151859. /**
  151860. * Get the class name
  151861. * @returns "SSAORenderingPipeline"
  151862. */
  151863. getClassName(): string;
  151864. /**
  151865. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151866. */
  151867. dispose(disableDepthRender?: boolean): void;
  151868. private _createBlurPostProcess;
  151869. /** @hidden */
  151870. _rebuild(): void;
  151871. private _createSSAOPostProcess;
  151872. private _createSSAOCombinePostProcess;
  151873. private _createRandomTexture;
  151874. }
  151875. }
  151876. declare module BABYLON {
  151877. /**
  151878. * Contains all parameters needed for the prepass to perform
  151879. * screen space reflections
  151880. */
  151881. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  151882. /**
  151883. * Is ssr enabled
  151884. */
  151885. enabled: boolean;
  151886. /**
  151887. * Name of the configuration
  151888. */
  151889. name: string;
  151890. /**
  151891. * Textures that should be present in the MRT for this effect to work
  151892. */
  151893. readonly texturesRequired: number[];
  151894. }
  151895. }
  151896. declare module BABYLON {
  151897. /** @hidden */
  151898. export var screenSpaceReflectionPixelShader: {
  151899. name: string;
  151900. shader: string;
  151901. };
  151902. }
  151903. declare module BABYLON {
  151904. /**
  151905. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151906. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151907. */
  151908. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151909. /**
  151910. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151911. */
  151912. threshold: number;
  151913. /**
  151914. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151915. */
  151916. strength: number;
  151917. /**
  151918. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151919. */
  151920. reflectionSpecularFalloffExponent: number;
  151921. /**
  151922. * 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]
  151923. */
  151924. step: number;
  151925. /**
  151926. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151927. */
  151928. roughnessFactor: number;
  151929. private _forceGeometryBuffer;
  151930. private _geometryBufferRenderer;
  151931. private _prePassRenderer;
  151932. private _enableSmoothReflections;
  151933. private _reflectionSamples;
  151934. private _smoothSteps;
  151935. /**
  151936. * Gets a string identifying the name of the class
  151937. * @returns "ScreenSpaceReflectionPostProcess" string
  151938. */
  151939. getClassName(): string;
  151940. /**
  151941. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151942. * @param name The name of the effect.
  151943. * @param scene The scene containing the objects to calculate reflections.
  151944. * @param options The required width/height ratio to downsize to before computing the render pass.
  151945. * @param camera The camera to apply the render pass to.
  151946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151947. * @param engine The engine which the post process will be applied. (default: current engine)
  151948. * @param reusable If the post process can be reused on the same frame. (default: false)
  151949. * @param textureType Type of textures used when performing the post process. (default: 0)
  151950. * @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)
  151951. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151952. */
  151953. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151954. /**
  151955. * Gets wether or not smoothing reflections is enabled.
  151956. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151957. */
  151958. get enableSmoothReflections(): boolean;
  151959. /**
  151960. * Sets wether or not smoothing reflections is enabled.
  151961. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151962. */
  151963. set enableSmoothReflections(enabled: boolean);
  151964. /**
  151965. * Gets the number of samples taken while computing reflections. More samples count is high,
  151966. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151967. */
  151968. get reflectionSamples(): number;
  151969. /**
  151970. * Sets the number of samples taken while computing reflections. More samples count is high,
  151971. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151972. */
  151973. set reflectionSamples(samples: number);
  151974. /**
  151975. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151976. * more the post-process will require GPU power and can generate a drop in FPS.
  151977. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151978. */
  151979. get smoothSteps(): number;
  151980. set smoothSteps(steps: number);
  151981. private _updateEffectDefines;
  151982. /** @hidden */
  151983. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151984. }
  151985. }
  151986. declare module BABYLON {
  151987. /** @hidden */
  151988. export var standardPixelShader: {
  151989. name: string;
  151990. shader: string;
  151991. };
  151992. }
  151993. declare module BABYLON {
  151994. /**
  151995. * Standard rendering pipeline
  151996. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151997. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151998. */
  151999. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152000. /**
  152001. * Public members
  152002. */
  152003. /**
  152004. * Post-process which contains the original scene color before the pipeline applies all the effects
  152005. */
  152006. originalPostProcess: Nullable<PostProcess>;
  152007. /**
  152008. * Post-process used to down scale an image x4
  152009. */
  152010. downSampleX4PostProcess: Nullable<PostProcess>;
  152011. /**
  152012. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152013. */
  152014. brightPassPostProcess: Nullable<PostProcess>;
  152015. /**
  152016. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152017. */
  152018. blurHPostProcesses: PostProcess[];
  152019. /**
  152020. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152021. */
  152022. blurVPostProcesses: PostProcess[];
  152023. /**
  152024. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152025. */
  152026. textureAdderPostProcess: Nullable<PostProcess>;
  152027. /**
  152028. * Post-process used to create volumetric lighting effect
  152029. */
  152030. volumetricLightPostProcess: Nullable<PostProcess>;
  152031. /**
  152032. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152033. */
  152034. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152035. /**
  152036. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152037. */
  152038. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152039. /**
  152040. * Post-process used to merge the volumetric light effect and the real scene color
  152041. */
  152042. volumetricLightMergePostProces: Nullable<PostProcess>;
  152043. /**
  152044. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152045. */
  152046. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152047. /**
  152048. * Base post-process used to calculate the average luminance of the final image for HDR
  152049. */
  152050. luminancePostProcess: Nullable<PostProcess>;
  152051. /**
  152052. * Post-processes used to create down sample post-processes in order to get
  152053. * the average luminance of the final image for HDR
  152054. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152055. */
  152056. luminanceDownSamplePostProcesses: PostProcess[];
  152057. /**
  152058. * Post-process used to create a HDR effect (light adaptation)
  152059. */
  152060. hdrPostProcess: Nullable<PostProcess>;
  152061. /**
  152062. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152063. */
  152064. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152065. /**
  152066. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152067. */
  152068. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152069. /**
  152070. * Post-process used to merge the final HDR post-process and the real scene color
  152071. */
  152072. hdrFinalPostProcess: Nullable<PostProcess>;
  152073. /**
  152074. * Post-process used to create a lens flare effect
  152075. */
  152076. lensFlarePostProcess: Nullable<PostProcess>;
  152077. /**
  152078. * Post-process that merges the result of the lens flare post-process and the real scene color
  152079. */
  152080. lensFlareComposePostProcess: Nullable<PostProcess>;
  152081. /**
  152082. * Post-process used to create a motion blur effect
  152083. */
  152084. motionBlurPostProcess: Nullable<PostProcess>;
  152085. /**
  152086. * Post-process used to create a depth of field effect
  152087. */
  152088. depthOfFieldPostProcess: Nullable<PostProcess>;
  152089. /**
  152090. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152091. */
  152092. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152093. /**
  152094. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152095. */
  152096. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152097. /**
  152098. * Represents the brightness threshold in order to configure the illuminated surfaces
  152099. */
  152100. brightThreshold: number;
  152101. /**
  152102. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152103. */
  152104. blurWidth: number;
  152105. /**
  152106. * Sets if the blur for highlighted surfaces must be only horizontal
  152107. */
  152108. horizontalBlur: boolean;
  152109. /**
  152110. * Gets the overall exposure used by the pipeline
  152111. */
  152112. get exposure(): number;
  152113. /**
  152114. * Sets the overall exposure used by the pipeline
  152115. */
  152116. set exposure(value: number);
  152117. /**
  152118. * Texture used typically to simulate "dirty" on camera lens
  152119. */
  152120. lensTexture: Nullable<Texture>;
  152121. /**
  152122. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152123. */
  152124. volumetricLightCoefficient: number;
  152125. /**
  152126. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152127. */
  152128. volumetricLightPower: number;
  152129. /**
  152130. * Used the set the blur intensity to smooth the volumetric lights
  152131. */
  152132. volumetricLightBlurScale: number;
  152133. /**
  152134. * Light (spot or directional) used to generate the volumetric lights rays
  152135. * The source light must have a shadow generate so the pipeline can get its
  152136. * depth map
  152137. */
  152138. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152139. /**
  152140. * For eye adaptation, represents the minimum luminance the eye can see
  152141. */
  152142. hdrMinimumLuminance: number;
  152143. /**
  152144. * For eye adaptation, represents the decrease luminance speed
  152145. */
  152146. hdrDecreaseRate: number;
  152147. /**
  152148. * For eye adaptation, represents the increase luminance speed
  152149. */
  152150. hdrIncreaseRate: number;
  152151. /**
  152152. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152153. */
  152154. get hdrAutoExposure(): boolean;
  152155. /**
  152156. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152157. */
  152158. set hdrAutoExposure(value: boolean);
  152159. /**
  152160. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152161. */
  152162. lensColorTexture: Nullable<Texture>;
  152163. /**
  152164. * The overall strengh for the lens flare effect
  152165. */
  152166. lensFlareStrength: number;
  152167. /**
  152168. * Dispersion coefficient for lens flare ghosts
  152169. */
  152170. lensFlareGhostDispersal: number;
  152171. /**
  152172. * Main lens flare halo width
  152173. */
  152174. lensFlareHaloWidth: number;
  152175. /**
  152176. * Based on the lens distortion effect, defines how much the lens flare result
  152177. * is distorted
  152178. */
  152179. lensFlareDistortionStrength: number;
  152180. /**
  152181. * Configures the blur intensity used for for lens flare (halo)
  152182. */
  152183. lensFlareBlurWidth: number;
  152184. /**
  152185. * Lens star texture must be used to simulate rays on the flares and is available
  152186. * in the documentation
  152187. */
  152188. lensStarTexture: Nullable<Texture>;
  152189. /**
  152190. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152191. * flare effect by taking account of the dirt texture
  152192. */
  152193. lensFlareDirtTexture: Nullable<Texture>;
  152194. /**
  152195. * Represents the focal length for the depth of field effect
  152196. */
  152197. depthOfFieldDistance: number;
  152198. /**
  152199. * Represents the blur intensity for the blurred part of the depth of field effect
  152200. */
  152201. depthOfFieldBlurWidth: number;
  152202. /**
  152203. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152204. */
  152205. get motionStrength(): number;
  152206. /**
  152207. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152208. */
  152209. set motionStrength(strength: number);
  152210. /**
  152211. * Gets wether or not the motion blur post-process is object based or screen based.
  152212. */
  152213. get objectBasedMotionBlur(): boolean;
  152214. /**
  152215. * Sets wether or not the motion blur post-process should be object based or screen based
  152216. */
  152217. set objectBasedMotionBlur(value: boolean);
  152218. /**
  152219. * List of animations for the pipeline (IAnimatable implementation)
  152220. */
  152221. animations: Animation[];
  152222. /**
  152223. * Private members
  152224. */
  152225. private _scene;
  152226. private _currentDepthOfFieldSource;
  152227. private _basePostProcess;
  152228. private _fixedExposure;
  152229. private _currentExposure;
  152230. private _hdrAutoExposure;
  152231. private _hdrCurrentLuminance;
  152232. private _motionStrength;
  152233. private _isObjectBasedMotionBlur;
  152234. private _floatTextureType;
  152235. private _camerasToBeAttached;
  152236. private _ratio;
  152237. private _bloomEnabled;
  152238. private _depthOfFieldEnabled;
  152239. private _vlsEnabled;
  152240. private _lensFlareEnabled;
  152241. private _hdrEnabled;
  152242. private _motionBlurEnabled;
  152243. private _fxaaEnabled;
  152244. private _screenSpaceReflectionsEnabled;
  152245. private _motionBlurSamples;
  152246. private _volumetricLightStepsCount;
  152247. private _samples;
  152248. /**
  152249. * @ignore
  152250. * Specifies if the bloom pipeline is enabled
  152251. */
  152252. get BloomEnabled(): boolean;
  152253. set BloomEnabled(enabled: boolean);
  152254. /**
  152255. * @ignore
  152256. * Specifies if the depth of field pipeline is enabed
  152257. */
  152258. get DepthOfFieldEnabled(): boolean;
  152259. set DepthOfFieldEnabled(enabled: boolean);
  152260. /**
  152261. * @ignore
  152262. * Specifies if the lens flare pipeline is enabed
  152263. */
  152264. get LensFlareEnabled(): boolean;
  152265. set LensFlareEnabled(enabled: boolean);
  152266. /**
  152267. * @ignore
  152268. * Specifies if the HDR pipeline is enabled
  152269. */
  152270. get HDREnabled(): boolean;
  152271. set HDREnabled(enabled: boolean);
  152272. /**
  152273. * @ignore
  152274. * Specifies if the volumetric lights scattering effect is enabled
  152275. */
  152276. get VLSEnabled(): boolean;
  152277. set VLSEnabled(enabled: boolean);
  152278. /**
  152279. * @ignore
  152280. * Specifies if the motion blur effect is enabled
  152281. */
  152282. get MotionBlurEnabled(): boolean;
  152283. set MotionBlurEnabled(enabled: boolean);
  152284. /**
  152285. * Specifies if anti-aliasing is enabled
  152286. */
  152287. get fxaaEnabled(): boolean;
  152288. set fxaaEnabled(enabled: boolean);
  152289. /**
  152290. * Specifies if screen space reflections are enabled.
  152291. */
  152292. get screenSpaceReflectionsEnabled(): boolean;
  152293. set screenSpaceReflectionsEnabled(enabled: boolean);
  152294. /**
  152295. * Specifies the number of steps used to calculate the volumetric lights
  152296. * Typically in interval [50, 200]
  152297. */
  152298. get volumetricLightStepsCount(): number;
  152299. set volumetricLightStepsCount(count: number);
  152300. /**
  152301. * Specifies the number of samples used for the motion blur effect
  152302. * Typically in interval [16, 64]
  152303. */
  152304. get motionBlurSamples(): number;
  152305. set motionBlurSamples(samples: number);
  152306. /**
  152307. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152308. */
  152309. get samples(): number;
  152310. set samples(sampleCount: number);
  152311. /**
  152312. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152313. * @constructor
  152314. * @param name The rendering pipeline name
  152315. * @param scene The scene linked to this pipeline
  152316. * @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)
  152317. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152319. */
  152320. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152321. private _buildPipeline;
  152322. private _createDownSampleX4PostProcess;
  152323. private _createBrightPassPostProcess;
  152324. private _createBlurPostProcesses;
  152325. private _createTextureAdderPostProcess;
  152326. private _createVolumetricLightPostProcess;
  152327. private _createLuminancePostProcesses;
  152328. private _createHdrPostProcess;
  152329. private _createLensFlarePostProcess;
  152330. private _createDepthOfFieldPostProcess;
  152331. private _createMotionBlurPostProcess;
  152332. private _getDepthTexture;
  152333. private _disposePostProcesses;
  152334. /**
  152335. * Dispose of the pipeline and stop all post processes
  152336. */
  152337. dispose(): void;
  152338. /**
  152339. * Serialize the rendering pipeline (Used when exporting)
  152340. * @returns the serialized object
  152341. */
  152342. serialize(): any;
  152343. /**
  152344. * Parse the serialized pipeline
  152345. * @param source Source pipeline.
  152346. * @param scene The scene to load the pipeline to.
  152347. * @param rootUrl The URL of the serialized pipeline.
  152348. * @returns An instantiated pipeline from the serialized object.
  152349. */
  152350. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152351. /**
  152352. * Luminance steps
  152353. */
  152354. static LuminanceSteps: number;
  152355. }
  152356. }
  152357. declare module BABYLON {
  152358. /** @hidden */
  152359. export var stereoscopicInterlacePixelShader: {
  152360. name: string;
  152361. shader: string;
  152362. };
  152363. }
  152364. declare module BABYLON {
  152365. /**
  152366. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152367. */
  152368. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152369. private _stepSize;
  152370. private _passedProcess;
  152371. /**
  152372. * Gets a string identifying the name of the class
  152373. * @returns "StereoscopicInterlacePostProcessI" string
  152374. */
  152375. getClassName(): string;
  152376. /**
  152377. * Initializes a StereoscopicInterlacePostProcessI
  152378. * @param name The name of the effect.
  152379. * @param rigCameras The rig cameras to be appled to the post process
  152380. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152381. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152383. * @param engine The engine which the post process will be applied. (default: current engine)
  152384. * @param reusable If the post process can be reused on the same frame. (default: false)
  152385. */
  152386. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152387. }
  152388. /**
  152389. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152390. */
  152391. export class StereoscopicInterlacePostProcess extends PostProcess {
  152392. private _stepSize;
  152393. private _passedProcess;
  152394. /**
  152395. * Gets a string identifying the name of the class
  152396. * @returns "StereoscopicInterlacePostProcess" string
  152397. */
  152398. getClassName(): string;
  152399. /**
  152400. * Initializes a StereoscopicInterlacePostProcess
  152401. * @param name The name of the effect.
  152402. * @param rigCameras The rig cameras to be appled to the post process
  152403. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152405. * @param engine The engine which the post process will be applied. (default: current engine)
  152406. * @param reusable If the post process can be reused on the same frame. (default: false)
  152407. */
  152408. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152409. }
  152410. }
  152411. declare module BABYLON {
  152412. /** @hidden */
  152413. export var tonemapPixelShader: {
  152414. name: string;
  152415. shader: string;
  152416. };
  152417. }
  152418. declare module BABYLON {
  152419. /** Defines operator used for tonemapping */
  152420. export enum TonemappingOperator {
  152421. /** Hable */
  152422. Hable = 0,
  152423. /** Reinhard */
  152424. Reinhard = 1,
  152425. /** HejiDawson */
  152426. HejiDawson = 2,
  152427. /** Photographic */
  152428. Photographic = 3
  152429. }
  152430. /**
  152431. * Defines a post process to apply tone mapping
  152432. */
  152433. export class TonemapPostProcess extends PostProcess {
  152434. private _operator;
  152435. /** Defines the required exposure adjustement */
  152436. exposureAdjustment: number;
  152437. /**
  152438. * Gets a string identifying the name of the class
  152439. * @returns "TonemapPostProcess" string
  152440. */
  152441. getClassName(): string;
  152442. /**
  152443. * Creates a new TonemapPostProcess
  152444. * @param name defines the name of the postprocess
  152445. * @param _operator defines the operator to use
  152446. * @param exposureAdjustment defines the required exposure adjustement
  152447. * @param camera defines the camera to use (can be null)
  152448. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152449. * @param engine defines the hosting engine (can be ignore if camera is set)
  152450. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152451. */
  152452. constructor(name: string, _operator: TonemappingOperator,
  152453. /** Defines the required exposure adjustement */
  152454. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152455. }
  152456. }
  152457. declare module BABYLON {
  152458. /** @hidden */
  152459. export var volumetricLightScatteringPixelShader: {
  152460. name: string;
  152461. shader: string;
  152462. };
  152463. }
  152464. declare module BABYLON {
  152465. /** @hidden */
  152466. export var volumetricLightScatteringPassVertexShader: {
  152467. name: string;
  152468. shader: string;
  152469. };
  152470. }
  152471. declare module BABYLON {
  152472. /** @hidden */
  152473. export var volumetricLightScatteringPassPixelShader: {
  152474. name: string;
  152475. shader: string;
  152476. };
  152477. }
  152478. declare module BABYLON {
  152479. /**
  152480. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152481. */
  152482. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152483. private _volumetricLightScatteringPass;
  152484. private _volumetricLightScatteringRTT;
  152485. private _viewPort;
  152486. private _screenCoordinates;
  152487. private _cachedDefines;
  152488. /**
  152489. * If not undefined, the mesh position is computed from the attached node position
  152490. */
  152491. attachedNode: {
  152492. position: Vector3;
  152493. };
  152494. /**
  152495. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152496. */
  152497. customMeshPosition: Vector3;
  152498. /**
  152499. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152500. */
  152501. useCustomMeshPosition: boolean;
  152502. /**
  152503. * If the post-process should inverse the light scattering direction
  152504. */
  152505. invert: boolean;
  152506. /**
  152507. * The internal mesh used by the post-process
  152508. */
  152509. mesh: Mesh;
  152510. /**
  152511. * @hidden
  152512. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152513. */
  152514. get useDiffuseColor(): boolean;
  152515. set useDiffuseColor(useDiffuseColor: boolean);
  152516. /**
  152517. * Array containing the excluded meshes not rendered in the internal pass
  152518. */
  152519. excludedMeshes: AbstractMesh[];
  152520. /**
  152521. * Controls the overall intensity of the post-process
  152522. */
  152523. exposure: number;
  152524. /**
  152525. * Dissipates each sample's contribution in range [0, 1]
  152526. */
  152527. decay: number;
  152528. /**
  152529. * Controls the overall intensity of each sample
  152530. */
  152531. weight: number;
  152532. /**
  152533. * Controls the density of each sample
  152534. */
  152535. density: number;
  152536. /**
  152537. * @constructor
  152538. * @param name The post-process name
  152539. * @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)
  152540. * @param camera The camera that the post-process will be attached to
  152541. * @param mesh The mesh used to create the light scattering
  152542. * @param samples The post-process quality, default 100
  152543. * @param samplingModeThe post-process filtering mode
  152544. * @param engine The babylon engine
  152545. * @param reusable If the post-process is reusable
  152546. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152547. */
  152548. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152549. /**
  152550. * Returns the string "VolumetricLightScatteringPostProcess"
  152551. * @returns "VolumetricLightScatteringPostProcess"
  152552. */
  152553. getClassName(): string;
  152554. private _isReady;
  152555. /**
  152556. * Sets the new light position for light scattering effect
  152557. * @param position The new custom light position
  152558. */
  152559. setCustomMeshPosition(position: Vector3): void;
  152560. /**
  152561. * Returns the light position for light scattering effect
  152562. * @return Vector3 The custom light position
  152563. */
  152564. getCustomMeshPosition(): Vector3;
  152565. /**
  152566. * Disposes the internal assets and detaches the post-process from the camera
  152567. */
  152568. dispose(camera: Camera): void;
  152569. /**
  152570. * Returns the render target texture used by the post-process
  152571. * @return the render target texture used by the post-process
  152572. */
  152573. getPass(): RenderTargetTexture;
  152574. private _meshExcluded;
  152575. private _createPass;
  152576. private _updateMeshScreenCoordinates;
  152577. /**
  152578. * Creates a default mesh for the Volumeric Light Scattering post-process
  152579. * @param name The mesh name
  152580. * @param scene The scene where to create the mesh
  152581. * @return the default mesh
  152582. */
  152583. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152584. }
  152585. }
  152586. declare module BABYLON {
  152587. /** @hidden */
  152588. export var screenSpaceCurvaturePixelShader: {
  152589. name: string;
  152590. shader: string;
  152591. };
  152592. }
  152593. declare module BABYLON {
  152594. /**
  152595. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152596. */
  152597. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152598. /**
  152599. * Defines how much ridge the curvature effect displays.
  152600. */
  152601. ridge: number;
  152602. /**
  152603. * Defines how much valley the curvature effect displays.
  152604. */
  152605. valley: number;
  152606. private _geometryBufferRenderer;
  152607. /**
  152608. * Gets a string identifying the name of the class
  152609. * @returns "ScreenSpaceCurvaturePostProcess" string
  152610. */
  152611. getClassName(): string;
  152612. /**
  152613. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152614. * @param name The name of the effect.
  152615. * @param scene The scene containing the objects to blur according to their velocity.
  152616. * @param options The required width/height ratio to downsize to before computing the render pass.
  152617. * @param camera The camera to apply the render pass to.
  152618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152619. * @param engine The engine which the post process will be applied. (default: current engine)
  152620. * @param reusable If the post process can be reused on the same frame. (default: false)
  152621. * @param textureType Type of textures used when performing the post process. (default: 0)
  152622. * @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)
  152623. */
  152624. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152625. /**
  152626. * Support test.
  152627. */
  152628. static get IsSupported(): boolean;
  152629. /** @hidden */
  152630. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152631. }
  152632. }
  152633. declare module BABYLON {
  152634. interface Scene {
  152635. /** @hidden (Backing field) */
  152636. _boundingBoxRenderer: BoundingBoxRenderer;
  152637. /** @hidden (Backing field) */
  152638. _forceShowBoundingBoxes: boolean;
  152639. /**
  152640. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152641. */
  152642. forceShowBoundingBoxes: boolean;
  152643. /**
  152644. * Gets the bounding box renderer associated with the scene
  152645. * @returns a BoundingBoxRenderer
  152646. */
  152647. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152648. }
  152649. interface AbstractMesh {
  152650. /** @hidden (Backing field) */
  152651. _showBoundingBox: boolean;
  152652. /**
  152653. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152654. */
  152655. showBoundingBox: boolean;
  152656. }
  152657. /**
  152658. * Component responsible of rendering the bounding box of the meshes in a scene.
  152659. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152660. */
  152661. export class BoundingBoxRenderer implements ISceneComponent {
  152662. /**
  152663. * The component name helpfull to identify the component in the list of scene components.
  152664. */
  152665. readonly name: string;
  152666. /**
  152667. * The scene the component belongs to.
  152668. */
  152669. scene: Scene;
  152670. /**
  152671. * Color of the bounding box lines placed in front of an object
  152672. */
  152673. frontColor: Color3;
  152674. /**
  152675. * Color of the bounding box lines placed behind an object
  152676. */
  152677. backColor: Color3;
  152678. /**
  152679. * Defines if the renderer should show the back lines or not
  152680. */
  152681. showBackLines: boolean;
  152682. /**
  152683. * Observable raised before rendering a bounding box
  152684. */
  152685. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152686. /**
  152687. * Observable raised after rendering a bounding box
  152688. */
  152689. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152690. /**
  152691. * @hidden
  152692. */
  152693. renderList: SmartArray<BoundingBox>;
  152694. private _colorShader;
  152695. private _vertexBuffers;
  152696. private _indexBuffer;
  152697. private _fillIndexBuffer;
  152698. private _fillIndexData;
  152699. /**
  152700. * Instantiates a new bounding box renderer in a scene.
  152701. * @param scene the scene the renderer renders in
  152702. */
  152703. constructor(scene: Scene);
  152704. /**
  152705. * Registers the component in a given scene
  152706. */
  152707. register(): void;
  152708. private _evaluateSubMesh;
  152709. private _activeMesh;
  152710. private _prepareRessources;
  152711. private _createIndexBuffer;
  152712. /**
  152713. * Rebuilds the elements related to this component in case of
  152714. * context lost for instance.
  152715. */
  152716. rebuild(): void;
  152717. /**
  152718. * @hidden
  152719. */
  152720. reset(): void;
  152721. /**
  152722. * Render the bounding boxes of a specific rendering group
  152723. * @param renderingGroupId defines the rendering group to render
  152724. */
  152725. render(renderingGroupId: number): void;
  152726. /**
  152727. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152728. * @param mesh Define the mesh to render the occlusion bounding box for
  152729. */
  152730. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152731. /**
  152732. * Dispose and release the resources attached to this renderer.
  152733. */
  152734. dispose(): void;
  152735. }
  152736. }
  152737. declare module BABYLON {
  152738. interface Scene {
  152739. /** @hidden (Backing field) */
  152740. _depthRenderer: {
  152741. [id: string]: DepthRenderer;
  152742. };
  152743. /**
  152744. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152745. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152746. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152747. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152748. * @returns the created depth renderer
  152749. */
  152750. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152751. /**
  152752. * Disables a depth renderer for a given camera
  152753. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152754. */
  152755. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152756. }
  152757. /**
  152758. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152759. * in several rendering techniques.
  152760. */
  152761. export class DepthRendererSceneComponent implements ISceneComponent {
  152762. /**
  152763. * The component name helpfull to identify the component in the list of scene components.
  152764. */
  152765. readonly name: string;
  152766. /**
  152767. * The scene the component belongs to.
  152768. */
  152769. scene: Scene;
  152770. /**
  152771. * Creates a new instance of the component for the given scene
  152772. * @param scene Defines the scene to register the component in
  152773. */
  152774. constructor(scene: Scene);
  152775. /**
  152776. * Registers the component in a given scene
  152777. */
  152778. register(): void;
  152779. /**
  152780. * Rebuilds the elements related to this component in case of
  152781. * context lost for instance.
  152782. */
  152783. rebuild(): void;
  152784. /**
  152785. * Disposes the component and the associated ressources
  152786. */
  152787. dispose(): void;
  152788. private _gatherRenderTargets;
  152789. private _gatherActiveCameraRenderTargets;
  152790. }
  152791. }
  152792. declare module BABYLON {
  152793. interface AbstractScene {
  152794. /** @hidden (Backing field) */
  152795. _prePassRenderer: Nullable<PrePassRenderer>;
  152796. /**
  152797. * Gets or Sets the current prepass renderer associated to the scene.
  152798. */
  152799. prePassRenderer: Nullable<PrePassRenderer>;
  152800. /**
  152801. * Enables the prepass and associates it with the scene
  152802. * @returns the PrePassRenderer
  152803. */
  152804. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152805. /**
  152806. * Disables the prepass associated with the scene
  152807. */
  152808. disablePrePassRenderer(): void;
  152809. }
  152810. /**
  152811. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152812. * in several rendering techniques.
  152813. */
  152814. export class PrePassRendererSceneComponent implements ISceneComponent {
  152815. /**
  152816. * The component name helpful to identify the component in the list of scene components.
  152817. */
  152818. readonly name: string;
  152819. /**
  152820. * The scene the component belongs to.
  152821. */
  152822. scene: Scene;
  152823. /**
  152824. * Creates a new instance of the component for the given scene
  152825. * @param scene Defines the scene to register the component in
  152826. */
  152827. constructor(scene: Scene);
  152828. /**
  152829. * Registers the component in a given scene
  152830. */
  152831. register(): void;
  152832. private _beforeCameraDraw;
  152833. private _afterCameraDraw;
  152834. private _beforeClearStage;
  152835. /**
  152836. * Rebuilds the elements related to this component in case of
  152837. * context lost for instance.
  152838. */
  152839. rebuild(): void;
  152840. /**
  152841. * Disposes the component and the associated ressources
  152842. */
  152843. dispose(): void;
  152844. }
  152845. }
  152846. declare module BABYLON {
  152847. /** @hidden */
  152848. export var fibonacci: {
  152849. name: string;
  152850. shader: string;
  152851. };
  152852. }
  152853. declare module BABYLON {
  152854. /** @hidden */
  152855. export var diffusionProfile: {
  152856. name: string;
  152857. shader: string;
  152858. };
  152859. }
  152860. declare module BABYLON {
  152861. /** @hidden */
  152862. export var subSurfaceScatteringPixelShader: {
  152863. name: string;
  152864. shader: string;
  152865. };
  152866. }
  152867. declare module BABYLON {
  152868. /**
  152869. * Sub surface scattering post process
  152870. */
  152871. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152872. /**
  152873. * Gets a string identifying the name of the class
  152874. * @returns "SubSurfaceScatteringPostProcess" string
  152875. */
  152876. getClassName(): string;
  152877. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152878. }
  152879. }
  152880. declare module BABYLON {
  152881. /**
  152882. * Contains all parameters needed for the prepass to perform
  152883. * screen space subsurface scattering
  152884. */
  152885. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152886. /** @hidden */
  152887. static _SceneComponentInitialization: (scene: Scene) => void;
  152888. private _ssDiffusionS;
  152889. private _ssFilterRadii;
  152890. private _ssDiffusionD;
  152891. /**
  152892. * Post process to attach for screen space subsurface scattering
  152893. */
  152894. postProcess: SubSurfaceScatteringPostProcess;
  152895. /**
  152896. * Diffusion profile color for subsurface scattering
  152897. */
  152898. get ssDiffusionS(): number[];
  152899. /**
  152900. * Diffusion profile max color channel value for subsurface scattering
  152901. */
  152902. get ssDiffusionD(): number[];
  152903. /**
  152904. * Diffusion profile filter radius for subsurface scattering
  152905. */
  152906. get ssFilterRadii(): number[];
  152907. /**
  152908. * Is subsurface enabled
  152909. */
  152910. enabled: boolean;
  152911. /**
  152912. * Name of the configuration
  152913. */
  152914. name: string;
  152915. /**
  152916. * Diffusion profile colors for subsurface scattering
  152917. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152918. * See ...
  152919. * Note that you can only store up to 5 of them
  152920. */
  152921. ssDiffusionProfileColors: Color3[];
  152922. /**
  152923. * Defines the ratio real world => scene units.
  152924. * Used for subsurface scattering
  152925. */
  152926. metersPerUnit: number;
  152927. /**
  152928. * Textures that should be present in the MRT for this effect to work
  152929. */
  152930. readonly texturesRequired: number[];
  152931. private _scene;
  152932. /**
  152933. * Builds a subsurface configuration object
  152934. * @param scene The scene
  152935. */
  152936. constructor(scene: Scene);
  152937. /**
  152938. * Adds a new diffusion profile.
  152939. * Useful for more realistic subsurface scattering on diverse materials.
  152940. * @param color The color of the diffusion profile. Should be the average color of the material.
  152941. * @return The index of the diffusion profile for the material subsurface configuration
  152942. */
  152943. addDiffusionProfile(color: Color3): number;
  152944. /**
  152945. * Creates the sss post process
  152946. * @return The created post process
  152947. */
  152948. createPostProcess(): SubSurfaceScatteringPostProcess;
  152949. /**
  152950. * Deletes all diffusion profiles.
  152951. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152952. */
  152953. clearAllDiffusionProfiles(): void;
  152954. /**
  152955. * Disposes this object
  152956. */
  152957. dispose(): void;
  152958. /**
  152959. * @hidden
  152960. * https://zero-radiance.github.io/post/sampling-diffusion/
  152961. *
  152962. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152963. * ------------------------------------------------------------------------------------
  152964. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152965. * PDF[r, phi, s] = r * R[r, phi, s]
  152966. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152967. * ------------------------------------------------------------------------------------
  152968. * We importance sample the color channel with the widest scattering distance.
  152969. */
  152970. getDiffusionProfileParameters(color: Color3): number;
  152971. /**
  152972. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152973. * 'u' is the random number (the value of the CDF): [0, 1).
  152974. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152975. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152976. */
  152977. private _sampleBurleyDiffusionProfile;
  152978. }
  152979. }
  152980. declare module BABYLON {
  152981. interface AbstractScene {
  152982. /** @hidden (Backing field) */
  152983. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152984. /**
  152985. * Gets or Sets the current prepass renderer associated to the scene.
  152986. */
  152987. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152988. /**
  152989. * Enables the subsurface effect for prepass
  152990. * @returns the SubSurfaceConfiguration
  152991. */
  152992. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152993. /**
  152994. * Disables the subsurface effect for prepass
  152995. */
  152996. disableSubSurfaceForPrePass(): void;
  152997. }
  152998. /**
  152999. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153000. * in several rendering techniques.
  153001. */
  153002. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153003. /**
  153004. * The component name helpful to identify the component in the list of scene components.
  153005. */
  153006. readonly name: string;
  153007. /**
  153008. * The scene the component belongs to.
  153009. */
  153010. scene: Scene;
  153011. /**
  153012. * Creates a new instance of the component for the given scene
  153013. * @param scene Defines the scene to register the component in
  153014. */
  153015. constructor(scene: Scene);
  153016. /**
  153017. * Registers the component in a given scene
  153018. */
  153019. register(): void;
  153020. /**
  153021. * Serializes the component data to the specified json object
  153022. * @param serializationObject The object to serialize to
  153023. */
  153024. serialize(serializationObject: any): void;
  153025. /**
  153026. * Adds all the elements from the container to the scene
  153027. * @param container the container holding the elements
  153028. */
  153029. addFromContainer(container: AbstractScene): void;
  153030. /**
  153031. * Removes all the elements in the container from the scene
  153032. * @param container contains the elements to remove
  153033. * @param dispose if the removed element should be disposed (default: false)
  153034. */
  153035. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153036. /**
  153037. * Rebuilds the elements related to this component in case of
  153038. * context lost for instance.
  153039. */
  153040. rebuild(): void;
  153041. /**
  153042. * Disposes the component and the associated ressources
  153043. */
  153044. dispose(): void;
  153045. }
  153046. }
  153047. declare module BABYLON {
  153048. /** @hidden */
  153049. export var outlinePixelShader: {
  153050. name: string;
  153051. shader: string;
  153052. };
  153053. }
  153054. declare module BABYLON {
  153055. /** @hidden */
  153056. export var outlineVertexShader: {
  153057. name: string;
  153058. shader: string;
  153059. };
  153060. }
  153061. declare module BABYLON {
  153062. interface Scene {
  153063. /** @hidden */
  153064. _outlineRenderer: OutlineRenderer;
  153065. /**
  153066. * Gets the outline renderer associated with the scene
  153067. * @returns a OutlineRenderer
  153068. */
  153069. getOutlineRenderer(): OutlineRenderer;
  153070. }
  153071. interface AbstractMesh {
  153072. /** @hidden (Backing field) */
  153073. _renderOutline: boolean;
  153074. /**
  153075. * Gets or sets a boolean indicating if the outline must be rendered as well
  153076. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153077. */
  153078. renderOutline: boolean;
  153079. /** @hidden (Backing field) */
  153080. _renderOverlay: boolean;
  153081. /**
  153082. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153083. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153084. */
  153085. renderOverlay: boolean;
  153086. }
  153087. /**
  153088. * This class is responsible to draw bothe outline/overlay of meshes.
  153089. * It should not be used directly but through the available method on mesh.
  153090. */
  153091. export class OutlineRenderer implements ISceneComponent {
  153092. /**
  153093. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153094. */
  153095. private static _StencilReference;
  153096. /**
  153097. * The name of the component. Each component must have a unique name.
  153098. */
  153099. name: string;
  153100. /**
  153101. * The scene the component belongs to.
  153102. */
  153103. scene: Scene;
  153104. /**
  153105. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153106. */
  153107. zOffset: number;
  153108. private _engine;
  153109. private _effect;
  153110. private _cachedDefines;
  153111. private _savedDepthWrite;
  153112. /**
  153113. * Instantiates a new outline renderer. (There could be only one per scene).
  153114. * @param scene Defines the scene it belongs to
  153115. */
  153116. constructor(scene: Scene);
  153117. /**
  153118. * Register the component to one instance of a scene.
  153119. */
  153120. register(): void;
  153121. /**
  153122. * Rebuilds the elements related to this component in case of
  153123. * context lost for instance.
  153124. */
  153125. rebuild(): void;
  153126. /**
  153127. * Disposes the component and the associated ressources.
  153128. */
  153129. dispose(): void;
  153130. /**
  153131. * Renders the outline in the canvas.
  153132. * @param subMesh Defines the sumesh to render
  153133. * @param batch Defines the batch of meshes in case of instances
  153134. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153135. */
  153136. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153137. /**
  153138. * Returns whether or not the outline renderer is ready for a given submesh.
  153139. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153140. * @param subMesh Defines the submesh to check readyness for
  153141. * @param useInstances Defines wheter wee are trying to render instances or not
  153142. * @returns true if ready otherwise false
  153143. */
  153144. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153145. private _beforeRenderingMesh;
  153146. private _afterRenderingMesh;
  153147. }
  153148. }
  153149. declare module BABYLON {
  153150. /**
  153151. * Defines the basic options interface of a Sprite Frame Source Size.
  153152. */
  153153. export interface ISpriteJSONSpriteSourceSize {
  153154. /**
  153155. * number of the original width of the Frame
  153156. */
  153157. w: number;
  153158. /**
  153159. * number of the original height of the Frame
  153160. */
  153161. h: number;
  153162. }
  153163. /**
  153164. * Defines the basic options interface of a Sprite Frame Data.
  153165. */
  153166. export interface ISpriteJSONSpriteFrameData {
  153167. /**
  153168. * number of the x offset of the Frame
  153169. */
  153170. x: number;
  153171. /**
  153172. * number of the y offset of the Frame
  153173. */
  153174. y: number;
  153175. /**
  153176. * number of the width of the Frame
  153177. */
  153178. w: number;
  153179. /**
  153180. * number of the height of the Frame
  153181. */
  153182. h: number;
  153183. }
  153184. /**
  153185. * Defines the basic options interface of a JSON Sprite.
  153186. */
  153187. export interface ISpriteJSONSprite {
  153188. /**
  153189. * string name of the Frame
  153190. */
  153191. filename: string;
  153192. /**
  153193. * ISpriteJSONSpriteFrame basic object of the frame data
  153194. */
  153195. frame: ISpriteJSONSpriteFrameData;
  153196. /**
  153197. * boolean to flag is the frame was rotated.
  153198. */
  153199. rotated: boolean;
  153200. /**
  153201. * boolean to flag is the frame was trimmed.
  153202. */
  153203. trimmed: boolean;
  153204. /**
  153205. * ISpriteJSONSpriteFrame basic object of the source data
  153206. */
  153207. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153208. /**
  153209. * ISpriteJSONSpriteFrame basic object of the source data
  153210. */
  153211. sourceSize: ISpriteJSONSpriteSourceSize;
  153212. }
  153213. /**
  153214. * Defines the basic options interface of a JSON atlas.
  153215. */
  153216. export interface ISpriteJSONAtlas {
  153217. /**
  153218. * Array of objects that contain the frame data.
  153219. */
  153220. frames: Array<ISpriteJSONSprite>;
  153221. /**
  153222. * object basic object containing the sprite meta data.
  153223. */
  153224. meta?: object;
  153225. }
  153226. }
  153227. declare module BABYLON {
  153228. /** @hidden */
  153229. export var spriteMapPixelShader: {
  153230. name: string;
  153231. shader: string;
  153232. };
  153233. }
  153234. declare module BABYLON {
  153235. /** @hidden */
  153236. export var spriteMapVertexShader: {
  153237. name: string;
  153238. shader: string;
  153239. };
  153240. }
  153241. declare module BABYLON {
  153242. /**
  153243. * Defines the basic options interface of a SpriteMap
  153244. */
  153245. export interface ISpriteMapOptions {
  153246. /**
  153247. * Vector2 of the number of cells in the grid.
  153248. */
  153249. stageSize?: Vector2;
  153250. /**
  153251. * Vector2 of the size of the output plane in World Units.
  153252. */
  153253. outputSize?: Vector2;
  153254. /**
  153255. * Vector3 of the position of the output plane in World Units.
  153256. */
  153257. outputPosition?: Vector3;
  153258. /**
  153259. * Vector3 of the rotation of the output plane.
  153260. */
  153261. outputRotation?: Vector3;
  153262. /**
  153263. * number of layers that the system will reserve in resources.
  153264. */
  153265. layerCount?: number;
  153266. /**
  153267. * number of max animation frames a single cell will reserve in resources.
  153268. */
  153269. maxAnimationFrames?: number;
  153270. /**
  153271. * number cell index of the base tile when the system compiles.
  153272. */
  153273. baseTile?: number;
  153274. /**
  153275. * boolean flip the sprite after its been repositioned by the framing data.
  153276. */
  153277. flipU?: boolean;
  153278. /**
  153279. * Vector3 scalar of the global RGB values of the SpriteMap.
  153280. */
  153281. colorMultiply?: Vector3;
  153282. }
  153283. /**
  153284. * Defines the IDisposable interface in order to be cleanable from resources.
  153285. */
  153286. export interface ISpriteMap extends IDisposable {
  153287. /**
  153288. * String name of the SpriteMap.
  153289. */
  153290. name: string;
  153291. /**
  153292. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153293. */
  153294. atlasJSON: ISpriteJSONAtlas;
  153295. /**
  153296. * Texture of the SpriteMap.
  153297. */
  153298. spriteSheet: Texture;
  153299. /**
  153300. * The parameters to initialize the SpriteMap with.
  153301. */
  153302. options: ISpriteMapOptions;
  153303. }
  153304. /**
  153305. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153306. */
  153307. export class SpriteMap implements ISpriteMap {
  153308. /** The Name of the spriteMap */
  153309. name: string;
  153310. /** The JSON file with the frame and meta data */
  153311. atlasJSON: ISpriteJSONAtlas;
  153312. /** The systems Sprite Sheet Texture */
  153313. spriteSheet: Texture;
  153314. /** Arguments passed with the Constructor */
  153315. options: ISpriteMapOptions;
  153316. /** Public Sprite Storage array, parsed from atlasJSON */
  153317. sprites: Array<ISpriteJSONSprite>;
  153318. /** Returns the Number of Sprites in the System */
  153319. get spriteCount(): number;
  153320. /** Returns the Position of Output Plane*/
  153321. get position(): Vector3;
  153322. /** Returns the Position of Output Plane*/
  153323. set position(v: Vector3);
  153324. /** Returns the Rotation of Output Plane*/
  153325. get rotation(): Vector3;
  153326. /** Returns the Rotation of Output Plane*/
  153327. set rotation(v: Vector3);
  153328. /** Sets the AnimationMap*/
  153329. get animationMap(): RawTexture;
  153330. /** Sets the AnimationMap*/
  153331. set animationMap(v: RawTexture);
  153332. /** Scene that the SpriteMap was created in */
  153333. private _scene;
  153334. /** Texture Buffer of Float32 that holds tile frame data*/
  153335. private _frameMap;
  153336. /** Texture Buffers of Float32 that holds tileMap data*/
  153337. private _tileMaps;
  153338. /** Texture Buffer of Float32 that holds Animation Data*/
  153339. private _animationMap;
  153340. /** Custom ShaderMaterial Central to the System*/
  153341. private _material;
  153342. /** Custom ShaderMaterial Central to the System*/
  153343. private _output;
  153344. /** Systems Time Ticker*/
  153345. private _time;
  153346. /**
  153347. * Creates a new SpriteMap
  153348. * @param name defines the SpriteMaps Name
  153349. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153350. * @param spriteSheet is the Texture that the Sprites are on.
  153351. * @param options a basic deployment configuration
  153352. * @param scene The Scene that the map is deployed on
  153353. */
  153354. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153355. /**
  153356. * Returns tileID location
  153357. * @returns Vector2 the cell position ID
  153358. */
  153359. getTileID(): Vector2;
  153360. /**
  153361. * Gets the UV location of the mouse over the SpriteMap.
  153362. * @returns Vector2 the UV position of the mouse interaction
  153363. */
  153364. getMousePosition(): Vector2;
  153365. /**
  153366. * Creates the "frame" texture Buffer
  153367. * -------------------------------------
  153368. * Structure of frames
  153369. * "filename": "Falling-Water-2.png",
  153370. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153371. * "rotated": true,
  153372. * "trimmed": true,
  153373. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153374. * "sourceSize": {"w":32,"h":32}
  153375. * @returns RawTexture of the frameMap
  153376. */
  153377. private _createFrameBuffer;
  153378. /**
  153379. * Creates the tileMap texture Buffer
  153380. * @param buffer normally and array of numbers, or a false to generate from scratch
  153381. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153382. * @returns RawTexture of the tileMap
  153383. */
  153384. private _createTileBuffer;
  153385. /**
  153386. * Modifies the data of the tileMaps
  153387. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153388. * @param pos is the iVector2 Coordinates of the Tile
  153389. * @param tile The SpriteIndex of the new Tile
  153390. */
  153391. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153392. /**
  153393. * Creates the animationMap texture Buffer
  153394. * @param buffer normally and array of numbers, or a false to generate from scratch
  153395. * @returns RawTexture of the animationMap
  153396. */
  153397. private _createTileAnimationBuffer;
  153398. /**
  153399. * Modifies the data of the animationMap
  153400. * @param cellID is the Index of the Sprite
  153401. * @param _frame is the target Animation frame
  153402. * @param toCell is the Target Index of the next frame of the animation
  153403. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153404. * @param speed is a global scalar of the time variable on the map.
  153405. */
  153406. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153407. /**
  153408. * Exports the .tilemaps file
  153409. */
  153410. saveTileMaps(): void;
  153411. /**
  153412. * Imports the .tilemaps file
  153413. * @param url of the .tilemaps file
  153414. */
  153415. loadTileMaps(url: string): void;
  153416. /**
  153417. * Release associated resources
  153418. */
  153419. dispose(): void;
  153420. }
  153421. }
  153422. declare module BABYLON {
  153423. /**
  153424. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153425. * @see https://doc.babylonjs.com/babylon101/sprites
  153426. */
  153427. export class SpritePackedManager extends SpriteManager {
  153428. /** defines the packed manager's name */
  153429. name: string;
  153430. /**
  153431. * Creates a new sprite manager from a packed sprite sheet
  153432. * @param name defines the manager's name
  153433. * @param imgUrl defines the sprite sheet url
  153434. * @param capacity defines the maximum allowed number of sprites
  153435. * @param scene defines the hosting scene
  153436. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153437. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153438. * @param samplingMode defines the smapling mode to use with spritesheet
  153439. * @param fromPacked set to true; do not alter
  153440. */
  153441. constructor(
  153442. /** defines the packed manager's name */
  153443. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153444. }
  153445. }
  153446. declare module BABYLON {
  153447. /**
  153448. * Defines the list of states available for a task inside a AssetsManager
  153449. */
  153450. export enum AssetTaskState {
  153451. /**
  153452. * Initialization
  153453. */
  153454. INIT = 0,
  153455. /**
  153456. * Running
  153457. */
  153458. RUNNING = 1,
  153459. /**
  153460. * Done
  153461. */
  153462. DONE = 2,
  153463. /**
  153464. * Error
  153465. */
  153466. ERROR = 3
  153467. }
  153468. /**
  153469. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153470. */
  153471. export abstract class AbstractAssetTask {
  153472. /**
  153473. * Task name
  153474. */ name: string;
  153475. /**
  153476. * Callback called when the task is successful
  153477. */
  153478. onSuccess: (task: any) => void;
  153479. /**
  153480. * Callback called when the task is not successful
  153481. */
  153482. onError: (task: any, message?: string, exception?: any) => void;
  153483. /**
  153484. * Creates a new AssetsManager
  153485. * @param name defines the name of the task
  153486. */
  153487. constructor(
  153488. /**
  153489. * Task name
  153490. */ name: string);
  153491. private _isCompleted;
  153492. private _taskState;
  153493. private _errorObject;
  153494. /**
  153495. * Get if the task is completed
  153496. */
  153497. get isCompleted(): boolean;
  153498. /**
  153499. * Gets the current state of the task
  153500. */
  153501. get taskState(): AssetTaskState;
  153502. /**
  153503. * Gets the current error object (if task is in error)
  153504. */
  153505. get errorObject(): {
  153506. message?: string;
  153507. exception?: any;
  153508. };
  153509. /**
  153510. * Internal only
  153511. * @hidden
  153512. */
  153513. _setErrorObject(message?: string, exception?: any): void;
  153514. /**
  153515. * Execute the current task
  153516. * @param scene defines the scene where you want your assets to be loaded
  153517. * @param onSuccess is a callback called when the task is successfully executed
  153518. * @param onError is a callback called if an error occurs
  153519. */
  153520. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153521. /**
  153522. * Execute the current task
  153523. * @param scene defines the scene where you want your assets to be loaded
  153524. * @param onSuccess is a callback called when the task is successfully executed
  153525. * @param onError is a callback called if an error occurs
  153526. */
  153527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153528. /**
  153529. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153530. * This can be used with failed tasks that have the reason for failure fixed.
  153531. */
  153532. reset(): void;
  153533. private onErrorCallback;
  153534. private onDoneCallback;
  153535. }
  153536. /**
  153537. * Define the interface used by progress events raised during assets loading
  153538. */
  153539. export interface IAssetsProgressEvent {
  153540. /**
  153541. * Defines the number of remaining tasks to process
  153542. */
  153543. remainingCount: number;
  153544. /**
  153545. * Defines the total number of tasks
  153546. */
  153547. totalCount: number;
  153548. /**
  153549. * Defines the task that was just processed
  153550. */
  153551. task: AbstractAssetTask;
  153552. }
  153553. /**
  153554. * Class used to share progress information about assets loading
  153555. */
  153556. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153557. /**
  153558. * Defines the number of remaining tasks to process
  153559. */
  153560. remainingCount: number;
  153561. /**
  153562. * Defines the total number of tasks
  153563. */
  153564. totalCount: number;
  153565. /**
  153566. * Defines the task that was just processed
  153567. */
  153568. task: AbstractAssetTask;
  153569. /**
  153570. * Creates a AssetsProgressEvent
  153571. * @param remainingCount defines the number of remaining tasks to process
  153572. * @param totalCount defines the total number of tasks
  153573. * @param task defines the task that was just processed
  153574. */
  153575. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153576. }
  153577. /**
  153578. * Define a task used by AssetsManager to load assets into a container
  153579. */
  153580. export class ContainerAssetTask extends AbstractAssetTask {
  153581. /**
  153582. * Defines the name of the task
  153583. */
  153584. name: string;
  153585. /**
  153586. * Defines the list of mesh's names you want to load
  153587. */
  153588. meshesNames: any;
  153589. /**
  153590. * Defines the root url to use as a base to load your meshes and associated resources
  153591. */
  153592. rootUrl: string;
  153593. /**
  153594. * Defines the filename or File of the scene to load from
  153595. */
  153596. sceneFilename: string | File;
  153597. /**
  153598. * Get the loaded asset container
  153599. */
  153600. loadedContainer: AssetContainer;
  153601. /**
  153602. * Gets the list of loaded meshes
  153603. */
  153604. loadedMeshes: Array<AbstractMesh>;
  153605. /**
  153606. * Gets the list of loaded particle systems
  153607. */
  153608. loadedParticleSystems: Array<IParticleSystem>;
  153609. /**
  153610. * Gets the list of loaded skeletons
  153611. */
  153612. loadedSkeletons: Array<Skeleton>;
  153613. /**
  153614. * Gets the list of loaded animation groups
  153615. */
  153616. loadedAnimationGroups: Array<AnimationGroup>;
  153617. /**
  153618. * Callback called when the task is successful
  153619. */
  153620. onSuccess: (task: ContainerAssetTask) => void;
  153621. /**
  153622. * Callback called when the task is successful
  153623. */
  153624. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153625. /**
  153626. * Creates a new ContainerAssetTask
  153627. * @param name defines the name of the task
  153628. * @param meshesNames defines the list of mesh's names you want to load
  153629. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153630. * @param sceneFilename defines the filename or File of the scene to load from
  153631. */
  153632. constructor(
  153633. /**
  153634. * Defines the name of the task
  153635. */
  153636. name: string,
  153637. /**
  153638. * Defines the list of mesh's names you want to load
  153639. */
  153640. meshesNames: any,
  153641. /**
  153642. * Defines the root url to use as a base to load your meshes and associated resources
  153643. */
  153644. rootUrl: string,
  153645. /**
  153646. * Defines the filename or File of the scene to load from
  153647. */
  153648. sceneFilename: string | File);
  153649. /**
  153650. * Execute the current task
  153651. * @param scene defines the scene where you want your assets to be loaded
  153652. * @param onSuccess is a callback called when the task is successfully executed
  153653. * @param onError is a callback called if an error occurs
  153654. */
  153655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153656. }
  153657. /**
  153658. * Define a task used by AssetsManager to load meshes
  153659. */
  153660. export class MeshAssetTask extends AbstractAssetTask {
  153661. /**
  153662. * Defines the name of the task
  153663. */
  153664. name: string;
  153665. /**
  153666. * Defines the list of mesh's names you want to load
  153667. */
  153668. meshesNames: any;
  153669. /**
  153670. * Defines the root url to use as a base to load your meshes and associated resources
  153671. */
  153672. rootUrl: string;
  153673. /**
  153674. * Defines the filename or File of the scene to load from
  153675. */
  153676. sceneFilename: string | File;
  153677. /**
  153678. * Gets the list of loaded meshes
  153679. */
  153680. loadedMeshes: Array<AbstractMesh>;
  153681. /**
  153682. * Gets the list of loaded particle systems
  153683. */
  153684. loadedParticleSystems: Array<IParticleSystem>;
  153685. /**
  153686. * Gets the list of loaded skeletons
  153687. */
  153688. loadedSkeletons: Array<Skeleton>;
  153689. /**
  153690. * Gets the list of loaded animation groups
  153691. */
  153692. loadedAnimationGroups: Array<AnimationGroup>;
  153693. /**
  153694. * Callback called when the task is successful
  153695. */
  153696. onSuccess: (task: MeshAssetTask) => void;
  153697. /**
  153698. * Callback called when the task is successful
  153699. */
  153700. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153701. /**
  153702. * Creates a new MeshAssetTask
  153703. * @param name defines the name of the task
  153704. * @param meshesNames defines the list of mesh's names you want to load
  153705. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153706. * @param sceneFilename defines the filename or File of the scene to load from
  153707. */
  153708. constructor(
  153709. /**
  153710. * Defines the name of the task
  153711. */
  153712. name: string,
  153713. /**
  153714. * Defines the list of mesh's names you want to load
  153715. */
  153716. meshesNames: any,
  153717. /**
  153718. * Defines the root url to use as a base to load your meshes and associated resources
  153719. */
  153720. rootUrl: string,
  153721. /**
  153722. * Defines the filename or File of the scene to load from
  153723. */
  153724. sceneFilename: string | File);
  153725. /**
  153726. * Execute the current task
  153727. * @param scene defines the scene where you want your assets to be loaded
  153728. * @param onSuccess is a callback called when the task is successfully executed
  153729. * @param onError is a callback called if an error occurs
  153730. */
  153731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153732. }
  153733. /**
  153734. * Define a task used by AssetsManager to load text content
  153735. */
  153736. export class TextFileAssetTask extends AbstractAssetTask {
  153737. /**
  153738. * Defines the name of the task
  153739. */
  153740. name: string;
  153741. /**
  153742. * Defines the location of the file to load
  153743. */
  153744. url: string;
  153745. /**
  153746. * Gets the loaded text string
  153747. */
  153748. text: string;
  153749. /**
  153750. * Callback called when the task is successful
  153751. */
  153752. onSuccess: (task: TextFileAssetTask) => void;
  153753. /**
  153754. * Callback called when the task is successful
  153755. */
  153756. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153757. /**
  153758. * Creates a new TextFileAssetTask object
  153759. * @param name defines the name of the task
  153760. * @param url defines the location of the file to load
  153761. */
  153762. constructor(
  153763. /**
  153764. * Defines the name of the task
  153765. */
  153766. name: string,
  153767. /**
  153768. * Defines the location of the file to load
  153769. */
  153770. url: string);
  153771. /**
  153772. * Execute the current task
  153773. * @param scene defines the scene where you want your assets to be loaded
  153774. * @param onSuccess is a callback called when the task is successfully executed
  153775. * @param onError is a callback called if an error occurs
  153776. */
  153777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153778. }
  153779. /**
  153780. * Define a task used by AssetsManager to load binary data
  153781. */
  153782. export class BinaryFileAssetTask extends AbstractAssetTask {
  153783. /**
  153784. * Defines the name of the task
  153785. */
  153786. name: string;
  153787. /**
  153788. * Defines the location of the file to load
  153789. */
  153790. url: string;
  153791. /**
  153792. * Gets the lodaded data (as an array buffer)
  153793. */
  153794. data: ArrayBuffer;
  153795. /**
  153796. * Callback called when the task is successful
  153797. */
  153798. onSuccess: (task: BinaryFileAssetTask) => void;
  153799. /**
  153800. * Callback called when the task is successful
  153801. */
  153802. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153803. /**
  153804. * Creates a new BinaryFileAssetTask object
  153805. * @param name defines the name of the new task
  153806. * @param url defines the location of the file to load
  153807. */
  153808. constructor(
  153809. /**
  153810. * Defines the name of the task
  153811. */
  153812. name: string,
  153813. /**
  153814. * Defines the location of the file to load
  153815. */
  153816. url: string);
  153817. /**
  153818. * Execute the current task
  153819. * @param scene defines the scene where you want your assets to be loaded
  153820. * @param onSuccess is a callback called when the task is successfully executed
  153821. * @param onError is a callback called if an error occurs
  153822. */
  153823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153824. }
  153825. /**
  153826. * Define a task used by AssetsManager to load images
  153827. */
  153828. export class ImageAssetTask extends AbstractAssetTask {
  153829. /**
  153830. * Defines the name of the task
  153831. */
  153832. name: string;
  153833. /**
  153834. * Defines the location of the image to load
  153835. */
  153836. url: string;
  153837. /**
  153838. * Gets the loaded images
  153839. */
  153840. image: HTMLImageElement;
  153841. /**
  153842. * Callback called when the task is successful
  153843. */
  153844. onSuccess: (task: ImageAssetTask) => void;
  153845. /**
  153846. * Callback called when the task is successful
  153847. */
  153848. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153849. /**
  153850. * Creates a new ImageAssetTask
  153851. * @param name defines the name of the task
  153852. * @param url defines the location of the image to load
  153853. */
  153854. constructor(
  153855. /**
  153856. * Defines the name of the task
  153857. */
  153858. name: string,
  153859. /**
  153860. * Defines the location of the image to load
  153861. */
  153862. url: string);
  153863. /**
  153864. * Execute the current task
  153865. * @param scene defines the scene where you want your assets to be loaded
  153866. * @param onSuccess is a callback called when the task is successfully executed
  153867. * @param onError is a callback called if an error occurs
  153868. */
  153869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153870. }
  153871. /**
  153872. * Defines the interface used by texture loading tasks
  153873. */
  153874. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153875. /**
  153876. * Gets the loaded texture
  153877. */
  153878. texture: TEX;
  153879. }
  153880. /**
  153881. * Define a task used by AssetsManager to load 2D textures
  153882. */
  153883. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153884. /**
  153885. * Defines the name of the task
  153886. */
  153887. name: string;
  153888. /**
  153889. * Defines the location of the file to load
  153890. */
  153891. url: string;
  153892. /**
  153893. * Defines if mipmap should not be generated (default is false)
  153894. */
  153895. noMipmap?: boolean | undefined;
  153896. /**
  153897. * Defines if texture must be inverted on Y axis (default is true)
  153898. */
  153899. invertY: boolean;
  153900. /**
  153901. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153902. */
  153903. samplingMode: number;
  153904. /**
  153905. * Gets the loaded texture
  153906. */
  153907. texture: Texture;
  153908. /**
  153909. * Callback called when the task is successful
  153910. */
  153911. onSuccess: (task: TextureAssetTask) => void;
  153912. /**
  153913. * Callback called when the task is successful
  153914. */
  153915. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153916. /**
  153917. * Creates a new TextureAssetTask object
  153918. * @param name defines the name of the task
  153919. * @param url defines the location of the file to load
  153920. * @param noMipmap defines if mipmap should not be generated (default is false)
  153921. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153922. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153923. */
  153924. constructor(
  153925. /**
  153926. * Defines the name of the task
  153927. */
  153928. name: string,
  153929. /**
  153930. * Defines the location of the file to load
  153931. */
  153932. url: string,
  153933. /**
  153934. * Defines if mipmap should not be generated (default is false)
  153935. */
  153936. noMipmap?: boolean | undefined,
  153937. /**
  153938. * Defines if texture must be inverted on Y axis (default is true)
  153939. */
  153940. invertY?: boolean,
  153941. /**
  153942. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153943. */
  153944. samplingMode?: number);
  153945. /**
  153946. * Execute the current task
  153947. * @param scene defines the scene where you want your assets to be loaded
  153948. * @param onSuccess is a callback called when the task is successfully executed
  153949. * @param onError is a callback called if an error occurs
  153950. */
  153951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153952. }
  153953. /**
  153954. * Define a task used by AssetsManager to load cube textures
  153955. */
  153956. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153957. /**
  153958. * Defines the name of the task
  153959. */
  153960. name: string;
  153961. /**
  153962. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153963. */
  153964. url: string;
  153965. /**
  153966. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153967. */
  153968. extensions?: string[] | undefined;
  153969. /**
  153970. * Defines if mipmaps should not be generated (default is false)
  153971. */
  153972. noMipmap?: boolean | undefined;
  153973. /**
  153974. * Defines the explicit list of files (undefined by default)
  153975. */
  153976. files?: string[] | undefined;
  153977. /**
  153978. * Gets the loaded texture
  153979. */
  153980. texture: CubeTexture;
  153981. /**
  153982. * Callback called when the task is successful
  153983. */
  153984. onSuccess: (task: CubeTextureAssetTask) => void;
  153985. /**
  153986. * Callback called when the task is successful
  153987. */
  153988. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153989. /**
  153990. * Creates a new CubeTextureAssetTask
  153991. * @param name defines the name of the task
  153992. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153993. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153994. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153995. * @param files defines the explicit list of files (undefined by default)
  153996. */
  153997. constructor(
  153998. /**
  153999. * Defines the name of the task
  154000. */
  154001. name: string,
  154002. /**
  154003. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154004. */
  154005. url: string,
  154006. /**
  154007. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154008. */
  154009. extensions?: string[] | undefined,
  154010. /**
  154011. * Defines if mipmaps should not be generated (default is false)
  154012. */
  154013. noMipmap?: boolean | undefined,
  154014. /**
  154015. * Defines the explicit list of files (undefined by default)
  154016. */
  154017. files?: string[] | undefined);
  154018. /**
  154019. * Execute the current task
  154020. * @param scene defines the scene where you want your assets to be loaded
  154021. * @param onSuccess is a callback called when the task is successfully executed
  154022. * @param onError is a callback called if an error occurs
  154023. */
  154024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154025. }
  154026. /**
  154027. * Define a task used by AssetsManager to load HDR cube textures
  154028. */
  154029. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154030. /**
  154031. * Defines the name of the task
  154032. */
  154033. name: string;
  154034. /**
  154035. * Defines the location of the file to load
  154036. */
  154037. url: string;
  154038. /**
  154039. * Defines the desired size (the more it increases the longer the generation will be)
  154040. */
  154041. size: number;
  154042. /**
  154043. * Defines if mipmaps should not be generated (default is false)
  154044. */
  154045. noMipmap: boolean;
  154046. /**
  154047. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154048. */
  154049. generateHarmonics: boolean;
  154050. /**
  154051. * 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)
  154052. */
  154053. gammaSpace: boolean;
  154054. /**
  154055. * Internal Use Only
  154056. */
  154057. reserved: boolean;
  154058. /**
  154059. * Gets the loaded texture
  154060. */
  154061. texture: HDRCubeTexture;
  154062. /**
  154063. * Callback called when the task is successful
  154064. */
  154065. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154066. /**
  154067. * Callback called when the task is successful
  154068. */
  154069. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154070. /**
  154071. * Creates a new HDRCubeTextureAssetTask object
  154072. * @param name defines the name of the task
  154073. * @param url defines the location of the file to load
  154074. * @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.
  154075. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154076. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154077. * @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)
  154078. * @param reserved Internal use only
  154079. */
  154080. constructor(
  154081. /**
  154082. * Defines the name of the task
  154083. */
  154084. name: string,
  154085. /**
  154086. * Defines the location of the file to load
  154087. */
  154088. url: string,
  154089. /**
  154090. * Defines the desired size (the more it increases the longer the generation will be)
  154091. */
  154092. size: number,
  154093. /**
  154094. * Defines if mipmaps should not be generated (default is false)
  154095. */
  154096. noMipmap?: boolean,
  154097. /**
  154098. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154099. */
  154100. generateHarmonics?: boolean,
  154101. /**
  154102. * 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)
  154103. */
  154104. gammaSpace?: boolean,
  154105. /**
  154106. * Internal Use Only
  154107. */
  154108. reserved?: boolean);
  154109. /**
  154110. * Execute the current task
  154111. * @param scene defines the scene where you want your assets to be loaded
  154112. * @param onSuccess is a callback called when the task is successfully executed
  154113. * @param onError is a callback called if an error occurs
  154114. */
  154115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154116. }
  154117. /**
  154118. * Define a task used by AssetsManager to load Equirectangular cube textures
  154119. */
  154120. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154121. /**
  154122. * Defines the name of the task
  154123. */
  154124. name: string;
  154125. /**
  154126. * Defines the location of the file to load
  154127. */
  154128. url: string;
  154129. /**
  154130. * Defines the desired size (the more it increases the longer the generation will be)
  154131. */
  154132. size: number;
  154133. /**
  154134. * Defines if mipmaps should not be generated (default is false)
  154135. */
  154136. noMipmap: boolean;
  154137. /**
  154138. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154139. * but the standard material would require them in Gamma space) (default is true)
  154140. */
  154141. gammaSpace: boolean;
  154142. /**
  154143. * Gets the loaded texture
  154144. */
  154145. texture: EquiRectangularCubeTexture;
  154146. /**
  154147. * Callback called when the task is successful
  154148. */
  154149. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154150. /**
  154151. * Callback called when the task is successful
  154152. */
  154153. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154154. /**
  154155. * Creates a new EquiRectangularCubeTextureAssetTask object
  154156. * @param name defines the name of the task
  154157. * @param url defines the location of the file to load
  154158. * @param size defines the desired size (the more it increases the longer the generation will be)
  154159. * If the size is omitted this implies you are using a preprocessed cubemap.
  154160. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154161. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154162. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154163. * (default is true)
  154164. */
  154165. constructor(
  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. * Defines the desired size (the more it increases the longer the generation will be)
  154176. */
  154177. size: number,
  154178. /**
  154179. * Defines if mipmaps should not be generated (default is false)
  154180. */
  154181. noMipmap?: boolean,
  154182. /**
  154183. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154184. * but the standard material would require them in Gamma space) (default is true)
  154185. */
  154186. gammaSpace?: boolean);
  154187. /**
  154188. * Execute the current task
  154189. * @param scene defines the scene where you want your assets to be loaded
  154190. * @param onSuccess is a callback called when the task is successfully executed
  154191. * @param onError is a callback called if an error occurs
  154192. */
  154193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154194. }
  154195. /**
  154196. * This class can be used to easily import assets into a scene
  154197. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154198. */
  154199. export class AssetsManager {
  154200. private _scene;
  154201. private _isLoading;
  154202. protected _tasks: AbstractAssetTask[];
  154203. protected _waitingTasksCount: number;
  154204. protected _totalTasksCount: number;
  154205. /**
  154206. * Callback called when all tasks are processed
  154207. */
  154208. onFinish: (tasks: AbstractAssetTask[]) => void;
  154209. /**
  154210. * Callback called when a task is successful
  154211. */
  154212. onTaskSuccess: (task: AbstractAssetTask) => void;
  154213. /**
  154214. * Callback called when a task had an error
  154215. */
  154216. onTaskError: (task: AbstractAssetTask) => void;
  154217. /**
  154218. * Callback called when a task is done (whatever the result is)
  154219. */
  154220. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154221. /**
  154222. * Observable called when all tasks are processed
  154223. */
  154224. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154225. /**
  154226. * Observable called when a task had an error
  154227. */
  154228. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154229. /**
  154230. * Observable called when all tasks were executed
  154231. */
  154232. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154233. /**
  154234. * Observable called when a task is done (whatever the result is)
  154235. */
  154236. onProgressObservable: Observable<IAssetsProgressEvent>;
  154237. /**
  154238. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154239. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154240. */
  154241. useDefaultLoadingScreen: boolean;
  154242. /**
  154243. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154244. * when all assets have been downloaded.
  154245. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154246. */
  154247. autoHideLoadingUI: boolean;
  154248. /**
  154249. * Creates a new AssetsManager
  154250. * @param scene defines the scene to work on
  154251. */
  154252. constructor(scene: Scene);
  154253. /**
  154254. * Add a ContainerAssetTask to the list of active tasks
  154255. * @param taskName defines the name of the new task
  154256. * @param meshesNames defines the name of meshes to load
  154257. * @param rootUrl defines the root url to use to locate files
  154258. * @param sceneFilename defines the filename of the scene file
  154259. * @returns a new ContainerAssetTask object
  154260. */
  154261. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154262. /**
  154263. * Add a MeshAssetTask to the list of active tasks
  154264. * @param taskName defines the name of the new task
  154265. * @param meshesNames defines the name of meshes to load
  154266. * @param rootUrl defines the root url to use to locate files
  154267. * @param sceneFilename defines the filename of the scene file
  154268. * @returns a new MeshAssetTask object
  154269. */
  154270. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154271. /**
  154272. * Add a TextFileAssetTask to the list of active tasks
  154273. * @param taskName defines the name of the new task
  154274. * @param url defines the url of the file to load
  154275. * @returns a new TextFileAssetTask object
  154276. */
  154277. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154278. /**
  154279. * Add a BinaryFileAssetTask to the list of active tasks
  154280. * @param taskName defines the name of the new task
  154281. * @param url defines the url of the file to load
  154282. * @returns a new BinaryFileAssetTask object
  154283. */
  154284. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154285. /**
  154286. * Add a ImageAssetTask to the list of active tasks
  154287. * @param taskName defines the name of the new task
  154288. * @param url defines the url of the file to load
  154289. * @returns a new ImageAssetTask object
  154290. */
  154291. addImageTask(taskName: string, url: string): ImageAssetTask;
  154292. /**
  154293. * Add a TextureAssetTask to the list of active tasks
  154294. * @param taskName defines the name of the new task
  154295. * @param url defines the url of the file to load
  154296. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154297. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154298. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154299. * @returns a new TextureAssetTask object
  154300. */
  154301. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154302. /**
  154303. * Add a CubeTextureAssetTask to the list of active tasks
  154304. * @param taskName defines the name of the new task
  154305. * @param url defines the url of the file to load
  154306. * @param extensions defines the extension to use to load the cube map (can be null)
  154307. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154308. * @param files defines the list of files to load (can be null)
  154309. * @returns a new CubeTextureAssetTask object
  154310. */
  154311. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154312. /**
  154313. *
  154314. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154315. * @param taskName defines the name of the new task
  154316. * @param url defines the url of the file to load
  154317. * @param size defines the size you want for the cubemap (can be null)
  154318. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154319. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154320. * @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)
  154321. * @param reserved Internal use only
  154322. * @returns a new HDRCubeTextureAssetTask object
  154323. */
  154324. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154325. /**
  154326. *
  154327. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154328. * @param taskName defines the name of the new task
  154329. * @param url defines the url of the file to load
  154330. * @param size defines the size you want for the cubemap (can be null)
  154331. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154332. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154333. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154334. * @returns a new EquiRectangularCubeTextureAssetTask object
  154335. */
  154336. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154337. /**
  154338. * Remove a task from the assets manager.
  154339. * @param task the task to remove
  154340. */
  154341. removeTask(task: AbstractAssetTask): void;
  154342. private _decreaseWaitingTasksCount;
  154343. private _runTask;
  154344. /**
  154345. * Reset the AssetsManager and remove all tasks
  154346. * @return the current instance of the AssetsManager
  154347. */
  154348. reset(): AssetsManager;
  154349. /**
  154350. * Start the loading process
  154351. * @return the current instance of the AssetsManager
  154352. */
  154353. load(): AssetsManager;
  154354. /**
  154355. * Start the loading process as an async operation
  154356. * @return a promise returning the list of failed tasks
  154357. */
  154358. loadAsync(): Promise<void>;
  154359. }
  154360. }
  154361. declare module BABYLON {
  154362. /**
  154363. * Wrapper class for promise with external resolve and reject.
  154364. */
  154365. export class Deferred<T> {
  154366. /**
  154367. * The promise associated with this deferred object.
  154368. */
  154369. readonly promise: Promise<T>;
  154370. private _resolve;
  154371. private _reject;
  154372. /**
  154373. * The resolve method of the promise associated with this deferred object.
  154374. */
  154375. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154376. /**
  154377. * The reject method of the promise associated with this deferred object.
  154378. */
  154379. get reject(): (reason?: any) => void;
  154380. /**
  154381. * Constructor for this deferred object.
  154382. */
  154383. constructor();
  154384. }
  154385. }
  154386. declare module BABYLON {
  154387. /**
  154388. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154389. */
  154390. export class MeshExploder {
  154391. private _centerMesh;
  154392. private _meshes;
  154393. private _meshesOrigins;
  154394. private _toCenterVectors;
  154395. private _scaledDirection;
  154396. private _newPosition;
  154397. private _centerPosition;
  154398. /**
  154399. * Explodes meshes from a center mesh.
  154400. * @param meshes The meshes to explode.
  154401. * @param centerMesh The mesh to be center of explosion.
  154402. */
  154403. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154404. private _setCenterMesh;
  154405. /**
  154406. * Get class name
  154407. * @returns "MeshExploder"
  154408. */
  154409. getClassName(): string;
  154410. /**
  154411. * "Exploded meshes"
  154412. * @returns Array of meshes with the centerMesh at index 0.
  154413. */
  154414. getMeshes(): Array<Mesh>;
  154415. /**
  154416. * Explodes meshes giving a specific direction
  154417. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154418. */
  154419. explode(direction?: number): void;
  154420. }
  154421. }
  154422. declare module BABYLON {
  154423. /**
  154424. * Class used to help managing file picking and drag'n'drop
  154425. */
  154426. export class FilesInput {
  154427. /**
  154428. * List of files ready to be loaded
  154429. */
  154430. static get FilesToLoad(): {
  154431. [key: string]: File;
  154432. };
  154433. /**
  154434. * Callback called when a file is processed
  154435. */
  154436. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154437. private _engine;
  154438. private _currentScene;
  154439. private _sceneLoadedCallback;
  154440. private _progressCallback;
  154441. private _additionalRenderLoopLogicCallback;
  154442. private _textureLoadingCallback;
  154443. private _startingProcessingFilesCallback;
  154444. private _onReloadCallback;
  154445. private _errorCallback;
  154446. private _elementToMonitor;
  154447. private _sceneFileToLoad;
  154448. private _filesToLoad;
  154449. /**
  154450. * Creates a new FilesInput
  154451. * @param engine defines the rendering engine
  154452. * @param scene defines the hosting scene
  154453. * @param sceneLoadedCallback callback called when scene is loaded
  154454. * @param progressCallback callback called to track progress
  154455. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154456. * @param textureLoadingCallback callback called when a texture is loading
  154457. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154458. * @param onReloadCallback callback called when a reload is requested
  154459. * @param errorCallback callback call if an error occurs
  154460. */
  154461. 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>);
  154462. private _dragEnterHandler;
  154463. private _dragOverHandler;
  154464. private _dropHandler;
  154465. /**
  154466. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154467. * @param elementToMonitor defines the DOM element to track
  154468. */
  154469. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154470. /** Gets the current list of files to load */
  154471. get filesToLoad(): File[];
  154472. /**
  154473. * Release all associated resources
  154474. */
  154475. dispose(): void;
  154476. private renderFunction;
  154477. private drag;
  154478. private drop;
  154479. private _traverseFolder;
  154480. private _processFiles;
  154481. /**
  154482. * Load files from a drop event
  154483. * @param event defines the drop event to use as source
  154484. */
  154485. loadFiles(event: any): void;
  154486. private _processReload;
  154487. /**
  154488. * Reload the current scene from the loaded files
  154489. */
  154490. reload(): void;
  154491. }
  154492. }
  154493. declare module BABYLON {
  154494. /**
  154495. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154496. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154497. */
  154498. export class SceneOptimization {
  154499. /**
  154500. * Defines the priority of this optimization (0 by default which means first in the list)
  154501. */
  154502. priority: number;
  154503. /**
  154504. * Gets a string describing the action executed by the current optimization
  154505. * @returns description string
  154506. */
  154507. getDescription(): string;
  154508. /**
  154509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154510. * @param scene defines the current scene where to apply this optimization
  154511. * @param optimizer defines the current optimizer
  154512. * @returns true if everything that can be done was applied
  154513. */
  154514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154515. /**
  154516. * Creates the SceneOptimization object
  154517. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154518. * @param desc defines the description associated with the optimization
  154519. */
  154520. constructor(
  154521. /**
  154522. * Defines the priority of this optimization (0 by default which means first in the list)
  154523. */
  154524. priority?: number);
  154525. }
  154526. /**
  154527. * Defines an optimization used to reduce the size of render target textures
  154528. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154529. */
  154530. export class TextureOptimization extends SceneOptimization {
  154531. /**
  154532. * Defines the priority of this optimization (0 by default which means first in the list)
  154533. */
  154534. priority: number;
  154535. /**
  154536. * 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
  154537. */
  154538. maximumSize: number;
  154539. /**
  154540. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154541. */
  154542. step: number;
  154543. /**
  154544. * Gets a string describing the action executed by the current optimization
  154545. * @returns description string
  154546. */
  154547. getDescription(): string;
  154548. /**
  154549. * Creates the TextureOptimization object
  154550. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154551. * @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
  154552. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154553. */
  154554. constructor(
  154555. /**
  154556. * Defines the priority of this optimization (0 by default which means first in the list)
  154557. */
  154558. priority?: number,
  154559. /**
  154560. * 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
  154561. */
  154562. maximumSize?: number,
  154563. /**
  154564. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154565. */
  154566. step?: number);
  154567. /**
  154568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154569. * @param scene defines the current scene where to apply this optimization
  154570. * @param optimizer defines the current optimizer
  154571. * @returns true if everything that can be done was applied
  154572. */
  154573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154574. }
  154575. /**
  154576. * Defines an optimization used to increase or decrease the rendering resolution
  154577. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154578. */
  154579. export class HardwareScalingOptimization extends SceneOptimization {
  154580. /**
  154581. * Defines the priority of this optimization (0 by default which means first in the list)
  154582. */
  154583. priority: number;
  154584. /**
  154585. * Defines the maximum scale to use (2 by default)
  154586. */
  154587. maximumScale: number;
  154588. /**
  154589. * Defines the step to use between two passes (0.5 by default)
  154590. */
  154591. step: number;
  154592. private _currentScale;
  154593. private _directionOffset;
  154594. /**
  154595. * Gets a string describing the action executed by the current optimization
  154596. * @return description string
  154597. */
  154598. getDescription(): string;
  154599. /**
  154600. * Creates the HardwareScalingOptimization object
  154601. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154602. * @param maximumScale defines the maximum scale to use (2 by default)
  154603. * @param step defines the step to use between two passes (0.5 by default)
  154604. */
  154605. constructor(
  154606. /**
  154607. * Defines the priority of this optimization (0 by default which means first in the list)
  154608. */
  154609. priority?: number,
  154610. /**
  154611. * Defines the maximum scale to use (2 by default)
  154612. */
  154613. maximumScale?: number,
  154614. /**
  154615. * Defines the step to use between two passes (0.5 by default)
  154616. */
  154617. step?: number);
  154618. /**
  154619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154620. * @param scene defines the current scene where to apply this optimization
  154621. * @param optimizer defines the current optimizer
  154622. * @returns true if everything that can be done was applied
  154623. */
  154624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154625. }
  154626. /**
  154627. * Defines an optimization used to remove shadows
  154628. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154629. */
  154630. export class ShadowsOptimization extends SceneOptimization {
  154631. /**
  154632. * Gets a string describing the action executed by the current optimization
  154633. * @return description string
  154634. */
  154635. getDescription(): string;
  154636. /**
  154637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154638. * @param scene defines the current scene where to apply this optimization
  154639. * @param optimizer defines the current optimizer
  154640. * @returns true if everything that can be done was applied
  154641. */
  154642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154643. }
  154644. /**
  154645. * Defines an optimization used to turn post-processes off
  154646. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154647. */
  154648. export class PostProcessesOptimization extends SceneOptimization {
  154649. /**
  154650. * Gets a string describing the action executed by the current optimization
  154651. * @return description string
  154652. */
  154653. getDescription(): string;
  154654. /**
  154655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154656. * @param scene defines the current scene where to apply this optimization
  154657. * @param optimizer defines the current optimizer
  154658. * @returns true if everything that can be done was applied
  154659. */
  154660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154661. }
  154662. /**
  154663. * Defines an optimization used to turn lens flares off
  154664. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154665. */
  154666. export class LensFlaresOptimization extends SceneOptimization {
  154667. /**
  154668. * Gets a string describing the action executed by the current optimization
  154669. * @return description string
  154670. */
  154671. getDescription(): string;
  154672. /**
  154673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154674. * @param scene defines the current scene where to apply this optimization
  154675. * @param optimizer defines the current optimizer
  154676. * @returns true if everything that can be done was applied
  154677. */
  154678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154679. }
  154680. /**
  154681. * Defines an optimization based on user defined callback.
  154682. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154683. */
  154684. export class CustomOptimization extends SceneOptimization {
  154685. /**
  154686. * Callback called to apply the custom optimization.
  154687. */
  154688. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154689. /**
  154690. * Callback called to get custom description
  154691. */
  154692. onGetDescription: () => string;
  154693. /**
  154694. * Gets a string describing the action executed by the current optimization
  154695. * @returns description string
  154696. */
  154697. getDescription(): string;
  154698. /**
  154699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154700. * @param scene defines the current scene where to apply this optimization
  154701. * @param optimizer defines the current optimizer
  154702. * @returns true if everything that can be done was applied
  154703. */
  154704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154705. }
  154706. /**
  154707. * Defines an optimization used to turn particles off
  154708. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154709. */
  154710. export class ParticlesOptimization extends SceneOptimization {
  154711. /**
  154712. * Gets a string describing the action executed by the current optimization
  154713. * @return description string
  154714. */
  154715. getDescription(): string;
  154716. /**
  154717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154718. * @param scene defines the current scene where to apply this optimization
  154719. * @param optimizer defines the current optimizer
  154720. * @returns true if everything that can be done was applied
  154721. */
  154722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154723. }
  154724. /**
  154725. * Defines an optimization used to turn render targets off
  154726. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154727. */
  154728. export class RenderTargetsOptimization extends SceneOptimization {
  154729. /**
  154730. * Gets a string describing the action executed by the current optimization
  154731. * @return description string
  154732. */
  154733. getDescription(): string;
  154734. /**
  154735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154736. * @param scene defines the current scene where to apply this optimization
  154737. * @param optimizer defines the current optimizer
  154738. * @returns true if everything that can be done was applied
  154739. */
  154740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154741. }
  154742. /**
  154743. * Defines an optimization used to merge meshes with compatible materials
  154744. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154745. */
  154746. export class MergeMeshesOptimization extends SceneOptimization {
  154747. private static _UpdateSelectionTree;
  154748. /**
  154749. * Gets or sets a boolean which defines if optimization octree has to be updated
  154750. */
  154751. static get UpdateSelectionTree(): boolean;
  154752. /**
  154753. * Gets or sets a boolean which defines if optimization octree has to be updated
  154754. */
  154755. static set UpdateSelectionTree(value: boolean);
  154756. /**
  154757. * Gets a string describing the action executed by the current optimization
  154758. * @return description string
  154759. */
  154760. getDescription(): string;
  154761. private _canBeMerged;
  154762. /**
  154763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154764. * @param scene defines the current scene where to apply this optimization
  154765. * @param optimizer defines the current optimizer
  154766. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154767. * @returns true if everything that can be done was applied
  154768. */
  154769. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154770. }
  154771. /**
  154772. * Defines a list of options used by SceneOptimizer
  154773. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154774. */
  154775. export class SceneOptimizerOptions {
  154776. /**
  154777. * Defines the target frame rate to reach (60 by default)
  154778. */
  154779. targetFrameRate: number;
  154780. /**
  154781. * Defines the interval between two checkes (2000ms by default)
  154782. */
  154783. trackerDuration: number;
  154784. /**
  154785. * Gets the list of optimizations to apply
  154786. */
  154787. optimizations: SceneOptimization[];
  154788. /**
  154789. * Creates a new list of options used by SceneOptimizer
  154790. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154791. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154792. */
  154793. constructor(
  154794. /**
  154795. * Defines the target frame rate to reach (60 by default)
  154796. */
  154797. targetFrameRate?: number,
  154798. /**
  154799. * Defines the interval between two checkes (2000ms by default)
  154800. */
  154801. trackerDuration?: number);
  154802. /**
  154803. * Add a new optimization
  154804. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154805. * @returns the current SceneOptimizerOptions
  154806. */
  154807. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154808. /**
  154809. * Add a new custom optimization
  154810. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154811. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154812. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154813. * @returns the current SceneOptimizerOptions
  154814. */
  154815. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154816. /**
  154817. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154818. * @param targetFrameRate defines the target frame rate (60 by default)
  154819. * @returns a SceneOptimizerOptions object
  154820. */
  154821. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154822. /**
  154823. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154824. * @param targetFrameRate defines the target frame rate (60 by default)
  154825. * @returns a SceneOptimizerOptions object
  154826. */
  154827. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154828. /**
  154829. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154830. * @param targetFrameRate defines the target frame rate (60 by default)
  154831. * @returns a SceneOptimizerOptions object
  154832. */
  154833. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154834. }
  154835. /**
  154836. * Class used to run optimizations in order to reach a target frame rate
  154837. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154838. */
  154839. export class SceneOptimizer implements IDisposable {
  154840. private _isRunning;
  154841. private _options;
  154842. private _scene;
  154843. private _currentPriorityLevel;
  154844. private _targetFrameRate;
  154845. private _trackerDuration;
  154846. private _currentFrameRate;
  154847. private _sceneDisposeObserver;
  154848. private _improvementMode;
  154849. /**
  154850. * Defines an observable called when the optimizer reaches the target frame rate
  154851. */
  154852. onSuccessObservable: Observable<SceneOptimizer>;
  154853. /**
  154854. * Defines an observable called when the optimizer enables an optimization
  154855. */
  154856. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154857. /**
  154858. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154859. */
  154860. onFailureObservable: Observable<SceneOptimizer>;
  154861. /**
  154862. * Gets a boolean indicating if the optimizer is in improvement mode
  154863. */
  154864. get isInImprovementMode(): boolean;
  154865. /**
  154866. * Gets the current priority level (0 at start)
  154867. */
  154868. get currentPriorityLevel(): number;
  154869. /**
  154870. * Gets the current frame rate checked by the SceneOptimizer
  154871. */
  154872. get currentFrameRate(): number;
  154873. /**
  154874. * Gets or sets the current target frame rate (60 by default)
  154875. */
  154876. get targetFrameRate(): number;
  154877. /**
  154878. * Gets or sets the current target frame rate (60 by default)
  154879. */
  154880. set targetFrameRate(value: number);
  154881. /**
  154882. * Gets or sets the current interval between two checks (every 2000ms by default)
  154883. */
  154884. get trackerDuration(): number;
  154885. /**
  154886. * Gets or sets the current interval between two checks (every 2000ms by default)
  154887. */
  154888. set trackerDuration(value: number);
  154889. /**
  154890. * Gets the list of active optimizations
  154891. */
  154892. get optimizations(): SceneOptimization[];
  154893. /**
  154894. * Creates a new SceneOptimizer
  154895. * @param scene defines the scene to work on
  154896. * @param options defines the options to use with the SceneOptimizer
  154897. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154898. * @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)
  154899. */
  154900. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154901. /**
  154902. * Stops the current optimizer
  154903. */
  154904. stop(): void;
  154905. /**
  154906. * Reset the optimizer to initial step (current priority level = 0)
  154907. */
  154908. reset(): void;
  154909. /**
  154910. * Start the optimizer. By default it will try to reach a specific framerate
  154911. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154912. */
  154913. start(): void;
  154914. private _checkCurrentState;
  154915. /**
  154916. * Release all resources
  154917. */
  154918. dispose(): void;
  154919. /**
  154920. * Helper function to create a SceneOptimizer with one single line of code
  154921. * @param scene defines the scene to work on
  154922. * @param options defines the options to use with the SceneOptimizer
  154923. * @param onSuccess defines a callback to call on success
  154924. * @param onFailure defines a callback to call on failure
  154925. * @returns the new SceneOptimizer object
  154926. */
  154927. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154928. }
  154929. }
  154930. declare module BABYLON {
  154931. /**
  154932. * Class used to serialize a scene into a string
  154933. */
  154934. export class SceneSerializer {
  154935. /**
  154936. * Clear cache used by a previous serialization
  154937. */
  154938. static ClearCache(): void;
  154939. /**
  154940. * Serialize a scene into a JSON compatible object
  154941. * @param scene defines the scene to serialize
  154942. * @returns a JSON compatible object
  154943. */
  154944. static Serialize(scene: Scene): any;
  154945. /**
  154946. * Serialize a mesh into a JSON compatible object
  154947. * @param toSerialize defines the mesh to serialize
  154948. * @param withParents defines if parents must be serialized as well
  154949. * @param withChildren defines if children must be serialized as well
  154950. * @returns a JSON compatible object
  154951. */
  154952. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154953. }
  154954. }
  154955. declare module BABYLON {
  154956. /**
  154957. * Class used to host texture specific utilities
  154958. */
  154959. export class TextureTools {
  154960. /**
  154961. * Uses the GPU to create a copy texture rescaled at a given size
  154962. * @param texture Texture to copy from
  154963. * @param width defines the desired width
  154964. * @param height defines the desired height
  154965. * @param useBilinearMode defines if bilinear mode has to be used
  154966. * @return the generated texture
  154967. */
  154968. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154969. }
  154970. }
  154971. declare module BABYLON {
  154972. /**
  154973. * This represents the different options available for the video capture.
  154974. */
  154975. export interface VideoRecorderOptions {
  154976. /** Defines the mime type of the video. */
  154977. mimeType: string;
  154978. /** Defines the FPS the video should be recorded at. */
  154979. fps: number;
  154980. /** Defines the chunk size for the recording data. */
  154981. recordChunckSize: number;
  154982. /** The audio tracks to attach to the recording. */
  154983. audioTracks?: MediaStreamTrack[];
  154984. }
  154985. /**
  154986. * This can help with recording videos from BabylonJS.
  154987. * This is based on the available WebRTC functionalities of the browser.
  154988. *
  154989. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154990. */
  154991. export class VideoRecorder {
  154992. private static readonly _defaultOptions;
  154993. /**
  154994. * Returns whether or not the VideoRecorder is available in your browser.
  154995. * @param engine Defines the Babylon Engine.
  154996. * @returns true if supported otherwise false.
  154997. */
  154998. static IsSupported(engine: Engine): boolean;
  154999. private readonly _options;
  155000. private _canvas;
  155001. private _mediaRecorder;
  155002. private _recordedChunks;
  155003. private _fileName;
  155004. private _resolve;
  155005. private _reject;
  155006. /**
  155007. * True when a recording is already in progress.
  155008. */
  155009. get isRecording(): boolean;
  155010. /**
  155011. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155012. * @param engine Defines the BabylonJS Engine you wish to record.
  155013. * @param options Defines options that can be used to customize the capture.
  155014. */
  155015. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155016. /**
  155017. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155018. */
  155019. stopRecording(): void;
  155020. /**
  155021. * Starts recording the canvas for a max duration specified in parameters.
  155022. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155023. * If null no automatic download will start and you can rely on the promise to get the data back.
  155024. * @param maxDuration Defines the maximum recording time in seconds.
  155025. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155026. * @return A promise callback at the end of the recording with the video data in Blob.
  155027. */
  155028. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155029. /**
  155030. * Releases internal resources used during the recording.
  155031. */
  155032. dispose(): void;
  155033. private _handleDataAvailable;
  155034. private _handleError;
  155035. private _handleStop;
  155036. }
  155037. }
  155038. declare module BABYLON {
  155039. /**
  155040. * Class containing a set of static utilities functions for screenshots
  155041. */
  155042. export class ScreenshotTools {
  155043. /**
  155044. * Captures a screenshot of the current rendering
  155045. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155046. * @param engine defines the rendering engine
  155047. * @param camera defines the source camera
  155048. * @param size This parameter can be set to a single number or to an object with the
  155049. * following (optional) properties: precision, width, height. If a single number is passed,
  155050. * it will be used for both width and height. If an object is passed, the screenshot size
  155051. * will be derived from the parameters. The precision property is a multiplier allowing
  155052. * rendering at a higher or lower resolution
  155053. * @param successCallback defines the callback receives a single parameter which contains the
  155054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155055. * src parameter of an <img> to display it
  155056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155057. * Check your browser for supported MIME types
  155058. */
  155059. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155060. /**
  155061. * Captures a screenshot of the current rendering
  155062. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155063. * @param engine defines the rendering engine
  155064. * @param camera defines the source camera
  155065. * @param size This parameter can be set to a single number or to an object with the
  155066. * following (optional) properties: precision, width, height. If a single number is passed,
  155067. * it will be used for both width and height. If an object is passed, the screenshot size
  155068. * will be derived from the parameters. The precision property is a multiplier allowing
  155069. * rendering at a higher or lower resolution
  155070. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155071. * Check your browser for supported MIME types
  155072. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155073. * to the src parameter of an <img> to display it
  155074. */
  155075. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155076. /**
  155077. * Generates an image screenshot from the specified camera.
  155078. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155079. * @param engine The engine to use for rendering
  155080. * @param camera The camera to use for rendering
  155081. * @param size This parameter can be set to a single number or to an object with the
  155082. * following (optional) properties: precision, width, height. If a single number is passed,
  155083. * it will be used for both width and height. If an object is passed, the screenshot size
  155084. * will be derived from the parameters. The precision property is a multiplier allowing
  155085. * rendering at a higher or lower resolution
  155086. * @param successCallback The callback receives a single parameter which contains the
  155087. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155088. * src parameter of an <img> to display it
  155089. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155090. * Check your browser for supported MIME types
  155091. * @param samples Texture samples (default: 1)
  155092. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155093. * @param fileName A name for for the downloaded file.
  155094. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155095. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155096. */
  155097. 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;
  155098. /**
  155099. * Generates an image screenshot from the specified camera.
  155100. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155101. * @param engine The engine to use for rendering
  155102. * @param camera The camera to use for rendering
  155103. * @param size This parameter can be set to a single number or to an object with the
  155104. * following (optional) properties: precision, width, height. If a single number is passed,
  155105. * it will be used for both width and height. If an object is passed, the screenshot size
  155106. * will be derived from the parameters. The precision property is a multiplier allowing
  155107. * rendering at a higher or lower resolution
  155108. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155109. * Check your browser for supported MIME types
  155110. * @param samples Texture samples (default: 1)
  155111. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155112. * @param fileName A name for for the downloaded file.
  155113. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155114. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155115. * to the src parameter of an <img> to display it
  155116. */
  155117. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155118. /**
  155119. * Gets height and width for screenshot size
  155120. * @private
  155121. */
  155122. private static _getScreenshotSize;
  155123. }
  155124. }
  155125. declare module BABYLON {
  155126. /**
  155127. * Interface for a data buffer
  155128. */
  155129. export interface IDataBuffer {
  155130. /**
  155131. * Reads bytes from the data buffer.
  155132. * @param byteOffset The byte offset to read
  155133. * @param byteLength The byte length to read
  155134. * @returns A promise that resolves when the bytes are read
  155135. */
  155136. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155137. /**
  155138. * The byte length of the buffer.
  155139. */
  155140. readonly byteLength: number;
  155141. }
  155142. /**
  155143. * Utility class for reading from a data buffer
  155144. */
  155145. export class DataReader {
  155146. /**
  155147. * The data buffer associated with this data reader.
  155148. */
  155149. readonly buffer: IDataBuffer;
  155150. /**
  155151. * The current byte offset from the beginning of the data buffer.
  155152. */
  155153. byteOffset: number;
  155154. private _dataView;
  155155. private _dataByteOffset;
  155156. /**
  155157. * Constructor
  155158. * @param buffer The buffer to read
  155159. */
  155160. constructor(buffer: IDataBuffer);
  155161. /**
  155162. * Loads the given byte length.
  155163. * @param byteLength The byte length to load
  155164. * @returns A promise that resolves when the load is complete
  155165. */
  155166. loadAsync(byteLength: number): Promise<void>;
  155167. /**
  155168. * Read a unsigned 32-bit integer from the currently loaded data range.
  155169. * @returns The 32-bit integer read
  155170. */
  155171. readUint32(): number;
  155172. /**
  155173. * Read a byte array from the currently loaded data range.
  155174. * @param byteLength The byte length to read
  155175. * @returns The byte array read
  155176. */
  155177. readUint8Array(byteLength: number): Uint8Array;
  155178. /**
  155179. * Read a string from the currently loaded data range.
  155180. * @param byteLength The byte length to read
  155181. * @returns The string read
  155182. */
  155183. readString(byteLength: number): string;
  155184. /**
  155185. * Skips the given byte length the currently loaded data range.
  155186. * @param byteLength The byte length to skip
  155187. */
  155188. skipBytes(byteLength: number): void;
  155189. }
  155190. }
  155191. declare module BABYLON {
  155192. /**
  155193. * Class for storing data to local storage if available or in-memory storage otherwise
  155194. */
  155195. export class DataStorage {
  155196. private static _Storage;
  155197. private static _GetStorage;
  155198. /**
  155199. * Reads a string from the data storage
  155200. * @param key The key to read
  155201. * @param defaultValue The value if the key doesn't exist
  155202. * @returns The string value
  155203. */
  155204. static ReadString(key: string, defaultValue: string): string;
  155205. /**
  155206. * Writes a string to the data storage
  155207. * @param key The key to write
  155208. * @param value The value to write
  155209. */
  155210. static WriteString(key: string, value: string): void;
  155211. /**
  155212. * Reads a boolean from the data storage
  155213. * @param key The key to read
  155214. * @param defaultValue The value if the key doesn't exist
  155215. * @returns The boolean value
  155216. */
  155217. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155218. /**
  155219. * Writes a boolean to the data storage
  155220. * @param key The key to write
  155221. * @param value The value to write
  155222. */
  155223. static WriteBoolean(key: string, value: boolean): void;
  155224. /**
  155225. * Reads a number from the data storage
  155226. * @param key The key to read
  155227. * @param defaultValue The value if the key doesn't exist
  155228. * @returns The number value
  155229. */
  155230. static ReadNumber(key: string, defaultValue: number): number;
  155231. /**
  155232. * Writes a number to the data storage
  155233. * @param key The key to write
  155234. * @param value The value to write
  155235. */
  155236. static WriteNumber(key: string, value: number): void;
  155237. }
  155238. }
  155239. declare module BABYLON {
  155240. /**
  155241. * Class used to record delta files between 2 scene states
  155242. */
  155243. export class SceneRecorder {
  155244. private _trackedScene;
  155245. private _savedJSON;
  155246. /**
  155247. * Track a given scene. This means the current scene state will be considered the original state
  155248. * @param scene defines the scene to track
  155249. */
  155250. track(scene: Scene): void;
  155251. /**
  155252. * Get the delta between current state and original state
  155253. * @returns a string containing the delta
  155254. */
  155255. getDelta(): any;
  155256. private _compareArray;
  155257. private _compareObjects;
  155258. private _compareCollections;
  155259. private static GetShadowGeneratorById;
  155260. /**
  155261. * Apply a given delta to a given scene
  155262. * @param deltaJSON defines the JSON containing the delta
  155263. * @param scene defines the scene to apply the delta to
  155264. */
  155265. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155266. private static _ApplyPropertiesToEntity;
  155267. private static _ApplyDeltaForEntity;
  155268. }
  155269. }
  155270. declare module BABYLON {
  155271. /**
  155272. * A 3D trajectory consisting of an order list of vectors describing a
  155273. * path of motion through 3D space.
  155274. */
  155275. export class Trajectory {
  155276. private _points;
  155277. private readonly _segmentLength;
  155278. /**
  155279. * Serialize to JSON.
  155280. * @returns serialized JSON string
  155281. */
  155282. serialize(): string;
  155283. /**
  155284. * Deserialize from JSON.
  155285. * @param json serialized JSON string
  155286. * @returns deserialized Trajectory
  155287. */
  155288. static Deserialize(json: string): Trajectory;
  155289. /**
  155290. * Create a new empty Trajectory.
  155291. * @param segmentLength radius of discretization for Trajectory points
  155292. */
  155293. constructor(segmentLength?: number);
  155294. /**
  155295. * Get the length of the Trajectory.
  155296. * @returns length of the Trajectory
  155297. */
  155298. getLength(): number;
  155299. /**
  155300. * Append a new point to the Trajectory.
  155301. * NOTE: This implementation has many allocations.
  155302. * @param point point to append to the Trajectory
  155303. */
  155304. add(point: DeepImmutable<Vector3>): void;
  155305. /**
  155306. * Create a new Trajectory with a segment length chosen to make it
  155307. * probable that the new Trajectory will have a specified number of
  155308. * segments. This operation is imprecise.
  155309. * @param targetResolution number of segments desired
  155310. * @returns new Trajectory with approximately the requested number of segments
  155311. */
  155312. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155313. /**
  155314. * Convert Trajectory segments into tokenized representation. This
  155315. * representation is an array of numbers where each nth number is the
  155316. * index of the token which is most similar to the nth segment of the
  155317. * Trajectory.
  155318. * @param tokens list of vectors which serve as discrete tokens
  155319. * @returns list of indices of most similar token per segment
  155320. */
  155321. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155322. private static _forwardDir;
  155323. private static _inverseFromVec;
  155324. private static _upDir;
  155325. private static _fromToVec;
  155326. private static _lookMatrix;
  155327. /**
  155328. * Transform the rotation (i.e., direction) of a segment to isolate
  155329. * the relative transformation represented by the segment. This operation
  155330. * may or may not succeed due to singularities in the equations that define
  155331. * motion relativity in this context.
  155332. * @param priorVec the origin of the prior segment
  155333. * @param fromVec the origin of the current segment
  155334. * @param toVec the destination of the current segment
  155335. * @param result reference to output variable
  155336. * @returns whether or not transformation was successful
  155337. */
  155338. private static _transformSegmentDirToRef;
  155339. private static _bestMatch;
  155340. private static _score;
  155341. private static _bestScore;
  155342. /**
  155343. * Determine which token vector is most similar to the
  155344. * segment vector.
  155345. * @param segment segment vector
  155346. * @param tokens token vector list
  155347. * @returns index of the most similar token to the segment
  155348. */
  155349. private static _tokenizeSegment;
  155350. }
  155351. /**
  155352. * Class representing a set of known, named trajectories to which Trajectories can be
  155353. * added and using which Trajectories can be recognized.
  155354. */
  155355. export class TrajectoryClassifier {
  155356. private _maximumAllowableMatchCost;
  155357. private _vector3Alphabet;
  155358. private _levenshteinAlphabet;
  155359. private _nameToDescribedTrajectory;
  155360. /**
  155361. * Serialize to JSON.
  155362. * @returns JSON serialization
  155363. */
  155364. serialize(): string;
  155365. /**
  155366. * Deserialize from JSON.
  155367. * @param json JSON serialization
  155368. * @returns deserialized TrajectorySet
  155369. */
  155370. static Deserialize(json: string): TrajectoryClassifier;
  155371. /**
  155372. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155373. * VERY naive, need to be generating these things from known
  155374. * sets. Better version later, probably eliminating this one.
  155375. * @returns auto-generated TrajectorySet
  155376. */
  155377. static Generate(): TrajectoryClassifier;
  155378. private constructor();
  155379. /**
  155380. * Add a new Trajectory to the set with a given name.
  155381. * @param trajectory new Trajectory to be added
  155382. * @param classification name to which to add the Trajectory
  155383. */
  155384. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155385. /**
  155386. * Remove a known named trajectory and all Trajectories associated with it.
  155387. * @param classification name to remove
  155388. * @returns whether anything was removed
  155389. */
  155390. deleteClassification(classification: string): boolean;
  155391. /**
  155392. * Attempt to recognize a Trajectory from among all the classifications
  155393. * already known to the classifier.
  155394. * @param trajectory Trajectory to be recognized
  155395. * @returns classification of Trajectory if recognized, null otherwise
  155396. */
  155397. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155398. }
  155399. }
  155400. declare module BABYLON {
  155401. /**
  155402. * An interface for all Hit test features
  155403. */
  155404. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155405. /**
  155406. * Triggered when new babylon (transformed) hit test results are available
  155407. */
  155408. onHitTestResultObservable: Observable<T[]>;
  155409. }
  155410. /**
  155411. * Options used for hit testing
  155412. */
  155413. export interface IWebXRLegacyHitTestOptions {
  155414. /**
  155415. * Only test when user interacted with the scene. Default - hit test every frame
  155416. */
  155417. testOnPointerDownOnly?: boolean;
  155418. /**
  155419. * The node to use to transform the local results to world coordinates
  155420. */
  155421. worldParentNode?: TransformNode;
  155422. }
  155423. /**
  155424. * Interface defining the babylon result of raycasting/hit-test
  155425. */
  155426. export interface IWebXRLegacyHitResult {
  155427. /**
  155428. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155429. */
  155430. transformationMatrix: Matrix;
  155431. /**
  155432. * The native hit test result
  155433. */
  155434. xrHitResult: XRHitResult | XRHitTestResult;
  155435. }
  155436. /**
  155437. * The currently-working hit-test module.
  155438. * Hit test (or Ray-casting) is used to interact with the real world.
  155439. * For further information read here - https://github.com/immersive-web/hit-test
  155440. */
  155441. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155442. /**
  155443. * options to use when constructing this feature
  155444. */
  155445. readonly options: IWebXRLegacyHitTestOptions;
  155446. private _direction;
  155447. private _mat;
  155448. private _onSelectEnabled;
  155449. private _origin;
  155450. /**
  155451. * The module's name
  155452. */
  155453. static readonly Name: string;
  155454. /**
  155455. * The (Babylon) version of this module.
  155456. * This is an integer representing the implementation version.
  155457. * This number does not correspond to the WebXR specs version
  155458. */
  155459. static readonly Version: number;
  155460. /**
  155461. * Populated with the last native XR Hit Results
  155462. */
  155463. lastNativeXRHitResults: XRHitResult[];
  155464. /**
  155465. * Triggered when new babylon (transformed) hit test results are available
  155466. */
  155467. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155468. /**
  155469. * Creates a new instance of the (legacy version) hit test feature
  155470. * @param _xrSessionManager an instance of WebXRSessionManager
  155471. * @param options options to use when constructing this feature
  155472. */
  155473. constructor(_xrSessionManager: WebXRSessionManager,
  155474. /**
  155475. * options to use when constructing this feature
  155476. */
  155477. options?: IWebXRLegacyHitTestOptions);
  155478. /**
  155479. * execute a hit test with an XR Ray
  155480. *
  155481. * @param xrSession a native xrSession that will execute this hit test
  155482. * @param xrRay the ray (position and direction) to use for ray-casting
  155483. * @param referenceSpace native XR reference space to use for the hit-test
  155484. * @param filter filter function that will filter the results
  155485. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155486. */
  155487. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155488. /**
  155489. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155490. * @param event the (select) event to use to select with
  155491. * @param referenceSpace the reference space to use for this hit test
  155492. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155493. */
  155494. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155495. /**
  155496. * attach this feature
  155497. * Will usually be called by the features manager
  155498. *
  155499. * @returns true if successful.
  155500. */
  155501. attach(): boolean;
  155502. /**
  155503. * detach this feature.
  155504. * Will usually be called by the features manager
  155505. *
  155506. * @returns true if successful.
  155507. */
  155508. detach(): boolean;
  155509. /**
  155510. * Dispose this feature and all of the resources attached
  155511. */
  155512. dispose(): void;
  155513. protected _onXRFrame(frame: XRFrame): void;
  155514. private _onHitTestResults;
  155515. private _onSelect;
  155516. }
  155517. }
  155518. declare module BABYLON {
  155519. /**
  155520. * Options used for hit testing (version 2)
  155521. */
  155522. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155523. /**
  155524. * Do not create a permanent hit test. Will usually be used when only
  155525. * transient inputs are needed.
  155526. */
  155527. disablePermanentHitTest?: boolean;
  155528. /**
  155529. * Enable transient (for example touch-based) hit test inspections
  155530. */
  155531. enableTransientHitTest?: boolean;
  155532. /**
  155533. * Offset ray for the permanent hit test
  155534. */
  155535. offsetRay?: Vector3;
  155536. /**
  155537. * Offset ray for the transient hit test
  155538. */
  155539. transientOffsetRay?: Vector3;
  155540. /**
  155541. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155542. */
  155543. useReferenceSpace?: boolean;
  155544. /**
  155545. * Override the default entity type(s) of the hit-test result
  155546. */
  155547. entityTypes?: XRHitTestTrackableType[];
  155548. }
  155549. /**
  155550. * Interface defining the babylon result of hit-test
  155551. */
  155552. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155553. /**
  155554. * The input source that generated this hit test (if transient)
  155555. */
  155556. inputSource?: XRInputSource;
  155557. /**
  155558. * Is this a transient hit test
  155559. */
  155560. isTransient?: boolean;
  155561. /**
  155562. * Position of the hit test result
  155563. */
  155564. position: Vector3;
  155565. /**
  155566. * Rotation of the hit test result
  155567. */
  155568. rotationQuaternion: Quaternion;
  155569. /**
  155570. * The native hit test result
  155571. */
  155572. xrHitResult: XRHitTestResult;
  155573. }
  155574. /**
  155575. * The currently-working hit-test module.
  155576. * Hit test (or Ray-casting) is used to interact with the real world.
  155577. * For further information read here - https://github.com/immersive-web/hit-test
  155578. *
  155579. * Tested on chrome (mobile) 80.
  155580. */
  155581. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155582. /**
  155583. * options to use when constructing this feature
  155584. */
  155585. readonly options: IWebXRHitTestOptions;
  155586. private _tmpMat;
  155587. private _tmpPos;
  155588. private _tmpQuat;
  155589. private _transientXrHitTestSource;
  155590. private _xrHitTestSource;
  155591. private initHitTestSource;
  155592. /**
  155593. * The module's name
  155594. */
  155595. static readonly Name: string;
  155596. /**
  155597. * The (Babylon) version of this module.
  155598. * This is an integer representing the implementation version.
  155599. * This number does not correspond to the WebXR specs version
  155600. */
  155601. static readonly Version: number;
  155602. /**
  155603. * When set to true, each hit test will have its own position/rotation objects
  155604. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155605. * the developers will clone them or copy them as they see fit.
  155606. */
  155607. autoCloneTransformation: boolean;
  155608. /**
  155609. * Triggered when new babylon (transformed) hit test results are available
  155610. * Note - this will be called when results come back from the device. It can be an empty array!!
  155611. */
  155612. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155613. /**
  155614. * Use this to temporarily pause hit test checks.
  155615. */
  155616. paused: boolean;
  155617. /**
  155618. * Creates a new instance of the hit test feature
  155619. * @param _xrSessionManager an instance of WebXRSessionManager
  155620. * @param options options to use when constructing this feature
  155621. */
  155622. constructor(_xrSessionManager: WebXRSessionManager,
  155623. /**
  155624. * options to use when constructing this feature
  155625. */
  155626. options?: IWebXRHitTestOptions);
  155627. /**
  155628. * attach this feature
  155629. * Will usually be called by the features manager
  155630. *
  155631. * @returns true if successful.
  155632. */
  155633. attach(): boolean;
  155634. /**
  155635. * detach this feature.
  155636. * Will usually be called by the features manager
  155637. *
  155638. * @returns true if successful.
  155639. */
  155640. detach(): boolean;
  155641. /**
  155642. * Dispose this feature and all of the resources attached
  155643. */
  155644. dispose(): void;
  155645. protected _onXRFrame(frame: XRFrame): void;
  155646. private _processWebXRHitTestResult;
  155647. }
  155648. }
  155649. declare module BABYLON {
  155650. /**
  155651. * Configuration options of the anchor system
  155652. */
  155653. export interface IWebXRAnchorSystemOptions {
  155654. /**
  155655. * a node that will be used to convert local to world coordinates
  155656. */
  155657. worldParentNode?: TransformNode;
  155658. /**
  155659. * If set to true a reference of the created anchors will be kept until the next session starts
  155660. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155661. */
  155662. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155663. }
  155664. /**
  155665. * A babylon container for an XR Anchor
  155666. */
  155667. export interface IWebXRAnchor {
  155668. /**
  155669. * A babylon-assigned ID for this anchor
  155670. */
  155671. id: number;
  155672. /**
  155673. * Transformation matrix to apply to an object attached to this anchor
  155674. */
  155675. transformationMatrix: Matrix;
  155676. /**
  155677. * The native anchor object
  155678. */
  155679. xrAnchor: XRAnchor;
  155680. /**
  155681. * if defined, this object will be constantly updated by the anchor's position and rotation
  155682. */
  155683. attachedNode?: TransformNode;
  155684. }
  155685. /**
  155686. * An implementation of the anchor system for WebXR.
  155687. * For further information see https://github.com/immersive-web/anchors/
  155688. */
  155689. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155690. private _options;
  155691. private _lastFrameDetected;
  155692. private _trackedAnchors;
  155693. private _referenceSpaceForFrameAnchors;
  155694. private _futureAnchors;
  155695. /**
  155696. * The module's name
  155697. */
  155698. static readonly Name: string;
  155699. /**
  155700. * The (Babylon) version of this module.
  155701. * This is an integer representing the implementation version.
  155702. * This number does not correspond to the WebXR specs version
  155703. */
  155704. static readonly Version: number;
  155705. /**
  155706. * Observers registered here will be executed when a new anchor was added to the session
  155707. */
  155708. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155709. /**
  155710. * Observers registered here will be executed when an anchor was removed from the session
  155711. */
  155712. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155713. /**
  155714. * Observers registered here will be executed when an existing anchor updates
  155715. * This can execute N times every frame
  155716. */
  155717. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155718. /**
  155719. * Set the reference space to use for anchor creation, when not using a hit test.
  155720. * Will default to the session's reference space if not defined
  155721. */
  155722. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155723. /**
  155724. * constructs a new anchor system
  155725. * @param _xrSessionManager an instance of WebXRSessionManager
  155726. * @param _options configuration object for this feature
  155727. */
  155728. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155729. private _tmpVector;
  155730. private _tmpQuaternion;
  155731. private _populateTmpTransformation;
  155732. /**
  155733. * Create a new anchor point using a hit test result at a specific point in the scene
  155734. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155735. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155736. *
  155737. * @param hitTestResult The hit test result to use for this anchor creation
  155738. * @param position an optional position offset for this anchor
  155739. * @param rotationQuaternion an optional rotation offset for this anchor
  155740. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155741. */
  155742. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155743. /**
  155744. * Add a new anchor at a specific position and rotation
  155745. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155746. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155747. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155748. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155749. *
  155750. * @param position the position in which to add an anchor
  155751. * @param rotationQuaternion an optional rotation for the anchor transformation
  155752. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155753. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155754. */
  155755. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155756. /**
  155757. * detach this feature.
  155758. * Will usually be called by the features manager
  155759. *
  155760. * @returns true if successful.
  155761. */
  155762. detach(): boolean;
  155763. /**
  155764. * Dispose this feature and all of the resources attached
  155765. */
  155766. dispose(): void;
  155767. protected _onXRFrame(frame: XRFrame): void;
  155768. /**
  155769. * avoiding using Array.find for global support.
  155770. * @param xrAnchor the plane to find in the array
  155771. */
  155772. private _findIndexInAnchorArray;
  155773. private _updateAnchorWithXRFrame;
  155774. private _createAnchorAtTransformation;
  155775. }
  155776. }
  155777. declare module BABYLON {
  155778. /**
  155779. * Options used in the plane detector module
  155780. */
  155781. export interface IWebXRPlaneDetectorOptions {
  155782. /**
  155783. * The node to use to transform the local results to world coordinates
  155784. */
  155785. worldParentNode?: TransformNode;
  155786. /**
  155787. * If set to true a reference of the created planes will be kept until the next session starts
  155788. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155789. */
  155790. doNotRemovePlanesOnSessionEnded?: boolean;
  155791. }
  155792. /**
  155793. * A babylon interface for a WebXR plane.
  155794. * A Plane is actually a polygon, built from N points in space
  155795. *
  155796. * Supported in chrome 79, not supported in canary 81 ATM
  155797. */
  155798. export interface IWebXRPlane {
  155799. /**
  155800. * a babylon-assigned ID for this polygon
  155801. */
  155802. id: number;
  155803. /**
  155804. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155805. */
  155806. polygonDefinition: Array<Vector3>;
  155807. /**
  155808. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155809. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155810. */
  155811. transformationMatrix: Matrix;
  155812. /**
  155813. * the native xr-plane object
  155814. */
  155815. xrPlane: XRPlane;
  155816. }
  155817. /**
  155818. * The plane detector is used to detect planes in the real world when in AR
  155819. * For more information see https://github.com/immersive-web/real-world-geometry/
  155820. */
  155821. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155822. private _options;
  155823. private _detectedPlanes;
  155824. private _enabled;
  155825. private _lastFrameDetected;
  155826. /**
  155827. * The module's name
  155828. */
  155829. static readonly Name: string;
  155830. /**
  155831. * The (Babylon) version of this module.
  155832. * This is an integer representing the implementation version.
  155833. * This number does not correspond to the WebXR specs version
  155834. */
  155835. static readonly Version: number;
  155836. /**
  155837. * Observers registered here will be executed when a new plane was added to the session
  155838. */
  155839. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155840. /**
  155841. * Observers registered here will be executed when a plane is no longer detected in the session
  155842. */
  155843. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155844. /**
  155845. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155846. * This can execute N times every frame
  155847. */
  155848. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155849. /**
  155850. * construct a new Plane Detector
  155851. * @param _xrSessionManager an instance of xr Session manager
  155852. * @param _options configuration to use when constructing this feature
  155853. */
  155854. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155855. /**
  155856. * detach this feature.
  155857. * Will usually be called by the features manager
  155858. *
  155859. * @returns true if successful.
  155860. */
  155861. detach(): boolean;
  155862. /**
  155863. * Dispose this feature and all of the resources attached
  155864. */
  155865. dispose(): void;
  155866. protected _onXRFrame(frame: XRFrame): void;
  155867. private _init;
  155868. private _updatePlaneWithXRPlane;
  155869. /**
  155870. * avoiding using Array.find for global support.
  155871. * @param xrPlane the plane to find in the array
  155872. */
  155873. private findIndexInPlaneArray;
  155874. }
  155875. }
  155876. declare module BABYLON {
  155877. /**
  155878. * Options interface for the background remover plugin
  155879. */
  155880. export interface IWebXRBackgroundRemoverOptions {
  155881. /**
  155882. * Further background meshes to disable when entering AR
  155883. */
  155884. backgroundMeshes?: AbstractMesh[];
  155885. /**
  155886. * flags to configure the removal of the environment helper.
  155887. * If not set, the entire background will be removed. If set, flags should be set as well.
  155888. */
  155889. environmentHelperRemovalFlags?: {
  155890. /**
  155891. * Should the skybox be removed (default false)
  155892. */
  155893. skyBox?: boolean;
  155894. /**
  155895. * Should the ground be removed (default false)
  155896. */
  155897. ground?: boolean;
  155898. };
  155899. /**
  155900. * don't disable the environment helper
  155901. */
  155902. ignoreEnvironmentHelper?: boolean;
  155903. }
  155904. /**
  155905. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155906. */
  155907. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155908. /**
  155909. * read-only options to be used in this module
  155910. */
  155911. readonly options: IWebXRBackgroundRemoverOptions;
  155912. /**
  155913. * The module's name
  155914. */
  155915. static readonly Name: string;
  155916. /**
  155917. * The (Babylon) version of this module.
  155918. * This is an integer representing the implementation version.
  155919. * This number does not correspond to the WebXR specs version
  155920. */
  155921. static readonly Version: number;
  155922. /**
  155923. * registered observers will be triggered when the background state changes
  155924. */
  155925. onBackgroundStateChangedObservable: Observable<boolean>;
  155926. /**
  155927. * constructs a new background remover module
  155928. * @param _xrSessionManager the session manager for this module
  155929. * @param options read-only options to be used in this module
  155930. */
  155931. constructor(_xrSessionManager: WebXRSessionManager,
  155932. /**
  155933. * read-only options to be used in this module
  155934. */
  155935. options?: IWebXRBackgroundRemoverOptions);
  155936. /**
  155937. * attach this feature
  155938. * Will usually be called by the features manager
  155939. *
  155940. * @returns true if successful.
  155941. */
  155942. attach(): boolean;
  155943. /**
  155944. * detach this feature.
  155945. * Will usually be called by the features manager
  155946. *
  155947. * @returns true if successful.
  155948. */
  155949. detach(): boolean;
  155950. /**
  155951. * Dispose this feature and all of the resources attached
  155952. */
  155953. dispose(): void;
  155954. protected _onXRFrame(_xrFrame: XRFrame): void;
  155955. private _setBackgroundState;
  155956. }
  155957. }
  155958. declare module BABYLON {
  155959. /**
  155960. * Options for the controller physics feature
  155961. */
  155962. export class IWebXRControllerPhysicsOptions {
  155963. /**
  155964. * Should the headset get its own impostor
  155965. */
  155966. enableHeadsetImpostor?: boolean;
  155967. /**
  155968. * Optional parameters for the headset impostor
  155969. */
  155970. headsetImpostorParams?: {
  155971. /**
  155972. * The type of impostor to create. Default is sphere
  155973. */
  155974. impostorType: number;
  155975. /**
  155976. * the size of the impostor. Defaults to 10cm
  155977. */
  155978. impostorSize?: number | {
  155979. width: number;
  155980. height: number;
  155981. depth: number;
  155982. };
  155983. /**
  155984. * Friction definitions
  155985. */
  155986. friction?: number;
  155987. /**
  155988. * Restitution
  155989. */
  155990. restitution?: number;
  155991. };
  155992. /**
  155993. * The physics properties of the future impostors
  155994. */
  155995. physicsProperties?: {
  155996. /**
  155997. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155998. * Note that this requires a physics engine that supports mesh impostors!
  155999. */
  156000. useControllerMesh?: boolean;
  156001. /**
  156002. * The type of impostor to create. Default is sphere
  156003. */
  156004. impostorType?: number;
  156005. /**
  156006. * the size of the impostor. Defaults to 10cm
  156007. */
  156008. impostorSize?: number | {
  156009. width: number;
  156010. height: number;
  156011. depth: number;
  156012. };
  156013. /**
  156014. * Friction definitions
  156015. */
  156016. friction?: number;
  156017. /**
  156018. * Restitution
  156019. */
  156020. restitution?: number;
  156021. };
  156022. /**
  156023. * the xr input to use with this pointer selection
  156024. */
  156025. xrInput: WebXRInput;
  156026. }
  156027. /**
  156028. * Add physics impostor to your webxr controllers,
  156029. * including naive calculation of their linear and angular velocity
  156030. */
  156031. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156032. private readonly _options;
  156033. private _attachController;
  156034. private _controllers;
  156035. private _debugMode;
  156036. private _delta;
  156037. private _headsetImpostor?;
  156038. private _headsetMesh?;
  156039. private _lastTimestamp;
  156040. private _tmpQuaternion;
  156041. private _tmpVector;
  156042. /**
  156043. * The module's name
  156044. */
  156045. static readonly Name: string;
  156046. /**
  156047. * The (Babylon) version of this module.
  156048. * This is an integer representing the implementation version.
  156049. * This number does not correspond to the webxr specs version
  156050. */
  156051. static readonly Version: number;
  156052. /**
  156053. * Construct a new Controller Physics Feature
  156054. * @param _xrSessionManager the corresponding xr session manager
  156055. * @param _options options to create this feature with
  156056. */
  156057. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156058. /**
  156059. * @hidden
  156060. * enable debugging - will show console outputs and the impostor mesh
  156061. */
  156062. _enablePhysicsDebug(): void;
  156063. /**
  156064. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156065. * @param xrController the controller to add
  156066. */
  156067. addController(xrController: WebXRInputSource): void;
  156068. /**
  156069. * attach this feature
  156070. * Will usually be called by the features manager
  156071. *
  156072. * @returns true if successful.
  156073. */
  156074. attach(): boolean;
  156075. /**
  156076. * detach this feature.
  156077. * Will usually be called by the features manager
  156078. *
  156079. * @returns true if successful.
  156080. */
  156081. detach(): boolean;
  156082. /**
  156083. * Get the headset impostor, if enabled
  156084. * @returns the impostor
  156085. */
  156086. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156087. /**
  156088. * Get the physics impostor of a specific controller.
  156089. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156090. * @param controller the controller or the controller id of which to get the impostor
  156091. * @returns the impostor or null
  156092. */
  156093. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156094. /**
  156095. * Update the physics properties provided in the constructor
  156096. * @param newProperties the new properties object
  156097. */
  156098. setPhysicsProperties(newProperties: {
  156099. impostorType?: number;
  156100. impostorSize?: number | {
  156101. width: number;
  156102. height: number;
  156103. depth: number;
  156104. };
  156105. friction?: number;
  156106. restitution?: number;
  156107. }): void;
  156108. protected _onXRFrame(_xrFrame: any): void;
  156109. private _detachController;
  156110. }
  156111. }
  156112. declare module BABYLON {
  156113. /**
  156114. * A babylon interface for a "WebXR" feature point.
  156115. * Represents the position and confidence value of a given feature point.
  156116. */
  156117. export interface IWebXRFeaturePoint {
  156118. /**
  156119. * Represents the position of the feature point in world space.
  156120. */
  156121. position: Vector3;
  156122. /**
  156123. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156124. */
  156125. confidenceValue: number;
  156126. }
  156127. /**
  156128. * The feature point system is used to detect feature points from real world geometry.
  156129. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156130. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156131. */
  156132. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156133. private _enabled;
  156134. private _featurePointCloud;
  156135. /**
  156136. * The module's name
  156137. */
  156138. static readonly Name: string;
  156139. /**
  156140. * The (Babylon) version of this module.
  156141. * This is an integer representing the implementation version.
  156142. * This number does not correspond to the WebXR specs version
  156143. */
  156144. static readonly Version: number;
  156145. /**
  156146. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156147. * Will notify the observers about which feature points have been added.
  156148. */
  156149. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156150. /**
  156151. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156152. * Will notify the observers about which feature points have been updated.
  156153. */
  156154. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156155. /**
  156156. * The current feature point cloud maintained across frames.
  156157. */
  156158. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156159. /**
  156160. * construct the feature point system
  156161. * @param _xrSessionManager an instance of xr Session manager
  156162. */
  156163. constructor(_xrSessionManager: WebXRSessionManager);
  156164. /**
  156165. * Detach this feature.
  156166. * Will usually be called by the features manager
  156167. *
  156168. * @returns true if successful.
  156169. */
  156170. detach(): boolean;
  156171. /**
  156172. * Dispose this feature and all of the resources attached
  156173. */
  156174. dispose(): void;
  156175. /**
  156176. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156177. */
  156178. protected _onXRFrame(frame: XRFrame): void;
  156179. /**
  156180. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156181. */
  156182. private _init;
  156183. }
  156184. }
  156185. declare module BABYLON {
  156186. /**
  156187. * Configuration interface for the hand tracking feature
  156188. */
  156189. export interface IWebXRHandTrackingOptions {
  156190. /**
  156191. * The xrInput that will be used as source for new hands
  156192. */
  156193. xrInput: WebXRInput;
  156194. /**
  156195. * Configuration object for the joint meshes
  156196. */
  156197. jointMeshes?: {
  156198. /**
  156199. * Should the meshes created be invisible (defaults to false)
  156200. */
  156201. invisible?: boolean;
  156202. /**
  156203. * A source mesh to be used to create instances. Defaults to a sphere.
  156204. * This mesh will be the source for all other (25) meshes.
  156205. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156206. */
  156207. sourceMesh?: Mesh;
  156208. /**
  156209. * Should the source mesh stay visible. Defaults to false
  156210. */
  156211. keepOriginalVisible?: boolean;
  156212. /**
  156213. * Scale factor for all instances (defaults to 2)
  156214. */
  156215. scaleFactor?: number;
  156216. /**
  156217. * Should each instance have its own physics impostor
  156218. */
  156219. enablePhysics?: boolean;
  156220. /**
  156221. * If enabled, override default physics properties
  156222. */
  156223. physicsProps?: {
  156224. friction?: number;
  156225. restitution?: number;
  156226. impostorType?: number;
  156227. };
  156228. /**
  156229. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156230. */
  156231. handMesh?: AbstractMesh;
  156232. };
  156233. }
  156234. /**
  156235. * Parts of the hands divided to writs and finger names
  156236. */
  156237. export const enum HandPart {
  156238. /**
  156239. * HandPart - Wrist
  156240. */
  156241. WRIST = "wrist",
  156242. /**
  156243. * HandPart - The THumb
  156244. */
  156245. THUMB = "thumb",
  156246. /**
  156247. * HandPart - Index finger
  156248. */
  156249. INDEX = "index",
  156250. /**
  156251. * HandPart - Middle finger
  156252. */
  156253. MIDDLE = "middle",
  156254. /**
  156255. * HandPart - Ring finger
  156256. */
  156257. RING = "ring",
  156258. /**
  156259. * HandPart - Little finger
  156260. */
  156261. LITTLE = "little"
  156262. }
  156263. /**
  156264. * Representing a single hand (with its corresponding native XRHand object)
  156265. */
  156266. export class WebXRHand implements IDisposable {
  156267. /** the controller to which the hand correlates */
  156268. readonly xrController: WebXRInputSource;
  156269. /** the meshes to be used to track the hand joints */
  156270. readonly trackedMeshes: AbstractMesh[];
  156271. /**
  156272. * Hand-parts definition (key is HandPart)
  156273. */
  156274. handPartsDefinition: {
  156275. [key: string]: number[];
  156276. };
  156277. /**
  156278. * Populate the HandPartsDefinition object.
  156279. * This is called as a side effect since certain browsers don't have XRHand defined.
  156280. */
  156281. private generateHandPartsDefinition;
  156282. /**
  156283. * Construct a new hand object
  156284. * @param xrController the controller to which the hand correlates
  156285. * @param trackedMeshes the meshes to be used to track the hand joints
  156286. */
  156287. constructor(
  156288. /** the controller to which the hand correlates */
  156289. xrController: WebXRInputSource,
  156290. /** the meshes to be used to track the hand joints */
  156291. trackedMeshes: AbstractMesh[]);
  156292. /**
  156293. * Update this hand from the latest xr frame
  156294. * @param xrFrame xrFrame to update from
  156295. * @param referenceSpace The current viewer reference space
  156296. * @param scaleFactor optional scale factor for the meshes
  156297. */
  156298. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156299. /**
  156300. * Get meshes of part of the hand
  156301. * @param part the part of hand to get
  156302. * @returns An array of meshes that correlate to the hand part requested
  156303. */
  156304. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156305. /**
  156306. * Dispose this Hand object
  156307. */
  156308. dispose(): void;
  156309. }
  156310. /**
  156311. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156312. */
  156313. export class WebXRHandTracking extends WebXRAbstractFeature {
  156314. /**
  156315. * options to use when constructing this feature
  156316. */
  156317. readonly options: IWebXRHandTrackingOptions;
  156318. private static _idCounter;
  156319. /**
  156320. * The module's name
  156321. */
  156322. static readonly Name: string;
  156323. /**
  156324. * The (Babylon) version of this module.
  156325. * This is an integer representing the implementation version.
  156326. * This number does not correspond to the WebXR specs version
  156327. */
  156328. static readonly Version: number;
  156329. /**
  156330. * This observable will notify registered observers when a new hand object was added and initialized
  156331. */
  156332. onHandAddedObservable: Observable<WebXRHand>;
  156333. /**
  156334. * This observable will notify its observers right before the hand object is disposed
  156335. */
  156336. onHandRemovedObservable: Observable<WebXRHand>;
  156337. private _hands;
  156338. /**
  156339. * Creates a new instance of the hit test feature
  156340. * @param _xrSessionManager an instance of WebXRSessionManager
  156341. * @param options options to use when constructing this feature
  156342. */
  156343. constructor(_xrSessionManager: WebXRSessionManager,
  156344. /**
  156345. * options to use when constructing this feature
  156346. */
  156347. options: IWebXRHandTrackingOptions);
  156348. /**
  156349. * Check if the needed objects are defined.
  156350. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156351. */
  156352. isCompatible(): boolean;
  156353. /**
  156354. * attach this feature
  156355. * Will usually be called by the features manager
  156356. *
  156357. * @returns true if successful.
  156358. */
  156359. attach(): boolean;
  156360. /**
  156361. * detach this feature.
  156362. * Will usually be called by the features manager
  156363. *
  156364. * @returns true if successful.
  156365. */
  156366. detach(): boolean;
  156367. /**
  156368. * Dispose this feature and all of the resources attached
  156369. */
  156370. dispose(): void;
  156371. /**
  156372. * Get the hand object according to the controller id
  156373. * @param controllerId the controller id to which we want to get the hand
  156374. * @returns null if not found or the WebXRHand object if found
  156375. */
  156376. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156377. /**
  156378. * Get a hand object according to the requested handedness
  156379. * @param handedness the handedness to request
  156380. * @returns null if not found or the WebXRHand object if found
  156381. */
  156382. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156383. protected _onXRFrame(_xrFrame: XRFrame): void;
  156384. private _attachHand;
  156385. private _detachHand;
  156386. }
  156387. }
  156388. declare module BABYLON {
  156389. /**
  156390. * The motion controller class for all microsoft mixed reality controllers
  156391. */
  156392. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156393. protected readonly _mapping: {
  156394. defaultButton: {
  156395. valueNodeName: string;
  156396. unpressedNodeName: string;
  156397. pressedNodeName: string;
  156398. };
  156399. defaultAxis: {
  156400. valueNodeName: string;
  156401. minNodeName: string;
  156402. maxNodeName: string;
  156403. };
  156404. buttons: {
  156405. "xr-standard-trigger": {
  156406. rootNodeName: string;
  156407. componentProperty: string;
  156408. states: string[];
  156409. };
  156410. "xr-standard-squeeze": {
  156411. rootNodeName: string;
  156412. componentProperty: string;
  156413. states: string[];
  156414. };
  156415. "xr-standard-touchpad": {
  156416. rootNodeName: string;
  156417. labelAnchorNodeName: string;
  156418. touchPointNodeName: string;
  156419. };
  156420. "xr-standard-thumbstick": {
  156421. rootNodeName: string;
  156422. componentProperty: string;
  156423. states: string[];
  156424. };
  156425. };
  156426. axes: {
  156427. "xr-standard-touchpad": {
  156428. "x-axis": {
  156429. rootNodeName: string;
  156430. };
  156431. "y-axis": {
  156432. rootNodeName: string;
  156433. };
  156434. };
  156435. "xr-standard-thumbstick": {
  156436. "x-axis": {
  156437. rootNodeName: string;
  156438. };
  156439. "y-axis": {
  156440. rootNodeName: string;
  156441. };
  156442. };
  156443. };
  156444. };
  156445. /**
  156446. * The base url used to load the left and right controller models
  156447. */
  156448. static MODEL_BASE_URL: string;
  156449. /**
  156450. * The name of the left controller model file
  156451. */
  156452. static MODEL_LEFT_FILENAME: string;
  156453. /**
  156454. * The name of the right controller model file
  156455. */
  156456. static MODEL_RIGHT_FILENAME: string;
  156457. profileId: string;
  156458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156459. protected _getFilenameAndPath(): {
  156460. filename: string;
  156461. path: string;
  156462. };
  156463. protected _getModelLoadingConstraints(): boolean;
  156464. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156466. protected _updateModel(): void;
  156467. }
  156468. }
  156469. declare module BABYLON {
  156470. /**
  156471. * The motion controller class for oculus touch (quest, rift).
  156472. * This class supports legacy mapping as well the standard xr mapping
  156473. */
  156474. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156475. private _forceLegacyControllers;
  156476. private _modelRootNode;
  156477. /**
  156478. * The base url used to load the left and right controller models
  156479. */
  156480. static MODEL_BASE_URL: string;
  156481. /**
  156482. * The name of the left controller model file
  156483. */
  156484. static MODEL_LEFT_FILENAME: string;
  156485. /**
  156486. * The name of the right controller model file
  156487. */
  156488. static MODEL_RIGHT_FILENAME: string;
  156489. /**
  156490. * Base Url for the Quest controller model.
  156491. */
  156492. static QUEST_MODEL_BASE_URL: string;
  156493. profileId: string;
  156494. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156495. protected _getFilenameAndPath(): {
  156496. filename: string;
  156497. path: string;
  156498. };
  156499. protected _getModelLoadingConstraints(): boolean;
  156500. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156501. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156502. protected _updateModel(): void;
  156503. /**
  156504. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156505. * between the touch and touch 2.
  156506. */
  156507. private _isQuest;
  156508. }
  156509. }
  156510. declare module BABYLON {
  156511. /**
  156512. * The motion controller class for the standard HTC-Vive controllers
  156513. */
  156514. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156515. private _modelRootNode;
  156516. /**
  156517. * The base url used to load the left and right controller models
  156518. */
  156519. static MODEL_BASE_URL: string;
  156520. /**
  156521. * File name for the controller model.
  156522. */
  156523. static MODEL_FILENAME: string;
  156524. profileId: string;
  156525. /**
  156526. * Create a new Vive motion controller object
  156527. * @param scene the scene to use to create this controller
  156528. * @param gamepadObject the corresponding gamepad object
  156529. * @param handedness the handedness of the controller
  156530. */
  156531. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156532. protected _getFilenameAndPath(): {
  156533. filename: string;
  156534. path: string;
  156535. };
  156536. protected _getModelLoadingConstraints(): boolean;
  156537. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156538. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156539. protected _updateModel(): void;
  156540. }
  156541. }
  156542. declare module BABYLON {
  156543. /**
  156544. * A cursor which tracks a point on a path
  156545. */
  156546. export class PathCursor {
  156547. private path;
  156548. /**
  156549. * Stores path cursor callbacks for when an onchange event is triggered
  156550. */
  156551. private _onchange;
  156552. /**
  156553. * The value of the path cursor
  156554. */
  156555. value: number;
  156556. /**
  156557. * The animation array of the path cursor
  156558. */
  156559. animations: Animation[];
  156560. /**
  156561. * Initializes the path cursor
  156562. * @param path The path to track
  156563. */
  156564. constructor(path: Path2);
  156565. /**
  156566. * Gets the cursor point on the path
  156567. * @returns A point on the path cursor at the cursor location
  156568. */
  156569. getPoint(): Vector3;
  156570. /**
  156571. * Moves the cursor ahead by the step amount
  156572. * @param step The amount to move the cursor forward
  156573. * @returns This path cursor
  156574. */
  156575. moveAhead(step?: number): PathCursor;
  156576. /**
  156577. * Moves the cursor behind by the step amount
  156578. * @param step The amount to move the cursor back
  156579. * @returns This path cursor
  156580. */
  156581. moveBack(step?: number): PathCursor;
  156582. /**
  156583. * Moves the cursor by the step amount
  156584. * If the step amount is greater than one, an exception is thrown
  156585. * @param step The amount to move the cursor
  156586. * @returns This path cursor
  156587. */
  156588. move(step: number): PathCursor;
  156589. /**
  156590. * Ensures that the value is limited between zero and one
  156591. * @returns This path cursor
  156592. */
  156593. private ensureLimits;
  156594. /**
  156595. * Runs onchange callbacks on change (used by the animation engine)
  156596. * @returns This path cursor
  156597. */
  156598. private raiseOnChange;
  156599. /**
  156600. * Executes a function on change
  156601. * @param f A path cursor onchange callback
  156602. * @returns This path cursor
  156603. */
  156604. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156605. }
  156606. }
  156607. declare module BABYLON {
  156608. /** @hidden */
  156609. export var blurPixelShader: {
  156610. name: string;
  156611. shader: string;
  156612. };
  156613. }
  156614. declare module BABYLON {
  156615. /** @hidden */
  156616. export var pointCloudVertexDeclaration: {
  156617. name: string;
  156618. shader: string;
  156619. };
  156620. }
  156621. // Mixins
  156622. interface Window {
  156623. mozIndexedDB: IDBFactory;
  156624. webkitIndexedDB: IDBFactory;
  156625. msIndexedDB: IDBFactory;
  156626. webkitURL: typeof URL;
  156627. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156628. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156629. WebGLRenderingContext: WebGLRenderingContext;
  156630. MSGesture: MSGesture;
  156631. CANNON: any;
  156632. AudioContext: AudioContext;
  156633. webkitAudioContext: AudioContext;
  156634. PointerEvent: any;
  156635. Math: Math;
  156636. Uint8Array: Uint8ArrayConstructor;
  156637. Float32Array: Float32ArrayConstructor;
  156638. mozURL: typeof URL;
  156639. msURL: typeof URL;
  156640. VRFrameData: any; // WebVR, from specs 1.1
  156641. DracoDecoderModule: any;
  156642. setImmediate(handler: (...args: any[]) => void): number;
  156643. }
  156644. interface HTMLCanvasElement {
  156645. requestPointerLock(): void;
  156646. msRequestPointerLock?(): void;
  156647. mozRequestPointerLock?(): void;
  156648. webkitRequestPointerLock?(): void;
  156649. /** Track wether a record is in progress */
  156650. isRecording: boolean;
  156651. /** Capture Stream method defined by some browsers */
  156652. captureStream(fps?: number): MediaStream;
  156653. }
  156654. interface CanvasRenderingContext2D {
  156655. msImageSmoothingEnabled: boolean;
  156656. }
  156657. interface MouseEvent {
  156658. mozMovementX: number;
  156659. mozMovementY: number;
  156660. webkitMovementX: number;
  156661. webkitMovementY: number;
  156662. msMovementX: number;
  156663. msMovementY: number;
  156664. }
  156665. interface Navigator {
  156666. mozGetVRDevices: (any: any) => any;
  156667. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156668. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156669. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156670. webkitGetGamepads(): Gamepad[];
  156671. msGetGamepads(): Gamepad[];
  156672. webkitGamepads(): Gamepad[];
  156673. }
  156674. interface HTMLVideoElement {
  156675. mozSrcObject: any;
  156676. }
  156677. interface Math {
  156678. fround(x: number): number;
  156679. imul(a: number, b: number): number;
  156680. }
  156681. interface WebGLRenderingContext {
  156682. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156683. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156684. vertexAttribDivisor(index: number, divisor: number): void;
  156685. createVertexArray(): any;
  156686. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156687. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156688. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156689. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156690. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156691. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156692. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156693. // Queries
  156694. createQuery(): WebGLQuery;
  156695. deleteQuery(query: WebGLQuery): void;
  156696. beginQuery(target: number, query: WebGLQuery): void;
  156697. endQuery(target: number): void;
  156698. getQueryParameter(query: WebGLQuery, pname: number): any;
  156699. getQuery(target: number, pname: number): any;
  156700. MAX_SAMPLES: number;
  156701. RGBA8: number;
  156702. READ_FRAMEBUFFER: number;
  156703. DRAW_FRAMEBUFFER: number;
  156704. UNIFORM_BUFFER: number;
  156705. HALF_FLOAT_OES: number;
  156706. RGBA16F: number;
  156707. RGBA32F: number;
  156708. R32F: number;
  156709. RG32F: number;
  156710. RGB32F: number;
  156711. R16F: number;
  156712. RG16F: number;
  156713. RGB16F: number;
  156714. RED: number;
  156715. RG: number;
  156716. R8: number;
  156717. RG8: number;
  156718. UNSIGNED_INT_24_8: number;
  156719. DEPTH24_STENCIL8: number;
  156720. MIN: number;
  156721. MAX: number;
  156722. /* Multiple Render Targets */
  156723. drawBuffers(buffers: number[]): void;
  156724. readBuffer(src: number): void;
  156725. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156726. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156727. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156728. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156729. // Occlusion Query
  156730. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156731. ANY_SAMPLES_PASSED: number;
  156732. QUERY_RESULT_AVAILABLE: number;
  156733. QUERY_RESULT: number;
  156734. }
  156735. interface WebGLProgram {
  156736. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156737. }
  156738. interface EXT_disjoint_timer_query {
  156739. QUERY_COUNTER_BITS_EXT: number;
  156740. TIME_ELAPSED_EXT: number;
  156741. TIMESTAMP_EXT: number;
  156742. GPU_DISJOINT_EXT: number;
  156743. QUERY_RESULT_EXT: number;
  156744. QUERY_RESULT_AVAILABLE_EXT: number;
  156745. queryCounterEXT(query: WebGLQuery, target: number): void;
  156746. createQueryEXT(): WebGLQuery;
  156747. beginQueryEXT(target: number, query: WebGLQuery): void;
  156748. endQueryEXT(target: number): void;
  156749. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156750. deleteQueryEXT(query: WebGLQuery): void;
  156751. }
  156752. interface WebGLUniformLocation {
  156753. _currentState: any;
  156754. }
  156755. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156756. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156757. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156758. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156759. interface WebGLRenderingContext {
  156760. readonly RASTERIZER_DISCARD: number;
  156761. readonly DEPTH_COMPONENT24: number;
  156762. readonly TEXTURE_3D: number;
  156763. readonly TEXTURE_2D_ARRAY: number;
  156764. readonly TEXTURE_COMPARE_FUNC: number;
  156765. readonly TEXTURE_COMPARE_MODE: number;
  156766. readonly COMPARE_REF_TO_TEXTURE: number;
  156767. readonly TEXTURE_WRAP_R: number;
  156768. readonly HALF_FLOAT: number;
  156769. readonly RGB8: number;
  156770. readonly RED_INTEGER: number;
  156771. readonly RG_INTEGER: number;
  156772. readonly RGB_INTEGER: number;
  156773. readonly RGBA_INTEGER: number;
  156774. readonly R8_SNORM: number;
  156775. readonly RG8_SNORM: number;
  156776. readonly RGB8_SNORM: number;
  156777. readonly RGBA8_SNORM: number;
  156778. readonly R8I: number;
  156779. readonly RG8I: number;
  156780. readonly RGB8I: number;
  156781. readonly RGBA8I: number;
  156782. readonly R8UI: number;
  156783. readonly RG8UI: number;
  156784. readonly RGB8UI: number;
  156785. readonly RGBA8UI: number;
  156786. readonly R16I: number;
  156787. readonly RG16I: number;
  156788. readonly RGB16I: number;
  156789. readonly RGBA16I: number;
  156790. readonly R16UI: number;
  156791. readonly RG16UI: number;
  156792. readonly RGB16UI: number;
  156793. readonly RGBA16UI: number;
  156794. readonly R32I: number;
  156795. readonly RG32I: number;
  156796. readonly RGB32I: number;
  156797. readonly RGBA32I: number;
  156798. readonly R32UI: number;
  156799. readonly RG32UI: number;
  156800. readonly RGB32UI: number;
  156801. readonly RGBA32UI: number;
  156802. readonly RGB10_A2UI: number;
  156803. readonly R11F_G11F_B10F: number;
  156804. readonly RGB9_E5: number;
  156805. readonly RGB10_A2: number;
  156806. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156807. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156808. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156809. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156810. readonly DEPTH_COMPONENT32F: number;
  156811. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156812. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156813. 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;
  156814. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156815. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156816. readonly TRANSFORM_FEEDBACK: number;
  156817. readonly INTERLEAVED_ATTRIBS: number;
  156818. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156819. createTransformFeedback(): WebGLTransformFeedback;
  156820. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156821. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156822. beginTransformFeedback(primitiveMode: number): void;
  156823. endTransformFeedback(): void;
  156824. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156825. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156826. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156827. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156828. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156829. }
  156830. interface ImageBitmap {
  156831. readonly width: number;
  156832. readonly height: number;
  156833. close(): void;
  156834. }
  156835. interface WebGLQuery extends WebGLObject {
  156836. }
  156837. declare var WebGLQuery: {
  156838. prototype: WebGLQuery;
  156839. new(): WebGLQuery;
  156840. };
  156841. interface WebGLSampler extends WebGLObject {
  156842. }
  156843. declare var WebGLSampler: {
  156844. prototype: WebGLSampler;
  156845. new(): WebGLSampler;
  156846. };
  156847. interface WebGLSync extends WebGLObject {
  156848. }
  156849. declare var WebGLSync: {
  156850. prototype: WebGLSync;
  156851. new(): WebGLSync;
  156852. };
  156853. interface WebGLTransformFeedback extends WebGLObject {
  156854. }
  156855. declare var WebGLTransformFeedback: {
  156856. prototype: WebGLTransformFeedback;
  156857. new(): WebGLTransformFeedback;
  156858. };
  156859. interface WebGLVertexArrayObject extends WebGLObject {
  156860. }
  156861. declare var WebGLVertexArrayObject: {
  156862. prototype: WebGLVertexArrayObject;
  156863. new(): WebGLVertexArrayObject;
  156864. };
  156865. // Type definitions for WebVR API
  156866. // Project: https://w3c.github.io/webvr/
  156867. // Definitions by: six a <https://github.com/lostfictions>
  156868. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156869. interface VRDisplay extends EventTarget {
  156870. /**
  156871. * Dictionary of capabilities describing the VRDisplay.
  156872. */
  156873. readonly capabilities: VRDisplayCapabilities;
  156874. /**
  156875. * z-depth defining the far plane of the eye view frustum
  156876. * enables mapping of values in the render target depth
  156877. * attachment to scene coordinates. Initially set to 10000.0.
  156878. */
  156879. depthFar: number;
  156880. /**
  156881. * z-depth defining the near plane of the eye view frustum
  156882. * enables mapping of values in the render target depth
  156883. * attachment to scene coordinates. Initially set to 0.01.
  156884. */
  156885. depthNear: number;
  156886. /**
  156887. * An identifier for this distinct VRDisplay. Used as an
  156888. * association point in the Gamepad API.
  156889. */
  156890. readonly displayId: number;
  156891. /**
  156892. * A display name, a user-readable name identifying it.
  156893. */
  156894. readonly displayName: string;
  156895. readonly isConnected: boolean;
  156896. readonly isPresenting: boolean;
  156897. /**
  156898. * If this VRDisplay supports room-scale experiences, the optional
  156899. * stage attribute contains details on the room-scale parameters.
  156900. */
  156901. readonly stageParameters: VRStageParameters | null;
  156902. /**
  156903. * Passing the value returned by `requestAnimationFrame` to
  156904. * `cancelAnimationFrame` will unregister the callback.
  156905. * @param handle Define the hanle of the request to cancel
  156906. */
  156907. cancelAnimationFrame(handle: number): void;
  156908. /**
  156909. * Stops presenting to the VRDisplay.
  156910. * @returns a promise to know when it stopped
  156911. */
  156912. exitPresent(): Promise<void>;
  156913. /**
  156914. * Return the current VREyeParameters for the given eye.
  156915. * @param whichEye Define the eye we want the parameter for
  156916. * @returns the eye parameters
  156917. */
  156918. getEyeParameters(whichEye: string): VREyeParameters;
  156919. /**
  156920. * Populates the passed VRFrameData with the information required to render
  156921. * the current frame.
  156922. * @param frameData Define the data structure to populate
  156923. * @returns true if ok otherwise false
  156924. */
  156925. getFrameData(frameData: VRFrameData): boolean;
  156926. /**
  156927. * Get the layers currently being presented.
  156928. * @returns the list of VR layers
  156929. */
  156930. getLayers(): VRLayer[];
  156931. /**
  156932. * Return a VRPose containing the future predicted pose of the VRDisplay
  156933. * when the current frame will be presented. The value returned will not
  156934. * change until JavaScript has returned control to the browser.
  156935. *
  156936. * The VRPose will contain the position, orientation, velocity,
  156937. * and acceleration of each of these properties.
  156938. * @returns the pose object
  156939. */
  156940. getPose(): VRPose;
  156941. /**
  156942. * Return the current instantaneous pose of the VRDisplay, with no
  156943. * prediction applied.
  156944. * @returns the current instantaneous pose
  156945. */
  156946. getImmediatePose(): VRPose;
  156947. /**
  156948. * The callback passed to `requestAnimationFrame` will be called
  156949. * any time a new frame should be rendered. When the VRDisplay is
  156950. * presenting the callback will be called at the native refresh
  156951. * rate of the HMD. When not presenting this function acts
  156952. * identically to how window.requestAnimationFrame acts. Content should
  156953. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156954. * asynchronously from other displays and at differing refresh rates.
  156955. * @param callback Define the eaction to run next frame
  156956. * @returns the request handle it
  156957. */
  156958. requestAnimationFrame(callback: FrameRequestCallback): number;
  156959. /**
  156960. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156961. * Repeat calls while already presenting will update the VRLayers being displayed.
  156962. * @param layers Define the list of layer to present
  156963. * @returns a promise to know when the request has been fulfilled
  156964. */
  156965. requestPresent(layers: VRLayer[]): Promise<void>;
  156966. /**
  156967. * Reset the pose for this display, treating its current position and
  156968. * orientation as the "origin/zero" values. VRPose.position,
  156969. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156970. * updated when calling resetPose(). This should be called in only
  156971. * sitting-space experiences.
  156972. */
  156973. resetPose(): void;
  156974. /**
  156975. * The VRLayer provided to the VRDisplay will be captured and presented
  156976. * in the HMD. Calling this function has the same effect on the source
  156977. * canvas as any other operation that uses its source image, and canvases
  156978. * created without preserveDrawingBuffer set to true will be cleared.
  156979. * @param pose Define the pose to submit
  156980. */
  156981. submitFrame(pose?: VRPose): void;
  156982. }
  156983. declare var VRDisplay: {
  156984. prototype: VRDisplay;
  156985. new(): VRDisplay;
  156986. };
  156987. interface VRLayer {
  156988. leftBounds?: number[] | Float32Array | null;
  156989. rightBounds?: number[] | Float32Array | null;
  156990. source?: HTMLCanvasElement | null;
  156991. }
  156992. interface VRDisplayCapabilities {
  156993. readonly canPresent: boolean;
  156994. readonly hasExternalDisplay: boolean;
  156995. readonly hasOrientation: boolean;
  156996. readonly hasPosition: boolean;
  156997. readonly maxLayers: number;
  156998. }
  156999. interface VREyeParameters {
  157000. /** @deprecated */
  157001. readonly fieldOfView: VRFieldOfView;
  157002. readonly offset: Float32Array;
  157003. readonly renderHeight: number;
  157004. readonly renderWidth: number;
  157005. }
  157006. interface VRFieldOfView {
  157007. readonly downDegrees: number;
  157008. readonly leftDegrees: number;
  157009. readonly rightDegrees: number;
  157010. readonly upDegrees: number;
  157011. }
  157012. interface VRFrameData {
  157013. readonly leftProjectionMatrix: Float32Array;
  157014. readonly leftViewMatrix: Float32Array;
  157015. readonly pose: VRPose;
  157016. readonly rightProjectionMatrix: Float32Array;
  157017. readonly rightViewMatrix: Float32Array;
  157018. readonly timestamp: number;
  157019. }
  157020. interface VRPose {
  157021. readonly angularAcceleration: Float32Array | null;
  157022. readonly angularVelocity: Float32Array | null;
  157023. readonly linearAcceleration: Float32Array | null;
  157024. readonly linearVelocity: Float32Array | null;
  157025. readonly orientation: Float32Array | null;
  157026. readonly position: Float32Array | null;
  157027. readonly timestamp: number;
  157028. }
  157029. interface VRStageParameters {
  157030. sittingToStandingTransform?: Float32Array;
  157031. sizeX?: number;
  157032. sizeY?: number;
  157033. }
  157034. interface Navigator {
  157035. getVRDisplays(): Promise<VRDisplay[]>;
  157036. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157037. }
  157038. interface Window {
  157039. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157040. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157041. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157042. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157043. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157044. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157045. }
  157046. interface Gamepad {
  157047. readonly displayId: number;
  157048. }
  157049. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157050. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157051. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157052. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157053. type XRHandedness = "none" | "left" | "right";
  157054. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157055. type XREye = "none" | "left" | "right";
  157056. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157057. interface XRSpace extends EventTarget {}
  157058. interface XRRenderState {
  157059. depthNear?: number;
  157060. depthFar?: number;
  157061. inlineVerticalFieldOfView?: number;
  157062. baseLayer?: XRWebGLLayer;
  157063. }
  157064. interface XRInputSource {
  157065. handedness: XRHandedness;
  157066. targetRayMode: XRTargetRayMode;
  157067. targetRaySpace: XRSpace;
  157068. gripSpace: XRSpace | undefined;
  157069. gamepad: Gamepad | undefined;
  157070. profiles: Array<string>;
  157071. hand: XRHand | undefined;
  157072. }
  157073. interface XRSessionInit {
  157074. optionalFeatures?: string[];
  157075. requiredFeatures?: string[];
  157076. }
  157077. interface XRSession {
  157078. addEventListener: Function;
  157079. removeEventListener: Function;
  157080. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157081. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157082. requestAnimationFrame: Function;
  157083. end(): Promise<void>;
  157084. renderState: XRRenderState;
  157085. inputSources: Array<XRInputSource>;
  157086. // hit test
  157087. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157088. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157089. // legacy AR hit test
  157090. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157091. // legacy plane detection
  157092. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157093. }
  157094. interface XRReferenceSpace extends XRSpace {
  157095. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157096. onreset: any;
  157097. }
  157098. type XRPlaneSet = Set<XRPlane>;
  157099. type XRAnchorSet = Set<XRAnchor>;
  157100. interface XRFrame {
  157101. session: XRSession;
  157102. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157103. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157104. // AR
  157105. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157106. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157107. // Anchors
  157108. trackedAnchors?: XRAnchorSet;
  157109. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157110. // Planes
  157111. worldInformation: {
  157112. detectedPlanes?: XRPlaneSet;
  157113. };
  157114. // Hand tracking
  157115. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157116. }
  157117. interface XRViewerPose extends XRPose {
  157118. views: Array<XRView>;
  157119. }
  157120. interface XRPose {
  157121. transform: XRRigidTransform;
  157122. emulatedPosition: boolean;
  157123. }
  157124. interface XRWebGLLayerOptions {
  157125. antialias?: boolean;
  157126. depth?: boolean;
  157127. stencil?: boolean;
  157128. alpha?: boolean;
  157129. multiview?: boolean;
  157130. framebufferScaleFactor?: number;
  157131. }
  157132. declare var XRWebGLLayer: {
  157133. prototype: XRWebGLLayer;
  157134. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157135. };
  157136. interface XRWebGLLayer {
  157137. framebuffer: WebGLFramebuffer;
  157138. framebufferWidth: number;
  157139. framebufferHeight: number;
  157140. getViewport: Function;
  157141. }
  157142. declare class XRRigidTransform {
  157143. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157144. position: DOMPointReadOnly;
  157145. orientation: DOMPointReadOnly;
  157146. matrix: Float32Array;
  157147. inverse: XRRigidTransform;
  157148. }
  157149. interface XRView {
  157150. eye: XREye;
  157151. projectionMatrix: Float32Array;
  157152. transform: XRRigidTransform;
  157153. }
  157154. interface XRInputSourceChangeEvent {
  157155. session: XRSession;
  157156. removed: Array<XRInputSource>;
  157157. added: Array<XRInputSource>;
  157158. }
  157159. interface XRInputSourceEvent extends Event {
  157160. readonly frame: XRFrame;
  157161. readonly inputSource: XRInputSource;
  157162. }
  157163. // Experimental(er) features
  157164. declare class XRRay {
  157165. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157166. origin: DOMPointReadOnly;
  157167. direction: DOMPointReadOnly;
  157168. matrix: Float32Array;
  157169. }
  157170. declare enum XRHitTestTrackableType {
  157171. "point",
  157172. "plane",
  157173. "mesh",
  157174. }
  157175. interface XRHitResult {
  157176. hitMatrix: Float32Array;
  157177. }
  157178. interface XRTransientInputHitTestResult {
  157179. readonly inputSource: XRInputSource;
  157180. readonly results: Array<XRHitTestResult>;
  157181. }
  157182. interface XRHitTestResult {
  157183. getPose(baseSpace: XRSpace): XRPose | undefined;
  157184. // When anchor system is enabled
  157185. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157186. }
  157187. interface XRHitTestSource {
  157188. cancel(): void;
  157189. }
  157190. interface XRTransientInputHitTestSource {
  157191. cancel(): void;
  157192. }
  157193. interface XRHitTestOptionsInit {
  157194. space: XRSpace;
  157195. entityTypes?: Array<XRHitTestTrackableType>;
  157196. offsetRay?: XRRay;
  157197. }
  157198. interface XRTransientInputHitTestOptionsInit {
  157199. profile: string;
  157200. entityTypes?: Array<XRHitTestTrackableType>;
  157201. offsetRay?: XRRay;
  157202. }
  157203. interface XRAnchor {
  157204. anchorSpace: XRSpace;
  157205. delete(): void;
  157206. }
  157207. interface XRPlane {
  157208. orientation: "Horizontal" | "Vertical";
  157209. planeSpace: XRSpace;
  157210. polygon: Array<DOMPointReadOnly>;
  157211. lastChangedTime: number;
  157212. }
  157213. interface XRJointSpace extends XRSpace {}
  157214. interface XRJointPose extends XRPose {
  157215. radius: number | undefined;
  157216. }
  157217. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157218. readonly length: number;
  157219. [index: number]: XRJointSpace;
  157220. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157221. readonly WRIST: number;
  157222. readonly THUMB_METACARPAL: number;
  157223. readonly THUMB_PHALANX_PROXIMAL: number;
  157224. readonly THUMB_PHALANX_DISTAL: number;
  157225. readonly THUMB_PHALANX_TIP: number;
  157226. readonly INDEX_METACARPAL: number;
  157227. readonly INDEX_PHALANX_PROXIMAL: number;
  157228. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157229. readonly INDEX_PHALANX_DISTAL: number;
  157230. readonly INDEX_PHALANX_TIP: number;
  157231. readonly MIDDLE_METACARPAL: number;
  157232. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157233. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157234. readonly MIDDLE_PHALANX_DISTAL: number;
  157235. readonly MIDDLE_PHALANX_TIP: number;
  157236. readonly RING_METACARPAL: number;
  157237. readonly RING_PHALANX_PROXIMAL: number;
  157238. readonly RING_PHALANX_INTERMEDIATE: number;
  157239. readonly RING_PHALANX_DISTAL: number;
  157240. readonly RING_PHALANX_TIP: number;
  157241. readonly LITTLE_METACARPAL: number;
  157242. readonly LITTLE_PHALANX_PROXIMAL: number;
  157243. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157244. readonly LITTLE_PHALANX_DISTAL: number;
  157245. readonly LITTLE_PHALANX_TIP: number;
  157246. }
  157247. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157248. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157249. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157250. interface XRSession {
  157251. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157252. }
  157253. interface XRFrame {
  157254. featurePointCloud? : Array<number>;
  157255. }